mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Complete Ralph to Loop rename across entire codebase
Rename all Ralph references to Loop including types, services, hooks, filenames, KV keys, API routes, frontend components, tests, and docs. Key changes: - Types: RalphState → LoopState, RalphConfig → LoopConfig - Services: ralph.ts → loop.ts with worktree field (inverted from inPlace) - KV keys: ralph: → loop:, ralph-session: → loop-session: - API routes: /ralph/* → /loop/* - Frontend: useLoopStatus, RepoLoopList, getLoopStatus, cancelLoop - Config backward compatibility: accepts both loop and ralph (prefers loop) - Automatic KV migration on plugin startup - memory-plan-execute keeps inPlace parameter (different semantics) Fixes critical bugs found in code review: - Backend /loop/cancel route using wrong ralph: KV prefix - Frontend error messages still referencing Ralph - Log message consistency
This commit is contained in:
1 parent
00489d9901
commit
2c4a9c9257
31 files changed
+789
-745
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { getLoopStatus, cancelLoop } from '@/api/memory'
|
||||
import { showToast } from '@/lib/toast'
|
||||
|
||||
export function useLoopStatus(repoId: number | undefined, open: boolean) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ['memory-loop-status', repoId],
|
||||
queryFn: () => getLoopStatus(repoId!),
|
||||
enabled: open && !!repoId,
|
||||
staleTime: 0,
|
||||
refetchInterval: ({ state }) => {
|
||||
const loops = state.data?.loops ?? []
|
||||
return loops.some(l => l.active) ? 5000 : false
|
||||
},
|
||||
})
|
||||
|
||||
const cancelMutation = useMutation({
|
||||
mutationFn: ({ sessionId }: { sessionId: string }) =>
|
||||
cancelLoop(repoId!, sessionId),
|
||||
onSuccess: (result) => {
|
||||
if (result.cancelled) {
|
||||
queryClient.invalidateQueries({ queryKey: ['memory-loop-status', repoId] })
|
||||
} else {
|
||||
showToast.error('Memory loop is no longer active')
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
showToast.error('Unable to cancel the memory loop. Please try again.')
|
||||
},
|
||||
})
|
||||
|
||||
const pendingSessionId = cancelMutation.isPending ? (cancelMutation.variables?.sessionId ?? null) : null
|
||||
|
||||
return { data, isLoading, error, cancelMutation, pendingSessionId }
|
||||
}
|
||||
|
||||
export function useLoopActiveCount(repoId: number | undefined, enabled: boolean) {
|
||||
const { data } = useQuery({
|
||||
queryKey: ['memory-loop-status', repoId],
|
||||
queryFn: () => getLoopStatus(repoId!),
|
||||
enabled: enabled && !!repoId,
|
||||
staleTime: 0,
|
||||
refetchInterval: 10000,
|
||||
})
|
||||
return data?.loops.filter(l => l.active).length ?? 0
|
||||
}
|
||||
Reference in new issue
Block a user