Repository navigation
fix(cli): name kcode in every resume hint, not jcode (supersedes #319) #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,10 +320,28 @@ pub fn show_crash_resume_hint() { | |
| /// `~/.kcode`, so the session they were told to resume is not in that store - | ||
| /// 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 { | ||
| "kcode" | ||
| } | ||
|
|
||
| /// `<bin> --resume <id>` - the exact command that resumes `session_id`. | ||
| /// | ||
| /// 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()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: cc @Kilo-Fix |
||
| } | ||
|
|
||
| /// 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 { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: cc @Kilo-Fix |
||
| format!( | ||
| "\nUse `{} --resume` to list available sessions.", | ||
| resume_binary_stem() | ||
| ) | ||
| } | ||
|
|
||
| /// Build the crash-resume hint lines for `crashed`, newest first. | ||
| /// | ||
| /// Pure so the wording is testable: the lines are printed to stderr outside the | ||
|
|
@@ -351,7 +369,7 @@ fn crash_resume_hint_lines( | |
| // Always mention the picker. Showing only the ID form reads as | ||
| // "write this down or lose the session", when bare | ||
| // `jcode --resume` opens a searchable list (issue #690). | ||
| format!("{yellow} Or browse all:{reset} jcode --resume"), | ||
| format!("{yellow} Or browse all:{reset} {bin} --resume"), | ||
| ] | ||
| } else { | ||
| vec![ | ||
|
|
@@ -360,14 +378,14 @@ fn crash_resume_hint_lines( | |
| crashed.len() | ||
| ), | ||
| format!("{yellow} Resume with:{reset} {bin} --resume {id}"), | ||
| format!("{yellow} List all:{reset} jcode --resume"), | ||
| format!("{yellow} List all:{reset} {bin} --resume"), | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod crash_resume_hint_tests { | ||
| use super::crash_resume_hint_lines; | ||
| use super::{crash_resume_hint_lines, resume_binary_stem}; | ||
|
|
||
| fn session(id: &str, name: &str) -> (String, String) { | ||
| (id.to_string(), name.to_string()) | ||
|
|
@@ -389,10 +407,9 @@ mod crash_resume_hint_tests { | |
| 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()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: The reworded picker assertion derives its expected string from cc @Kilo-Fix |
||
| assert!( | ||
| lines | ||
| .iter() | ||
| .any(|line| line.contains("Or browse all: jcode --resume")), | ||
| lines.iter().any(|line| line.contains(&picker)), | ||
| "the picker form (bare --resume) must be mentioned too: {joined}" | ||
| ); | ||
| } | ||
|
|
@@ -632,7 +649,7 @@ fn write_session_resume_hint(mut writer: impl Write, session_id: &str) -> io::Re | |
| if let Some(command) = super::ssh::resume_hint(session_id) { | ||
| writeln!(writer, " {command}")?; | ||
| } else { | ||
| writeln!(writer, " {} --resume {}", resume_binary_stem(), session_id)?; | ||
| writeln!(writer, " {}", resume_hint(session_id))?; | ||
| } | ||
| writeln!(writer)?; | ||
| Ok(()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: Making
resume_binary_stempub(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:136builds its ownvec!["kcode", "--ssh", ...]cloud_move.rs:124remote_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