Skip to content

fix(chat): hide stale option chips once the running turn moves on - #24766

Merged
bolichen97 merged 1 commit into
mainfrom
fix/chips-mid-turn-15926
Oct 27, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/chips-mid-turn-15926

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: In the main chat, option chips from an earlier segment disappear once the running turn has moved on to tool work.

The agent writes a segment that ends in [OPTIONS: ...] and keeps working in the same turn (most often after a steered message). The chips from that segment stay under the composer while tool calls and "Thinking..." run below it. They answer a question the agent has already moved past.

Why it matters

Clicking a stale chip queues or steers a duplicate instruction. In the reported case the chip asked the user to confirm a step that the steered message had already confirmed. The split-view pane does not show these chips, so the two surfaces disagree on the same transcript.

Not a goal

  • Hiding chips for the whole running turn. fix(chat): option chip sends honor the busy-send mode #17291 relies on main-chat chips staying clickable mid-turn so a pick can be steered into the turn; that stays.
  • Any change to the split-view pane, the side chat or the app-kit embed. They already gate on their own busy signals.
  • Any change to what a chip click sends.

Intended? / Repro

Intended? No. ChatPage.tsx:597 on main gates the chips on lastMsg?.role === 'streaming' only. The tool / thinking rows that follow a finalized segment close that gate, and deriveFollowUpOptions (website/src/app-sdk/protocol/options.ts) skips those rows, so the earlier segment's options come back. Nothing in the code, the docs or #17291 asks for chips to survive the agent moving on; #17291 only needs them while the offering row is the newest row.

Repro on main 6c3c0f105: the real built SPA with fixture APIs and a Playwright-driven websocket (website/scripts/capture-15926-chips-mid-turn.mjs). A segment streams ... [OPTIONS: Done, check now | Wait], a chat_segment finalizes it, then a tool_call and its tool row arrive while the slot stays running. On main both chips stay up under the tool row and "Thinking..." (before screenshot 02 below). The issue's reducer-driven repro gives the same result.

What changed (motivation → approach → change)

  • Symptom: stale chips under later tool work in the same turn.
  • Root cause: the main chat's only mid-turn gate is "newest row is streaming", which a finalized segment followed by tool rows does not meet.
  • Choice: B (hide once a tool or thinking row follows the offering row) over A (hide for the whole running turn): B fixes the report and keeps fix(chat): option chip sends honor the busy-send mode #17291's mid-turn chip steering and its pinned tests intact.
  • Change:
    • deriveFollowUpOptions takes an optional 4th argument, a movedOnRow predicate. A matching row newer than the offering row hides that row's chips. Without it the scan is unchanged. It is a predicate, not a flag, because app-sdk/protocol imports no rendering layer and so cannot import the shared isReasoningRole.
    • useFollowUpChips (pages/chat/page/followUpChips.ts) takes turnRunning and, only while it is true, passes isTurnActivityRow: a tool row, or a reasoning row by the shared isReasoningRole.
    • ChatPage.tsx passes turnRunning: !!slotRunning. When the turn ends the chips come back from whatever the newest offer is.

Backwards compatibility

Compatible: the new argument is optional and unset by default, so ChatPane, SideChat, ChatEmbed and app-kit callers keep today's behaviour.

Removes nothing: no key, function, record or accepted input is taken away; one surface hides chips in one more state.

Tests

  • website/src/test/followUpChips.midTurn.test.ts (new):
    • the issue's sequence through the real chatSlice reducer and the real useFollowUpChips hook: chips hide once tool and thinking rows follow the segment while the turn runs;
    • chips stay while the offering row is still the newest row (the fix(chat): option chip sends honor the busy-send mode #17291 state);
    • chips come back when the turn ends;
    • deriveFollowUpOptions: a tool row, a thinking row, no movedOnRow (old scan), and a newer offer after tool rows.
  • website/src/test/ChatPage.followUpBusySend.test.tsx is unchanged and should stay green: its rows have no tool or thinking row after the offer.

Proof: not provable -- frontend test (prove.py runs Python only)

Tests run in CI only. Locally: tsc -p tsconfig.app.json (plus the new test file), eslint on the changed files and lint:i18n are clean.

Manual verification

Done with the capture harness above against dists built from main and from this branch. Still useful for a reviewer: in a live session, steer a message into a turn that just offered chips and confirm they leave once the agent starts a tool call.

Screenshots / video

Before (main): the segment just finalized, chips shown.

before: segment finalized

Before (main): a tool row follows, the stale chips stay.

before: tool row follows

After (this PR): the segment just finalized, chips still shown so a pick can be steered in.

after: segment finalized

After (this PR): a tool row follows, the chips are gone.

after: tool row follows

Related Issues

Fixes #15926

Refs #17291: the mid-turn chip steering this keeps.

Sibling sweep

Swept: git grep -n "deriveFollowUpOptions(" -- website/src
Sibling: website/src/components/ChatPane.tsx:394 -- not affected -- gates on selectComposerBusy, so no chips during any busy turn
Sibling: website/src/app-sdk/ChatEmbed.tsx:579 -- not affected -- gates on the embed's running flag for the whole turn
Sibling: website/src/pages/chat/SideChat.tsx:238 -- not affected -- gates on the side chat's whole-stream flag, not the newest row
Sibling: website/src/pages/chat/page/followUpChips.ts:45 -- changed here

Pattern harvest

Not generalizable: the defect is one surface using "newest row is streaming" as its turn-running signal; the other three surfaces already use a real running flag.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 27, 2026 06:32
@CrysisDeu
CrysisDeu requested a review from bolichen97 October 27, 2026 06:32
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of a0bad526199d015a4afb16d470f4d7052a31f174 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the scan stops showing chips once a row is newer than the offer, the argument is optional so the three sibling surfaces are untouched, and the four attached screenshots show before and after.

Notes

  • website/scripts/capture-15926-chips-mid-turn.mjs is a one-off harness for this issue. Commit it only if the repo keeps per-issue capture scripts; otherwise it is upkeep with no reader.

[DESIGN-REVIEWED] a0bad52

Description read

[DESCRIPTION-READ] 3d4ccf2b78f914b091dde5eb9154bc77ece27904a793f2974f9b74f6c9badbeb

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a0bad526199d015a4afb16d470f4d7052a31f174 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The fix works at the mechanism level and comes with a reproduction. One note: the hide rule is exposed on the public app-sdk export, and only one caller uses it.

Notes

  • Item 3 — one consumer, generalized: movedOnRow?: (m: ChatMessage) => boolean is added to deriveFollowUpOptions, which app-sdk/index.ts:487 (export * from './protocol') publishes to app authors. Only followUpChips.ts passes it; ChatPane.tsx:394 and ChatEmbed.tsx:579 don't. Subtraction: keep the SDK signature as it is. Inside useFollowUpChips, while turnRunning, return no chips when a row matching isTurnActivityRow comes after the row that offered them.

What this change ships

Inventory (5 items) — 4 justified

Intent: a FIX. In the main chat, chips from an earlier segment stop offering an answer to a question the agent has already moved past.

  1. Main chat hides earlier chips once a tool or thinking row follows them mid-turn — justified
  2. Chips still show while the offering row is the newest row mid-turn — justified
  3. New optional movedOnRow predicate on the public SDK function deriveFollowUpOptions — one consumer, generalized
  4. Chips come back when the turn ends — justified
  5. Screenshot harness capture-15926-chips-mid-turn.mjs — justified

[FIRST-PRINCIPLES-REVIEWED] a0bad52

Description read

[DESCRIPTION-READ] 1747c8b935fda75a94af00e76c5f6fe39c29ca78e6245f4324df801615877dff

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of a0bad526199d015a4afb16d470f4d7052a31f174 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: the change only hides existing chips in one more state, and the blind reader read shot-04 correctly ("the quick replies went away, maybe because the assistant moved on").

Notes

  • In shot-02 (main), the reader hesitated: "I can't tell whether the question is still open." That supports this fix.
  • Chips come back when the turn ends, using whatever offer is newest. If that is the same earlier offer, a question the agent already moved past shows up again under the finished reply. A screenshot of the state after the turn ends would confirm whether this is the intended experience.

[UX-REVIEWED] a0bad52

Description read

[DESCRIPTION-READ] daf6f585b4ff81586fe4d02a122b462d92ed223d15af7617e7a44c8465ac4cb5

That sha256 names everything this verdict read: the PR description, plus the 7 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of a0bad526199d015a4afb16d470f4d7052a31f174 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a0bad52

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a0bad526199d015a4afb16d470f4d7052a31f174 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed a0bad526199d015a4afb16d470f4d7052a31f174 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] a0bad52

