fix(desktop): preserve tool details in history#3286
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03ffefa688
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const result = resultByID.get(tc.id); | ||
| if (tc.id) consumedToolIDs.add(tc.id); |
There was a problem hiding this comment.
Pair historical tool results by turn
This uses one global toolCallId -> result map for the entire session, so histories with repeated call IDs render the wrong result. Repeated IDs are possible across separate model responses (for example OpenAI-compatible streams that omit IDs are synthesized as call_0 per response), and in that case every later call_0 card gets the first result while the later tool result is treated as consumed. Reopening or previewing such a session shows stale tool output; pair only the tool messages adjacent to each assistant turn, or otherwise make the lookup position-aware.
Useful? React with 👍 / 👎.
| const result=resultById.get(tc.id); | ||
| if(tc.id)consumed.add(tc.id); |
There was a problem hiding this comment.
Avoid globally matching duplicate tool call IDs
The standalone history renderer has the same session-wide toolCallId lookup, which mis-renders sessions where separate turns reuse the same tool call ID. With repeated IDs such as synthesized call_0, this line pulls the first result for later tool cards and consumed then suppresses their actual result messages, so /serve history displays incorrect tool output after resume/reload. The match needs to be limited to the tool results belonging to the current assistant turn.
Useful? React with 👍 / 👎.
Summary
reasonix serve/historyRelated
Verification
go test ./internal/serve -count=1go test . -run 'TestHistoryMessages|TestPreviewSessionMessages' -count=1fromdesktop/\n-git diff --check\n\nNote: frontendnpm run typecheckis blocked in this worktree by missing generated Wails bindings (wailsjs/go/main/Appandwailsjs/runtime/runtime), unrelated to this change.