Skip to content

fix(crew): a message sent while a crewmate works shows at once - #18565

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/crew-steer-lands-now
Oct 9, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/crew-steer-lands-now

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: In a crewmate's chat on the Crew page, a message sent while the crewmate works shows in the thread at once, the way the main chat shows a steer.

Today the "working" ghost shows, the user presses Enter, the composer clears, and nothing appears in the thread until the server echoes the message back. On a slow turn that reads as a lost message.

Why it matters

A DM is a conversation: a message that vanishes for seconds after Enter reads as lost, and the user retypes it. The main chat already lands it at once; the crewmate chat should not be worse.

Not a goal

  • Changing how a background slot tracks its run state in the store.
  • Any change to the main chat, the queue, or the steer receipt rulings.
  • The status line or the header pill (siblings in flight).

Why it happens

A crewmate's DM is a BACKGROUND slot (the Members page never makes it the active chat slot), and that one fact splits two readings of "is a turn running":

  • ChatPane's running reads this tab's stream state (slotRun[slot]). For a background slot it turns busy only on a live chunk or tool frame. A thinking frame, the slot-detail hydrate and the slots snapshot never set it (syncSlotRunningFromServer only idles a background slot).
  • The working indicator and the composer's busy also read the slot's server flag (paneSlot.running) and subagents_running.

So while the crewmate's turn thinks, or was already running when the DM opened, running is false and busy is true (sub-agents out). The busy composer steers, and doSteer's first line took the "no turn to inject into" branch: doSend(undefined, true). doSend is busy, so it mints no bubble and waits for the echo.

Chain: background slot -> stream state idle -> doSteer !running branch -> busy doSend -> no optimistic bubble -> message shows only on the echo.

The main chat is the active slot, whose running state follows the server, so it never takes this path.

What changed (motivation -> approach -> change)

