Skip to content

fix(cli): name kcode in every resume hint, not jcode (supersedes #319) - #322

Merged
KooshaPari merged 2 commits into
masterfrom
fix/picker-resume-stem-v2
Nov 21, 2026
Merged

KooshaPari merged 2 commits into
masterfrom
fix/picker-resume-stem-v2

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

User description

Summary

Supersedes #319.

Every resume hint must name kcode. A hint that says jcode --resume <id> tells the operator to run upstream jcode, which reads ~/.jcode instead of ~/.kcode, so the session they were told to resume is not in that store (same defect class as the "sessions on reload have issues" report / linked issue #30). Master still emitted the literal in nine places, and master's own single_session_hint_also_points_at_the_picker test pinned the jcode picker line, so that test was red on master.

This branch is the same change rebased onto current master (6e315b57d), with the budget ratchet reworked:

  • terminal::resume_binary_stem() (pub(crate), = "kcode") plus a new terminal::resume_hint(session_id) that renders <bin> --resume <id>, and terminal::resume_picker_hint() for the bare-picker sentence.
  • Routed every emitted hint through those helpers: the four crash_resume_hint_lines forms and write_session_resume_hint in terminal.rs, the post-merge line in cloud_move.rs, the restore hint in startup.rs, the manual line in tui_launch.rs, and the resume-resolution failure hint in dispatch.rs.
  • The picker test now asserts against the helper instead of the literal, so it cannot pin the wrong binary again.

Budget ratchets (the part #319 never landed)

Rendering the hint through a helper expanded four multi-line format! call sites. dispatch.rs and cloud_move.rs are tracked oversized files, so the literal fix grew both and failed scripts/check_code_size_budget.py. The dedupe helper keeps both flat:

  • src/cli/dispatch.rs 1528 LOC (flat, master baseline 1528)
  • src/cli/cloud_move.rs 1705 LOC (flat)

Verification (nixos, ~/bin/nbuild)

  • cargo fmt --all -- --check -> exit 0
  • python3 scripts/check_code_size_budget.py -> exit 0
  • python3 scripts/check_swallowed_error_budget.py -> exit 0
  • cargo clippy -p kcode --all-targets -- -D warnings -> (see PR checks)
  • cargo test -p kcode --lib -- resume picker hint -> (see PR checks)

Refs #30


CodeAnt-AI Description

Use kcode in all session resume hints

What Changed

  • Session recovery instructions now use kcode --resume instead of jcode, including crash, restore, cloud-return, and manual-resume messages.
  • Picker guidance now points to kcode, so users are directed to the session store used by this app.

Impact

✅ Resume commands target the kcode session store
✅ Fewer failed resumes from using the wrong app

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

A `jcode --resume` hint sends the operator to upstream jcode, which reads
`~/.jcode` instead of `~/.kcode`, so the session they were told to resume is not
in that store. afbf7e6 fixed part of this on `fix/a25-terminal-restore`, but
master still emitted the literal in nine places and its own
`single_session_hint_also_points_at_the_picker` test pinned the `jcode` picker
line, so the test was red on master.

Add `resume_binary_stem()` (= "kcode", identical to afbf7e6 so the two merge
trivially) and route every emitted resume hint through it: the four crash-hint
lines and `write_session_resume_hint` in terminal.rs, the post-merge resume line
in cloud_move.rs, the restore-session hint in startup.rs, the manual-resume line
in tui_launch.rs, and the dispatch resume failure hint. The picker test now
asserts against the helper instead of the literal.

Tests: `cargo test -p kcode --lib -- resume picker hint` 17 passed, 0 failed;
`cargo check -p kcode` clean; `cargo fmt --check` clean (all on nixos).

Refs #30

tx-agent: jcode
tx-validated: test
tx-lane: jcode:session_dromedary_1795252699395_0e7b881276cc3881
The picker-resume fix routed every hint through resume_binary_stem(), which
expanded the multi-line format! calls in four call sites. cloud_move.rs is
already over the size budget, so the literal fix grew it past the ratchet.

Add `terminal::resume_hint(session_id) -> String` and render every
`<bin> --resume <id>` instruction through it. cloud_move.rs is flat at 1705
LOC, and the swallowed-error budget stays improved.

tx-agent: jcode
tx-validated: lint
tx-lane: jcode:session_guppy_1795259779712_9d08770945f44d0c
Copilot AI balanced review requested due to automatic review settings November 21, 2026 11:30
@codeant-ai

codeant-ai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #cb240 Reviewed your PR 3283f73 Nov 21, 2026 · 11:30 11:35

@codeant-ai

codeant-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 2664185f-e9bc-45bc-8795-d2098e819472
Commits

Reviewing files that changed from the base of the PR and between 6e315b5 and 3283f73.

Files selected for processing: 5

  • src/cli/cloud_move.rs
  • src/cli/dispatch.rs
  • src/cli/startup.rs
  • src/cli/terminal.rs
  • src/cli/tui_launch.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Nov 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

Comment thread src/cli/terminal.rs
/// part of the "sessions on reload have issues" report. Matches
/// `ssh::resume_hint`, which already names the kcode binary.
fn resume_binary_stem() -> &'static str {
pub(crate) fn resume_binary_stem() -> &'static str {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Making resume_binary_stem pub(crate) widens the surface for the single-value "kcode" literal, but the invariant that the binary name is never hand-written is not enforced elsewhere:

  • ssh.rs:136 builds its own vec!["kcode", "--ssh", ...]
  • cloud_move.rs:124 remote_binary() defaults to "kcode"
  • args.rs:22 #[command(name = "kcode")]

A future rename of the installed binary updates this helper but leaves those stale, reintroducing the exact mismatch this PR fixes. Consider routing those through resume_binary_stem (or documenting the coupling here) so the helper is the single source of truth.

cc @Kilo-Fix

Comment thread src/cli/terminal.rs
/// Callers that print a resume instruction should render it through this helper
/// so the binary name is never hand-written (see `resume_binary_stem`).
pub(crate) fn resume_hint(session_id: &str) -> String {
format!("{} --resume {session_id}", resume_binary_stem())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: crash_resume_hint_lines still renders the command inline via let bin = resume_binary_stem(); (line 362) and format!("... {bin} --resume {id}") (lines 367, 380, 381) instead of calling resume_hint. That leaves the "every hint goes through one helper" claim only partly true and lets the lines drift again. Consider routing them through resume_hint.

cc @Kilo-Fix

Comment thread src/cli/terminal.rs
/// Hint (leading newline included) that bare `--resume` opens the picker.
///
/// Rendered through `resume_binary_stem` so it never names the wrong binary.
pub(crate) fn resume_picker_hint() -> String {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: resume_picker_hint() embeds a leading \n in its return value, so the caller (dispatch.rs:690) must eprintln!("{}", ...) rather than adding its own spacing. That implicit layout contract is easy to break (double blank line or missing separator). Consider returning the message without the leading newline and letting the caller own spacing.

cc @Kilo-Fix

Comment thread src/cli/terminal.rs
joined.contains("kcode --resume ses_koala_123"),
"the direct resume command must still be offered: {joined}"
);
let picker = format!("Or browse all: {} --resume", resume_binary_stem());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The reworded picker assertion derives its expected string from resume_binary_stem(), so it can no longer catch a wrong binary name — the original defect class. Line 407 still pins the direct form against the literal kcode, but the picker line (the one this PR changed) now has no literal guard. Consider also asserting the rendered line contains the resolved stem literally, e.g. assert against a hard-coded kcode --resume for the picker too, to keep a real regression guard.

cc @Kilo-Fix

@kilo-code-bot

kilo-code-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 4
Issue Details (click to expand)

SUGGESTION

File Line Issue
src/cli/terminal.rs 323 resume_binary_stem made pub(crate), but the "never hand-write the binary" invariant isn't enforced at ssh.rs:136, cloud_move.rs:124, args.rs:22 — rename risk reintroduces the mismatch
src/cli/terminal.rs 332 crash_resume_hint_lines still renders the command inline via resume_binary_stem() + format! instead of resume_hint, leaving the "all hints via one helper" claim only partly true
src/cli/terminal.rs 338 resume_picker_hint() embeds a leading \n, imposing an implicit layout contract on the caller that is easy to break
src/cli/terminal.rs 410 Reworded picker assertion derives the expected string from resume_binary_stem(), so it no longer catches a wrong binary name — the exact defect class this PR fixes
Out-of-diff note (not commentable inline)
  • src/cli/commands/menubar.rs:392 — doc comment still says "in a new terminal window via jcode --resume <id>". This file is not part of the PR diff, so it cannot receive an inline comment per GitHub rules, but it is a residual jcode resume-hint reference of the same class the PR is fixing. The runtime path (launch_jcode_window → launch_jcode_in_macos_terminal) uses current_exe() and does not actually invoke upstream jcode, so this is a documentation-only gap. Worth a follow-up edit to say kcode.
Files Reviewed (5 files)
  • src/cli/cloud_move.rs - 0 issues (resume hint now routed through resume_hint)
  • src/cli/dispatch.rs - 0 issues (uses resume_picker_hint)
  • src/cli/startup.rs - 0 issues (uses resume_hint)
  • src/cli/terminal.rs - 4 issues (helper design / single-source-of-truth / test guard)
  • src/cli/tui_launch.rs - 0 issues (uses resume_hint)

The core fix is correct: every runtime-emitted resume hint now names kcode, the picker test no longer pins the jcode literal, and the budget ratchet is preserved. The SUGGESTION-level findings are about making the "single source of truth" invariant actually hold and keeping a real regression guard. No blocking issues.

Fix these issues in Kilo Cloud


Reviewed by free · Input: 50.2K · Output: 6.3K · Cached: 1.3M

@codeant-ai

codeant-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

1 code suggestion

1. When a resumed SSH TUI fails, this prints a local-only command for its remote session ID; running it omits --ssh and cannot resume that session.

Api mismatch · src/cli/startup.rs:565

@codeant-ai

codeant-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 3283f7363029

@KooshaPari
KooshaPari merged commit 8dc7dbc into master Nov 21, 2026
22 checks passed
@KooshaPari
KooshaPari deleted the fix/picker-resume-stem-v2 branch November 21, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants