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:
Chris Scott committed 2026-03-27 14:45:54 -04:00
1 parent 00489d9901
commit 2c4a9c9257
31 files changed
+789 -745

No files matched your search

+5 -5
View File
@@ -1,6 +1,6 @@
import { fetchWrapper, fetchWrapperVoid } from './fetchWrapper'
import { API_BASE_URL } from '@/config'
import type { Memory, MemoryStats, CreateMemoryRequest, UpdateMemoryRequest, PluginConfig, KvEntry, CreateKvEntryRequest, UpdateKvEntryRequest, RalphState } from '@opencode-manager/shared/types'
import type { Memory, MemoryStats, CreateMemoryRequest, UpdateMemoryRequest, PluginConfig, KvEntry, CreateKvEntryRequest, UpdateKvEntryRequest, LoopState } from '@opencode-manager/shared/types'
export async function listMemories(filters?: {
projectId?: string
@@ -123,12 +123,12 @@ export async function updateKvEntry(projectId: string, key: string, data: Update
})
}
export async function getRalphStatus(repoId: number): Promise<{ loops: RalphState[]; projectId?: string | null }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/ralph/status?repoId=${repoId}`)
export async function getLoopStatus(repoId: number): Promise<{ loops: LoopState[]; projectId?: string | null }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/loop/status?repoId=${repoId}`)
}
export async function cancelRalphLoop(repoId: number, sessionId: string): Promise<{ cancelled: boolean; worktreeName?: string }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/ralph/cancel`, {
export async function cancelLoop(repoId: number, sessionId: string): Promise<{ cancelled: boolean; worktreeName?: string }> {
return fetchWrapper(`${API_BASE_URL}/api/memory/loop/cancel`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ repoId, sessionId }),
@@ -1,17 +1,17 @@
import { Loader2, CheckCircle2, XCircle, Ban, AlertCircle } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import type { RalphState } from '@opencode-manager/shared'
import type { LoopState } from '@opencode-manager/shared'
interface RepoRalphListProps {
interface RepoLoopListProps {
isLoading: boolean
data: RalphState[] | undefined
data: LoopState[] | undefined
error: Error | null
onCancel: (sessionId: string) => void
pendingSessionId: string | null
}
function StatusIcon({ loop }: { loop: RalphState }) {
function StatusIcon({ loop }: { loop: LoopState }) {
if (loop.active) return <Loader2 className="h-4 w-4 animate-spin text-blue-400" />
if (loop.terminationReason === 'completed') return <CheckCircle2 className="h-4 w-4 text-green-400" />
if (loop.terminationReason === 'cancelled' || loop.terminationReason === 'user_aborted') return <Ban className="h-4 w-4 text-yellow-400" />
@@ -28,7 +28,7 @@ function formatDuration(startedAt: string, completedAt?: string): string {
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
}
export function RepoRalphList({ isLoading, data, error, onCancel, pendingSessionId }: RepoRalphListProps) {
export function RepoLoopList({ isLoading, data, error, onCancel, pendingSessionId }: RepoLoopListProps) {
if (isLoading) {
return (
<div className="flex items-center justify-center p-8">
@@ -41,7 +41,7 @@ export function RepoRalphList({ isLoading, data, error, onCancel, pendingSession
return (
<div className="flex items-center gap-2 p-6 text-destructive">
<AlertCircle className="h-4 w-4" />
<span className="text-sm">Failed to load Ralph status</span>
<span className="text-sm">Failed to load loop status</span>
</div>
)
}
@@ -49,7 +49,7 @@ export function RepoRalphList({ isLoading, data, error, onCancel, pendingSession
if (!data?.length) {
return (
<div className="flex flex-col items-center justify-center p-8 text-muted-foreground">
<span className="text-sm">No Ralph loops found</span>
<span className="text-sm">No loops found</span>
</div>
)
}
@@ -1,13 +1,13 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { getRalphStatus, cancelRalphLoop } from '@/api/memory'
import { getLoopStatus, cancelLoop } from '@/api/memory'
import { showToast } from '@/lib/toast'
export function useRalphStatus(repoId: number | undefined, open: boolean) {
export function useLoopStatus(repoId: number | undefined, open: boolean) {
const queryClient = useQueryClient()
const { data, isLoading, error } = useQuery({
queryKey: ['ralph-status', repoId],
queryFn: () => getRalphStatus(repoId!),
queryKey: ['memory-loop-status', repoId],
queryFn: () => getLoopStatus(repoId!),
enabled: open && !!repoId,
staleTime: 0,
refetchInterval: ({ state }) => {
@@ -18,16 +18,16 @@ export function useRalphStatus(repoId: number | undefined, open: boolean) {
const cancelMutation = useMutation({
mutationFn: ({ sessionId }: { sessionId: string }) =>
cancelRalphLoop(repoId!, sessionId),
cancelLoop(repoId!, sessionId),
onSuccess: (result) => {
if (result.cancelled) {
queryClient.invalidateQueries({ queryKey: ['ralph-status', repoId] })
queryClient.invalidateQueries({ queryKey: ['memory-loop-status', repoId] })
} else {
showToast.error('Ralph loop is no longer active')
showToast.error('Memory loop is no longer active')
}
},
onError: () => {
showToast.error('Unable to cancel the Ralph loop. Please try again.')
showToast.error('Unable to cancel the memory loop. Please try again.')
},
})
@@ -36,10 +36,10 @@ export function useRalphStatus(repoId: number | undefined, open: boolean) {
return { data, isLoading, error, cancelMutation, pendingSessionId }
}
export function useRalphActiveCount(repoId: number | undefined, enabled: boolean) {
export function useLoopActiveCount(repoId: number | undefined, enabled: boolean) {
const { data } = useQuery({
queryKey: ['ralph-status', repoId],
queryFn: () => getRalphStatus(repoId!),
queryKey: ['memory-loop-status', repoId],
queryFn: () => getLoopStatus(repoId!),
enabled: enabled && !!repoId,
staleTime: 0,
refetchInterval: 10000,
+2 -2
View File
@@ -3,7 +3,7 @@ import { useMemo, useRef, useEffect, useCallback, useState } from "react";
import { OpenCodeClient } from "../api/opencode";
import { API_BASE_URL } from "../config";
import { fetchWrapper } from "../api/fetchWrapper";
import { cancelRalphLoop } from "../api/memory";
import { cancelLoop } from "../api/memory";
import type {
Message,
Part,
@@ -544,7 +544,7 @@ export const useAbortSession = (
attemptAbort();
if (repoId) {
cancelRalphLoop(repoId, targetSessionID).catch(() => {})
cancelLoop(repoId, targetSessionID).catch(() => {})
}
retryIntervalRef.current = setInterval(() => {
+10 -10
View File
@@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom'
import { useQuery } from '@tanstack/react-query'
import { getRepo } from '@/api/repos'
import { useProjectSummary, useKvEntries } from '@/hooks/useMemories'
import { useRalphStatus } from '@/hooks/useRalphStatus'
import { useLoopStatus } from '@/hooks/useLoopStatus'
import { Header } from '@/components/ui/header'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
@@ -14,7 +14,7 @@ import { getRepoDisplayName } from '@/lib/utils'
import { MemoryList } from '@/components/memory/MemoryList'
import { MemoryFormDialog } from '@/components/memory/MemoryFormDialog'
import { KvList } from '@/components/memory/KvList'
import { RepoRalphList } from '@/components/repo/RepoRalphList'
import { RepoLoopList } from '@/components/repo/RepoLoopList'
export function Memories() {
const { id } = useParams<{ id: string }>()
@@ -30,7 +30,7 @@ export function Memories() {
const { data: projectSummary, isLoading: projectSummaryLoading } = useProjectSummary(repoId)
const { data: kvEntries } = useKvEntries(projectSummary?.projectId ?? undefined)
const { data: ralphData, isLoading: ralphLoading, error: ralphError, cancelMutation, pendingSessionId } = useRalphStatus(repoId, activeTab === 'ralph')
const { data: loopData, isLoading: loopLoading, error: loopError, cancelMutation, pendingSessionId } = useLoopStatus(repoId, activeTab === 'loops')
const projectId = projectSummary?.projectId ?? null
const stats = projectSummary?.stats ?? null
@@ -128,9 +128,9 @@ export function Memories() {
<Key className="w-4 h-4 mr-2" />
Key-Value
</TabsTrigger>
<TabsTrigger value="ralph">
<TabsTrigger value="loops">
<Bot className="w-4 h-4 mr-2" />
Ralph
Loops
</TabsTrigger>
</TabsList>
<TabsContent value="memories">
@@ -139,11 +139,11 @@ export function Memories() {
<TabsContent value="kv">
<KvList projectId={projectId ?? undefined} />
</TabsContent>
<TabsContent value="ralph">
<RepoRalphList
isLoading={ralphLoading}
data={ralphData?.loops}
error={ralphError}
<TabsContent value="loops">
<RepoLoopList
isLoading={loopLoading}
data={loopData?.loops}
error={loopError}
onCancel={(sessionId) => cancelMutation.mutate({ sessionId })}
pendingSessionId={pendingSessionId}
/>