Skip to content

Collapse work details during final answer streaming#3152

Open
AadiJo wants to merge 1 commit into
pingdotgg:mainfrom
AadiJo:fix/streaming-final-answer-fold
Open

Collapse work details during final answer streaming#3152
AadiJo wants to merge 1 commit into
pingdotgg:mainfrom
AadiJo:fix/streaming-final-answer-fold

Conversation

@AadiJo

@AadiJo AadiJo commented Jun 18, 2026

Copy link
Copy Markdown

What Changed

  • T3 Code now collapses the “worked for...” details as soon as the final answer starts streaming.
  • Before, it waited until the answer was fully done before collapsing that section.
  • This matches the behavior in the Codex desktop app more closely.

Why

When an agent is working, the timeline shows tool calls and progress updates. Once the final answer starts, those details should move out of the way immediately so the answer is easier to read.

The old behavior was based on the final message being finished. That was too late, and if the user was actively trying to read the message, it would be jarring as everything shifted upward.

UI Changes

This changes when the work-session section collapses during a streaming response.

Before: the work session stays open until the final answer finishes.

After: the work session collapses when the final answer starts streaming, like Codex desktop.

before_after.mov

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Touches orchestration events, provider ingestion, and timeline folding logic; changes are additive (optional phase) but affect live streaming UX and message projection.

Overview
Adds an optional assistant message phase (commentary | final_answer) end-to-end so the chat timeline can tell commentary from the final answer.

Codex maps lifecycle item phase into runtime messagePhase; provider runtime ingestion caches phase per runtime item and message and attaches it to assistant delta commands. Orchestration (decider, projector, SQL projection) and the web store persist and merge phase on streaming updates.

UI: MessagesTimeline folds the active turn’s “worked for…” section as soon as any assistant message in that turn has phase === "final_answer", including while it is still streaming—instead of waiting for the turn to settle or streaming to finish.

Reviewed by Cursor Bugbot for commit a50270e. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Collapse work details during final answer streaming by propagating message phase end-to-end

  • Introduces a phase field ('commentary' | 'final_answer') on messages across contracts, server orchestration, and client state, sourced from provider item lifecycle events in CodexAdapter.ts.
  • The server ingestion pipeline in ProviderRuntimeIngestion.ts tracks phase per assistant message and includes it on thread.message.assistant.delta commands, which flow through the decider and projector into persisted thread state.
  • On the client, MessagesTimeline.logic.ts adds deriveFinalAnswerStartedTurnIds and updates deriveTurnFolds to fold commentary/tool activity turns as soon as a final_answer-phase message starts streaming, without waiting for the turn to settle.
  • Behavioral Change: turns with active work items now fold mid-stream once a final answer begins, changing the visible chat layout during streaming.

Macroscope summarized a50270e.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 21e8b6a4-9582-44f1-83ba-9551f767e5b3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 18, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a50270e. Configure here.

turnId: event.payload.turnId,
role: event.payload.role,
text: nextText,
...(event.payload.phase !== undefined ? { phase: event.payload.phase } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phase not persisted in projection

Medium Severity

The PR writes phase on thread.message-sent projection upserts, but the projection message schema, SQL row mapping, and snapshot hydration never define or read phase. After a reload or snapshot-based thread fetch, assistant messages lose final_answer, so deriveFinalAnswerStartedTurnIds cannot early-collapse work during streaming.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a50270e. Configure here.

@macroscopeapp

macroscopeapp Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces new user-facing behavior (collapsing work details during final answer streaming) across multiple system layers. An unresolved review comment identifies a medium-severity bug where the phase field isn't persisted, causing the feature to break after thread reload.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant