Skip to content

feat: move deprecation details to wt config show#828

Merged
max-sixty merged 32 commits intomainfrom
depr
Jan 24, 2026
Merged

feat: move deprecation details to wt config show#828
max-sixty merged 32 commits intomainfrom
depr

Conversation

@max-sixty
Copy link
Owner

Summary

  • Deprecation warnings on wt list and other commands now show a brief pointer: "Run wt config show for details"
  • wt config show displays full deprecation details within each config section (USER CONFIG, PROJECT CONFIG) including:
    • Warning message listing deprecated patterns
    • Migration file apply command (mv --)
    • Inline diff showing the changes
  • Addresses Codex review findings: proper error handling for file writes, shell escaping for paths, linked worktree hint, cleaner API

Test plan

  • cargo test --test integration config_show — 37 tests pass
  • cargo test --test integration — 935 tests pass
  • pre-commit run --all-files — all lints pass

This was written by Claude Code on behalf of @max-sixty

max-sixty and others added 24 commits January 23, 2026 17:29
- Display mv and git diff commands in gutters with syntax highlighting
- Use `git diff --no-index` instead of plain `diff` for colored output
- With -v flag, show actual diff output inline instead of just commands
- Add snapshot test for verbose output

Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
#	src/config/deprecation.rs
Update snapshots for commit-generation deprecation warnings to use the
new gutter-formatted output with git diff preview command.

Co-Authored-By: Claude <noreply@anthropic.com>
Other commands now show a brief warning pointing to `wt config show`,
while `wt config show` displays full details including inline diff
and apply command. This reduces noise in normal operation while
keeping migration guidance easily accessible.

- Add `show_brief_warning` parameter to `check_and_migrate()`
- Extract `write_migration_file()` and `display_migration_diff()` helpers
- Add `DeprecationInfo` struct for passing deprecation context
- Update call sites to pass `show_brief_warning=true` for brief warnings
- `wt config show` calls with `show_brief_warning=false` for full details

Co-Authored-By: Claude <noreply@anthropic.com>
Move deprecation warnings and diff output into the USER CONFIG and
PROJECT CONFIG sections of `wt config show`, rather than at the top
of stderr. This makes the output structure cleaner and more intuitive.

Also adds regenerate hint when user deleted the migration file.

Co-Authored-By: Claude <noreply@anthropic.com>
- write_migration_file_silent() returns bool, callers check before setting
  migration_path
- Early return now sets migration_path when .new file exists
- Add in_linked_worktree field with hint to run from main worktree
- Shell-escape paths in mv commands for safe copy/paste
- Add -- separator in git diff for filenames starting with -
- Re-export DeprecationInfo from mod.rs for public API
- Remove redundant config_path parameter from format_deprecation_details()
- Fix misleading test comment about verbose mode

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
The TEMP_HOME filter must be added before the generic PROJECT_ID filters
so paths like /tmp/.tmpXXX/.config/worktrunk/config.toml get replaced
with [TEMP_HOME] instead of [PROJECT_ID].

Also handle macOS /private prefix mismatch - canonicalize returns
/private/var/... but git diff output shows /var/...

Co-Authored-By: Claude <noreply@anthropic.com>
…rder

When setup_snapshot_settings_with_home is called, the TestRepo may have
already bound snapshot settings with PROJECT_ID filters. Cloning those
settings would inherit those filters, causing them to be applied before
our TEMP_HOME filter.

Fix by creating fresh settings (insta::Settings::new()) when temp_home
is provided, ensuring TEMP_HOME filter is added first.

Co-Authored-By: Claude <noreply@anthropic.com>
- Strip quotes around full paths like '_REPO_/.config/wt.toml' (not just
  '_REPO_' alone), since Windows shell_escape quotes paths with ':'
- Normalize git diff header prefixes: a/_REPO_ -> a_REPO_ to match Unix
  format where the leading / is consumed during path replacement

Co-Authored-By: Claude <noreply@anthropic.com>
On Windows, shell_escape quotes paths containing ':' (drive letters),
producing output like 'C:/Users/.../Temp/.tmpXXX/...' instead of
unquoted paths. Add a filter that matches the quoted form first.

Co-Authored-By: Claude <noreply@anthropic.com>
On Windows, the original temp path may differ from the canonicalized
path due to short path names (e.g., RUNNER~1 vs runneradmin) or other
normalization. Add filters for both variants to ensure TEMP_HOME
paths are matched regardless of which form appears in the output.

Co-Authored-By: Claude <noreply@anthropic.com>
The [TEMP_HOME] quote-stripping and git diff header normalization
filters were being applied before the TEMP_HOME path replacement,
meaning [TEMP_HOME] didn't exist yet in the text when they ran.
Move these filters inside the temp_home block so they run after
the replacement has happened.

Co-Authored-By: Claude <noreply@anthropic.com>
On Windows, shell_escape quotes paths containing ':' (drive letters),
and tree-sitter highlights quoted strings in green. After the path
filter replaces the quoted path with [TEST_CONFIG] or [TEST_CONFIG_NEW],
the ANSI color codes remain around the placeholder, causing snapshot
mismatches between platforms.

Add a post-processing filter that strips ANSI codes wrapping these
test placeholders.

Co-Authored-By: Claude <noreply@anthropic.com>
Windows git diff produces different output for absolute paths:
1. Quoted format without a/b prefixes: diff --git 'C:/...' 'C:/...'
2. ANSI green highlighting from tree-sitter on quoted strings

Add filters to:
- Strip ANSI codes wrapping [TEMP_HOME] paths
- Add missing a/b prefixes to Windows git diff format to match Unix

