Agent chat: never fold a finished turn's reply into Worked for
On nightly 331e2e9, a finished turn's final reply was drawn inside its "Worked for 1m 7s" fold. Leo: "Those replies should never be collapsed."
Why
answerAt (conversation/turns.ts) took a turn's answer to be the text it ended on. If a tool call came after that text, the turn had no answer, so the reply folded with the work.
What changed
- A finished turn's answer is now its last reply, even when work comes after it.
- Work after the reply (tool rows and interim notes) folds with the rest, so the reply stays the turn's last words below the fold.
- Only short interim notes that the turn worked on after (≤160 characters, one paragraph, no code; the existing
isShortNote) count as status, and they still fold. - When work comes after the reply, "Worked for" times the whole turn rather than stopping at the reply.
Changelog
- Fixed: a finished agent chat turn's reply is never folded into "Worked for", even when the agent ran a tool after it.
Tests
test/transcript-worked-fold.test.ts; the test commit 631639bb comes before the fix:
- a reply that a tool ran after stays open below the fold, the tool folds, and the opened fold holds every tool row of the turn in order and never the reply;
- the last reply stays open when short notes and tools come after it.
The existing cases are unchanged: interim short notes followed by a tool still fold, a turn stopped mid-tool still folds, and an edit after the answer still joins the edit card.
Observed / Not run
- Observed: Leo's screenshot of nightly 331e2e9, with the reply inside the open "Worked for 1m 7s" fold under "Ran defaults read …".
- Not run locally: the unit tests, the type checker and the gallery. They run in this PR's CI (this Mac does not build). The base-red run of the new tests is CI's run on 631639bb.
No capture: webview transcript shaping change, covered by unit tests; the gallery advisory run captures the transcript entries.
Agent session: cosmic-gray
🤖 Generated with Claude Code
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Fixes agent chat transcript shaping so a finished turn's final reply is never collapsed into its "Worked for" fold, even when the agent ran a tool after replying.
Bug Fixes
- A finished turn's answer is now its last reply; tool rows and interim notes after it fold with the rest so the reply stays the turn's last words.
- Only short interim notes (≤160 characters, one paragraph, no code) count as status and still fold.
- "Worked for" now times the whole turn when work came after the reply, instead of stopping at the reply.