Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(picker): show the resolved config path in disabled-summary hints (#3290)
Maximilian Roos14c79c161bde
diff --git a/src/commands/picker/mod.rs b/src/commands/picker/mod.rsindex b6552640c..60474c413 100644--- a/src/commands/picker/mod.rs+++ b/src/commands/picker/mod.rs@@ -1666,19 +1666,53 @@ pub fn handle_picker(if config.list.summary() && config.commit_generation.is_configured() {(config.commit_generation.command.clone(), None)} else {+ // Point at the config file wt actually loads from — respecting+ // --config, WORKTRUNK_CONFIG_PATH, and $XDG_CONFIG_HOME — rather+ // than a hardcoded default. Fall back to the canonical path on the+ // rare occasion no location can be determined.+ let config_path = worktrunk::config::config_path()+ .map(|p| format_path_for_display(&p))+ .unwrap_or_else(|| "~/.config/worktrunk/config.toml".to_string());+ // Keep every prose line short and put the resolved path on its own+ // line. `render_summary` word-wraps prose to the preview width, and+ // that width is a column narrower under Windows' PTY — so a sentence+ // long enough to wrap lands its break on a different word there, and+ // the single cross-platform snapshot can't match. A short lead line,+ // the path alone (one unbreakable token, no wrap boundary to shift),+ // and the fenced config block (code blocks are never wrapped) all+ // render identically on every platform. The first line stays the bold+ // H4 subject, which `render_summary` promotes and never wraps.let hint = if !config.commit_generation.is_configured() {- "Configure [commit.generation] command to enable LLM summaries.\n\n\- Example in ~/.config/worktrunk/config.toml:\n\n\- [commit.generation]\n\- command = \"llm -m haiku\"\n\n\- [list]\n\- summary = true\n"+ format!(+ r#"Summaries not configured++Add a [commit.generation] command in:+{config_path}++```toml+[commit.generation]+command = "llm -m haiku"++[list]+summary = true+```+"#+ )} else {- "Enable summaries in ~/.config/worktrunk/config.toml:\n\n\- [list]\n\- summary = true\n"+ format!(+ r#"Summaries off++Enable summaries in:+{config_path}++```toml+[list]+summary = true+```+"#+ )};- (None, Some(hint.to_string()))+ (None, Some(hint))};// The picker's full row list — header, worktree/branch rows, and (in `--prs`diff --git a/tests/integration_tests/switch_picker.rs b/tests/integration_tests/switch_picker.rsindex 5800e86a4..9f651f080 100644--- a/tests/integration_tests/switch_picker.rs+++ b/tests/integration_tests/switch_picker.rs@@ -1311,8 +1311,8 @@ fn test_switch_picker_preview_panel_summary(mut repo: TestRepo) {&[// Cursor-navigation select: see test_switch_picker_preview_panel_uncommitted// for the matcher-lag rationale.- ("\x1b[B", None), // Down: move cursor to `feature`- ("\x1b5", Some("Configure")), // Alt-5: summary panel; wait for hint+ ("\x1b[B", None), // Down: move cursor to `feature`+ ("\x1b5", Some("commit.generation")), // Alt-5: summary panel; wait for hint],);@@ -1326,6 +1326,49 @@ fn test_switch_picker_preview_panel_summary(mut repo: TestRepo) {});}+/// The summary panel's "enable summaries" hint — shown when commit.generation+/// IS configured but `[list] summary = false`. Covers the second hint arm (the+/// first is exercised by `test_switch_picker_preview_panel_summary`), and pins+/// that both hints point at the resolved config path: under the test's+/// `WORKTRUNK_CONFIG_PATH` isolation that path redacts to `[TEST_CONFIG]`, not+/// a hardcoded `~/.config/worktrunk/config.toml`.+#[rstest]+fn test_switch_picker_preview_panel_summary_disabled(mut repo: TestRepo) {+ repo.remove_fixture_worktrees();+ // Remove origin so snapshots don't show origin/main+ repo.run_git(&["remote", "remove", "origin"]);+ repo.add_worktree("feature");++ // commit.generation configured, but summaries off — the picker seeds the+ // Summary tab with the "enable summaries" hint rather than generating one.+ repo.write_test_config(+ "[commit.generation]\ncommand = \"llm -m haiku\"\n\n[list]\nsummary = false\n",+ );++ let env_vars = repo.test_env_vars();+ // Select `feature`, then Alt-5 for the summary panel. Wait for the hint.+ let result = exec_in_pty_capture_before_abort(+ wt_bin().to_str().unwrap(),+ &["switch"],+ repo.root_path(),+ &env_vars,+ &[+ // Cursor-navigation select: see test_switch_picker_preview_panel_uncommitted+ // for the matcher-lag rationale.+ ("\x1b[B", None), // Down: move cursor to `feature`+ ("\x1b5", Some("Enable")), // Alt-5: summary panel; wait for hint+ ],+ );++ assert_valid_abort_exit_code(result.exit_code);++ let (_, preview) = result.panels();+ let settings = switch_picker_settings(&repo);+ settings.bind(|| {+ assert_snapshot!("switch_picker_preview_summary_disabled_preview", preview);+ });+}+/// Seed a fresh CI-status cache entry for `branch` so the picker primes the/// row's `pr_status` at skeleton time (`populate_from_cache`) — making the `pr`/// and `comments` tabs resolve deterministically with no dependence on the livediff --git a/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_disabled_preview.snap b/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_disabled_preview.snapnew file mode 100644index 000000000..23bc8d06b--- /dev/null+++ b/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_disabled_preview.snap@@ -0,0 +1,14 @@+---+source: tests/integration_tests/switch_picker.rs+expression: preview+---+1 2 3 4 5: summary 6 7+Enter: switch | ctrl-u/d: scroll | Tab/alt-1…7: preview | a++Summaries off++Enable summaries in:+[TEST_CONFIG]++ [list]+ summary = truediff --git a/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_preview.snap b/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_preview.snapindex 193698061..6bfad660c 100644--- a/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_preview.snap+++ b/tests/snapshots/integration__integration_tests__switch_picker__switch_picker_preview_summary_preview.snap@@ -5,12 +5,13 @@ expression: preview1 2 3 4 5: summary 6 7Enter: switch | ctrl-u/d: scroll | Tab/alt-1…7: preview | a-Configure [commit.generation] command to enable LLM summari+Summaries not configured-Example in ~/.config/worktrunk/config.toml:+Add a [commit.generation] command in:+[TEST_CONFIG]-[commit.generation]-command = "llm -m haiku"+ [commit.generation]+ command = "llm -m haiku"-[list]-summary = true+ [list]+ summary = true