Skip to content

Tell the user the resume route that actually works (#6225) - #6233

Open
Hmbown wants to merge 1 commit into
mainfrom
fix/resume-message-6225
Open

Hmbown wants to merge 1 commit into
mainfrom
fix/resume-message-6225

Conversation

@Hmbown

@Hmbown Hmbown commented Sep 15, 2026

Copy link
Copy Markdown
Owner

The session-switch refusal told users to do something impossible.

This session belongs to another Runtime host.
Resume it in a new Codewhale process to reopen its saved store.

#6225 hits this from the plainest path on a clean install — start codewhale, /quit, start codewhale, /resume, pick the session — and the advice cannot be followed, because they were in a new process.

Why the advice was circular

Starting a new process and then picking the session from /resume returns to this same switch path. The route that actually works is opening the session at launch: TaskManager::start (event_loop.rs:849) passes the saved binding through to open_for_session, which calls validate_existing_store(), points the runtime at that store and opens it. That is adoption. The picker inside a running session is not — it can rebind the conversation but cannot carry a store's durable work across, so it refuses.

Both halves were true; neither was actionable.

What this changes

Only the message, which now names the condition and the command, with the session id interpolated so it is copy-pasteable:

This session's saved Runtime store belongs to a different host. Switching to it from inside a running session cannot carry that store's queued work across, but opening it directly can: run codewhale resume <id> from your shell.

This is not a fix for the refusal itself. That is #6207, and it is still wrong for the case #6225 reports — a store that exists, is owned by nobody, and holds nothing. But users should not wait on that to reach their sessions, and codewhale resume <id> works today on 0.9.13 with no patch.

Test

The binding test asserted the old literal string. It now asserts the two properties that matter — the refusal points at the direct-open path, and it names the session — rather than pinning wording:

assert!(error.contains("codewhale resume"), ...);
assert!(error.contains(&loaded.metadata.id), ...);

Checks

  • ./scripts/dev-test.sh tui12707 run, 12707 passed, 19 skipped
  • ./scripts/dev-test.sh tui runtime_store_binding — 7 passed
  • CI clippy gate --workspace --all-targets --all-features -D warnings — exits 0
  • cargo fmt --check — clean on both files

🤖 Generated with Claude Code

No-Issue: message-only remediation. This deliberately does not close #6225 — it makes the refusal's advice followable (codewhale resume <id>) without fixing the refusal itself, which is #6207 and stays open, as the body above states. Using Closes here would auto-close a bug that is still reproducible.

The session-switch refusal said:

    This session belongs to another Runtime host.
    Resume it in a new Codewhale process to reopen its saved store.

#6225 reports hitting this from the plainest possible path on a clean install —
start `codewhale`, `/quit`, start `codewhale`, `/resume`, pick the session — and
the advice is impossible to follow, because they *were* in a new process.

Starting a new process and then picking the session from `/resume` returns to
this same switch path. The route that works is opening the session **at launch**:
`TaskManager::start` passes the saved binding through to `open_for_session`,
which calls `validate_existing_store()`, points the runtime at that store and
opens it. That is adoption; the picker inside a running session is not.

So the message was true and unactionable at once. It now names the real
condition and the command, with the session id interpolated so it can be
pasted:

    This session's saved Runtime store belongs to a different host. Switching to
    it from inside a running session cannot carry that store's queued work
    across, but opening it directly can: run `codewhale resume <id>` from your
    shell.

This is only the message. The underlying refusal is #6207 and is still wrong
for the case #6225 reports — an existing, ownerless, empty store — but a user
should not have to wait for that to reach their session.

The binding test asserted the old string; it now asserts the refusal points at
the direct-open path and names the session, which is the property that matters
rather than the wording.

Checks: `./scripts/dev-test.sh tui` — 12707 tests run, 12707 passed, 19 skipped.
`./scripts/dev-test.sh tui runtime_store_binding` — 7 passed. CI clippy gate
exits 0; `cargo fmt --check` clean on both files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWzjx9Q7Mw2G7K8rpiJy9p
Copilot AI lite review requested due to automatic review settings September 15, 2026 19:14
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@claude

claude Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Claude finished @Hmbown's task in 1m 43s —— View job


Reviewing PR #6233

  • Gather context (PR body, changed files)
  • Read crates/tui/src/tui/ui/apply.rs diff
  • Read crates/tui/src/tui/ui/tests/runtime_store_binding.rs diff
  • Check for related refusal-message call sites / duplication
  • Post review findings

Summary

Small, well-scoped change: it only rewords the refusal in apply_loaded_session_with_goal (crates/tui/src/tui/ui/apply.rs:3639-3646) and loosens the matching test assertion. I traced the control flow and don't see any correctness issues.

Verified correct:

  • session: &SavedSession is in scope at the return Err(...) site, and session.metadata.id is a String (crates/tui/src/session_manager.rs:315), so format!("...{}", session.metadata.id) is sound — no borrow/lifetime issue.
  • The multi-line string literal's \-continuations strip the newline + leading indentation correctly, so the rendered message matches the PR description exactly (no stray double spaces, no line breaks embedded in the sentence).
  • codewhale resume <id> is a real, existing CLI invocation shape (confirmed via crates/cli/src/lib.rs:5435 and its tests around line 7768), so the advice is actually actionable, not aspirational.
  • The id interpolated (loaded.metadata.id in the test, session.metadata.id in the impl) is the same conversation id passed to TaskManager::start in the test setup — i.e., the id codewhale resume actually expects, not some other identifier.
  • Grepped for other copies of the old string ("belongs to another Runtime host", "Resume it in a new Codewhale process") — none found, so there's no stale duplicate left elsewhere.
  • Test change (runtime_store_binding.rs:284-293) correctly swaps a wording-pinned assertion for two property assertions (contains("codewhale resume"), contains(&loaded.metadata.id)), matching this repo's guidance to assert behavior/invariants rather than exact copy.

Minor, non-blocking:

  • The new comments in both files cite issue numbers inline (#6207, #6225) inside the code. AGENTS.md in this repo explicitly asks not to reference the current task/fix in comments ("...since those belong in the PR description and rot as the codebase evolves"). The reasoning in the comment (why the old advice was circular, which code path is real) is legitimate non-obvious WHY and worth keeping — I'd just drop the trailing issue-number citations, not the explanation.
  • Out of scope for this PR, but noting for awareness: crates/tui/src/tui/ui/frame.rs:1138 has a structurally similar terse refusal ("session snapshot refused to replace its saved Runtime store ownership") on a related Runtime-store-ownership-mismatch path. Not claiming it has the same circularity bug — just flagging it as a sibling spot worth a glance if bug(tui): session picker refuses saved sessions whose runtime store exists but is not the running host's own #6207 later does a broader pass on these refusal messages.

No provider/model-routing, security, or reuse/duplication concerns — this PR doesn't touch provider selection logic at all.

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

Codewhale review

Complete review coverage: 1/1 passes, 2 file patches, sha256:fcbe667c62bafaffbc3ae35f8ef5d60c926519e13471e19e5842aa8a694fa952.

Pass 1: PR #6233 replaces a circular/unactionable session-switch refusal message with one that names the working route (codewhale resume <id>) and interpolates the session id, and loosens the binding test from pinning the old literal to asserting two properties. The message construction (backslash line-continuations, spacing, id interpolation) is correct, and the error type remains String so format! compiles and contains works in the test. The main gaps are that the user-facing promise is not verified anywhere end-to-end, and the new wording still asserts a cause ('belongs to a different host') that the PR itself says is wrong for the case #6225 reports.

Findings

  • [WARNING] Message hardcodes an unverified CLI invocation; no test proves it works (crates/tui/src/tui/ui/apply.rs:3642)
    The new message tells users to run codewhale resume {id}, but nothing here validates that this exact command/binary/flags form is real or that passing the session id (rather than a store id/path) actually adopts the store. session.metadata.id is the session id, and the message is about reopening a saved Runtime store; if the CLI resume subcommand expects a different identifier or invocation, users are sent to a second dead end — the exact failure mode this PR is fixing. Because the test only asserts the substring "codewhale resume", a divergence between the message and the real CLI (wrong flag, wrong binary name, id rejected) would pass CI silently.
  • [WARNING] Core user-facing claim is untested; only the string is tested (crates/tui/src/tui/ui/tests/runtime_store_binding.rs:289)
    The value of this change is the claim that opening the session at launch adopts the store. The updated test only asserts that the error string contains "codewhale resume" and the session id (runtime_store_binding.rs:288-295); it does not exercise TaskManager::start -> open_for_session/validate_existing_store to prove adoption succeeds, nor does it pin the full command shape (codewhale resume <id>). A regression that changes the CLI syntax, or that breaks the direct-open path the message now advertises, would leave the message confidently wrong with all tests green.
  • [INFO] New wording may still misdiagnose the #6225 case (crates/tui/src/tui/ui/apply.rs:3639)
    The message asserts the store "belongs to a different host." The PR description states the underlying refusal (#6207) is still wrong for the case #6225 actually reports — a store that exists, is owned by nobody, and holds nothing. For that user the new message attributes a cause (foreign host) that may not be true, even though the actionable advice is now correct. Consider softening the causal clause (e.g. describing the observable condition rather than the inferred owner) so the message is accurate for both cases.
  • [INFO] Comment duplicates PR narrative and references internal symbols that can drift (crates/tui/src/tui/ui/apply.rs:3634)
    The 9-line comment (apply.rs:3629-3637) restates the PR description and hardcodes internal names (TaskManager::start, open_for_session, runtime_threads.rs, validate_existing_store, open_inner) plus issue numbers. These are not checked by the compiler, so they will silently go stale as the call path is refactored. A shorter comment describing why the picker differs from launch would carry the intent without the drift risk.

Suggestions

  • crates/tui/src/tui/ui/tests/runtime_store_binding.rs:289 — Keep these substring assertions, but treat them as a message-shape check rather than proof of the advertised route. Add a separate test that actually drives the launch-based adoption path (start the runtime with the saved binding already present, as TaskManager::start does, and assert the store is opened/adopted and no switch error is produced). That directly validates the promise the new message makes, which the current string-only assertions cannot. If a launch-route test is expensive here, at minimum add a CLI/integration test that codewhale resume <id> (with the exact command text in this message) succeeds against the foreign store. This is a test-infrastructure change, so no literal replacement is provided.

Assessment

Pass 1: Small, low-risk change that is correct as written: the format string's line-continuations produce the intended single-spaced message, the interpolated session.metadata.id is a String so format! and the error type are consistent, and the test's use of contains on String with a &String pattern is valid. The wording is a genuine improvement over the circular advice. The remaining risk is not in the diff's mechanics but in its verification: the newly advertised codewhale resume <id> route is unproven end-to-end and its exact syntax is unpinned by the test, and the message still asserts a cause that the PR acknowledges may not hold for the #6225 scenario. Recommend following up with a launch-path adoption test and, ideally, softening the causal clause.


Advisory review by Codewhale (codewhale review --pr 6233 --post, head 2ebbef696b0771b6eed4c243753286bdb3efa423). Line-specific findings are also posted as inline review comments; mechanical fixes arrive as committable suggestions you can apply from the Files tab. CODEOWNERS approval still governs merge.

"This session's saved Runtime store belongs to a different host. \
Switching to it from inside a running session cannot carry that \
store's queued work across, but opening it directly can: run \
`codewhale resume {}` from your shell.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[WARNING] Message hardcodes an unverified CLI invocation; no test proves it works

The new message tells users to run codewhale resume {id}, but nothing here validates that this exact command/binary/flags form is real or that passing the session id (rather than a store id/path) actually adopts the store. session.metadata.id is the session id, and the message is about reopening a saved Runtime store; if the CLI resume subcommand expects a different identifier or invocation, users are sent to a second dead end — the exact failure mode this PR is fixing. Because the test only asserts the substring "codewhale resume", a divergence between the message and the real CLI (wrong flag, wrong binary name, id rejected) would pass CI silently.

// then picking the session from `/resume` returns here, because that is
// this same switch path (#6207, #6225).
assert!(
error.contains("codewhale resume"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[WARNING] Core user-facing claim is untested; only the string is tested

The value of this change is the claim that opening the session at launch adopts the store. The updated test only asserts that the error string contains "codewhale resume" and the session id (runtime_store_binding.rs:288-295); it does not exercise TaskManager::start -> open_for_session/validate_existing_store to prove adoption succeeds, nor does it pin the full command shape (codewhale resume <id>). A regression that changes the CLI syntax, or that breaks the direct-open path the message now advertises, would leave the message confidently wrong with all tests green.

// adopts it (runtime_threads.rs, `validate_existing_store` then
// `open_inner`). So the advice has to say which one (#6207, #6225).
return Err(format!(
"This session's saved Runtime store belongs to a different host. \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[INFO] New wording may still misdiagnose the #6225 case

The message asserts the store "belongs to a different host." The PR description states the underlying refusal (#6207) is still wrong for the case #6225 actually reports — a store that exists, is owned by nobody, and holds nothing. For that user the new message attributes a cause (foreign host) that may not be true, even though the actionable advice is now correct. Consider softening the causal clause (e.g. describing the observable condition rather than the inferred owner) so the message is accurate for both cases.

// in circles: starting a new process and then picking the session
// from `/resume` lands here again, because that is this same
// switch path. Opening the session *at launch* is a different
// route — `TaskManager::start` passes the saved binding through to

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[INFO] Comment duplicates PR narrative and references internal symbols that can drift

The 9-line comment (apply.rs:3629-3637) restates the PR description and hardcodes internal names (TaskManager::start, open_for_session, runtime_threads.rs, validate_existing_store, open_inner) plus issue numbers. These are not checked by the compiler, so they will silently go stale as the call path is refactored. A shorter comment describing why the picker differs from launch would carry the intent without the drift risk.

assert!(
error.contains(&loaded.metadata.id),
"the refusal must name the session to open: {error}"
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Keep these substring assertions, but treat them as a message-shape check rather than proof of the advertised route. Add a separate test that actually drives the launch-based adoption path (start the runtime with the saved binding already present, as TaskManager::start does, and assert the store is opened/adopted and no switch error is produced). That directly validates the promise the new message makes, which the current string-only assertions cannot. If a launch-route test is expensive here, at minimum add a CLI/integration test that codewhale resume <id> (with the exact command text in this message) succeeds against the foreign store. This is a test-infrastructure change, so no literal replacement is provided.

@Hmbown

Hmbown commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

I had written the same message fix independently before reading this PR, and have dropped my commit — this one is better (full id, copy-pasteable). One thing mine had that this does not, offered as a note rather than a change:

The advice is only actionable when the store can actually be adopted. open_for_session calls binding.validate_existing_store(), which fails closed on a store whose owner.json is unreadable or whose recomputed scope does not match the saved one. In that case codewhale resume <id> refuses too, and the new message has replaced one circle with another — a quieter one, because the user now has a command that looks authoritative.

Guarding it is a couple of lines at the same site:

let remedy = match binding.validate_existing_store() {
    Ok(()) => format!("…run `codewhale resume {}` from your shell.", session.metadata.id),
    Err(error) => format!("That store cannot be adopted as it stands: {error:#}"),
};

Not a blocker — the common case is a store that validates, which is exactly #6225. Take it or leave it.

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.

Nifty selfdiagnosis; unable to resume from within new process

2 participants