Verdict parsed from the review's SHA-scoped output markers for commit a0bad526199d015a4afb16d470f4d7052a31f174.

False positive or not applicable? A repository writer can comment:
/ai-review override fable a0bad526199d015a4afb16d470f4d7052a31f174 false-positive: <reason, 20 to 500 characters>

@bolichen97 bolichen97 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.

Thanks for the clear write-up and the before/after captures. The approach (hide the chips only once a tool or thinking row follows the offering row, and only while the turn runs) is the right scope: it fixes the stale chips and keeps the mid-turn steering that the busy-send tests pin. The optional fourth argument defaults to false, so ChatPane, SideChat and the embed keep their current behaviour.

One blocker on this head:

  • Frontend Tests (1) is red because of this diff. src/test/reasoningBurst.contract.test.tsx ("no display-layer file re-spells the reasoning-role predicate") scans app-sdk/ and rejects the new m.role === 'thinking' in options.ts. Use the shared isReasoningRole helper instead (inline comment below). Frontend Coverage Merge fails only because that shard failed.

Not caused by this PR: Integration (in-process gateway) fails on test_route_sweep with /api/publish-providers -> 500, a backend route this frontend-only change does not touch.

Verified at 094c4d0: read the full diff and the scan loop in options.ts; tool and thinking rows previously matched no branch, so skipping them with continue keeps the old scan when turnRunning is false; read the failing job logs for both red jobs.

Comment thread website/src/app-sdk/protocol/options.ts Outdated
let movedOn = false
for (let i = messages.length - 1; i >= 0; i--) {
const m = messages[i]
if (m.role === 'tool' || m.role === 'thinking') { if (turnRunning) movedOn = true; continue }

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.

The new role check fails the reasoning-role structural pin, so Frontend Tests (1) is red.

reasoningBurst.contract.test.tsx walks app-sdk/ and fails on any role === 'thinking' spelling, so the reasoning role keeps one definition (REASONING_ROLES in pages/chat/groupDisplayItems). This line re-spells it, and CI reports: "options.ts re-spells the reasoning predicate, use isReasoningRole/hasReasoningContent/REASONING_ROLES from groupDisplayItems".

if (m.role === 'tool' || m.role === 'thinking') { if (turnRunning) movedOn = true; continue }

Suggestion (the same import app-sdk/messageRenderers.tsx already uses):

import { isReasoningRole } from '../../pages/chat/groupDisplayItems'
// ...
if (m.role === 'tool' || isReasoningRole(m)) { if (turnRunning) movedOn = true; continue }

Rule: reuse the shared reasoning-role predicate; the structural pin forbids re-spelling it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 79facdc. app-sdk/protocol no longer spells the role: deriveFollowUpOptions takes an optional movedOnRow predicate, and followUpChips.ts passes isTurnActivityRow, built on the shared isReasoningRole, only while the turn runs. The predicate stays out of the protocol module because that module may not import from pages/ (chatProtocolBoundary.test.ts).

The one red left, Backend Tests (Windows) (2), is the strict xfail now red on main too (#24765, fix in #24774). I'll rebase once that lands.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/chips-mid-turn-15926 branch from 094c4d0 to 79facdc Compare October 27, 2026 07:48
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026

@bolichen97 bolichen97 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.

Thanks for the quick turnaround. The blocker from my earlier review is fixed at 79facdc: deriveFollowUpOptions now takes an optional movedOnRow predicate, and the main chat passes isTurnActivityRow, which uses the shared isReasoningRole helper, only while its turn runs. Nothing in app-sdk/ spells the reasoning role any more, and all four Frontend Tests shards pass on this head, including the reasoning-role structural pin.

Verified at 79facdc: read the range diff against the previous head; with no predicate the scan behaves as on main, so the pane, side chat and embed are unchanged; groupDisplayItems does not import back from followUpChips, so there is no cycle; the only useFollowUpChips caller (ChatPage) passes turnRunning.

The code looks good to ship. I am holding the approval only for CI: Backend Tests (Windows) (2) failed on test/test_crew_log_fullscan_guard.py::test_a_warm_session_read_that_earns_a_savepoint_reads_only_the_gap (a strict xfail that passed), a backend crew log test this frontend change does not touch, and several backend shards plus PR Readiness are still pending. Once that shard is rerun green and readiness passes, I will approve.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • acknowledged span=ee9546a634a9 -- Temporary hiding loses ownership of an unsent chip selection (website/src/pages/chat/page/followUpChips.ts:49)

Acknowledged, no change in this PR. The sequence is real and the adjudication's LOW rating fits: it needs a mid-turn pick, then a tool row, then a turn that ends with no new text, then a second pick. Nothing is sent; the stray "Yes, No" sits in the composer, where one edit clears it. A fix means tracking offer identity apart from visibility, with a second reset key in the chips hook, which is more than this one-gate fix should carry.

The main chat gated its option chips on the newest row being 'streaming'. After a segment finalized into an assistant row, the tool and thinking rows that followed opened that gate, so chips from the earlier segment stayed up for a question the agent had already moved past.

deriveFollowUpOptions takes an optional movedOnRow predicate: a matching row newer than the offering row hides its chips. The main chat passes isTurnActivityRow (a tool row or a reasoning row, via the shared isReasoningRole) only while its turn runs. While the offering row is still the newest row the chips stay, so a pick can still be steered into the turn (#17291). The pane and embed already hide chips for the whole busy turn and pass nothing.

Fixes #15926
@CrysisDeu
CrysisDeu force-pushed the fix/chips-mid-turn-15926 branch from 79facdc to a0bad52 Compare October 27, 2026 13:03
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 27, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

@bolichen97 head a0bad5261 is green: every check passed, including Backend Tests (Windows) (2), now that #24774 is on main. PR Readiness passes too. Could you re-review when you have a moment? Thanks.

@bolichen97 bolichen97 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.

Approving at head a0bad52. This replaces my earlier request for changes.

What changed since that review: deriveFollowUpOptions no longer takes a turnRunning boolean that spelled the reasoning role inside app-sdk/. It now takes an optional movedOnRow predicate, and the main chat passes isTurnActivityRow, built on the shared isReasoningRole helper, only while its turn runs. Nothing in app-sdk/ spells the reasoning role any more, so the structural pin is satisfied. This head is a rebase of 79facdc onto newer main with an identical patch per git range-diff.

What I verified:

  • Read the range diff against the head I reviewed before. With no predicate the scan behaves as on main, so the pane, side chat and embed are unchanged.
  • groupDisplayItems does not import back from followUpChips, so there is no import cycle.
  • The only useFollowUpChips caller passes turnRunning.
  • Gates: readiness passed on this head, all required checks green, no AI lane BLOCK, no merge conflict, no other review requesting changes.

@bolichen97
bolichen97 merged commit 85567f7 into main Oct 27, 2026
108 checks passed
@bolichen97
bolichen97 deleted the fix/chips-mid-turn-15926 branch October 27, 2026 15:06
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 27, 2026
@rubencu rubencu mentioned this pull request Oct 27, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Main chat shows the previous segment's [OPTIONS:] chips while the turn is still running

2 participants