Repository navigation
ensure draft chat spec is updated when update_current_session tool is called - #1342
Conversation
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 81d66c2. Configure here.
| } catch (error) { | ||
| onError?.(error); | ||
| } | ||
| }, [adoptAgentSpec, draftBridge, draftSessionId, onError]); |
There was a problem hiding this comment.
Overlapping reloads can apply a stale spec
Medium Severity
reloadAgentSpec does not ignore stale in-flight fetches. Each finished update_current_session starts a new GET, and adoptAgentSpec always applies whichever response returns last. A slower first fetch can overwrite a later spec, so the draft UI can miss the most recent agent edit.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 81d66c2. Configure here.
| } catch (error) { | ||
| onError?.(error); | ||
| } | ||
| }, [adoptAgentSpec, draftBridge, draftSessionId, onError]); |
There was a problem hiding this comment.
In-flight spec sync can clobber agent updates
Medium Severity
reloadAgentSpec adopts the GET result without stopping a PATCH that is already in flight. Clearing inFlightFlushRef only drops the local promise; a debounced user syncAgentSpec can still complete afterward and overwrite the spec update_current_session just wrote, leaving the UI and server disagreeing.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 81d66c2. Configure here.
| handledSessionSpecUpdateIdRef.current = sessionSpecUpdateId; | ||
| if (agent.mode === 'draft') { | ||
| void reloadAgentSpec(); | ||
| } |
There was a problem hiding this comment.
Paused turns skip the spec reload
Medium Severity
The reload effect treats any update_current_session seen before isRunning as historical and never fetches again. A session opened while paused (for example waiting on approval) never sets that flag, so when the tool later finishes the new spec is marked handled and the draft UI stays on the old spec.
Reviewed by Cursor Bugbot for commit 81d66c2. Configure here.


Closes AGE-2765
Note
Medium Risk
Touches draft session sync and message scanning during agent runs; logic is scoped to draft mode with deduplication guards, but incorrect detection could skip or double-reload specs.
Overview
Draft chat sessions now reload the stored agent spec when the agent finishes a TrueForge
update_current_sessiontool call during an active run, so UI state stays in sync when the backend rewrites the session spec.This adds
findLatestSessionSpecUpdateto detect completedcall_toolinvocations targetingbuilt-in:trueforge-mcp/update_current_session(ignoring other servers, direct calls, and in-flight tools), exposesreloadAgentSpecon the draft spec hook to re-fetch from the draft bridge, and wires a runtime effect that reloads once per new tool call id after the session has run in the current mount—avoiding redundant reloads for history loaded on open and race cases when streaming ends in the same batch as the tool result.Reviewed by Cursor Bugbot for commit 81d66c2. Bugbot is set up for automated code reviews on this repo. Configure here.