From edd9a565ce18bee7cc1f0b515dfe9ace2d8fe9d1 Mon Sep 17 00:00:00 2001 From: hotragn Date: Tue, 4 Aug 2026 15:16:37 -0400 Subject: [PATCH] Fix stay-scout-hub progress text never updating researchArea() in src/lib/api/area-search.ts handled two event types the research-area route never sent: route emits: CONNECTED, SCREENSHOT, COMPLETE, ERROR client reads: STATUS, COMPLETE, ERROR, and event.data.streamingUrl STATUS was the only source of currentAction, so the branch never ran and the progress line stayed empty for the whole run while the live preview and final analysis worked normally. The route consumes the agent stream but only forwarded STREAMING_URL and COMPLETE, dropping PROGRESS -- which is what carries the running narration. It now forwards PROGRESS as STATUS with the event's purpose, matching the vocabulary the client already expects. CONNECTED had the mirror problem: emitted with a "Starting research on X..." message that nothing read. The client now treats it like STATUS so that first message lands. Verified with tsc --noEmit, clean. Note npm run lint fails on main for this recipe -- eslint 9 with no eslint.config.js -- which predates this change and is untouched here. Found by the check in #244; refs #86. --- stay-scout-hub/src/app/api/research-area/route.ts | 6 ++++++ stay-scout-hub/src/lib/api/area-search.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stay-scout-hub/src/app/api/research-area/route.ts b/stay-scout-hub/src/app/api/research-area/route.ts index be3ac00d1..84c9dedfc 100644 --- a/stay-scout-hub/src/app/api/research-area/route.ts +++ b/stay-scout-hub/src/app/api/research-area/route.ts @@ -128,6 +128,12 @@ RETURN JSON ONLY (no markdown): enqueue({ type: "SCREENSHOT", data: { streamingUrl: event.streaming_url } }); } + // The client renders this as the current action. Without it, progress + // text stays on the initial message for the whole run. + if (event.type === EventType.PROGRESS) { + enqueue({ type: "STATUS", message: event.purpose }); + } + if (event.type === EventType.COMPLETE && event.status === RunStatus.COMPLETED) { const raw = typeof event.result === "string" ? JSON.parse(event.result) : event.result; const analysis = parseResearchResult(raw as Record, area, city); diff --git a/stay-scout-hub/src/lib/api/area-search.ts b/stay-scout-hub/src/lib/api/area-search.ts index 0706a79c3..928f9ed73 100644 --- a/stay-scout-hub/src/lib/api/area-search.ts +++ b/stay-scout-hub/src/lib/api/area-search.ts @@ -83,7 +83,7 @@ export function researchArea( }); } - if (event.type === 'STATUS') { + if (event.type === 'CONNECTED' || event.type === 'STATUS') { onStatus({ areaId: area.id, areaName: area.name,