Repository navigation
fix(native-chat): keep the prose before an answered question visible after the turn folds - #43724
Conversation
…in a settled turn The turn fold kept only a settled turn's last reply as its answer, so the words an agent wrote right before AskUserQuestion folded behind "Worked for" once the person answered and the turn went on. A row that asks the person (an ask tool call, or a structured question receipt) now keeps the prose leading straight into it visible, on desktop and mobile, for terminal and structured chats.
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
A settled turn keeps back-to-back replies visible but folds a reply that work follows. Reasoning rows advanced the per-turn "previous drawn row" pointer, so a reply split by interleaved thinking (text -> thinking -> text) looked like a reply followed by work, and the collapsed turn showed only the text after the last thinking block. Reasoning rows no longer move that pointer. Prose rows separated only by thinking are linked so the pieces show or fold together: a split reply that ends the turn (or leads into another reply, a question or a steer) stays visible in full, and one that work follows folds in full instead of leaving a lone first fragment. Intended side effect: words -> thinking -> AskUserQuestion now keeps the words visible, since the question check no longer sees the thinking row as the row before it. This matches the intent of stablyai#43724. Fixes stablyai#48352 Co-authored-by: Neil <[email protected]>
#48353) A settled turn keeps back-to-back replies visible but folds a reply that work follows. Reasoning rows advanced the per-turn "previous drawn row" pointer, so a reply split by interleaved thinking (text -> thinking -> text) looked like a reply followed by work, and the collapsed turn showed only the text after the last thinking block. Reasoning rows no longer move that pointer. Prose rows separated only by thinking are linked so the pieces show or fold together: a split reply that ends the turn (or leads into another reply, a question or a steer) stays visible in full, and one that work follows folds in full instead of leaving a lone first fragment. Intended side effect: words -> thinking -> AskUserQuestion now keeps the words visible, since the question check no longer sees the thinking row as the row before it. This matches the intent of #43724. Fixes #48352 Co-authored-by: Neil <[email protected]>
ELI5
When an agent writes something for you (a table, a cost estimate, a draft) and then asks you a question about it, that text now stays on screen after you answer. Before, it disappeared behind "Worked for …" as soon as the turn finished, leaving only the question and the final reply.
What Changed
Mechanism: the shared turn fold (
src/shared/native-chat/transcript/folding/native-chat-turn-fold.ts) decides which rows of a settled turn are "answers" and stay visible. It already keeps the last reply, the reply before a steer or a Stop-hook send-back, and back-to-back replies. It had no idea a question is another place where the agent hands the turn to the person. Each fold row now carries anasksfact: the row holds an ask tool call (hasNativeChatAskCall: ClaudeAskUserQuestion, Codex async question) or carries a structuredquestionreceipt.nativeChatTurnAnswerRowskeeps the latest prose when it is that row itself (terminal chats merge the ask call into the prose row) or the row drawn right before it (structured chats draw the question as its own row). Older narration that work followed still folds.nativeChatTurnFoldRownow takes the receipt rather than ahasReceiptboolean, so it can tell a question from an approval; desktop slots and mobile rows already had the receipt map.Why
Root cause:
nativeChatTurnAnswerRowstreated a question as ordinary work, so the words written for the person to answer from were indistinguishable from narration once the turn settled.Options considered:
endsAnswer(the steer rule) for question rows. Rejected: it runs before the current row can become the answer, so a terminal row whose own words lead into the question would not count, and it keeps any earlier prose in the turn, even narration far above the question.Agents checked: Claude terminal chat (ask call merged into the prose row), Claude structured chat (question row with a receipt, confirmed live), Codex async questions (
request_user_input_asyncviaisNativeChatAskCall), and ACP/structured agents whose questions land as journalquestionitems (same receipt path).Linked Issue
Fixes #32073
#43602: the "after it is answered" half is fixed here. The "while it is pending" half did not reproduce. A pending question keeps the turn running on both routes: on terminal chats Claude's
PreToolUsehook forAskUserQuestionreportswaiting, which keepsturnActivetrue (native-chat-terminal-turn.ts); on structured chats the SDK holdscanUseToolopen, so the turn never settles and nothing folds. In a live run the findings table stayed visible above the open card (screenshot below).Visual Proof
Structured Claude chat in a hidden dev build, real Claude CLI 2.1.326 against a local fake Anthropic API (3 Bash calls → findings table → AskUserQuestion → answer → 1 Bash call → final reply).
While the question is open (main and this branch alike; nothing folds):
Testing
Live repro on macOS (above): before, the table folded after the answer; after hot-reloading this change, the same settled turn keeps the table and still folds "Ran 3 commands".
New case in
native-chat-turn-fold.test.tscovers the terminal shape (words and ask call in one row), the structured shape (question row with a receipt), and prose that work followed staying folded. It fails without the fix (answers[5]instead of[3, 5]).Focused tests:
native-chat-turn-fold.test.ts,native-chat-side-chat-fork-point.test.ts,native-chat-message-list-projection.test.ts, mobileuse-mobile-native-chat-transcript-rows.test.tsx;pnpm check:changed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
Riskiest part: settled turns that contain a question now show one more prose row than before. If the rule misfired, a turn would show a bit of extra prose (never hide more than before). Pure client-side rendering; no saved data, wire or host change, so mixed-version phones and hosts are unaffected. Back out with a plain revert.
Level: Low
AI Disclosure
Review
review-loop, one round (Codex + Claude): no P0/P1. Taken: keep only prose that leads straight into the question (not any earlier narration). Left: a recovered system error directly before a question could be the kept row (rare, P3); an ask call whose result errored still counts as a question, matching
isNativeChatAskCallused by work runs.Agent skill upstream boundary
Notes
Shared module used by desktop and mobile, so the phone gets the same behaviour. No platform, SSH or folder-workspace specific code. Per-row cost is one cached
some()over the row's blocks.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)