fix(web): show only the agent's latest chunk in the magic chip - #6115
fix(web): show only the agent's latest chunk in the magic chip#6115404Wolf wants to merge 1 commit into
Conversation
The chip concatenated every text part of a turn, so a Cursor session that narrated between tool calls stacked its whole running commentary above the answer. The fold coalesces streamed chunks into the trailing text part (agent_fold append_text), which makes a text part that is no longer last a chunk the agent moved on from — so the answer is the trailing text part and only that. Mid-turn prose now rides the activity line as its detail instead of rendering as a block. That holds a running turn to one h-6 row from the first event to the last, however much the agent narrates: the message below no longer shifts while the agent works, and a long thought truncates at the message's width instead of extending past it. The chip takes real height at exactly one moment, when the turn ends. Any ending settles, not just end_turn, so a cancelled or failed turn still shows the prose it managed with the reason underneath.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughMagic Chip presentation now uses working and settled states only. Working prose appears as activity detail, while narration before a tool call is excluded from answer markdown. Settled responses use the final text chunk and can include activity for non-clean endings. MagicChipView uses one layout for markdown, activity, and the “Open session” fallback. Tests cover tool activity, final text selection, and cancelled responses. Merge Risk: ⚪ Minimal · up to This localized UI change limits in-progress activity to a fixed row and displays only the latest completed response chunk, with no changes to authentication, data handling, or service interfaces. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Two things, both visible on any Cursor session that narrates between tool calls:
answerMarkdownjoined every text part of the folded turn, so what you read was the sum of all chunks up to that point rather than the agent's reply.Thinkingdetail could extend well past the right edge of the message it sits in.Fix
Only the last chunk is the answer. The fold coalesces streamed chunks into the trailing text part (
agent_foldappend_text), so a text part that is no longer last is exactly a chunk the agent moved on from. The answer is the trailing text part and only that.One fixed row until the answer. Mid-turn prose now rides the activity line as its
detailrather than rendering as a block, so a running turn is oneh-6row from the first event to the last. The message below never shifts while the agent works, and an arbitrarily long thought truncates at whatever width the message gives it. The chip takes real height at exactly one moment — when the turn ends.MagicChipPresentationdrops from three states to two (working|settled) as a result. Any ending settles now, not justend_turn, so a cancelled or failed turn still shows the prose it managed with the reason underneath.Verification
Driven against a live local stack with real Cursor turns.
Height, sampled every 250ms across an 87-second turn — 348 in-flight samples, one distinct height, zero horizontal escapes:
Content — settled on a single 5.5k-char answer opening "Octopuses are the closest thing the ocean has to an alien neighbor", with none of the four narration chunks from that turn leaking in.
bun run check(tsc + biome) clean; 13 tests pass.Note for review
If a turn ends on a tool call after its last prose, the chip shows "Agent finished without a response" rather than that earlier prose. Consistent with the rule above and Cursor normally ends turns with prose, but it is a live behavior change.
Note
Low Risk
Scoped to Lexical Magic Chip UI and presentation derivation; behavior changes for edge cases (e.g. turn ending on a tool after prose) but no auth, data, or API surface changes.
Overview
Fixes Magic Chip layout and content during agent turns: mid-turn narration no longer stacks or expands the chip, and settled answers use only the final text chunk, not every narration segment in the turn.
Presentation model drops the
answeringstate (working|settledonly).answerMarkdownnow reads only the trailing text part (aligned with fold coalescing); streaming prose appears on the activity line asdetailwith “Writing response”. Turns that end with prose settle for anystopkind, with optional footer activity for non–end_turnendings (e.g. cancelled).MagicChipViewuses one grid: quoted markdown when settled, then either the fixedh-6activity row or “Open session”. Activity line getsoverflow-hidden,flex-1, and truncation so long thoughts/commands stay within the message width.Tests in
presentation.test.tscover the new derivation rules (including last-chunk answer and narration dropped after a tool).Reviewed by Cursor Bugbot for commit d959700. Bugbot is set up for automated code reviews on this repo. Configure here.