Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat: move deprecation details to `wt config show` (#828)

Maximilian Roos5f42e8442f8f
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rs
index 7ca94b7ab..1ec59b400 100644
--- a/src/commands/config/show.rs
+++ b/src/commands/config/show.rs
@@ -312,9 +312,6 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
- // Trigger deprecation warnings (runs on raw content before parsing, so works even for invalid configs)
- let _ = UserConfig::load();
-
// Read and display the file contents
let contents = std::fs::read_to_string(&config_path).context("Failed to read config file")?;
@@ -323,6 +320,20 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
+ // Check for deprecations with show_brief_warning=false (silent mode)
+ // User config is global, not tied to any repository
+ if let Ok(Some(info)) = worktrunk::config::check_and_migrate(
+ &config_path,
+ &contents,
+ true,
+ "User config",
+ None,
+ false, // silent mode - we'll format the output ourselves
+ ) {
+ // Add deprecation details to the output buffer
+ out.push_str(&worktrunk::config::format_deprecation_details(&info));
+ }
+
// Validate config (syntax + schema) and warn if invalid
if let Err(e) = toml::from_str::<UserConfig>(&contents) {
// Use gutter for error details to avoid markup interpretation of user content
@@ -369,7 +380,21 @@ pub(super) fn warn_unknown_keys<C: worktrunk::config::WorktrunkConfig>(
fn render_project_config(out: &mut String) -> anyhow::Result<()> {
// Try to get current repository root
- let repo_root = match Repository::current().and_then(|repo| repo.current_worktree().root()) {
+ let repo = match Repository::current() {
+ Ok(repo) => repo,
+ Err(_) => {
+ writeln!(
+ out,
+ "{}",
+ cformat!(
+ "<dim>{}</>",
+ format_heading("PROJECT CONFIG", Some("Not in a git repository"))
+ )
+ )?;
+ return Ok(());
+ }
+ };
+ let repo_root = match repo.current_worktree().root() {
Ok(root) => root,
Err(_) => {
writeln!(
@@ -400,11 +425,6 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
- // Trigger deprecation warnings (runs on raw content before parsing, so works even for invalid configs)
- if let Ok(repo) = Repository::current() {
- let _ = repo.load_project_config();
- }
-
// Read and display the file contents
let contents = std::fs::read_to_string(&config_path).context("Failed to read config file")?;
@@ -413,6 +433,21 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {
return Ok(());
}
+ // Check for deprecations with show_brief_warning=false (silent mode)
+ // Only show in main worktree (where .git is a directory)
+ let is_main_worktree = repo_root.join(".git").is_dir();
+ if let Ok(Some(info)) = worktrunk::config::check_and_migrate(
+ &config_path,
+ &contents,
+ is_main_worktree,
+ "Project config",
+ Some(&repo),
+ false, // silent mode - we'll format the output ourselves
+ ) {
+ // Add deprecation details to the output buffer
+ out.push_str(&worktrunk::config::format_deprecation_details(&info));
+ }
+
// Validate config (syntax + schema) and warn if invalid
if let Err(e) = toml::from_str::<ProjectConfig>(&contents) {
// Use gutter for error details to avoid markup interpretation of user content
diff --git a/src/config/deprecation.rs b/src/config/deprecation.rs
index f94c68aa5..f8062696b 100644
--- a/src/config/deprecation.rs
+++ b/src/config/deprecation.rs
@@ -25,8 +25,10 @@ use regex::Regex;
use shell_escape::unix::escape;
use crate::config::WorktrunkConfig;
-use crate::path::format_path_for_display;
-use crate::styling::{eprintln, hint_message, warning_message};
+use crate::shell_exec::Cmd;
+use crate::styling::{
+ eprintln, format_bash_with_gutter, format_with_gutter, hint_message, warning_message,
+};
/// Tracks which config paths have already shown deprecation warnings this process.
/// Prevents repeated warnings when config is loaded multiple times.
@@ -154,7 +156,7 @@ pub fn replace_deprecated_vars(content: &str) -> String {
}
/// Information about deprecated commit-generation sections found in config
-#[derive(Default)]
+#[derive(Debug, Default, Clone)]
pub struct CommitGenerationDeprecations {
/// Has top-level [commit-generation] section
pub has_top_level: bool,
@@ -384,6 +386,34 @@ fn shell_join(args: &[&str]) -> String {
.join(" ")
}
+/// Information about deprecated config patterns that were found.
+///
+/// Used by `wt config show` to display full deprecation details including inline diff.
+#[derive(Debug)]
+pub struct DeprecationInfo {
+ /// Path to the config file with deprecations
+ pub config_path: PathBuf,
+ /// Path to the generated migration file (if written)
+ pub migration_path: Option<PathBuf>,
+ /// Deprecated template variables found: (old_name, new_name)
+ pub deprecated_vars: Vec<(&'static str, &'static str)>,
+ /// Deprecated commit-generation sections found
+ pub commit_gen_deprecations: CommitGenerationDeprecations,
+ /// Label for this config (e.g., "User config", "Project config")
+ pub label: String,
+ /// True if user deleted the migration file (show regenerate hint)
+ pub user_deleted_migration: bool,
+ /// True if in a linked worktree (migration file written to main worktree only)
+ pub in_linked_worktree: bool,
+}
+
+impl DeprecationInfo {
+ /// Returns true if any deprecations were found
+ pub fn has_deprecations(&self) -> bool {
+ !self.deprecated_vars.is_empty() || !self.commit_gen_deprecations.is_empty()
+ }
+}
+
/// Check config content for deprecated patterns and optionally create migration file
///
/// Detects and migrates:
@@ -404,16 +434,20 @@ fn shell_join(args: &[&str]) -> String {
/// (global, not repo-specific), pass `None` and the function will check if the `.new`
/// file already exists instead.
///
+/// When `show_brief_warning` is true, only a brief pointer to `wt config show` is emitted
+/// instead of full deprecation details. Use this for commands other than `config show`.
+///
/// Warnings are deduplicated per path per process.
///
-/// Returns Ok(true) if any deprecations were found, Ok(false) otherwise.
+/// Returns `Ok(Some(info))` if deprecations were found, `Ok(None)` otherwise.
pub fn check_and_migrate(
path: &Path,
content: &str,
warn_and_migrate: bool,
label: &str,
repo: Option<&crate::git::Repository>,
-) -> anyhow::Result<bool> {
+ show_brief_warning: bool,
+) -> anyhow::Result<Option<DeprecationInfo>> {
// Detect all deprecation types
let deprecated_vars = find_deprecated_vars(content);
let commit_gen_deprecations = find_commit_generation_deprecations(content);
@@ -422,12 +456,36 @@ pub fn check_and_migrate(
let has_commit_gen_deprecations = !commit_gen_deprecations.is_empty();
if !has_deprecated_vars && !has_commit_gen_deprecations {
- return Ok(false);
+ return Ok(None);
}
+ // Build the .new path: "config.toml" -> "config.toml.new"
+ let new_path = path.with_extension(format!(
+ "{}.new",
+ path.extension().unwrap_or_default().to_string_lossy()
+ ));
+
+ // Check if we should skip writing the migration file
+ // - Always regenerate if .new file exists (user kept it, so overwrite with fresh version)
+ // - For project config: skip if hint shown AND .new doesn't exist (user deleted it)
+ // - For user config: always write (no persistent hint tracking without repo)
+ let should_skip_write =
+ !new_path.exists() && repo.is_some_and(|r| r.has_shown_hint(HINT_DEPRECATED_CONFIG));
+
+ // Build deprecation info for return
+ let mut info = DeprecationInfo {
+ config_path: path.to_path_buf(),
+ migration_path: None,
+ deprecated_vars: deprecated_vars.clone(),
+ commit_gen_deprecations: commit_gen_deprecations.clone(),
+ label: label.to_string(),
+ user_deleted_migration: should_skip_write,
+ in_linked_worktree: !warn_and_migrate,
+ };
+
// Skip warning entirely if not in main worktree (for project config)
if !warn_and_migrate {
- return Ok(true);
+ return Ok(Some(info));
}
// Deduplicate warnings per path per process
@@ -435,123 +493,266 @@ pub fn check_and_migrate(
{
let mut guard = WARNED_DEPRECATED_PATHS.lock().unwrap();
if guard.contains(&canonical_path) {
- return Ok(true); // Already warned, skip
+ // Already warned, but still set migration_path if file exists
+ if new_path.exists() {
+ info.migration_path = Some(new_path);
+ }
+ return Ok(Some(info));
}
guard.insert(canonical_path.clone());
}
- // Build the .new path: "config.toml" -> "config.toml.new"
- let new_path = path.with_extension(format!(
- "{}.new",
- path.extension().unwrap_or_default().to_string_lossy()
- ));
+ // For brief warnings (non-config-show commands), just show a pointer
+ if show_brief_warning {
+ eprintln!(
+ "{}",
+ warning_message(cformat!(
+ "{} has deprecated settings. To see details, run <bright-black>wt config show</>",
+ label
+ ))
+ );
- // Check if we should skip writing the migration file
- // - Always regenerate if .new file exists (user kept it, so overwrite with fresh version)
- // - For project config: skip if hint shown AND .new doesn't exist (user deleted it)
- // - For user config: always write (no persistent hint tracking without repo)
- let should_skip_write =
- !new_path.exists() && repo.is_some_and(|r| r.has_shown_hint(HINT_DEPRECATED_CONFIG));
+ // Still write migration file if needed
+ if !should_skip_write {
+ let wrote_file = write_migration_file(
+ path,
+ content,
+ &new_path,
+ repo,
+ &deprecated_vars,
+ &commit_gen_deprecations,
+ );
+ if wrote_file {
+ info.migration_path = Some(new_path);
+ }
+ }
+
+ std::io::stderr().flush().ok();
+ return Ok(Some(info));
+ }
+
+ // Silent mode for `wt config show` - just write migration file and return info
+ // The caller will use format_deprecation_details() to add output to its buffer
+ if !should_skip_write {
+ let wrote_file = write_migration_file_silent(
+ content,
+ &new_path,
+ repo,
+ &deprecated_vars,
+ &commit_gen_deprecations,
+ );
+ if wrote_file {
+ info.migration_path = Some(new_path.clone());
+ }
+ }
+
+ Ok(Some(info))
+}
+
+/// Write migration file with all deprecation fixes applied (with stderr output)
+/// Returns true if file was written successfully, false otherwise.
+fn write_migration_file(
+ path: &Path,
+ content: &str,
+ new_path: &Path,
+ repo: Option<&crate::git::Repository>,
+ deprecated_vars: &[(&'static str, &'static str)],
+ commit_gen_deprecations: &CommitGenerationDeprecations,
+) -> bool {
+ let wrote_file = write_migration_file_silent(
+ content,
+ new_path,
+ repo,
+ deprecated_vars,
+ commit_gen_deprecations,
+ );
+
+ if !wrote_file {
+ return false;
+ }
+
+ // Show just the filename in the message
+ let new_filename = new_path
+ .file_name()
+ .map(|n| n.to_string_lossy())
+ .unwrap_or_default();
+
+ // Shell-escape paths for safe copy/paste
+ let new_path_str = escape(new_path.to_string_lossy().replace('\\', "/").into());
+ let path_str = escape(path.to_string_lossy().replace('\\', "/").into());
+
+ eprintln!(
+ "{}",
+ hint_message(cformat!(
+ "Wrote migrated <bold>{}</>. To apply:",
+ new_filename
+ ))
+ );
+ eprintln!(
+ "{}",
+ format_bash_with_gutter(&format!("mv -- {} {}", new_path_str, path_str))
+ );
+
+ true
+}
- // Emit warnings for each deprecation type
+/// Write migration file without any stderr output (for silent mode)
+/// Returns true if file was written successfully, false otherwise.
+fn write_migration_file_silent(
+ content: &str,
+ new_path: &Path,
+ repo: Option<&crate::git::Repository>,
+ deprecated_vars: &[(&'static str, &'static str)],
+ commit_gen_deprecations: &CommitGenerationDeprecations,
+) -> bool {
+ let has_deprecated_vars = !deprecated_vars.is_empty();
+ let has_commit_gen_deprecations = !commit_gen_deprecations.is_empty();
+
+ // Apply all migrations to generate new content
+ let mut new_content = content.to_string();
if has_deprecated_vars {
- let var_list: Vec<String> = deprecated_vars
+ new_content = replace_deprecated_vars(&new_content);
+ }
+ if has_commit_gen_deprecations {
+ new_content = migrate_commit_generation_sections(&new_content);
+ }
+
+ if let Err(e) = std::fs::write(new_path, &new_content) {
+ // Log write failure but don't block config loading
+ log::warn!("Could not write migration file: {}", e);
+ return false;
+ }
+
+ // Mark hint as shown for project config
+ if let Some(repo) = repo {
+ let _ = repo.mark_hint_shown(HINT_DEPRECATED_CONFIG);
+ }
+
+ true
+}
+
+/// Format the diff between original and migrated config files as a string
+pub fn format_migration_diff(original_path: &Path, new_path: &Path) -> Option<String> {
+ let new_path_str = new_path.to_string_lossy().replace('\\', "/");
+ let path_str = original_path.to_string_lossy().replace('\\', "/");
+
+ // Run git diff and return the formatted output
+ // Use -- to separate options from file paths (guards against filenames starting with -)
+ if let Ok(output) = Cmd::new("git")
+ .args(["diff", "--no-index", "--color=always", "--"])
+ .arg(&path_str)
+ .arg(&new_path_str)
+ .run()
+ {
+ // git diff --no-index exits 1 when files differ, which is expected
+ let diff_output = String::from_utf8_lossy(&output.stdout);
+ if !diff_output.is_empty() {
+ return Some(format_with_gutter(diff_output.trim_end(), None));
+ }
+ }
+ None
+}
+
+/// Format deprecation details for display (for use by wt config show)
+///
+/// Returns formatted output including:
+/// - Warning message listing deprecated patterns
+/// - Migration hint with apply command
+/// - Inline diff showing the changes
+pub fn format_deprecation_details(info: &DeprecationInfo) -> String {
+ use std::fmt::Write;
+ let mut out = String::new();
+
+ // Warning message listing deprecated patterns
+ if !info.deprecated_vars.is_empty() {
+ let var_list: Vec<String> = info
+ .deprecated_vars
.iter()
.map(|(old, new)| cformat!("<dim>{}</> → <bold>{}</>", old, new))
.collect();
- eprintln!(
+ let _ = writeln!(
+ out,
"{}",
warning_message(format!(
"{} uses deprecated template variables: {}",
- label,
+ info.label,
var_list.join(", ")
))
);
}
- if has_commit_gen_deprecations {
+ if !info.commit_gen_deprecations.is_empty() {
let mut parts = Vec::new();
- if commit_gen_deprecations.has_top_level {
+ if info.commit_gen_deprecations.has_top_level {
parts.push("[commit-generation] → [commit.generation]".to_string());
}
- for project_key in &commit_gen_deprecations.project_keys {
+ for project_key in &info.commit_gen_deprecations.project_keys {
parts.push(format!(
"[projects.\"{}\".commit-generation] → [projects.\"{}\".commit.generation]",
project_key, project_key
));
}
- eprintln!(
+ let _ = writeln!(
+ out,
"{}",
warning_message(format!(
"{} uses deprecated config sections: {}",
- label,
+ info.label,
parts.join(", ")
))
);
}
- if should_skip_write {
- // User deleted the .new file but hint is set - they don't want the migration file
- // Show how to regenerate if they change their mind
- eprintln!(
+ // Migration hint with apply command
+ if let Some(new_path) = &info.migration_path {
+ let new_filename = new_path
+ .file_name()
+ .map(|n| n.to_string_lossy())
+ .unwrap_or_default();
+ // Shell-escape paths for safe copy/paste
+ let new_path_str = escape(new_path.to_string_lossy().replace('\\', "/").into());
+ let path_str = escape(info.config_path.to_string_lossy().replace('\\', "/").into());
+
+ let _ = writeln!(
+ out,
"{}",
hint_message(cformat!(
- "To regenerate, rerun after <bright-black>wt config state hints clear {}</>",
- HINT_DEPRECATED_CONFIG
+ "Wrote migrated <bold>{}</>. To apply:",
+ new_filename
))
);
- } else {
- // Apply all migrations to generate new content
- let mut new_content = content.to_string();
- if has_deprecated_vars {
- new_content = replace_deprecated_vars(&new_content);
- }
- if has_commit_gen_deprecations {
- new_content = migrate_commit_generation_sections(&new_content);
- }
-
- match std::fs::write(&new_path, &new_content) {
- Ok(()) => {
- // Mark hint as shown for project config
- if let Some(repo) = repo {
- let _ = repo.mark_hint_shown(HINT_DEPRECATED_CONFIG);
- }
+ let _ = writeln!(
+ out,
+ "{}",
+ format_bash_with_gutter(&format!("mv -- {} {}", new_path_str, path_str))
+ );
- // Show just the filename in the message, tilde paths when safe in the command
- let new_filename = new_path
- .file_name()
- .map(|n| n.to_string_lossy())
- .unwrap_or_default();
-
- let new_path_display = format_path_for_display(&new_path);
- let path_display = format_path_for_display(path);
- eprintln!(
- "{}",
- hint_message(cformat!(
- "Wrote migrated {}; to apply: <bright-black>mv -- {} {}</>",
- new_filename,
- new_path_display,
- path_display
- ))
- );
- }
- Err(e) => {
- // Warn about write failure but don't block config loading
- eprintln!(
- "{}",
- hint_message(cformat!(
- "Could not write migration file: <bright-black>{}</>",
- e
- ))
- );
- }
+ // Inline diff
+ if let Some(diff) = format_migration_diff(&info.config_path, new_path) {
+ let _ = writeln!(out, "{}", diff);
}
+ } else if info.in_linked_worktree {
+ // In linked worktree - migration file is written to main worktree
+ let _ = writeln!(
+ out,
+ "{}",
+ hint_message(cformat!(
+ "To generate migration file, run <bright-black>wt config show</> from main worktree",
+ ))
+ );
+ } else if info.user_deleted_migration {
+ // User deleted the migration file - show how to regenerate
+ let _ = writeln!(
+ out,
+ "{}",
+ hint_message(cformat!(
+ "To regenerate migration file, run <bright-black>wt config state hints clear {}</>",
+ HINT_DEPRECATED_CONFIG
+ ))
+ );
}
- // Flush stderr to ensure output appears before any subsequent messages
- std::io::stderr().flush().ok();
-
- Ok(true)
+ out
}
/// Returns the config location where this key belongs, if it's in the wrong config.
@@ -907,10 +1108,11 @@ approved-commands = [
let content = r#"post-create = "{{ repo_root }}/script.sh""#;
let non_existent_path = std::path::Path::new("/nonexistent/dir/config.toml");
- // Should return Ok(true) even if write fails - the function logs error but doesn't fail
- let result = check_and_migrate(non_existent_path, content, true, "Test config", None);
+ // Should return Ok(Some(_)) even if write fails - the function logs error but doesn't fail
+ let result =
+ check_and_migrate(non_existent_path, content, true, "Test config", None, false);
assert!(result.is_ok());
- assert!(result.unwrap());
+ assert!(result.unwrap().is_some());
}
#[test]
@@ -921,14 +1123,14 @@ approved-commands = [
let unique_path = std::path::Path::new("/nonexistent/dedup_test_12345/config.toml");
// First call should process normally
- let result1 = check_and_migrate(unique_path, content, true, "Test config", None);
+ let result1 = check_and_migrate(unique_path, content, true, "Test config", None, false);
assert!(result1.is_ok());
- assert!(result1.unwrap());
+ assert!(result1.unwrap().is_some());
// Second call with same path should early-return (hits the deduplication branch)
- let result2 = check_and_migrate(unique_path, content, true, "Test config", None);
+ let result2 = check_and_migrate(unique_path, content, true, "Test config", None, false);
assert!(result2.is_ok());
- assert!(result2.unwrap());
+ assert!(result2.unwrap().is_some());
}
// Tests for commit-generation section migration
diff --git a/src/config/mod.rs b/src/config/mod.rs
index bb563b7e3..a81cc0d0f 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -78,7 +78,9 @@ impl WorktrunkConfig for ProjectConfig {
// Re-export public types
pub use commands::{Command, CommandConfig};
-pub use deprecation::check_and_migrate as check_deprecated_vars;
+pub use deprecation::DeprecationInfo;
+pub use deprecation::check_and_migrate;
+pub use deprecation::format_deprecation_details;
pub use deprecation::normalize_template_vars;
pub use deprecation::{DEPRECATED_SECTION_KEYS, key_belongs_in, warn_unknown_fields};
pub use expansion::{
diff --git a/src/config/project.rs b/src/config/project.rs
index 85fb08038..9dd1123c2 100644
--- a/src/config/project.rs
+++ b/src/config/project.rs
@@ -139,6 +139,7 @@ impl ProjectConfig {
// Check for deprecated template variables and create migration file if needed
// Only write migration file in main worktree (where .git is a directory)
// Linked worktrees have .git as a file pointing to the main worktree
+ // Use show_brief_warning=true to emit a brief pointer to `wt config show`
let is_main_worktree = repo_root.join(".git").is_dir();
let repo_for_hints = if write_hints { Some(repo) } else { None };
let _ = super::deprecation::check_and_migrate(
@@ -147,6 +148,7 @@ impl ProjectConfig {
is_main_worktree,
"Project config",
repo_for_hints,
+ true, // show_brief_warning
);
// Warn about unknown fields (only in main worktree where it's actionable)
diff --git a/src/config/user.rs b/src/config/user.rs
index a892b56f3..f1ead2159 100644
--- a/src/config/user.rs
+++ b/src/config/user.rs
@@ -629,6 +629,7 @@ impl UserConfig {
// Check for deprecated template variables and create migration file if needed
// User config always gets migration file (it's global, not worktree-specific)
// Pass None for repo since user config is global and not tied to any repository
+ // Use show_brief_warning=true to emit a brief pointer to `wt config show`
if let Ok(content) = std::fs::read_to_string(config_path) {
let _ = super::deprecation::check_and_migrate(
config_path,
@@ -636,6 +637,7 @@ impl UserConfig {
true,
"User config",
None,
+ true, // show_brief_warning
);
// Warn about unknown fields in the config file
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index d23c58fa3..46695b624 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -2225,7 +2225,14 @@ pub fn add_standard_env_redactions(settings: &mut insta::Settings) {
/// This extracts the common settings configuration while allowing the
/// `assert_cmd_snapshot!` macro to remain in test files for correct module path capture.
pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
- setup_snapshot_settings_for_paths(repo.root_path(), &repo.worktrees)
+ setup_snapshot_settings_impl(repo.root_path(), None)
+}
+
+/// Internal implementation that optionally includes temp_home filter.
+/// The temp_home filter MUST be added before PROJECT_ID filters to take precedence.
+fn setup_snapshot_settings_impl(root: &Path, temp_home: Option<&Path>) -> insta::Settings {
+ let worktrees = HashMap::new(); // Caller doesn't need worktree filters
+ setup_snapshot_settings_for_paths_with_home(root, &worktrees, temp_home)
}
/// Full snapshot settings - path filters AND ANSI cleanup.
@@ -2235,7 +2242,26 @@ fn setup_snapshot_settings_for_paths(
root: &Path,
worktrees: &HashMap<String, PathBuf>,
) -> insta::Settings {
- let mut settings = insta::Settings::clone_current();
+ setup_snapshot_settings_for_paths_with_home(root, worktrees, None)
+}
+
+/// Internal implementation with optional temp_home support.
+///
+/// When `temp_home` is provided, we create fresh settings rather than cloning current settings.
+/// This is critical because TestRepo's snapshot guard may have already added PROJECT_ID filters,
+/// and cloning would inherit those filters which would be applied BEFORE our TEMP_HOME filter.
+fn setup_snapshot_settings_for_paths_with_home(
+ root: &Path,
+ worktrees: &HashMap<String, PathBuf>,
+ temp_home: Option<&Path>,
+) -> insta::Settings {
+ // When temp_home is provided, start fresh to ensure TEMP_HOME filter is applied before
+ // any inherited PROJECT_ID filters. Otherwise, clone current settings for consistency.
+ let mut settings = if temp_home.is_some() {
+ insta::Settings::new()
+ } else {
+ insta::Settings::clone_current()
+ };
settings.set_snapshot_path("../snapshots");
// Normalize project root path (for test fixtures)
@@ -2327,10 +2353,52 @@ fn setup_snapshot_settings_for_paths(
);
// Also strip quotes around bracket placeholders like [PROJECT_ID]
+ // NOTE: This filter runs BEFORE PROJECT_ID replacement, so it handles
+ // cases where ANSI codes appear between quotes and placeholders.
+ // A simpler post-replacement filter is added after PROJECT_ID filters.
settings.add_filter(
r"'(?:\x1b\[[0-9;]*m)*(\[[A-Z_]+\])(?:\x1b\[[0-9;]*m)*'",
"$1",
);
+ // Also strip quotes around paths that include subdirectories (e.g., '_REPO_/.config/wt.toml')
+ // On Windows, shell_escape quotes paths containing ':' so full paths get quoted.
+ settings.add_filter(
+ r"'(_(?:REPO|WORKTREE_[A-Z0-9_]+)_(?:\.[a-zA-Z0-9_-]+)?/[^']+)'",
+ "$1",
+ );
+ // Normalize git diff header prefixes: a/_REPO_ -> a_REPO_, b/_REPO_ -> b_REPO_
+ // On Windows, git diff --no-index with absolute paths produces a/C:/... which becomes a/_REPO_
+ // On Unix, relative paths produce a/repo/... which becomes a_REPO_
+ // Note: [TEMP_HOME] filters are added later, after TEMP_HOME replacement happens.
+ settings.add_filter(r"(diff --git )a/(_(?:REPO|WORKTREE_[A-Z0-9_]+)_)", "$1a$2");
+ settings.add_filter(r" b/(_(?:REPO|WORKTREE_[A-Z0-9_]+)_)", " b$1");
+ settings.add_filter(r"(--- )a/(_(?:REPO|WORKTREE_[A-Z0-9_]+)_)", "$1a$2");
+ settings.add_filter(r"(\+\+\+ )b/(_(?:REPO|WORKTREE_[A-Z0-9_]+)_)", "$1b$2");
+
+ // Windows git diff may produce headers without "diff --git a" prefix.
+ // Pattern: _REPO_/path1 b_REPO_/path2 (just paths with b prefix for second)
+ // Match bold ANSI + _REPO_ path + space + b + _REPO_ path
+ settings.add_filter(
+ r"(\x1b\[1m)(_(?:REPO|WORKTREE_[A-Z0-9_]+)_/[^\s]+) b(_(?:REPO|WORKTREE_[A-Z0-9_]+)_/[^\s]+)",
+ "$1diff --git a$2 b$3",
+ );
+ // Windows may have " --git a_REPO_" with leading spaces after ANSI reset (missing "diff" and bold).
+ // Match: ANSI reset + one or more spaces + "--git a" pattern
+ // Replace with: ANSI reset + space + bold + "diff --git a" to match Unix format
+ settings.add_filter(
+ r"(\x1b\[0m) +--git a(_(?:REPO|WORKTREE_[A-Z0-9_]+)_/)",
+ "$1 \x1b[1mdiff --git a$2",
+ );
+ // Windows may also omit --- a prefix on the source file line
+ settings.add_filter(r"(--- )(_(?:REPO|WORKTREE_[A-Z0-9_]+)_/)", "$1a$2");
+ // Windows may also omit +++ b prefix on the destination file line
+ settings.add_filter(r"(\+\+\+ )(_(?:REPO|WORKTREE_[A-Z0-9_]+)_/)", "$1b$2");
+ // Windows may output bare path for --- line: \x1b[1m_REPO_/...\x1b[m (no "--- a")
+ // Add the missing "--- a" prefix.
+ settings.add_filter(
+ r"(\x1b\[1m)(_(?:REPO|WORKTREE_[A-Z0-9_]+)_/[^\x1b]+\.toml)(\x1b\[m)",
+ "$1--- a$2$3",
+ );
// Normalize syntax highlighting around placeholders.
// Bash syntax highlighters may split tokens differently on different platforms.
@@ -2343,6 +2411,15 @@ fn setup_snapshot_settings_for_paths(
"\x1b[2m $1 \x1b[0m",
);
+ // Strip green ANSI highlighting from _REPO_ paths.
+ // On Windows, tree-sitter may highlight paths with green (\x1b[32m) even when not quoted.
+ // Example: \x1b[0m\x1b[2m\x1b[32m_REPO_/.config/wt.toml\x1b[0m\x1b[2m
+ // Strip ANSI codes before/after the path when green highlighting is present.
+ settings.add_filter(
+ r"(?:\x1b\[\d+m)*\x1b\[32m(_(?:REPO|WORKTREE_[A-Z0-9_]+)_(?:/[^\x1b\s]+)?)(?:\x1b\[\d+m)*",
+ "$1",
+ );
+
// Normalize WORKTRUNK_CONFIG_PATH temp paths in stdout/stderr output
// (metadata is handled via redactions below)
// IMPORTANT: These specific filters must come BEFORE the generic [PROJECT_ID] filters
@@ -2356,6 +2433,14 @@ fn setup_snapshot_settings_for_paths(
r"'?(?:[A-Z]:)?[/\\][^\s']+[/\\]\.tmp[^/\\']+[/\\]test-config\.toml'?",
"[TEST_CONFIG]",
);
+ // Strip ANSI codes that may wrap [TEST_CONFIG*] placeholders.
+ // On Windows, tree-sitter may add ANSI codes around paths even without quotes.
+ // Example: \x1b[0m\x1b[2m[TEST_CONFIG_NEW]\x1b[2m
+ // Match: optional ANSI codes + [TEST_CONFIG...] + optional ANSI codes -> just the placeholder
+ settings.add_filter(
+ r"(?:\x1b\[\d+m)+(\[TEST_CONFIG(?:_NEW)?\])(?:\x1b\[\d+m)+",
+ "$1",
+ );
// Normalize GIT_CONFIG_GLOBAL temp paths
// (?:[A-Z]:)? handles Windows drive letters
@@ -2364,6 +2449,123 @@ fn setup_snapshot_settings_for_paths(
"[TEST_GIT_CONFIG]",
);
+ // TEMP_HOME filter MUST come before PROJECT_ID filters to take precedence.
+ // Otherwise, paths like /tmp/.tmpXXX/.config/worktrunk/config.toml would match
+ // the PROJECT_ID filter first.
+ //
+ // We replace the full temp_home path prefix with [TEMP_HOME], so paths like
+ // /tmp/.tmpABC/.config/worktrunk/config.toml become [TEMP_HOME]/.config/worktrunk/config.toml
+ if let Some(temp_home) = temp_home {
+ // Get both the original path and the canonicalized path - they may differ on Windows
+ // due to short path names (e.g., RUNNER~1 vs runneradmin) or other normalization.
+ let temp_home_original = temp_home.to_string_lossy().replace('\\', "/");
+ let temp_home_canonical =
+ canonicalize(temp_home).unwrap_or_else(|_| temp_home.to_path_buf());
+ let temp_home_str = temp_home_canonical.to_string_lossy().replace('\\', "/");
+
+ // On Windows, paths may be quoted by shell_escape due to ':' in drive letters.
+ // Add filters for both quoted and unquoted variants, for both original and canonical paths.
+ if temp_home_str.contains(':') {
+ // Quoted canonical path
+ settings.add_filter(
+ &format!("'{}", regex::escape(&temp_home_str)),
+ "'[TEMP_HOME]",
+ );
+ // Quoted original path (may differ from canonical)
+ if temp_home_original != temp_home_str {
+ settings.add_filter(
+ &format!("'{}", regex::escape(&temp_home_original)),
+ "'[TEMP_HOME]",
+ );
+ }
+ }
+ // Unquoted canonical path
+ settings.add_filter(&regex::escape(&temp_home_str), "[TEMP_HOME]");
+ // Unquoted original path (may differ from canonical)
+ if temp_home_original != temp_home_str {
+ settings.add_filter(&regex::escape(&temp_home_original), "[TEMP_HOME]");
+ }
+
+ // On macOS, canonicalize returns /private/var/... but git diff output shows /var/...
+ // Add both variants to catch all cases
+ if temp_home_str.starts_with("/private/") {
+ let without_private = &temp_home_str["/private".len()..];
+ settings.add_filter(&regex::escape(without_private), "[TEMP_HOME]");
+ }
+
+ // [TEMP_HOME] post-processing filters - must run AFTER the replacement above.
+
+ // Strip ANSI sequences immediately before [TEMP_HOME] paths.
+ // On Windows, tree-sitter highlights paths with green (\x1b[32m) inside mv commands.
+ // The output has: ...code (space) code code [TEMP_HOME]/path code code...
+ // We strip ONLY the codes between space and [TEMP_HOME], keeping codes elsewhere.
+ // Pattern: (space)(ANSI codes)(optional quote)([TEMP_HOME]) -> (space)(quote)([TEMP_HOME])
+ // The optional quote handles Windows where paths may be quoted: 'C:/...'
+ settings.add_filter(r"( )(?:\x1b\[[0-9;]*m)+('?)(\[TEMP_HOME\]/)", "$1$2$3");
+ // Strip trailing ANSI codes after [TEMP_HOME] paths.
+ // Match path followed by one or more ANSI codes.
+ settings.add_filter(r"(\[TEMP_HOME\]/[^\x1b\s]+)(?:\x1b\[[0-9;]*m)+", "$1");
+
+ // Strip quotes around [TEMP_HOME] paths (Windows shell_escape quotes paths with ':')
+ // Also handles git diff quoted format which lacks a/b prefixes.
+ settings.add_filter(r"'\[TEMP_HOME\](/[^']+)'", "[TEMP_HOME]$1");
+
+ // Normalize git diff header prefixes for [TEMP_HOME]:
+ // Unix: a/[TEMP_HOME] -> a[TEMP_HOME], b/[TEMP_HOME] -> b[TEMP_HOME]
+ settings.add_filter(r"(diff --git )a/(\[TEMP_HOME\])", "$1a$2");
+ settings.add_filter(r" b/(\[TEMP_HOME\])", " b$1");
+ settings.add_filter(r"(--- )a/(\[TEMP_HOME\])", "$1a$2");
+ settings.add_filter(r"(\+\+\+ )b/(\[TEMP_HOME\])", "$1b$2");
+
+ // Windows git diff uses different format for absolute paths.
+ // After quote stripping, the diff header may or may not have "diff --git " prefix,
+ // and may or may not have a/b prefixes. Normalize to Unix format.
+
+ // Pattern 1: Has "diff --git " but no a/b prefixes
+ // diff --git [TEMP_HOME]/a [TEMP_HOME]/b -> diff --git a[TEMP_HOME]/a b[TEMP_HOME]/b
+ settings.add_filter(
+ r"(diff --git )(\[TEMP_HOME\]/[^\s]+) (\[TEMP_HOME\]/)",
+ "$1a$2 b$3",
+ );
+
+ // Pattern 2: Windows git diff header with only b prefix present.
+ // Windows git diff --no-index may produce: path1 bpath2 (without diff --git a)
+ // After path replacement: [TEMP_HOME]/a b[TEMP_HOME]/b
+ // Add the full header format to match Unix.
+ settings.add_filter(
+ r"(\x1b\[1m)(\[TEMP_HOME\]/[^\s]+) b(\[TEMP_HOME\]/[^\s]+)",
+ "$1diff --git a$2 b$3",
+ );
+
+ // Pattern 3: Windows may have " --git a[path]" with leading spaces after ANSI (missing "diff" and bold).
+ // Match: ANSI reset + one or more spaces + "--git a" pattern
+ // Replace with: ANSI reset + space + bold + "diff --git a" to match Unix format
+ settings.add_filter(
+ r"(\x1b\[0m) +--git a(\[TEMP_HOME\]/)",
+ "$1 \x1b[1mdiff --git a$2",
+ );
+
+ // --- [TEMP_HOME]/... -> --- a[TEMP_HOME]/... (Unix has slash, remove it)
+ settings.add_filter(r"(--- )a/(\[TEMP_HOME\]/)", "$1a$2");
+ // --- [TEMP_HOME]/... -> --- a[TEMP_HOME]/... (Windows: add missing a prefix)
+ settings.add_filter(r"(--- )(\[TEMP_HOME\]/)", "$1a$2");
+
+ // +++ [TEMP_HOME]/... -> +++ b[TEMP_HOME]/... (Unix has slash, remove it)
+ settings.add_filter(r"(\+\+\+ )b/(\[TEMP_HOME\]/)", "$1b$2");
+ // +++ [TEMP_HOME]/... -> +++ b[TEMP_HOME]/... (Windows: add missing b prefix)
+ settings.add_filter(r"(\+\+\+ )(\[TEMP_HOME\]/)", "$1b$2");
+
+ // Windows git diff may have bare path without --- prefix at all.
+ // Match: bold ANSI + bare [TEMP_HOME] path that's NOT preceded by diff/---/+++
+ // This catches the case where git outputs just the path on its own line.
+ // Look for standalone [TEMP_HOME]/...config.toml (trailing ANSI codes may be stripped).
+ // Use negative lookbehind (not supported) - instead match newline + gutter + bold.
+ settings.add_filter(
+ r"(\x1b\[1m)(\[TEMP_HOME\]/[^\s\x1b]+\.toml)(\x1b\[m|\n|$)",
+ "$1--- a$2$3",
+ );
+ }
+
// Normalize temp directory paths in project identifiers (approval prompts)
// Example: /private/var/folders/wf/.../T/.tmpABC123/origin -> [PROJECT_ID]
// Note: [^)'\s\x1b]+ stops at ), ', whitespace, or ANSI escape to avoid matching too much
@@ -2379,6 +2581,12 @@ fn setup_snapshot_settings_for_paths(
r"[A-Z]:/Users/[^/]+/AppData/Local/Temp/\.tmp[^/]+/[^)'\s\x1b]+",
"[PROJECT_ID]",
);
+ // Windows quoted paths: shell_escape quotes paths containing ':' (drive letter)
+ // Example: 'C:/Users/user/AppData/Local/Temp/.tmpXXXXXX/repo/.config/wt.toml' -> [PROJECT_ID]
+ settings.add_filter(
+ r"'[A-Z]:/Users/[^/]+/AppData/Local/Temp/\.tmp[^/]+/[^']+'",
+ "[PROJECT_ID]",
+ );
// Generic tilde-prefixed paths that aren't repo or worktree paths.
// On CI, HOME is a temp directory, so paths under HOME become ~/something.
@@ -2386,6 +2594,11 @@ fn setup_snapshot_settings_for_paths(
// MUST come AFTER specific ~/repo patterns so they match first.
settings.add_filter(r"~/[a-zA-Z0-9_-]+", "[PROJECT_ID]");
+ // Strip quotes around [PROJECT_ID] after replacement.
+ // On Windows, paths inside quotes get replaced but quotes remain: 'C:/...' -> '[PROJECT_ID]'
+ // This filter MUST come AFTER PROJECT_ID filters to clean up the result.
+ settings.add_filter(r"'\[PROJECT_ID\]'", "[PROJECT_ID]");
+
// Normalize HOME temp directory in snapshots (stdout/stderr content)
// Matches any temp directory path (without trailing filename)
// Examples:
@@ -2516,13 +2729,12 @@ fn setup_snapshot_settings_for_paths(
///
/// This extends `setup_snapshot_settings` by adding a filter for the temporary home directory.
/// Use this for tests that need both a TestRepo and a temporary home (for user config testing).
+///
+/// IMPORTANT: The temp_home filter is passed to setup_snapshot_settings_impl so it gets added
+/// BEFORE the generic [PROJECT_ID] filters. Otherwise, paths like /tmp/.tmpXXX/.config/worktrunk/config.toml
+/// would match [PROJECT_ID] first.
pub fn setup_snapshot_settings_with_home(repo: &TestRepo, temp_home: &TempDir) -> insta::Settings {
- let mut settings = setup_snapshot_settings(repo);
- settings.add_filter(
- &regex::escape(&temp_home.path().to_string_lossy()),
- "[TEMP_HOME]",
- );
- settings
+ setup_snapshot_settings_impl(repo.root_path(), Some(temp_home.path()))
}
/// Create configured insta Settings for snapshot tests with only a temporary home directory
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index e1d951c54..37aba0115 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -839,6 +839,31 @@ post-create = "ln -sf {{ repo_root }}/node_modules {{ worktree }}/node_modules"
);
}
+/// With -v flag, the brief deprecation warning includes the mv command hint
+/// and template expansion logs are shown
+#[rstest]
+fn test_deprecated_template_variables_verbose_shows_content(repo: TestRepo, temp_home: TempDir) {
+ // Write config with deprecated variables
+ let config_path = repo.test_config_path();
+ fs::write(
+ config_path,
+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"
+post-create = "ln -sf {{ repo_root }}/node_modules {{ worktree }}/node_modules"
+"#,
+ )
+ .unwrap();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.args(["-v", "list"]).current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
/// When a migration file has already been written, subsequent commands should:
/// 1. Still show the deprecation warning
/// 2. NOT overwrite the migration file
@@ -1334,3 +1359,189 @@ command = "llm -m gpt-4"
"Migration should rename project-level section"
);
}
+
+/// Test that `wt config show` displays full deprecation details including inline diff
+#[rstest]
+fn test_config_show_displays_deprecation_details(mut repo: TestRepo, temp_home: TempDir) {
+ repo.setup_mock_ci_tools_unauthenticated();
+
+ // Write user config with deprecated variables at XDG path
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ let config_path = global_config_dir.join("config.toml");
+ fs::write(
+ &config_path,
+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"
+post-create = "ln -sf {{ repo_root }}/node_modules"
+"#,
+ )
+ .unwrap();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ repo.configure_mock_commands(&mut cmd);
+ cmd.arg("config").arg("show").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+
+ // Verify migration file was created
+ let migration_file = config_path.with_extension("toml.new");
+ assert!(
+ migration_file.exists(),
+ "Migration file should be created at {:?}",
+ migration_file
+ );
+}
+
+/// Test that `wt config show` shows regenerate hint when user deleted migration file
+///
+/// When the hint is set but migration file doesn't exist, `wt config show` should
+/// show how to regenerate it (via `wt config state hints clear deprecated-config`).
+#[rstest]
+fn test_config_show_user_deleted_migration_shows_regenerate_hint(
+ mut repo: TestRepo,
+ temp_home: TempDir,
+) {
+ // Setup mock gh/glab/claude for deterministic output
+ repo.setup_mock_ci_tools_unauthenticated();
+
+ // Write project config with deprecated variables
+ let project_config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&project_config_dir).unwrap();
+ let project_config_path = project_config_dir.join("wt.toml");
+ fs::write(
+ &project_config_path,
+ r#"post-create = "ln -sf {{ main_worktree }}/node_modules"
+"#,
+ )
+ .unwrap();
+
+ // First run with wt list - creates migration file and sets hint
+ {
+ let mut cmd = repo.wt_command();
+ cmd.arg("list").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+ let output = cmd.output().unwrap();
+ assert!(
+ output.status.success(),
+ "First run should succeed: {:?}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ }
+
+ let migration_file = project_config_path.with_extension("toml.new");
+ assert!(migration_file.exists(), "Migration file should be created");
+
+ // Delete the migration file (simulating user doesn't want it)
+ fs::remove_file(&migration_file).unwrap();
+
+ // Run wt config show - should show regenerate hint
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ repo.configure_mock_commands(&mut cmd);
+ cmd.arg("config").arg("show").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+
+ // Migration file should NOT be recreated (hint is set)
+ assert!(
+ !migration_file.exists(),
+ "Migration file should not be recreated when hint is set"
+ );
+}
+
+/// Test that `wt config show` from linked worktree shows hint to run from main worktree
+///
+/// When project config has deprecations and you run from a linked worktree, it should
+/// show a hint to run `wt config show` from the main worktree.
+#[rstest]
+fn test_config_show_from_linked_worktree_shows_main_worktree_hint(
+ mut repo: TestRepo,
+ temp_home: TempDir,
+) {
+ // Setup mock gh/glab/claude for deterministic output
+ repo.setup_mock_ci_tools_unauthenticated();
+
+ // Write project config with deprecated variables
+ let project_config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&project_config_dir).unwrap();
+ fs::write(
+ project_config_dir.join("wt.toml"),
+ r#"post-create = "ln -sf {{ main_worktree }}/node_modules"
+"#,
+ )
+ .unwrap();
+ repo.commit("Add deprecated project config");
+
+ // Create a linked worktree using git directly
+ let feature_path = repo.root_path().parent().unwrap().join("feature-test");
+ repo.run_git(&[
+ "worktree",
+ "add",
+ feature_path.to_str().unwrap(),
+ "-b",
+ "feature-test",
+ ]);
+
+ // Run wt config show from the linked worktree
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ repo.configure_mock_commands(&mut cmd);
+ cmd.arg("config").arg("show").current_dir(&feature_path);
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// Test that `wt config show` displays project-level commit-generation deprecations
+#[rstest]
+fn test_config_show_displays_project_commit_generation_deprecations(
+ mut repo: TestRepo,
+ temp_home: TempDir,
+) {
+ repo.setup_mock_ci_tools_unauthenticated();
+
+ // Write user config with deprecated project-level commit-generation
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ let config_path = global_config_dir.join("config.toml");
+ fs::write(
+ &config_path,
+ r#"worktree-path = "../{{ repo }}.{{ branch }}"
+
+[projects."github.com/example/repo".commit-generation]
+command = "llm -m gpt-4"
+"#,
+ )
+ .unwrap();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ repo.configure_mock_commands(&mut cmd);
+ cmd.arg("config").arg("show").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+
+ // Verify migration file was created
+ let migration_file = config_path.with_extension("toml.new");
+ assert!(
+ migration_file.exists(),
+ "Migration file should be created at {:?}",
+ migration_file
+ );
+}
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap
new file mode 100644
index 000000000..4bc84f002
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap
@@ -0,0 +1,69 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - show
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+USER CONFIG ~/.config/worktrunk/config.toml
+▲ User config uses deprecated template variables: repo_root → repo_path, main_worktree → repo
+↳ Wrote migrated config.toml.new. To apply:
+  mv -- [TEMP_HOME]/.config/worktrunk/config.toml.new [TEMP_HOME]/.config/worktrunk/config.toml
+  diff --git a[TEMP_HOME]/.config/worktrunk/config.toml b[TEMP_HOME]/.config/worktrunk/config.toml.new
+  index d95d100..ceb381d 100644
+  --- a[TEMP_HOME]/.config/worktrunk/config.toml
+  +++ b[TEMP_HOME]/.config/worktrunk/config.toml.new
+  @@ -1,2 +1,2 @@
+  -worktree-path = "../{{ main_worktree }}.{{ branch }}"
+  -post-create = "ln -sf {{ repo_root }}/node_modules"
+  +worktree-path = "../{{ repo }}.{{ branch }}"
+  +post-create = "ln -sf {{ repo_path }}/node_modules"
+  worktree-path = "../{{ main_worktree }}.{{ branch }}"
+  post-create = "ln -sf {{ repo_root }}/node_modules"
+
+PROJECT CONFIG _REPO_/.config/wt.toml
+↳ Not found
+
+SHELL INTEGRATION
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+
+○ Skipped bash; ~/.bashrc not found
+○ Skipped zsh; ~/.zshrc not found
+○ Skipped fish; ~/.config/fish/functions not found
+
+OTHER
+○ wt: [VERSION]
+○ git: [VERSION]
+↳ Claude Code plugin not installed (claude not found)
+○ Hyperlinks: inactive
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap
new file mode 100644
index 000000000..e0c9c03dc
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap
@@ -0,0 +1,74 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - show
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+USER CONFIG ~/.config/worktrunk/config.toml
+▲ User config uses deprecated config sections: [projects."github.com/example/repo".commit-generation] → [projects."github.com/example/repo".commit.generation]
+↳ Wrote migrated config.toml.new. To apply:
+  mv -- [TEMP_HOME]/.config/worktrunk/config.toml.new [TEMP_HOME]/.config/worktrunk/config.toml
+  diff --git a[TEMP_HOME]/.config/worktrunk/config.toml b[TEMP_HOME]/.config/worktrunk/config.toml.new
+  index de80729..eb69d44 100644
+  --- a[TEMP_HOME]/.config/worktrunk/config.toml
+  +++ b[TEMP_HOME]/.config/worktrunk/config.toml.new
+  @@ -1,4 +1,6 @@
+  worktree-path = "../{{ repo }}.{{ branch }}"
+  
+  -[projects."github.com/example/repo".commit-generation]
+  +[projects."github.com/example/repo".commit]
+  +
+  +[projects."github.com/example/repo".commit.generation]
+  command = "llm -m gpt-4"
+  worktree-path = "../{{ repo }}.{{ branch }}"
+ 
+  [projects."github.com/example/repo".commit-generation]
+  command = "llm -m gpt-4"
+
+PROJECT CONFIG _REPO_/.config/wt.toml
+↳ Not found
+
+SHELL INTEGRATION
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+
+○ Skipped bash; ~/.bashrc not found
+○ Skipped zsh; ~/.zshrc not found
+○ Skipped fish; ~/.config/fish/functions not found
+
+OTHER
+○ wt: [VERSION]
+○ git: [VERSION]
+↳ Claude Code plugin not installed (claude not found)
+○ Hyperlinks: inactive
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap
new file mode 100644
index 000000000..3771403fb
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap
@@ -0,0 +1,58 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - show
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+USER CONFIG ~/.config/worktrunk/config.toml
+↳ Not found; to create one, run wt config create
+
+PROJECT CONFIG [PROJECT_ID]
+▲ Project config uses deprecated template variables: main_worktree → repo
+↳ To generate migration file, run wt config show from main worktree
+  post-create = "ln -sf {{ main_worktree }}/node_modules"
+
+SHELL INTEGRATION
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+
+○ Skipped bash; ~/.bashrc not found
+○ Skipped zsh; ~/.zshrc not found
+○ Skipped fish; ~/.config/fish/functions not found
+
+OTHER
+○ wt: [VERSION]
+○ git: [VERSION]
+↳ Claude Code plugin not installed (claude not found)
+○ Hyperlinks: inactive
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
index 14090e219..c3b076a36 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
@@ -35,12 +35,24 @@ exit_code: 0
----- stdout -----
----- stderr -----
-▲ Project config uses deprecated config sections: [commit-generation] → [commit.generation]
-↳ Wrote migrated wt.toml.new; to apply: mv -- _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml
USER CONFIG ~/.config/worktrunk/config.toml
  worktree-path = "../{{ repo }}.{{ branch }}"
PROJECT CONFIG _REPO_/.config/wt.toml
+▲ Project config uses deprecated config sections: [commit-generation] → [commit.generation]
+↳ Wrote migrated wt.toml.new. To apply:
+  mv -- _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml
+  diff --git a_REPO_/.config/wt.toml b_REPO_/.config/wt.toml.new
+  index 074c30f..e97c84f 100644
+  --- a_REPO_/.config/wt.toml
+  +++ b_REPO_/.config/wt.toml.new
+  @@ -1,2 +1,3 @@
+  -[commit-generation]
+  -command = "claude"
+  / No newline at end of file
+  +[commit]
+  +[commit.generation]
+  +command = "claude"
▲ Key commit-generation belongs in user config (will be ignored)
  [commit-generation]
  command = "claude"
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_user_deleted_migration_shows_regenerate_hint.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_user_deleted_migration_shows_regenerate_hint.snap
new file mode 100644
index 000000000..4661abba2
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_user_deleted_migration_shows_regenerate_hint.snap
@@ -0,0 +1,58 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - show
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+USER CONFIG ~/.config/worktrunk/config.toml
+↳ Not found; to create one, run wt config create
+
+PROJECT CONFIG _REPO_/.config/wt.toml
+▲ Project config uses deprecated template variables: main_worktree → repo
+↳ To regenerate migration file, run wt config state hints clear deprecated-config
+  post-create = "ln -sf {{ main_worktree }}/node_modules"
+
+SHELL INTEGRATION
+▲ Shell integration not active
+  Invoked as: [PROJECT_ROOT]/target/debug/wt
+
+○ Skipped bash; ~/.bashrc not found
+○ Skipped zsh; ~/.zshrc not found
+○ Skipped fish; ~/.config/fish/functions not found
+
+OTHER
+○ wt: [VERSION]
+○ git: [VERSION]
+↳ Claude Code plugin not installed (claude not found)
+○ Hyperlinks: inactive
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
index 8849df38a..d3d27eb3d 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
@@ -35,7 +35,6 @@ exit_code: 0
----- stdout -----
----- stderr -----
-▲ Project config has unknown field post-merge-command (will be ignored)
USER CONFIG ~/.config/worktrunk/config.toml
  worktree-path = "../{{ repo }}.{{ branch }}"
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap
index e6e710536..9f3194707 100644
--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap
@@ -41,5 +41,6 @@ exit_code: 0
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config uses deprecated config sections: [projects."github.com/example/repo".commit-generation] → [projects."github.com/example/repo".commit.generation]
-↳ Wrote migrated test-config.toml.new; to apply: mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. To see details, run wt config show
+↳ Wrote migrated test-config.toml.new. To apply:
+  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap
index 755bfc650..9f3194707 100644
--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap
@@ -41,5 +41,6 @@ exit_code: 0
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config uses deprecated config sections: [commit-generation] → [commit.generation]
-↳ Wrote migrated test-config.toml.new; to apply: mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. To see details, run wt config show
+↳ Wrote migrated test-config.toml.new. To apply:
+  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap
index 7f3326378..8f69c4f04 100644
--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_config_deleted_shows_regenerate_hint.snap
@@ -41,5 +41,4 @@ exit_code: 0
○ Showing 4 worktrees, 1 with changes, 3 ahead
----- stderr -----
-▲ Project config uses deprecated template variables: main_worktree → repo
-↳ To regenerate, rerun after wt config state hints clear deprecated-config
+▲ Project config has deprecated settings. To see details, run wt config show
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap
index c86bc4bed..9f3194707 100644
--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap
@@ -41,5 +41,6 @@ exit_code: 0
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config uses deprecated template variables: repo_root → repo_path, worktree → worktree_path, main_worktree → repo
-↳ Wrote migrated test-config.toml.new; to apply: mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. To see details, run wt config show
+↳ Wrote migrated test-config.toml.new. To apply:
+  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snap
new file mode 100644
index 000000000..02b7c2b47
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snap
@@ -0,0 +1,53 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - "-v"
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ WT_TEST_EPOCH: "1735776000"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
+@ main ^| . | 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 3 ahead
+
+----- stderr -----
+▲ User config has deprecated settings. To see details, run wt config show
+↳ Wrote migrated test-config.toml.new. To apply:
+  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+○ Expanding worktree-path
+  ../{{ main_worktree }}.{{ branch }} → ../repo.feature-a
+○ Expanding worktree-path
+  ../{{ main_worktree }}.{{ branch }} → ../repo.feature-b
+○ Expanding worktree-path
+  ../{{ main_worktree }}.{{ branch }} → ../repo.feature-c