COD-52 fix: wire maxTodos + todoExpirationMinutes through ralph-config to the tracker

The Ralph settings modal sent maxTodos/todoExpirationMinutes but RalphConfigSchema
(zod) stripped them and the ralph-config route never applied them, so the inputs
were silent no-ops.

Fix: add both as optional positive-int fields to RalphConfigSchema; destructure
and apply them in the ralph-config route (matching the maxIterations pattern).
RalphTracker had no setters (the values were module constants) — added per-instance
_maxTodos/_todoExpiryMs (defaulting to the same constants, behavior unchanged),
switched the eviction + expiry sites to read them, and added
setMaxTodos/setTodoExpirationMinutes (minutes→ms) + getters.

Test: route test POSTs the two fields and asserts the route applies them to the
tracker. Verified RED (setters not called — fields stripped) → GREEN. 34/34
ralph-routes tests pass; tsc + eslint(src) + prettier + build clean. Frontend
already sent the fields (no change).
This commit is contained in:
Aamer Akhter
2026-06-19 18:00:29 -04:00
parent 1255e28f6f
commit 509595b837
4 changed files with 78 additions and 14 deletions
+18 -11
View File
@@ -32,17 +32,16 @@ export function registerRalphRoutes(
// Configure Ralph tracker for a session
app.post('/api/sessions/:id/ralph-config', async (req) => {
const { id } = req.params as { id: string };
const { enabled, completionPhrase, maxIterations, reset, disableAutoEnable } = parseBody(
RalphConfigSchema,
req.body,
'Invalid request body'
) as {
enabled?: boolean;
completionPhrase?: string;
maxIterations?: number;
reset?: boolean | 'full';
disableAutoEnable?: boolean;
};
const { enabled, completionPhrase, maxIterations, maxTodos, todoExpirationMinutes, reset, disableAutoEnable } =
parseBody(RalphConfigSchema, req.body, 'Invalid request body') as {
enabled?: boolean;
completionPhrase?: string;
maxIterations?: number;
maxTodos?: number;
todoExpirationMinutes?: number;
reset?: boolean | 'full';
disableAutoEnable?: boolean;
};
const session = findSessionOrFail(ctx, id);
// Ralph tracker is not supported for external-CLI sessions (opencode/codex)
@@ -98,6 +97,14 @@ export function registerRalphRoutes(
session.ralphTracker.setMaxIterations(maxIterations || null);
}
if (maxTodos !== undefined) {
session.ralphTracker.setMaxTodos(maxTodos);
}
if (todoExpirationMinutes !== undefined) {
session.ralphTracker.setTodoExpirationMinutes(todoExpirationMinutes);
}
// Persist and broadcast the update
ctx.persistSessionState(session);
ctx.broadcast(SseEvent.SessionRalphLoopUpdate, {
+2
View File
@@ -497,6 +497,8 @@ export const RalphConfigSchema = z.object({
enabled: z.boolean().optional(),
completionPhrase: z.string().max(500).optional(),
maxIterations: z.number().int().min(0).max(10000).optional(),
maxTodos: z.number().int().positive().max(10000).optional(),
todoExpirationMinutes: z.number().int().positive().max(525600).optional(),
reset: z.union([z.boolean(), z.literal('full')]).optional(),
disableAutoEnable: z.boolean().optional(),
});