Co-Authored-By: Claude <noreply@anthropic.com>
Windows git diff with absolute paths may strip the "diff --git " prefix
entirely. Add a filter that detects this case (line starting with
[TEMP_HOME]/... followed by bold ANSI code) and restores the header.

Also fix ANSI stripping to handle multiple consecutive ANSI codes
(e.g., dim+green from tree-sitter highlighting quoted strings).

Co-Authored-By: Claude <noreply@anthropic.com>
Windows git diff with --no-index produces different output than Unix:
- Paths with ':' get quoted by shell_escape
- Tree-sitter highlights quoted strings in green (\x1b[32m)
- git diff headers may have only 'b' prefix or no prefixes at all
- bare paths may appear without --- prefix

Update filters to handle these patterns while keeping Unix format unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Windows tree-sitter produces multiple ANSI codes around paths (reset+dim+green),
not just a single green code. Update filters to handle these sequences for:
- [TEMP_HOME] paths
- [TEST_CONFIG*] placeholders
- _REPO_ paths

Also add filters for Windows git diff format which may omit:
- "diff --git a" prefix in headers
- "--- a" prefix on source file lines
- "+++ b" prefix on destination file lines

Co-Authored-By: Claude <noreply@anthropic.com>
Windows git diff output may show " --git a[path]" (with leading space)
instead of "diff --git a[path]". Add filters to restore the "diff" word
when it's missing after an ANSI reset code.

Also add filter for bare path on --- line (missing "--- a" prefix).

Co-Authored-By: Claude <noreply@anthropic.com>
Windows git diff --no-index output may have two spaces and be missing
the bold ANSI code between \x1b[0m and "--git a". Filters now:
- Match one or more spaces with " +" instead of single space
- Insert \x1b[1m (bold) along with "diff" to match Unix format

Co-Authored-By: Claude <noreply@anthropic.com>
…mands

Windows tree-sitter wraps each path in mv commands with ANSI codes, including
the spaces between paths. Update filter to capture the leading space and strip
ANSI codes before and after the path:
  Before: " \x1b[0m\x1b[2m\x1b[32m[TEMP_HOME]/a.toml\x1b[0m\x1b[2m"
  After:  " [TEMP_HOME]/a.toml"

Co-Authored-By: Claude <noreply@anthropic.com>
Windows tree-sitter output has ANSI codes both before AND after the space
preceding paths: \x1b[0m\x1b[2m (space) \x1b[0m\x1b[2m\x1b[32m[TEMP_HOME]/...

Add (?:\x1b[\d+m)* at pattern start to match optional ANSI codes before space.

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty force-pushed the depr branch 5 times, most recently from 10e0127 to a08c9fe Compare January 24, 2026 12:06
…] paths

The single complex regex wasn't matching reliably on Windows. Split into:
1. Strip ANSI codes between space and [TEMP_HOME] (when green code present)
2. Strip trailing ANSI codes after path (when followed by space)

This simpler approach handles the Windows tree-sitter highlighting patterns
where each path has \x1b[32m before and \x1b[0m\x1b[2m after.

Co-Authored-By: Claude <noreply@anthropic.com>
max-sixty and others added 7 commits January 24, 2026 04:40
Adds tests for previously uncovered code paths in format_deprecation_details():

- test_config_show_user_deleted_migration_shows_regenerate_hint: exercises
  the user_deleted_migration branch showing how to regenerate migration file
- test_config_show_from_linked_worktree_shows_main_worktree_hint: exercises
  the in_linked_worktree branch showing hint to run from main worktree
- test_config_show_displays_project_commit_generation_deprecations: exercises
  the project-level commit-generation deprecation display

Also fixes missing cformat!() call in the linked worktree hint message.

Co-Authored-By: Claude <noreply@anthropic.com>
Add `repo.setup_mock_ci_tools_unauthenticated()` and
`repo.configure_mock_commands(&mut cmd)` to the new coverage tests.

Without mocking, the tests produce different output locally vs CI:
- Local: shows Claude Code install commands (claude is installed)
- CI: shows "(claude not found)"

This caused snapshot mismatches on CI.

Co-Authored-By: Claude <noreply@anthropic.com>
The install_preview_declined snapshot was accidentally modified when
running insta accept for the coverage tests. Restore it to main's
version to fix CI failures.

Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
#	src/config/deprecation.rs
On Windows, `format_path_for_display()` quotes paths containing ':'
(drive letter) using shell_escape. The existing PROJECT_ID filter
expected unquoted paths starting with `[A-Z]:`, so quoted paths like
`'C:/Users/.../test-repo/.config/wt.toml'` weren't matched.

Add a filter variant that handles quoted Windows temp paths.

Co-Authored-By: Claude <noreply@anthropic.com>
The existing quote-stripping filter expected ANSI codes between quotes
and the placeholder. Add a simpler direct filter for the common case
where there are no ANSI codes: `'[PROJECT_ID]'` -> `[PROJECT_ID]`.

This happens on Windows when the unquoted path filter matches inside
quotes (matching up to but not including the closing quote), producing
`'[PROJECT_ID]'`.

Co-Authored-By: Claude <noreply@anthropic.com>
Insta filters are applied in order. The quote stripping filter for
`'[PROJECT_ID]'` was placed before the PROJECT_ID replacement filters,
so it never matched (the path hadn't been replaced yet).

Move the filter to after all PROJECT_ID filters so it can clean up
the result: `'C:/Users/.../path'` → `'[PROJECT_ID]'` → `[PROJECT_ID]`

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit 5f42e84 into main Jan 24, 2026
21 checks passed
@max-sixty max-sixty deleted the depr branch January 24, 2026 17:52
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.

1 participant