Goal -> make the steer path see the same running turn the indicator sees; nothing else moves.

  • ChatPane.tsx doSteer: the "no turn" guard is !running && !paneSlot?.running (was !running). With the server saying a turn runs, the send takes the existing steer path: the optimistic { steer, optimistic, sendId } bubble lands at once, and the steer_push echo reconciles it by sendId, exactly as for a pane that already saw a frame. No new branch, no store change.
  • A stale server flag is safe: the server finds no turn, dispatches a fresh one, and the receipt's existing dispatched && !steered ruling (applySteerReceipt -> resolveOptimisticSteer('turn')) demotes the bubble to a plain user row.
  • capture/members-page.tsx gains ?subagents=1 (radar's slot with subagents_running, no live frame), and scripts/capture-members-steer-lands-now.mjs drives the screenshots below. Capture harness only.

Backwards compatibility

Compatible: no API, config or data shape changes.

Reader: website/src/components/ChatPane.tsx:doSteer -- pane composer -- the only reader of the changed guard; split-view panes share it and gain the same fix (they are background slots too)
Reader: website/src/test/ChatPane.steerOnly.test.tsx:"busy only with sub-agents" path -- test -- the no-turn branch still runs when the server flag is false, pinned by the new test 3 below

Tests

  • New website/src/test/ChatPane.crewSteerLandsNow.test.tsx (crewmate pane, background slot, server running + subagents_running, no live frame):
    1. the send is a steer and the optimistic bubble is drawn before any echo. RED on the old guard (no bubble), green on the fix.
    2. the steer_push echo settles that bubble in place, one copy.
    3. sub-agents only (server running: false): still the fresh-turn send, no steer bubble.
  • Local, serial (vitest --maxWorkers=1): all 32 ChatPane.* suites, the ChatPage steer / busySend / followUpBusySend / sendResponseLate suites, crewmateBubbles, SessionGridViewCoverage: 39 files, 392 tests pass. tsc -p tsconfig.app.json, eslint on touched files, i18n:check: clean.

Manual verification

The capture script below asserts each frame before writing it: before (base commit) draws 0 bubbles after Enter, after draws 1. /api/chat is held unanswered, so neither frame contains a server echo.

Screenshots / video

Before (main): Enter pressed while radar works, the thread shows nothing.

./temp-screenshots/steer-lands-now/01-sent-before.png

After: the message is in the thread at once.

./temp-screenshots/steer-lands-now/01-sent-after.png

Before, recorded:

./temp-screenshots/steer-lands-now/02-sent-before.webm

After, recorded:

./temp-screenshots/steer-lands-now/02-sent-after.webm

Pattern harvest

Rule candidate: a pane-scoped host that gates a branch on "is a turn running" must read the slot's server flag (paneSlot.running) as well as this tab's stream state, because a background slot's stream state turns busy only on a chunk or tool frame.
Pattern: !running guards in ChatPane.tsx for a background slot (the indicator and selectComposerBusy already OR in the server flag; doSteer did not).

Related Issues

Follow-up to #18256 (crewmate live status line) and #17836 (CrewComposer).

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

Contributions are accepted under the project's Apache-2.0 license.

01-sent-before

01-sent-after

02-sent-before.webm
02-sent-after.webm

A crewmate's DM is a background slot: its stream state turns busy only
on a chunk or tool frame. While the crewmate's turn is thinking, or was
already running when the DM opened, the stream state reads idle though
the slot's server flag says running and the working indicator shows.
With sub-agents out the composer is busy, so its send is a steer, and
doSteer read only the stream state: it took the no-turn branch, which
sends with no bubble, and the message appeared only on the server echo.

doSteer now treats the slot's server running flag as a live turn too,
so the optimistic steer bubble is minted at once, exactly as the main
chat does. A stale flag is safe: the server dispatches a fresh turn and
the receipt's turn ruling demotes the bubble to a plain row.
@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 9, 2026 19:05
@iamwhatever
iamwhatever requested a review from buluoray October 9, 2026 19:05
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 645b0b4ec0df603f1ff2fcca5d6deed5a1e3eb23 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that the stale-flag case really demotes the bubble to a plain row: a server running flag left over after the turn ended, with applySteerReceipt returning dispatched && !steered.

[DESIGN-REVIEWED] 645b0b4

Description read

[DESCRIPTION-READ] 745f0a21c2aefa5caae97f8892a0484beb1ee0a62fda8fda7bb1d22361ef5793

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 9, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 645b0b4ec0df603f1ff2fcca5d6deed5a1e3eb23 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The fix writes out running || paneSlot?.running inline for the fourth time in ChatPane, even though line 532 already gives it a name.

Not justified as shipped

  • Item 1 — duplicate of ChatPane.tsx:532 crewmateLive: the new guard if (!running && !paneSlot?.running) is the negation of const crewmateLive = running || !!paneSlot?.running. That constant is declared above doSteer and is already the pane's single meaning of "the crewmate is at work". grep 'running || !!paneSlot?.running' finds 3 existing copies (lines 532, 1750, 1855). This guard makes 4 copies of one rule, and they can drift apart.
    Subtraction: write the guard as if (!crewmateLive), and swap paneSlot?.running in the deps array for crewmateLive. Delete the inline second reading.
    Clears when: doSteer reads crewmateLive instead of re-deriving it.
Inventory (4 items) — 3 justified

Intent: when the user sends a message to a working crewmate, it appears in the thread right away instead of after the server echo. FIX.

  1. A message sent while a crewmate is thinking or has sub-agents out appears in the thread right away, as a steer bubble — duplicate of ChatPane.tsx:532 crewmateLive
  2. When sub-agents are out but no turn is running on the server, the send still starts a fresh turn (pinned by test 3) — justified
  3. New capture harness option ?subagents=1 — justified
  4. New capture script capture-members-steer-lands-now.mjs, which records the before/after evidence — justified

[FIRST-PRINCIPLES-REVIEWED] 645b0b4

Description read

[DESCRIPTION-READ] 3b31136995f095a6eb26fd5e1e498f2b639cd294307aab8707f207c262e2599a

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 9, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 645b0b4ec0df603f1ff2fcca5d6deed5a1e3eb23 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Check the stale-flag case by hand: when the server finds no running turn, the steer bubble should turn into a plain user message in place, with no flicker or duplicate.

[UX-REVIEWED] 645b0b4

Description read

[DESCRIPTION-READ] 5df0b3d32810a7b3049031fd513db924ae3672a29b4ce27171c55fed4fab5206

That sha256 names everything this verdict read: the PR description, plus the 5 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 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 645b0b4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 645b0b4ec0df603f1ff2fcca5d6deed5a1e3eb23: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 645b0b4

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 645b0b4ec0df603f1ff2fcca5d6deed5a1e3eb23: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 9, 2026
@iamwhatever

iamwhatever commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=59906ab808fa

Outcome: accepted, deferred. Same value as crewmateLive (running || !!paneSlot?.running), so no behaviour differs.
Kept inline because doSteer serves every pane (split view too), and crewmateLive is named and documented as the crewmate chat's liveness. Reusing it would make the shared steer path read a crew-named flag.
The PR is all green on this head; a rename of crewmateLive to a pane-wide name is a separate one-line follow-up, not worth a full CI rerun here.

@iamwhatever

iamwhatever commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=3870bfb482f1

Outcome: accepted, deferred. Same item as span 59906ab808fa (the guard restates crewmateLive); same rationale: identical value, the shared steer path keeps its own read rather than a crew-named constant, rename is a follow-up.

@iamwhatever

iamwhatever commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=99cf9bebd141

Outcome: kept. The lane rates this justified: sub-agents with no server turn still take the fresh-turn send, pinned by test 3 in ChatPane.crewSteerLandsNow.test.tsx.

@iamwhatever

iamwhatever commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=a6c0f90f7bee

Outcome: kept. The lane rates this justified: ?subagents=1 is capture-harness only and is the one scene the evidence needs (server running + sub-agents, no live frame).

@iamwhatever

iamwhatever commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=0a3fa9cca45a

Outcome: kept. The lane rates this justified: the script asserts drawn=0 on main and drawn=1 on the fix before it writes each frame.

@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: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 9, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE

This fixes the crewmate DM case where a message sent while the crewmate is thinking or has sub-agents out shows nothing until the server echo. The fix is at the root: doSteer's "no turn" guard read only this tab's stream state, which a background slot never sets from a thinking frame or a hydrate. It now also reads paneSlot.running (ChatPane.tsx:1292), the same server flag the indicator, crewmateLive and both running={running || !!paneSlot?.running} props already use, so doSteer was the last reader out of step. I read the full doSteer body at head 645b0b4: a stale server flag goes down the existing steer path, and applySteerReceipt's 'turn' ruling demotes the bubble through resolveOptimisticSteer. Attachments are inlined on both paths, so a demoted send loses nothing. The new test file pins all three cases (optimistic bubble before echo, the echo settles it in place by sendId, sub-agents only with no server turn still takes the fresh send), and test 1 goes red without the guard. All checks are green, base is main, nobody has requested changes, and the screenshots are user-attachments. The First Principles CONCERNS (write the guard as !crewmateLive) is a pure-equivalence nit and was answered with a disposition. Optional follow-up: rename crewmateLive to a pane-wide name and reuse it here. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 9, 2026 23:32
@chenmingwei23
chenmingwei23 merged commit 727f226 into main Oct 9, 2026
122 of 124 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/crew-steer-lands-now branch October 9, 2026 23:49
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 2026
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.

2 participants