Repository navigation
fix(interrupt): migrate turn cancel registry on session rename (fixes #732, #730) - #733
Merged
Merged
Conversation
…ixes #726) The clang export sat before the mode dispatch, so it applied to `system` mode too. On a machine without clang the script logged 'using system linker settings' and then told cargo to invoke a linker that is not installed, failing every build script with exit 101. Only mold and lld need clang as the driver; system mode now leaves the choice to cargo's default cc.
The live router catalog authorizes claude-opus-5 for every paid tier, but the client catalog omitted it, so `--model claude-opus-5` silently ran claude-opus-4-8 instead. Added as a non-default entry; which model is the default remains a separate decision.
… real tools The OAuth endpoint expects Claude-Code builtin tool names, so a few schemas are hand-maintained. Two had drifted: - ScheduleWakeup advertised delaySeconds/reason/prompt while the real `schedule` handler requires `task` plus wake_in_minutes/wake_at, so every call failed with 'task is required for action=create'. Dropped the fabricated entry and let the real schema forward under the OAuth name, so the two stay in sync by construction (fixes #706). - Bash omitted `justification`, the destructive gate's documented Confirm-tier escape hatch, leaving it discoverable only from an error string after a block (fixes #722). Regressions live in oauth_tool_schema_tests.rs.
…#719) binds_block_insert_point returned the first line that textually started with `binds` and ended with `{`, ignoring KDL brace depth. In a split config with a `recent-windows { binds { ... } }` node, the managed region landed there, niri rejected the `spawn` action, and the whole config failed to load. Insertion now skips nested binds nodes, and a managed block a previous version wrote into one is relocated on the next run instead of being left broken. Reported with a repro and a reference branch by @tingfeng347.
spawn_in_new_terminal was a hardcoded Ok(false) off Unix, so /judge, /fork, /review, /autoreview, /autojudge, /transfer, batch crash-restore and remote split responses all printed 'No terminal found' and never opened a window. Everything below it was already Windows-capable: jcode-terminal-launch detects Windows Terminal / Alacritty / WezTerm and falls back to `cmd /C start`, and the session picker's resume already used it. Dropping the cfg split routes every platform through that machinery. Diagnosed with a reference branch by @rensburger.
…ixes #712) apply_login_provider_profile_env unconditionally called force_apply_openai_compatible_profile_env, which clears JCODE_NAMED_PROVIDER_PROFILE. `auth-test --provider-profile <name>` therefore probed the built-in generic openai-compatible slot and reported not_configured for profiles that work fine for inference, sending users to debug config that was never broken. Named profiles now short-circuit, matching the precedence the explicit `--provider <compatible>` path already applies. Diagnosed by @e-kotov.
0501448 added tests/context_window_matrix.rs with a jcode-provider-core dev-dependency but did not commit the regenerated lock file, so every CI job that runs cargo with --locked fails before compiling anything: error: cannot update the lock file ... because --locked was passed This is one generated line; no dependency versions change.
#719) The unit tests assert where the managed block lands. Only niri itself can confirm the result is a config it will actually load, which is the property the reporter cared about: the old code produced output niri rejected outright. Verified this test earns its keep: with the brace-depth check removed it fails against real niri, and passes with it. Skips cleanly when niri is absent, so it is a hard check on a niri machine and a no-op elsewhere.
delete_back/delete_forward consume a selection first, but delete_word_back and delete_word_forward did not. A word-delete with an active selection therefore shortened the buffer while leaving `anchor` pointing past the new end. The next ordinary Backspace sliced out of bounds and panicked, and because the panic crosses winit's Objective-C key_down boundary it aborted the process rather than unwinding. Reported with a deterministic repro (type 'hello world', Shift+Left, Option+Backspace, Backspace) and the correct minimal fix by @wtchronos. The two regression tests fail before this change and pass after it.
…ixes #729) create_headless_session called enable_memory_test_mode() unconditionally, even though its own doc comment says test mode is 'called when session is marked as debug'. That function is also the production path for real swarm-spawned workers, so every inline/headless worker got MemoryManager { test_mode: true }, and project_memory_path() then short-circuits to ~/.jcode/memory/test/ before ctx.working_dir is ever consulted. The effect: a spawned worker could never read what the session that spawned it remembered, and its own 'durable' writes went to throwaway storage. This is distinct from #491 and #720, which fix working-dir scoping in paths that never reach this override. Isolation is now explicit per caller: debug-socket admin sessions opt in (where isolation is the point), real swarm spawns opt out. Diagnosed by @jonschull while verifying the #720 follow-up.
Keeps editor.rs near the code-size budget, following this test directory's stated 'split by concern so no file grows unbounded' rule. Rebaselines the two entries the fixes genuinely grow: editor.rs (+9, the selection guards) and comm_session.rs (+2, the new isolate_memory argument). No other baselines touched.
Makes the severity of enabling memory test mode on a production path explicit: a manager in test mode cannot see real project memory even when handed the correct project directory, because project_memory_path() short-circuits before the directory is consulted. That is exactly what swarm-spawned workers were subjected to unconditionally, so they could never read what the session that spawned them remembered.
…715) A cfg'd-out stub cannot be caught by tests that only run where it is absent, which is why spawn_in_new_terminal could be a silent no-op on Windows for so long. This asserts the checkable property instead: the function exists on every target, and the launcher arguments it forwards are platform-neutral. Verified it catches the regression: reintroducing the cfg(not(unix)) split makes this test fail to build.
…ime slot (refs #712) Named profiles run on the generic openai-compatible runtime, so the report was headed 'auth-test: openai-compatible' and the credential probe said 'OpenAI-compatible auth status is ...' no matter which profile the user selected. After the probe-target fix the verdict was correct but still not attributable to a target, which is most of what made #712 confusing. Both the header and the credential line now name the profile: === auth-test: company-gateway (openai-compatible profile) === ✓ credential_probe — company-gateway auth status is available (...) Builtin providers are unchanged, including while a profile is set. The regression test fails if the label falls back to the runtime slot.
…#715) The compile-time guard proves spawn_in_new_terminal exists on every target, but not that a spawn happens. spawn_in_new_terminal short-circuits under cfg!(test) so unit tests never pop real windows, so this drives the layer immediately below that guard: the exact TerminalCommand the fixed function builds, through the real launcher, with the configured spawn hook as the injectable seam. A recording hook script asserts the launcher both received the --resume invocation and reported success. Verified sensitive: emptying the forwarded args makes it fail with 'launcher never received the resume invocation'.
…729) A bare bool at the call site is one typo away from silently reintroducing #729, where every real swarm worker was forced into throwaway test storage and could never read what the session that spawned it remembered. The original bug was exactly this shape: an unconditional call whose intent was documented only in a comment on the function it called. The call sites now read: comm_session.rs HeadlessMemoryScope::RealProject debug_session_admin.rs HeadlessMemoryScope::IsolatedTest so the wrong one is hard to pick by accident and obvious in review.
The first version drove the configured spawn hook, which is resolved through the process-wide cached config. It passed when run alone and failed in CI, where an earlier test in the same binary had already loaded config, so the hook override was never observed. That is a flaky test, which is worse than no test. Now it drives spawn_command_in_new_terminal_with directly, the injectable seam the real path bottoms out in, and records what the spawner received. No config, no env vars, no process spawning, so ordering cannot affect it. Verified: passes standalone, in-module, and under --test-threads=1, and still fails with 'launcher never received the resume invocation' when the forwarded args are emptied.
… node (refs #719) The depth scanner added for #719 only understood `//` line comments. KDL also has `/* */` block comments, which may contain *unbalanced* braces, and real niri accepts that. A single stray `{` in a comment therefore made every following node look nested, so the genuine top-level `binds` node was skipped and a duplicate one appended. Found by probing real niri for constructs the scanner had not been written against, rather than re-testing what it already handled. The original fix was verified only against configs I had thought of. The real-niri test now sweeps four shapes: nested compositor binds, unbalanced braces in a block comment, a brace inside a quoted string, and a config with no binds node. Verified all of it catches the regression: removing block-comment handling fails both the unit test and the real-niri sweep.
…efs #719) Extends the real-niri sweep to six shapes, adding two KDL string forms the depth scanner had not been checked against: an escaped quote followed by a brace, and a raw string (r#"..."#) where a backslash is not an escape and the content ends with a backslash before the closing delimiter. Both are accepted by real niri, and both are now confirmed to leave the insert point correct.
The reported bug was one method forgetting to clear `anchor`, and it only surfaced on the *next* keystroke. Two targeted tests cover the two reported methods; this checks the invariant across every mutating operation, four selection shapes and four buffers including multibyte text, then drives one further edit because that is where the panic actually landed. Verified it rediscovers the original defect independently: removing the fix fails with 'delete_word_back after extend_left on "hello world": stale selection 6..11 over "hello d"', which is the reporter's exact buffer state.
…#719) Hand-written cases are how the block-comment bug survived the first fix: they only cover constructs I had already thought of. This uses niri itself as the oracle instead. The generator emits random KDL built from constructs that stress a brace scanner (block comments with unbalanced braces, nested and multiline block comments, /- slashdash nodes, line comments ending in a brace, quoted and raw strings, nested compositor binds), keeps only configs real niri accepts, and the test asserts each still validates after jcode splices its block in. 550-case corpus committed for a hermetic ~3s test. Beyond it, ~2400 configs across five independent seeds were run out-of-band with no failures. Verified the corpus earns its keep: removing block-comment handling fails with 'niri rejected a spliced config that it accepted before'.
…y (refs #729) The existing coverage was structural: it pinned that test mode ignores the project dir, and the call sites now name their choice. Neither actually executes the tool, which is what the reporter did. This drives Tool::execute end to end: a spawning session records a project-scoped memory, then a worker with real memory (the fixed path) must see it, and a worker in test mode (the pre-fix path) must not. Driving the tool rather than inspecting a flag keeps it honest across refactors. Verified sensitive: switching the worker back to test mode fails with 'a swarm worker must see the spawning session's project memory, got: No memories stored', which is the exact symptom reported.
… (refs #715) The Windows spawn tests in this crate are all cfg(not(unix)), so none of them run in this repo's Linux CI or on a Linux dev box. That is the same blind spot that let the in-app spawn stub sit unnoticed off Unix in the first place. windows_command_line is compiled under cfg(test) on every platform, so pin the resume invocation where it will actually be exercised: a program path containing a space must be quoted (or cmd.exe would run 'C:\\Program'), and safe arguments must not be needlessly quoted. Verified sensitive: replacing the quoting with a plain join fails with 'unquoted program path would break on a default Windows install'.
Keeps lib.rs near its budget and gives the platform-independent Windows checks an obvious home, with a module doc explaining why they exist: the cfg(not(unix)) tests beside them never run in this repo's Linux CI, which is the blind spot that hid #715. One baseline line moves (1216 -> 1219) for the module declaration itself.
…732) A session can be renamed while a turn is still streaming (attach/resume of an existing session goes through rename_shutdown_signal). The process-global turn cancel registry is keyed by session id but was never migrated, so the running turn stayed filed under the old id. A later Esc resolved no active-turn signal for the new id and fell back to firing only the control-handle signal, which can be a stale instance: the client showed 'Interrupting...' while the model kept generating (regression of #428). - rename_active_turns() moves in-flight registrations, called from rename_shutdown_signal alongside the shutdown/background signals. - ActiveTurnGuard cleanup now removes by token across buckets, since the guard's session id can be stale after a rename (no orphan entries). - Both turn loops refuse to open a new provider request once a cancel is observed, so recovery/continuation paths cannot restart a cancelled turn. Tests: two registry regression tests; jcode-app-core lib suite green.
…ixes #730) The description was reworded to open with 'Requirement-to-check', which broke the case-sensitive contains() check and left master's workspace unit tests red (CI cohorts do not run them, so it went unnoticed).
This was referenced Aug 2, 2026
Closed
Contributor
Greptile SummaryThis PR fixes interrupt cancellation across session renames and updates related regression paths. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The cancellation fix is localized and covered by targeted registry tests. The related wiring changes are explicit and include focused regression coverage. No blocking correctness or security issues were identified. Files Needing Attention: No files require special attention.
What T-Rex did
|
| Filename | Overview |
|---|---|
| crates/jcode-app-core/src/turn_cancel_registry.rs | Adds active-turn registry rename support and token-based cleanup for guards whose session id became stale. |
| crates/jcode-app-core/src/server/client_session.rs | Migrates active turn cancel registrations during session-id rename alongside existing shutdown/background signals. |
| crates/jcode-app-core/src/agent/turn_streaming_mpsc.rs | Adds a loop-head cancellation guard for streaming turns and recovery continuations. |
| crates/jcode-app-core/src/agent/turn_loops.rs | Adds a cancellation check at the non-streaming turn loop head to avoid starting provider retries after interrupt. |
| crates/jcode-app-core/src/server/headless.rs | Replaces unconditional memory test mode with an explicit HeadlessMemoryScope enum selected by callers. |
| crates/jcode-provider-anthropic/src/lib.rs | Forwards the real schedule schema in OAuth mode and exposes bash justification in the curated schema. |
| crates/jcode-setup-hints/src/linux_niri.rs | Improves niri managed-block insertion to avoid nested binds and ignore braces inside strings/comments. |
| crates/jcode-terminal-launch/src/lib.rs | Adds client-terminal environment propagation and injectable terminal spawning behavior. |
| src/cli/provider_init.rs | Extends provider initialization choices and wiring for the updated provider/runtime set. |
Sequence Diagram
sequenceDiagram
participant Client
participant Session as client_session::rename_shutdown_signal
participant Shutdown as shutdown_signals
participant Bg as background tool signals
participant Registry as turn_cancel_registry
participant Turn as streaming turn
Client->>Session: attach/resume existing session
Session->>Shutdown: move old_session_id signal to new_session_id
Session->>Bg: rename_background_tool_signal(old, new)
Session->>Registry: rename_active_turns(old, new)
Registry->>Registry: move active turn signals to new bucket
Client->>Registry: request_cancel(new_session_id)
Registry->>Turn: fire registered InterruptSignal
Turn->>Turn: observe graceful shutdown at loop head
Turn-->>Client: stop without opening another provider request
Reviews (2): Last reviewed commit: "docs: onboarding state-space graph + pri..." | Re-trigger Greptile
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.
Fixes #732 (regression of #428) and #730.
#732 — Esc during streaming does nothing, model keeps generating
Root cause: the process-global turn cancel registry (added for #428) is keyed by session id, but a session can be renamed while a turn is still streaming. Attaching to or resuming an existing session goes through
rename_shutdown_signal, which migrated the shutdown signal and the background-tool signal but not the turn cancel registry. The running turn stayed filed under the old id, so a laterrequest_cancelon the new id resolved zero active-turn signals and fell back to firing only the control-handle signal, which is exactly the stale instance #428 was about. Result:SERVER_INTERRUPT_CANCEL_NO_LOCAL_TASK, "Interrupting..." in the client, and the model streaming on for minutes.Changes
turn_cancel_registry::rename_active_turns()migrates in-flight registrations; called fromrename_shutdown_signalnext to the other two signal migrations.ActiveTurnGuard::dropnow removes by token across all session buckets, because the guard's stored session id can be stale after a rename. This prevents an orphaned entry from letting a later cancel fire a finished turn's signal.New log line:
TURN_CANCEL_RENAMED old_session=... new_session=... moved=N#730 — pre-existing red unit test on master
tool::todo::schema_advertises_intent_and_todosassertedcontains("requirement-to-check")case-sensitively; the description was reworded to start with "Requirement-to-check". The assertion is now case-insensitive with a message that prints the actual description.Validation
cargo test -p jcode-app-core --lib: 1066 passed, 0 failed (was 1 failed before the Pre-existing test failure on master: tool::todo schema_advertises_intent_and_todos (CI cohorts do not run workspace unit tests) #730 fix).cargo clippy -p jcode-app-core --lib --all-targets: no new warnings.@dmt4 this should address the case you hit on 36d9479. If it recurs after this lands, the new
TURN_CANCEL_RENAMED/SESSION_CANCEL_ACTIVE_TURN_SIGNALS_FIREDlines in~/.jcode/logs/will show whether the cancel reached a registered turn.--- — Jcode agent (automated triage), on behalf of @1jehuang