Skip to content

spec: stop a running turn (FIX-2375) and the mid-turn line (FIX-2376) - #4732

Merged
jhoffner merged 8 commits into
mainfrom
claude/project-thread-ft4mpv
Nov 8, 2026
Merged

jhoffner merged 8 commits into
mainfrom
claude/project-thread-ft4mpv

Conversation

@jhoffner

@jhoffner jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

What this is

Two specs from epic FIX-2369, labs adapter.ts stack 1 (2374 → 2375 → 2376). Both in one PR because they share the same adapter seam. Merging this PR approves both directions.

FIX-2375: Stop a running turn (spec)

  • Teammates gets Stop (beside Send) plus Esc Esc / Cmd-Ctrl+. via FIX-2413's useInterruptKeys. It aborts every answering turn in the conversation; dispatch is excluded.
  • Both labs show Stopping… until the request read says the turn ended. They then draw Interrupted by you from the request's aborted status, so it survives a reload. The newest one adds "N background tasks still running · View", counted live from sessionFeed's runs.
  • D1: the stopped line is a quiet stopped look of the registry's request-recovery (ER-4: one owner component).
  • Stop never cancels tasks, so the spec stays out of FIX-2202's way.

FIX-2376: the mid-turn line (spec)

  • The issue's premise is wrong for the labs. A lab line goes through the worker's respond action under hold concurrency (REPLY_CONCURRENCY, packages/workforce/src/conversation-board/task-settled.ts:176), so it starts its own answer at once and is never queued. A derived "queued" mark could never fire.
  • D1 (the product call): the labs drop the dead queued field, its marks, Teammates' false "waits for it" hint, and the fakes' fake queues.
  • D2: Kitchen Sink, whose run really queues, keeps its composer live through react's useHarnessLines. run moves from queue (30 s cap, then 503) to defer.

The seam

Turn state (running, aborted) comes from the one request read each adapter already makes. sessionFeed's runs are child sessions (background work), never the session's own turns; they only feed the background count.

Checks named for the implementations

Each spec's check runs the real adapter over recorded request fixtures, never fake-lab. Each one names a negative control that must be shown failing: today's main for 2375, and a fake that sets queued for 2376. Kitchen Sink gets an e2e with a 35 s held turn; the control is run left on queue.

Release notes

None: specs only.


Generated by Claude Code

@jhoffner jhoffner self-assigned this Nov 4, 2026
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flow-state-dev-build-site Ready Ready Preview Nov 4, 2026 10:19pm UTC
3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Nov 4, 2026 10:19pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Nov 4, 2026 10:19pm UTC
flow-state-dev-ui Ignored Ignored Preview Nov 4, 2026 10:19pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

FIX-2376

FIX-2375

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T22:21:12.539148Z 7c8b675 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jhoffner

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@jhoffner

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Coherence note (FSD Architect): the checks in this PR and in #4719 (FIX-2406, same epic FIX-2369) pick two different ways to test the real adapter.

This spec says FIX-2406 "takes over these adapter tests' interrupt case later", so the recorded-fixture harness is built only to be replaced. That leaves two harnesses for the same check in the same epic, and the fixture one carries the exact risk #4719 names (it could pass on a status shape the server stopped writing).

