fix: errand output race condition + require commit before signal
Merge two useEffects in AgentOutputViewer into one to fix race where agentId reset clears messages after data effect sets them on remount. Add "commit before signaling" instruction to errand prompts so Changes tab shows diff after completion.
This commit is contained in:
@@ -4,6 +4,7 @@ export function buildErrandPrompt(description: string): string {
|
||||
Description: ${description}
|
||||
|
||||
Work interactively with the user. Make only the changes needed to fulfill the description.
|
||||
Before signaling completion, commit all your changes with a clear commit message describing what you did. Do not leave uncommitted work.
|
||||
When you are done, write .cw/output/signal.json:
|
||||
|
||||
{ "status": "done", "result": { "message": "<one-sentence summary of what you changed>" } }
|
||||
@@ -25,6 +26,7 @@ The user reviewed your changes and requested revisions:
|
||||
${feedback}
|
||||
|
||||
Make only the changes needed to address the feedback. Do not undo prior work unless the feedback specifically asks for it.
|
||||
Before signaling completion, commit all your changes with a clear commit message describing what you did. Do not leave uncommitted work.
|
||||
When you are done, write .cw/output/signal.json:
|
||||
|
||||
{ "status": "done", "result": { "message": "<one-sentence summary of what you changed>" } }
|
||||
|
||||
@@ -53,21 +53,18 @@ export function AgentOutputViewer({ agentId, agentName, status, onStop }: AgentO
|
||||
}
|
||||
);
|
||||
|
||||
// Set initial output when query loads
|
||||
useEffect(() => {
|
||||
if (outputQuery.data) {
|
||||
chunksRef.current = outputQuery.data;
|
||||
setMessages(parseAgentOutput(outputQuery.data));
|
||||
}
|
||||
}, [outputQuery.data]);
|
||||
|
||||
// Reset output when agent changes
|
||||
// Reset on agent change, then hydrate from query cache
|
||||
useEffect(() => {
|
||||
chunksRef.current = [];
|
||||
setMessages([]);
|
||||
setFollow(true);
|
||||
setExpandedResults(new Set());
|
||||
}, [agentId]);
|
||||
|
||||
if (outputQuery.data) {
|
||||
chunksRef.current = outputQuery.data;
|
||||
setMessages(parseAgentOutput(outputQuery.data));
|
||||
}
|
||||
}, [agentId, outputQuery.data]);
|
||||
|
||||
// Auto-scroll to bottom when following
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user