Skip to content

test: guard fork-while-mid-turn in the web UI - #166

Merged
saucam merged 1 commit into
mainfrom
test/fork-while-mid-turn
Jul 12, 2026
Merged

test: guard fork-while-mid-turn in the web UI#166
saucam merged 1 commit into
mainfrom
test/fork-while-mid-turn

Conversation

@saucam

@saucam saucam commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Answers "I clicked fork while the model was still streaming and nothing happened."

Investigation (no bug found in the fork path)

  • Daemon: smoke-tested session.fork while the parent is mid-turn — it returns response.ok, creates the fork with the history-so-far (forkedFrom.atTurn = user turns committed so far), the fork appears in session.list, and the parent turn keeps streaming and finishes cleanly (thinking → idle). Not gated on status.
  • Web: ForkButton is always rendered/enabled (only its own in-flight busy() disables it); the working flag only arms the interrupt button. doFork sends session.fork and focuses the returned session regardless of turn status.

So fork-while-running works on both layers. The likely causes of "nothing happened" are unrelated to fork itself: (a) the earlier fork-to-openai-without-a-key case (already fixed by gating openai on its key), or (b) the multi-backend fork control is a dropdown — one click opens the menu, a second click on "fork (same backend)" / a target actually forks.

This PR

Locks the behavior in with a regression test: renders a focused session with status:"thinking" (asserts the interrupt button is enabled, proving it's genuinely mid-turn) and asserts the fork button is enabled and dispatches session.fork. Extends the sess() test helper with an optional status (defaults "idle").

Web suite: 211 pass, tsc clean.

Product note (not changed here)

Forking mid-turn branches at the last completed turn — the response currently streaming isn't in the fork yet (it's only committed to canonical history on turn_done). If we'd rather have mid-turn fork wait for the turn to finish (or snapshot the partial), that's a small follow-up — flag it if you want that behavior.

🤖 Generated with Claude Code

A fork clicked while the model is still streaming should still fire — the
daemon accepts session.fork mid-turn (it snapshots the history-so-far and the
parent keeps streaming), and the fork button is not gated on turn status.
Adds a SessionControls test that renders a focused session with status
"thinking" (interrupt button armed to prove it's mid-turn) and asserts the
fork button is enabled and dispatches session.fork.

Extends the sess() helper with an optional status (defaults to "idle", so all
existing cases are unchanged).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🤖 Gemini code review

This PR adds a regression test to ensure that the session fork feature in the Web UI is not gated when the session is currently mid-turn (with a status of 'thinking'). It also enhances the sess test helper to allow specifying a session status, defaulting to 'idle'.

Findings: 🔴 0 · 🟠 0 · 🟡 0 · 🟢 0


Tokens spent · ⬆️ Input: 1,349 · ⬇️ Output: 73 · Σ Total: 2,133
Total may be higher due to thinking token counts.

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.51%. Comparing base (ccf28d3) to head (ae9ed6a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #166   +/-   ##
=======================================
  Coverage   84.51%   84.51%           
=======================================
  Files         104      104           
  Lines       18319    18319           
=======================================
  Hits        15482    15482           
  Misses       2837     2837           
Flag Coverage Δ
daemon 84.51% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@saucam
saucam merged commit 05b2b3b into main Jul 12, 2026
5 checks passed
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.

1 participant