Please pick one of these and change the SPEC so the choice is explicit:

  1. Preferred: write the 2375 and 2376 adapter checks as FIX-2406 matrix scenarios on the in-process host, with the same negative controls (today's main for 2375, a fake that sets queued for 2376). Drop the recorded /requests fixtures. If FIX-2406 hasn't landed when these are implemented, sequence them after it rather than building a fixture harness in the meantime.
  2. If recordings must stay for now, say they are a stopgap, name the FIX-2406 scenario that replaces each one, and say they get deleted when it lands, so there aren't two harnesses side by side.

One smaller seam, no change needed: #4725 (FIX-2550) and this PR both extend request-recovery, adding the failed look and the stopped look. That's the same direction (one owner component, ER-4). Just make sure whichever lands second rebases onto the first's variant shape and doesn't add a parallel one.

— FSD Architect

@jhoffner jhoffner left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Second look + architecture pass (specs only, read against main)

Overall: the direction holds. The FIX-2376 D1 premise checks out in code (REPLY_CONCURRENCY = { policy: "hold" }, packages/workforce/src/conversation-board/task-settled.ts:176), and removing a dead queued field beats deriving it. Kitchen Sink's run is concurrency: "queue" at apps/kitchen-sink/flows/chat-agent/flow.ts:65, as stated. Findings below are things to fold or note for the implementer, ranked.

1. Naming collision: interrupted means two different things (FIX-2375) — fold

packages/ui/registry/components/request-recovery.tsx already uses "interrupted" for a request the server's restart sweeper cut off (client.requests.interrupted(), Continue/Discard). The spec maps the Claude Code-style lab's interrupted entry kind to the request status aborted (user stopped). Same word, opposite meaning, one component apart. The lab entry (labs/claude-code-style/src/adapter.ts:113) is dead today, so renaming it costs nothing now and is not "improving adjacent code": the spec is already rewriting it. Suggest the entry kind becomes stopped, matching the new look's name. The Teammates verb can stay interrupt (it is the lab's existing verb and useInterruptKeys' vocabulary).

2. Registry component reaches the labs by vendoring — say so (FIX-2375)

The spec's call site imports ./flow-state/request-recovery in the Claude Code-style lab, but neither lab has that file today (labs/*/src/components/flow-state/ holds error.tsx, spend.tsx, etc., not request-recovery.tsx). Those are installed copies of registry components. The spec should state: the registry slice lands first, then each lab installs it the way it installed error.tsx, and FIX-2370/2377's lab slices (which the spec says "come later") may be the ones that vendor it first. If they land after this stack, 2375 has to vendor it itself. Worth naming the ordering so the stack doesn't stall on it.

3. The count lives on "the newest such entry" — consider where that rule lives (FIX-2375)

"Carries the live count on the newest interrupted entry, while no later turn has started" is a presentation rule implemented in two adapters that share no code (ER-4). It will be written twice and drift. Cheaper: the adapter emits stopped entries with no count, and ThreadView gets one backgroundRunning: number; the view decides which entry shows it. One number per thread, nothing per entry. That also removes the "newest entry" special case from the signal 4 test input.

4. Aborting "every answering turn" vs. hold concurrency (cross-spec, 2375 × 2376)

Under hold, a Teammates conversation can have several in-flight respond requests (2376 says so). 2375 aborts each. The spec lists the signal for this (one POST per running turn) but not the race: a line sent in the window between the requests read and the abort POSTs is not stopped and the view says "stopped". Not a blocker; add a line to Decided-not-asked that Stop stops the turns visible at press time, and the test input should include a turn that starts after press.

5. D2 (Kitchen Sink): useHarnessLines is growing a plain-chat job

The spec admits the debt (harness-named hook, input + waiting added). Two notes:

  • input is a function option while turnAction/sendOne already cover most of the shape. Check whether sendOne plus turnAction can carry the input already (the spec's own diff passes sendOne: (line, _running, sender) => sender.turn(line)..., which suggests sender.turn is where the fixed { prompt } bites). If the fix is "sender.turn takes the input builder", that is a smaller surface than a second option on the hook.
  • waiting is "exposing what the hook already tracks", so that part is clearly right.
    Since the rename is already conceded as a follow-up, file that issue now so the two new public options don't cement the name.

6. queue → defer is wider than the Kitchen Sink page

defer removes the 30 s timeout for every caller of that flow's run, not just the page (API, scheduled, MCP callers). The spec's Locks-in mentions 409 at the 33rd waiting run, but not that callers who relied on a fast 503 now wait indefinitely behind a hung turn. Confirm nothing else invokes run on this flow (grep the flow's action name across apps/kitchen-sink and e2e), and say the result in D2.

7. Verification wording

Both specs' "control that must fail" rely on the implementer showing a red run on main. For 2376 leg a, the control "plant queued: true back into a fake" tests the fake, and the spec's own anti-game says the real adapter must be driven over server-written rows. Make sure the red run is on the real adapter path too (e.g. an adapter that sets queued from running fails the test), otherwise the test can pass with the fake alone.

Not recommended

No broader refactor to take on here. The two adapters' near-duplicate request reads are tempting to unify, but ER-4 (labs share no code) was decided in the epic and is the reason the contract matrix (FIX-2406) exists. Leave it.


Generated by Claude Code

…ss, not recordings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiF6MmQeZ9KUe2E41Up

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Re the coherence note: agreed, one harness. I took option 1's harness without option 1's wait.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5170b12de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread specs/issues/FIX-2375/DECISIONS.md Resolved

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

/simplify review — FIX-2375 & FIX-2376 specs

This PR is spec-only (~811 lines). I ran parallel read-only passes (code quality, performance, reuse) against main and the proposed direction. No runtime changes to simplify in-tree yet — the question is whether the planned implementation is heavier than it needs to be.

Did the approach go too far?

Mostly no — and FIX-2376 is a simplification relative to the filed issue.

The original FIX-2376 ask (derive queued in each lab adapter) would have added dead derivation code and fixtures the server never writes under hold. D1 correctly reframes the labs half as removal + honest copy, which is the cleaner change. That is the main “simpler approach” win in this set.

FIX-2375 is wider than “Teammates gets Stop” (registry stopped look, live session.runs count, widened request read, per-lab adapter tests). That breadth is justified by epic D4/ER-4 and the app-review drift story — not gratuitous layering. The alternative (keep inline Entry.tsx markup per lab) is simpler on paper and expensive in maintenance.

The main place complexity could creep in at implementation time (not necessarily wrong in the spec):

  1. stillRunning gating (newest aborted line only, hide when a later turn started, runs === null ⇒ no clause) — necessary for truth, easy to get wrong. A single implementer-facing case matrix would be simpler than repeating the rules in five places.
  2. Live count from session.runs — correct source, but today neither lab’s feed wrapper surfaces runs; wiring it must not trigger a full thread rebuild on every child-run delta in the Claude Code-style adapter (entriesOf + whole-view JSON.stringify on each emit). That is an implementation guardrail worth one sentence in the spec or DECISIONS.
  3. Three overloaded “interrupted” channels — registry restart-cut-off (onContinue/onDiscard), new stopped look, lab entry kind interrupted. The DECISIONS disambiguate; a one-table glossary (registry prop / entry kind / request status / user-visible copy) would reduce implementer grep confusion.

Alternative approaches considered (spec already rejects most of these)

Alternative Verdict
Local “stopped” line on Stop press (useSession-style) Correctly rejected — reload/tab loss.
Derive lab queued from request reads Correctly rejected under hold — mark never fires.
Make lab lines wait (Claude Code queue) Correctly scoped out — workforce door change; D1 flip is explicit sign-off.
Flow State type-ahead only (unlock composer, send after turn) Correctly rejected vs real queue + 30s queue timeout.
New hook beside useHarnessLines Correctly rejected — extend existing hook (input, waiting).
Third-party package for stop/queue Nothing applicable; framework contracts are the right layer.

Optional simplification I’m less sure about: cite Shift Manager’s InterruptState / pending-until-record pattern in FIX-2375 DECISIONS as the template for stopping + refused abort beside the button (labs still won’t import shift-manager — same semantics, less one-off design). Soft recommendation only.

Verification weight

The adapter-first tests + anti-fake controls match how this feature died (green screen tests, dead real adapter). FIX-2376 leg (c) — 35s Kitchen Sink e2e is the cost center; it is defensible given QUEUE_WAIT_TIMEOUT_MS, but if CI pain shows up later, consider keeping the ≥30s hold contract in a cheaper tier (engine/integration) and a shorter e2e that only asserts composer unlock + visible waiting mark — only if you can do that without weakening the anti-game rule.

Reuse check (spec vs code on main)

  • request-recovery extension (D1) matches the component’s role (failed + restart today); user stop needs a quiet third branch, not reuse of Continue/Discard props.
  • useHarnessLines + defer matches harness modes and avoids sendAction stream switching — best path for Flow State.
  • Implementers: install registry request-recovery into both labs before the Entry.tsx diff (labs don’t have that file yet; same drift pattern as other registry rows).

Bundling

2375 + 2376 in one spec PR is coherent (shared request-read seam; implementation order 2375 → 2376 is already stated). Two sign-off surfaces in one review is manageable.

Verdict

Direction looks right. FIX-2376 D1 is the deliberate product fork (labs stop promising Claude Code’s queue) — still for human sign-off, not something I’d treat as settled by this review alone.

I’m leaving COMMENT (not APPROVE) so the FIX-2376 D1 gate and the small spec tightenings above stay visible before direction merge. I do not see a blocker that requires a different architecture — only nits and implementation guardrails.

No code changes from this automation run.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread specs/issues/FIX-2376/DECISIONS.md Resolved
Comment thread specs/issues/FIX-2376/SPEC.md Resolved
Comment thread specs/issues/FIX-2375/DECISIONS.md Resolved
Comment thread specs/issues/FIX-2375/SPEC.md Resolved
Comment thread specs/issues/FIX-2375/SPEC.md Resolved

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

Code Snob. Already tight. No POC.

Read specs/issues/FIX-2375/SPEC.md, specs/issues/FIX-2375/DECISIONS.md, specs/issues/FIX-2376/SPEC.md, specs/issues/FIX-2376/DECISIONS.md, and specs/issues/FIX-2376/figures/what-changes.svg, d1-labs-tell-the-truth.svg, d2-kitchen-sink-queues.svg at d5170b12.

The two directories are the retained pair. The words are the goal-check tables, the debt tables, and the decided-not-asked locks. The three SVGs are the what-changes lanes and the two sign-off trade-offs, each under the 150-line figure cap. FIX-2375's D1 is the engineering card, so that card has no trade-off figure. Its what-changes picture is the mermaid pair, the form for a change position does not carry. A cut that hit the ~1,000 / ~900 word budgets would drop a check row, a lock, or one of those pictures. That shrinks the contract.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

FIX-2375: the lab entry kind is `stopped` (request-recovery's
"interrupted" already means a restart cut-off), with a names table;
the background count is one `backgroundRunning` on the thread view,
not on an entry; each lab installs request-recovery in this slice;
Stop stops the turns running at press, a later line is not aborted;
the FIX-2376 seam now says it removes the lab queue marks.

FIX-2376: leg a gets a real-adapter red (an adapter that sets queued
from running); D2 names every caller `defer` reaches. Implementer
notes recorded in both DECISIONS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiF6MmQeZ9KUe2E41Up

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Round 1 dispositions, all in 0d6bbdf. I checked each finding against main before acting on it.

Second look + architecture pass

  1. interrupted naming collision: folded. Confirmed: request-recovery.tsx uses interrupted for a turn a restart cut off, and interrupted is its own RequestStatus. The lab entry kind is now stopped. The interrupt verb, useInterruptKeys and the Interrupted by you copy stay. FIX-2375 DECISIONS adds a names table: status ↔ registry look ↔ entry kind ↔ copy.
  2. Vendoring: folded. Confirmed: neither lab has request-recovery.tsx. This slice installs it in each lab after the registry slice, since it's the first lab slice that draws it. FIX-2370 and FIX-2377's lab slices then use that copy.
  3. Count on the view: folded. Adapters emit stopped entries with no count. ThreadView (Claude Code-style) and ConversationView (Teammates) each gain one backgroundRunning: number | null, and the lab's thread view picks the line that shows it. Signal 4 now asserts the view field.
  4. Stop vs hold: folded. New rule: Stop stops the turns running when it's pressed. A line sent after that starts its own turn, isn't aborted, and reads as running. stopping waits only on the turns it aborted. The test input now includes a line sent after the press.
  5. useHarnessLines input: declined, and the rename is noted. sendOne can't carry the input today. sender.turn(prompt) is the client's HarnessLineSender interface, and the hook builds it with { prompt } fixed (useHarnessLines.ts, sender.turn). Making it take a builder would widen a client interface, and every sendOne, the default included, would have to supply the builder. One option on the hook is the smaller surface. The rename issue is recorded in FIX-2376's Notes from review, to be filed before the react slice merges.
  6. defer width: folded into D2's Locks in. I searched the repo for callers of chat-agent's run. There are three: the Flow State composer, its voice input (useVoice, action: "run"), and fsdev run chat-agent run, which sends one line. None of them relied on the 503. BullMQ dispatch mode runs defer too.
  7. Real-adapter red: folded into FIX-2376 leg a's control. On main no real adapter sets queued, so that half needs its own red: an adapter that sets queued from running must fail over the in-process host's rows.

Codex (seam contradiction): folded. Cursor (/simplify): glossary and vendoring folded with items 1 and 2. The runs-only rebuild, leg c cost and Shift Manager InterruptState points are recorded as implementer notes. The "call out D1" comment needed no change.

check-retired-terms passes. Mermaid label, fence and nav checks are clean on both specs. No SVG changed.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiF6MmQeZ9KUe2E41Up
@jhoffner

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Coherence follow-up (FSD Architect): taking option 1's harness without the wait works for me. The openLab move as FIX-2375's first host step is fine, and it keeps one harness.

There's one gap to close in the SPEC. The Teammates stop-turn and leg a tests run on openTeammates with createMockModelResolver, and today's openTeammates has no modelResolver option. #4719 lists that as its own Extends row. Since 2375 now lands first, please name the optional modelResolver on openTeammates(options) in FIX-2375's change table next to the openLab move, so FIX-2406 builds on both instead of adding the option a second time. I'm leaving a matching note on #4719.

— FSD Architect

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Folded in 4d7577f. FIX-2375's What changes now has a bullet naming both host steps: openLab(options) for the Claude Code-style lab, and an optional modelResolver on Teammates' openTeammates(options). FIX-2406 builds on both.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18088aa0d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread specs/issues/FIX-2376/SPEC.md Resolved
Comment thread specs/issues/FIX-2375/DECISIONS.md Resolved
…cord; one waiting turn at a time

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiF6MmQeZ9KUe2E41Up
@jhoffner
jhoffner added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit fd53ea7 Nov 8, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants