Repository navigation
[backport cloud/1.54] feat: restore tool-call work summary on reload and chat switch - #18555
Merged
Merged
Conversation
## Before Reloading the page or switching chats mid-thread dropped a completed turn's tool-call trace: the collapsible "Worked for Xs" work summary (with the tool names/durations inside it) that shows up live while the agent is running would not reappear once the transcript was rehydrated from history. Only the final reply text survived a refresh. ## After `GET /agent/threads/:id/messages` now returns each assistant message's `tool_calls`. This PR reads that field and folds it into the same `ToolPart` entries the live WebSocket `agent_tool_call` handler already builds, so a reloaded or chat-switched transcript renders through the exact same `WorkSummary`/`ActivityTrace` components a live turn uses — no parallel UI. The collapsible starts closed and expands on click identically for a historical trace as for a live one, since that behavior is owned by the (stateless) `CollapsibleRoot` the component already used. ### What changed - `agentApiSchema.ts`: adds `zPersistedToolCallSummary`, a validated FE-side schema for one `content.tool_calls` entry (`id`, `tool_name`, `status`, `duration_ms`), following the same `.extend()`/local-schema pattern this file already uses for `pending_ask`. `status` is deliberately `z.string()` rather than a closed enum, since an unrecognized value must still surface as a failed `ToolPart` rather than be dropped by schema validation. - `agentTranscript.ts`: `normalizeAgentTranscript()` now parses each assistant row's `content.tool_calls` through that schema into `ToolPart[]` and appends them to that turn's `AssistantMessage.parts`, ahead of the row's reply text — mirroring how the live event transport appends tool/text parts into the same array. A restored `pending`/`running` call clamps to a terminal `done`/`ok:false` state unless its row is the one actively backed by a live transport (the run_approval mid-ask case); `ok`/`success` map to success, everything else terminal maps to failure; duplicate `callId`s within one row are deduped; malformed `duration_ms` is rejected without dropping the whole entry. - `agentEventTransport.ts`: `createAgentEventTransport()` now seeds its `tool_call_id` map from any `ToolPart`s already on the message it's given, so a live frame for an already-restored call updates it in place instead of duplicating it. - No changes were needed in `agentConversationStore.ts`: `hydrate()` already assigns `transcript.messages` (which now carries the tool parts) straight into the store's `messages`, the same field the live turn path writes to and the same field the rendering components read. - Unit tests added to `agentTranscript.test.ts` (parsing, ordering, multiple calls, in-flight status, malformed/missing `tool_calls`, restore-without-transport clamping, broadened terminal vocabulary, duration guard, dedup) and `agentConversationStore.test.ts` (hydrate wiring into `store.messages`, and a chat-switch A→B→A test confirming a tool-call summary doesn't bleed across chats). - One Playwright e2e test added (`browser_tests/tests/agent/agentToolCallHistoryPersistence.spec.ts`): sends a message, mocks the history GET to return a completed turn with two tool calls (using both the `ok` and `success` terminal literals), reloads, and asserts the same work-summary button appears with the exact expected duration label, stays collapsed by default, and expands to show both tool names. ### Known limitations The restored "Worked for Xs" headline is computed client-side from `totalDurationMs(parts)`, but only tool-call durations are restored — thinking-span durations are not persisted/parsed in this PR. A turn that spent significant time thinking can therefore show a different total live vs. after a reload (or across two tabs on the same conversation, one reloaded and one not). Persisting/serving the turn's worked-duration (or its thinking spans) so live and restored render from the same source is tracked as a follow-up rather than fixed here. ### Compatibility This is safe to merge independently of the backend change: when a response has no `tool_calls` key (today's shape, or a user message), parsing simply returns `undefined` and nothing is appended — covered by an explicit unit test. The full frontend behavior (tool history actually showing up after reload) only takes effect once the corresponding cloud backend change, [Comfy-Org/cloud#9960](Comfy-Org/cloud#9960), lands. That PR's shared `persist.ToolCallWireStatus` translation emits `success`/`error` as the two terminal wire values for both the live and reload paths, and excludes `pending`/`running` rows from restored history entirely; this PR's parsing handles that vocabulary (plus the legacy `ok`/`error` pair and any other unrecognized terminal string, defensively) either way. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RuB3pFMNyS3AE7JYNFNesb --- _Generated by [Claude Code](https://claude.ai/code/session_01RuB3pFMNyS3AE7JYNFNesb)_ --------- Co-authored-by: Christian Byrne <cbyrne@comfy.org>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
christian-byrne
approved these changes
Sep 23, 2026
christian-byrne
left a comment
Contributor
There was a problem hiding this comment.
Verified patch-equivalent to the approved source: #18282. Only stable-branch hunk offsets differ.
christian-byrne
force-pushed
the
backport-18282-to-cloud-1.54
branch
from
September 23, 2026 05:49
410d8ef to
4010c14
Compare
Contributor
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 1938 passed, 0 failed · 1 flaky📊 Browser Reports
|
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## cloud/1.54 #18555 +/- ##
=============================================
Coverage ? 78.70%
=============================================
Files ? 2010
Lines ? 111244
Branches ? 33593
=============================================
Hits ? 87554
Misses ? 23511
Partials ? 179
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
christian-byrne
approved these changes
Sep 23, 2026
christian-byrne
left a comment
Contributor
There was a problem hiding this comment.
Backport compatibility fix verified: browser typecheck and repository pre-commit/pre-push gates pass.
This was referenced Sep 23, 2026
This was referenced Sep 23, 2026
christian-byrne
added a commit
that referenced
this pull request
Sep 23, 2026
…ession (#18581) (#18582) ## Summary Repair the release-only failing assertion introduced by #18555, with chat-switch coverage from #18581. ## Changes - cloud/1.54 has ToolCallGroup, not main’s WorkSummary. Its exact accessible name for the existing payload is "Ran 2 tool calls for 0.6 seconds", not "Worked". - Preserve all collapse/expand and visible-call assertions. Also require exactly two rows with their separate 0.4s/0.2s durations, no summary in a new chat, and restoration via chat history. - Test-only; no runtime, package pins, feature flags, or deployment changes. #18574 remains untouched. ## Review Focus Baseline e790192 reproduced the exact line-132 failure. Its accessibility snapshot already showed the completed two-call summary and "Found it." Hydration was working; the backport had assumed a newer renderer. This is an exact branch-contract adaptation, not a fallback selector or skipped assertion. Validation: Cloud browser test plus adjacent prompt-history test: 2 passed (32.3s), retries disabled. Transcript/store/transport/ToolCallGroup/glyph unit tests: 117 passed. Browser typecheck, targeted ESLint/oxfmt passed. Await exact-head CI and source #18581 before merge. --------- Co-authored-by: Amp <amp@ampcode.com>
christian-byrne
added a commit
that referenced
this pull request
Sep 23, 2026
## Summary Preserve the tool-call reload regression and extend it through New chat → chat history → original chat, including exact rendered row counts and labels. ## Changes - Keep all existing collapsed/expanded and visible-label assertions; ensure no summary leaks into the new chat and both calls return. - Source follow-up to #18282. The Cloud backport #18555 expects main’s "Worked" label, but cloud/1.54 still renders "Ran 2 tool calls for 0.6 seconds". That release-specific adaptation will be a separate backport, not a runtime or package change. ## Review Focus Check the preserved GET content.tool_calls fixture, both terminal success vocabularies, and reload/chat-switch behavior. No deployment or feature-flag changes. Validation: targeted Cloud Playwright 1 passed (23.6s); transcript/store/transport/WorkSummary/glyph Vitest 139 passed; browser typecheck, targeted ESLint and oxfmt passed. Release baseline independently reproduced the exact line-132 failure while its accessibility tree already contained the correct two-call summary. --------- Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #18282 to
cloud/1.54Automatically created by backport workflow.