test: guard fork-while-mid-turn in the web UI - #166
Merged
Conversation
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>
🤖 Gemini code reviewThis 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 Findings: 🔴 0 · 🟠 0 · 🟡 0 · 🟢 0 Tokens spent · ⬆️ Input: 1,349 · ⬇️ Output: 73 · Σ Total: 2,133 |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Answers "I clicked fork while the model was still streaming and nothing happened."
Investigation (no bug found in the fork path)
session.forkwhile the parent is mid-turn — it returnsresponse.ok, creates the fork with the history-so-far (forkedFrom.atTurn= user turns committed so far), the fork appears insession.list, and the parent turn keeps streaming and finishes cleanly (thinking → idle). Not gated on status.ForkButtonis always rendered/enabled (only its own in-flightbusy()disables it); theworkingflag only arms the interrupt button.doForksendssession.forkand 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 dispatchessession.fork. Extends thesess()test helper with an optional status (defaults"idle").Web suite: 211 pass,
tscclean.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