Skip to content

fix(config): preserve unknown keys and comments when rewriting an inline config section - #4120

Merged
max-sixty merged 8 commits into
mainfrom
fix/issue-4113
Sep 16, 2026
Merged

max-sixty merged 8 commits into
mainfrom
fix/issue-4113

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A config section can be written inline — merge = { squash = false } — and worktrunk rewrites the user's config file in two places: UserConfig::save_to, and the deprecation migration that runs before serde on every load. Both handled inline sections worse than the [merge] spelling, and one of them wrote a file that no longer parsed.

Unknown keys were dropped on save. save_to preserves schema-unknown keys — a typo, or a field from a newer wt — at every nesting level, but only the standard-table branch of merge_tables applied that preservation tree. The inline branch compared the existing inline table against the serialized form and, on any difference, replaced the whole item. An unknown key guarantees that difference, so with

merge = { squash = false, future-option = true }

a save triggered by an unrelated setting dropped future-option. The same config written as [merge] kept it.

Rewriting an inline section as a standard table produced TOML wt can't read. Both rewrite paths have to convert — the save path once a value inside the section really changed, the migration because TOML forbids extending an inline table with a later subtable — and both left the key's own decor in place. A standard table renders that decor inside its brackets, and the key was parsed from merge = { … }, so its decor holds everything that preceded the line. A comment, or just a blank line, therefore landed between the brackets:

# why squash is off
merge = { squash = false }

wt config set merge.squash true wrote back [# why squash is off\nmerge ], and every later command failed with TOML parse error at line 2, column 7. The user's own comment was what broke the file.

The migration path is worse, because it runs on load rather than on save. commit = { stage = "all" } under a comment, alongside a deprecated commit-generation section — or an inline switch alongside [select] — stopped the config from loading at all, on every command, at a line number matching nothing the user wrote, and wt config update then wrote the broken text to disk.

Solution

The save path's inline branch now merges into a table view of the existing inline table, recursing through merge_tables with that key's preserve.nested subtree — the same path the standard-table branch takes. It writes back only when the merge changed something, so an inline section nothing touched keeps its formatting.

When a conversion does happen, it goes through one shared replace_inline_with_table: the key's prefix — its leading comments and blank lines — moves onto the table header, and the rest of the key's decor is dropped (which also clears the stray space in [merge ]). Both rewrite sites call it, so the migration's ensure_standard_table_parent can't drift back.

values_equal also gained an InlineTable arm. Without it two identical inline tables never compared equal, so a section whose only child is an unchanged inline table — commit = { generation = { command = "…" } } — was reported as changed and expanded on every save.

What is still not preserved

A trailing comment on the same line, merge = { squash = false } # why, is dropped when the section is rewritten: it lives in the inline table's own decor, which InlineTable::into_table discards. That is comment loss rather than corruption, and it predates this PR.

A leading comment above an inline commit whose only contents are subtables is also dropped, because make_commit_table_implicit_if_only_subtables suppresses the [commit] header the comment was moved onto. main loses the same comment from the standard-table spelling, so it is a separate pre-existing bug rather than something this change introduces.

Testing

Unit tests in the existing save_to group and in the deprecation tests, each failing before the change it covers:

  • test_save_to_existing_file_preserves_unknown_keys_in_inline_table / …_when_inline_table_changes — future-option survives an unrelated save and a real change.
  • test_save_to_existing_file_preserves_nested_inline_table_formatting — an unchanged nested inline table round-trips byte-identical.
  • test_save_to_rewrites_commented_inline_section_as_parseable_toml / …_blank_line_separated_… — the saved file re-parses and the comment sits above the header.
  • test_migrate_commented_inline_parent_keeps_the_config_loadable / test_migrate_inline_parent_after_blank_line_keeps_the_config_loadable — assert through UserConfig::load_from_str, the user-visible failure, rather than through the migrated string.

Also verified by hand across a trailing comment, an indented key, a CRLF file, a dotted key, and a [projects."<id>"]-scoped inline section — all re-parse.

cargo test --lib passes apart from copy::tests::test_copy_dir_recursive_does_not_count_a_non_regular_file, which fails on main in this sandbox too (UnixListener::bind → PermissionDenied, socket(AF_UNIX, …) is blocked). cargo test --test integration config, cargo clippy --all-targets and cargo fmt --check are clean.

Reported by @zach-hammad-vs from source inspection; the reproduction above confirms it.

Closes #4113 — automated triage

… user config

The inline-table branch of `UserConfig::merge_tables` replaced the whole
item instead of recursing with the unknown-key preservation tree, so an
unrelated config save deleted forward-compatible keys a user had written
inside `merge = { ... }`.

Closes #4113

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Two findings, both reproduced by running save_to against a scratch config.

The inline section this PR is about is still expanded when its child is an inline table. values_equal has no Value::InlineTable arm, so it falls through to _ => false and two identical inline tables never compare equal. The new branch compares as_table against merged — both derived from the same on-disk item — so a section whose only child is an unchanged inline table is reported as changed and rewritten. commit = { generation = { command = "summarize" } }, saved after an unrelated setting changes, comes back as

[commit ]
generation = { command = "summarize" }

where main produced a clean [commit.generation]. The stray space in the header is the key decor of commit = { carried into the standard-table render. So this case both misses the stated goal ("an inline section nothing touched keeps its formatting") and leaves a worse-looking file than before the change. The doc bullet on merge_tables — "compare contents, preserve inline format when semantically equal" — describes the intent, not the behavior.

An InlineTable arm in values_equal that compares key-by-key closes it; with that arm the file above round-trips byte-identical. Pushing it with a regression test.

Separately, predating this PR: a section whose known fields are all default is deleted outright, unknown keys included. stale_keys spares a key in preserve.keys, but a known section with unknown children lands in preserve.nested, not preserve.keys. When none of its known fields are set, serialization omits the section, so desired doesn't hold it either and it is removed as stale. A [merge] table holding only future-option = true, plus any unrelated save, leaves the file with no [merge] at all — and the same for the inline spelling this PR fixes, merge = { future-option = true }. That contradicts the save_to docstring ("Schema-unknown keys at any nesting level … are preserved so older wt versions don't silently strip forward-compatible config data"), and test_save_to_existing_file_preserves_section_with_only_unknown_fields reads as covering it while only exercising the variant where a mutation reintroduces a known field.

Sparing every preserve.nested key isn't sufficient on its own — a known field cleared back to its default still has to be removed. The shape that works: when a stale key has a preserve.nested entry, recurse merge_tables into it with an empty desired and drop the key only if nothing survives. Leaving it out of this PR because it is a main bug on the standard-table path too, but it is the same loss this change is closing and worth its own fix.

…one keeps its formatting

values_equal had no InlineTable arm, so two identical inline tables never
compared equal. The new inline branch of merge_tables compares the on-disk
table against the merge of itself, so a section whose only child is an
unchanged inline table read as changed and was rewritten as a standard
table -- with a stray space in the header, since the key decor of
`commit = {` carries into the standard-table render.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Self-review of the follow-up commit, plus one finding on the branch it rewrites.

The nested-inline-table fix in a53b563 is correct — values_equal now has an InlineTable arm, and commit = { generation = { command = "summarize" } } round-trips byte-identical through an unrelated save.

Changing a value inside an inline section writes a config file wt can no longer read. The branch converts the section to a standard table on a real change, but leaves the key's leaf decor in place, and a standard table renders that decor inside its brackets. The key was parsed from merge = { … }, so its decor holds everything that preceded the line. With

# why squash is off
merge = { squash = false, future-option = true }

wt config set merge.squash true writes back

[# why squash is off
merge ]
squash = true
future-option = true

and every later command fails with TOML parse error at line 2, column 7: key with no value, expected '='. A blank line before the section does it too — that is prefix decor as well, so [\nmerge ] — which makes any config file where the inline section is not the very first line a candidate. The user's own comment is what breaks the file.

This is on main, not introduced here; I reproduced it against both trees. This PR narrows it — the rewrite now fires only on a real change rather than on every save of a section holding an unknown key — but the remaining path still corrupts, and it is the same branch and the same save this PR is about, so I've fixed it here rather than opening a third PR against merge_tables.

The fix moves the key's prefix onto the table header and clears the rest, in a replace_inline_with_table helper, with two regression tests that assert the saved file re-parses. It also drops the stray space in [merge ]. Verified across a trailing comment, a leading blank line, an indented key, a CRLF file, and a dotted key — all re-parse. Full cargo test --lib is green apart from copy::tests::test_copy_dir_recursive_does_not_count_a_non_regular_file, which fails on main in this sandbox too (socket(AF_UNIX, …) is blocked); cargo clippy --all-targets and cargo fmt --check are clean.

Not fixed, and worth a look: a trailing comment on the same line — merge = { squash = false } # why — is still dropped when the section is rewritten, because it lives in the inline table's own decor, which into_table() discards. That is comment loss rather than corruption, and it predates this PR.

Requesting review from @max-sixty rather than self-approving: this is worktrunk's own config file, one of the files named under Data Safety in CLAUDE.md as something it writes on the user's behalf, and the failure mode is a file the user cannot load until they hand-edit it.

…r it becomes

Rewriting a changed inline section as a standard table left the key's leaf
decor in place, and a standard table renders that decor inside its brackets.
A comment or blank line before `merge = { … }` therefore landed between the
brackets, and every later command failed with a TOML parse error.

The prefix now moves onto the table header and the rest of the key's decor is
dropped, which also clears the stray space in the rewritten header.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Self-review of 0d19b04, plus the same-pattern search it invites.

The other place worktrunk converts a user's inline table to a standard table still writes a config file it can't read — and that one breaks on load, not on save. ensure_standard_table_parent in src/config/deprecation.rs has to convert, because TOML forbids extending an inline table with a later subtable, and it replaces the item without touching the key's decor. So this valid config:

# my commit settings
commit = { stage = "all" }
commit-generation = { command = "x" }

migrates to [# my commit settings\ncommit ]\nstage = "all"\n\n[commit.generation]\ncommand = "x"\n, and UserConfig::load_from_str on the original returns TOML parse error at line 2, column 8. migrate_commit_generation_doc is a Structural rule, so that rewrite runs before serde on every command — the user's config stops loading entirely, at a line number that matches nothing they wrote, and wt config update then writes the broken text to disk. switch = { … } above a [select] section is the same path ([# picker prefs\nswitch ]), and a blank line before the key triggers it just as a comment does, so an inline section anywhere but the first line of the file is a candidate.

This PR's helper is the fix; it just isn't reachable from there. Pushing a commit that hoists the decor move into one shared function and calls it from both sites, with regression tests that assert through load_from_str — the user-visible failure — rather than through the migrated string.

Separately, and predating this PR: the leading comment is dropped when the header it moves to is suppressed. With

# lead
commit = { generation = { command = "a" } }

changing commit.generation.command saves [commit.generation]\ncommand = "b" and the comment is gone: replace_inline_with_table moves the prefix onto the [commit] header, and make_commit_table_implicit_if_only_subtables then suppresses that header and takes the comment with it. main loses the same comment (the standard-table spelling — a comment above [commit] holding only subtables — loses it too), so this isn't a regression, and it's comment loss rather than corruption. Skipping the implicit marking when the table carries a non-empty prefix would close both. Leaving it out of this PR for the reason the stale-key bug went to #4123: it is a main bug on a different path.

One overlap worth knowing about at merge time: #4123 edits the adjacent bullet in the merge_tables doc comment and the stale-key filter just above this change. The two fixes are independent — that one keeps an all-unknown section from being swept as stale, this one governs how a section that survives is rewritten — so it's a textual conflict, not a duplicate.

…on gives it

Converting an inline `commit = { … }` or `switch = { … }` so a migrated
`[commit.generation]` or `[switch.picker]` could be nested under it left the
key's decor in place, and a standard table renders that decor inside its
brackets. A comment or blank line above the key therefore landed between them,
and because these rules run before serde on every load, the config stopped
parsing on every command — not just on the file `wt config update` writes.

The decor move added for the save path now lives in one shared helper that both
call sites use.
@worktrunk-bot worktrunk-bot changed the title fix(config): preserve unknown keys inside inline sections when saving user config fix(config): preserve unknown keys and comments when rewriting an inline config section Sep 15, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Self-review of 9232bcb, the shared-helper hoist.

values_equal still has no Float or Datetime arm, so an inline section holding one is expanded on every unrelated save. The InlineTable arm closed the nested-table case, but the same fall-through to _ => false remains for the two scalar variants the match never names. Those types only reach a user config as unknown keys — a typo, or a field from a newer wt — which is exactly what this PR's inline branch exists to preserve. With

merge = { squash = false, future-timeout = 1.5 }

a save triggered by an unrelated setting compares the section against itself, 1.5 fails to match any arm, and the file comes back as

skip-shell-integration-prompt = true
[merge]
squash = false
future-timeout = 1.5

No key is lost — the merge branch this PR adds holds — but "an inline section nothing changed keeps its formatting", which the changelog entry claims, is false for those two variants. A datetime value behaves identically. Pushing the two arms plus a regression test; with them that file round-trips byte-identical. Every Value variant then has an arm, and the function gains a docstring saying why a missing one isn't inert.

Separately, predating this PR: an existing config file gains a bare [projects] header the first time worktrunk saves it. projects carries no skip_serializing_if, so serde always emits it, and save_to's new-file branch marks that table implicit while the existing-file branch doesn't — the empty section is merged in as a real one. Any save_to caller reaches it: answering the shell-integration prompt, set_commit_generation_command, set_project_worktree_path. Nothing is lost and the file still parses, so it's cosmetic, but it is the same "don't rewrite what the user wrote" contract this PR is about, and the fix is one set_implicit(true) in the existing-file branch. Leaving it out here for the reason the stale-key bug went to #4123 — it's a main bug on a path this change doesn't touch.

…rvives a float

`values_equal` named String, Integer, Boolean, InlineTable and Array, and any
other pair fell through to `_ => false`. In the inline-table branch of
`merge_tables` "not equal" is what rewrites the user's inline section as a
standard table, so an unknown float or datetime key inside `merge = { … }`
expanded the whole section on a save triggered by an unrelated setting — the
formatting preservation that branch exists for, undone by the two variants the
match never named.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Self-review of 2bf72ee, the Float/Datetime arms.

The arms are right, but the thing that let them go missing is still there. values_equal ends in _ => false, so a Value variant with no arm of its own is not a compile error — it is an inline section that silently stops keeping its formatting, because in the inline-table branch of merge_tables "not equal" is what rewrites the user's section as a standard table. This PR has now hit that twice: InlineTable in a53b563, Float and Datetime here. The docstring 2bf72ee adds ("Every Value variant needs an arm") is the only thing standing between the next toml_edit release and a third round, and a doc comment is not a guard.

toml_edit::Value is not #[non_exhaustive], so the mismatched-variant arm can spell out all seven variants instead of _, and a new variant becomes error[E0004] here rather than a formatting regression a user reports months later. Pushing that plus the docstring rewrite it makes redundant; cargo clippy --all-targets and the config suite are clean with it.

Known residual, deliberately not fixed: the Float arm compares with ==, so merge = { future-timeout = nan } still compares unequal to itself and expands the section on an unrelated save. No key is lost — it is formatting only — and nan in a wt config is not a value anyone writes, so the is_nan() special case costs more than the case is worth. Noting it rather than adding the line.

Still requesting review from @max-sixty rather than self-approving, for the reason the earlier round gave: this is worktrunk's own config file, one of the files Data Safety in CLAUDE.md names as something wt writes on the user's behalf.

`values_equal` ended in `_ => false`, so a `Value` variant with no arm of its
own was not a compile error but an inline config section that silently stopped
keeping its formatting: in the inline-table branch of `merge_tables` "not
equal" is what rewrites the user's section as a standard table. This branch hit
that twice — `InlineTable`, then `Float` and `Datetime`.

`toml_edit::Value` is not `#[non_exhaustive]`, so the mismatched-variant arm
names all seven variants instead of using `_`. A variant added upstream is now
`error[E0004]` here rather than a regression a user reports months later, which
also retires the doc comment that was asking a reader to remember the rule.
Drop this PR's CHANGELOG.md entry. Changelog entries are written from the commits at release time (CLAUDE.md, Releases), so an open PR carrying an entry drops it rather than resolving a conflict on it.
@max-sixty
max-sixty merged commit 988e7aa into main Sep 16, 2026
37 checks passed
@max-sixty
max-sixty deleted the fix/issue-4113 branch September 16, 2026 06:54
max-sixty added a commit that referenced this pull request Sep 16, 2026
Resolves the conflict in src/config/user/persistence.rs, where #4120 and
the release branch's comment-preservation fix both edited merge_tables.

#4120's inline-table arm is taken whole: it merges through the recursive
path so nested preserve applies, and moves the key's leading decor onto
the header through replace_inline_with_table. It left two gaps, one by
design ("the value's own decor ... is still dropped"):

- The scalar arm still replaced a changed value wholesale, dropping the
  line's comment. replace_keeping_decor from the release branch is kept
  for that arm.
- A trailing comment after an inline table's closing brace was
  discarded by InlineTable::into_table. replace_inline_with_table now
  reads it from the still-inline value and sets it after the header's
  `]`, so both of its callers (the save path and
  ensure_standard_table_parent) keep it.

test_saving_config_mutation_preserves_an_inline_entry_comment now
snapshots the rewritten file and parses it, since #4120's point was that
a misplaced comment is what breaks the header.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@worktrunk-bot worktrunk-bot mentioned this pull request Sep 16, 2026
max-sixty added a commit that referenced this pull request Sep 16, 2026
…4140)

A config rewrite that breaks the TOML syntax leaves a file wt can't
load: every later command skips user config with a warning, and commands
that need project config fail, until the user hand-edits it. #4120 fixed
one such rewrite (an inline table converted to `[# comment\nmerge ]`);
this makes the next one fail instead of writing.

`ensure_config_parses` (`src/config/mod.rs`) parses the content before
it's persisted, in both writers that rewrite a config file the user
owns:

- `UserConfig::save_to` checks just before `write_atomically`.
- `wt config update` checks when it computes the migration
(`UpdateCandidate::new`, which also replaces the two duplicated struct
literals). The in-place update and `--output` both refuse it there,
before the preview prompt.

On refusal the file on disk is unchanged. No rewrite produces invalid
TOML today, so the error paths have no integration trigger; a unit test
covers the check against the #4120 output shape.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 16, 2026
Version bump to 0.78.0 plus the changelog section for this release, a comment-preservation fix the release review turned up, a PTY test-filter fix, and merges of `main` (commits that landed during the review, including #4124, #4122, #4141, #4140 and #4145).

**Bump level**: minor. `cargo semver-checks` reports 2 breaking library changes — a new `leftover_branch` field on the `GitError::WorktreeCreationFailed` struct variant, and `DEPRECATED_TEMPLATE_VARS` removed. Pre-1.0, so a breaking change takes a minor bump.

## Comment-preservation fix

A config save — declining the commit-generation offer, say — dropped the trailing comment on every value it rewrote. That was already true in v0.77.0 for a line the save itself changed (`skip-commit-generation-prompt = false  # note` → `true`, reproduced on the v0.77.0 binary). #4080 widened it to lines the command never touched: retired template variables now migrate on every load, so the next unrelated save rewrote any line naming one. #4080's own PR said this "needs a call before merge" and merged without one.

- `replace_keeping_decor` keeps the value's decor (spacing after `=`, trailing comment) when `merge_tables` replaces a scalar. Comments *above* a line sit on the key and were never at risk.
- `main`'s #4120 independently reworked the inline-table arm and moved a key's leading comment onto the rewritten header, but documented that a trailing comment after the closing brace "is still dropped". `replace_inline_with_table` now carries it after the header's `]`, so both of its callers keep it.
- Tests: the existing comment-preservation test goes back to a retired name (the only fixture that exercises the replacement) and adds a comment on the mutated line; a new test snapshots and re-parses an inline `[projects]` entry. Each fails without its half of the fix.

Not fixed, and identical on v0.77.0: a save deletes an explicitly written *default* value (e.g. `skip-commit-generation-prompt = false  # note`) as a stale key, comment included.

## `--help` correction

#4104 moved the OpenCode plugin path to etcetera's `Xdg` strategy, which uses `$XDG_CONFIG_HOME` only when absolute — a deliberate, documented choice — but `wt config plugins opencode --help` still said install mirrors OpenCode's precedence. OpenCode reads a relative value as-is, so the help now says an empty `$OPENCODE_CONFIG_DIR` and an empty or relative `$XDG_CONFIG_HOME` are ignored.

## Data-loss surface review

Independent finders swept the full diff, including the five commits merged from `main`. Nothing holds the tag; candidates were adjudicated against v0.77.0 binaries:

- **Fixed in this release, reproduced on v0.77.0**: #4104 stops `wt config shell install` (with Nushell) deleting a `nushell/vendor/autoload/wt.nu` under the current directory when `$XDG_CONFIG_HOME` is empty or relative; #4120 stops a save or migration from writing an inline section's comment inside `[commit]` brackets, which made the config unparseable, and from dropping unknown keys.
- **`wt step prune --min-age` doesn't apply where no reflog exists** — pre-existing, proven by building the pre-#4077 binary. `git clone --bare` and `git fetch` into `refs/heads/*` write no reflog, so in the bare layout `tips-patterns.md` recommends every branch starts unprotected. Docstring corrected here; behavioral fix is follow-up.
- **`wt config update --output <path>` replaces any named file whole**, no existence check or prompt — pre-existing, follow-up.
- **`wt config shell install fish --yes` replaces a hand-written wrapper at the XDG path** — accepted ("ownership is the path", predates #3602), newly reachable only for users with `$XDG_CONFIG_HOME` set. The FAQ's delete inventory now cross-references it.
- **`--var <retired-name>` binds a name nothing references** after #4080 — inert, no shipped usage; follow-up.
- **#4135 migrates nothing**: an existing oh-my-pi hook stays put, `pi uninstall` points at `omp uninstall`. `PI_CODING_AGENT_DIR='~/x'` is used literally (Pi expands `~`) — creates a stray directory, deletes nothing; follow-up.

## Changelog

37 entries; each new or edited entry was re-verified against v0.77.0 until a pass came back clean (six passes in all). Passes caught, among others: the OpenCode `-x` recipe was wrong since 0.76.0, not 0.75.0; #4080's JSON reaches every hook, not just `pre-start`/`post-start`; a quoted git error string git never prints; a copy-button overlap that existed only inside this release; #4104's relative-`XDG_CONFIG_HOME` OpenCode change described as a fix when OpenCode reads that path as-is; and which commands a broken inline section stopped. **Fixed** leads with the data-loss entries.

## Open PRs checked against v0.77.0

- **#4124** fixed a bug new in this release, caused by #4080, and has landed and been merged in here. The hand-rolled template-variable scanner it extends is slated for removal; see its commit message.
- **#4112** — no data-loss regression vs v0.77.0; two small non-safety regressions from #4111 (an uncapped auto-staging file list, a narrow `Nothing to commit` refusal under `status.showUntrackedFiles = no`). Not merged, by decision.
- **#4122** (merged in) and **#4123** — pre-existing bugs, identical on v0.77.0.

## PTY filter fix

`test (macos)` failed once on a shell's failed-`setpgid` diagnostic that landed straight after the capture's trailing `\x1b[0m`, with no newline between, so #4136's line-anchored filter missed it. The filter now also matches right after an SGR escape and keeps the escape; its test gains that shape and fails on the old pattern.

## Validation

- `cargo run -- hook pre-merge --yes` — 4930 tests passed, 1 skipped; clippy, fmt, doc-sync, snapshot and lockfile checks green
- Nightly on the original cut-from tip (https://github.com/max-sixty/worktrunk/actions/runs/35060617020): green across `full-tests` on linux/macos/windows, `feature-powerset`, all `release-target`s, `nix-flake`, `minimal-versions`, `link-check`

> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.78.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Release Notes

### Improved

- **Hook scripts read renamed context keys**: the JSON piped to every hook drops `worktree`, `repo_root`, `main_worktree`, and `main_worktree_path` in favour of `worktree_path`, `repo_path`, `repo`, and `primary_worktree_path`. Config templates migrate on load, so hooks written with the old names keep working; scripts reading the JSON, `--execute` templates, and `--var` overrides need updating. (Breaking.) ([#4080](max-sixty/worktrunk#4080))

- **`wt config plugins pi` installs for Pi; oh-my-pi moves to `wt config plugins omp`**: `pi install` wrote an oh-my-pi hook, which Pi never loads; Pi users re-run it to get a Pi extension. Existing oh-my-pi hooks keep working, listed as outdated until `wt config plugins omp install`. (Breaking: scripts that run `wt config plugins pi` for oh-my-pi need `omp`.) [Docs](https://worktrunk.dev/claude-code/#oh-my-pi) ([#4135](max-sixty/worktrunk#4135), thanks @ashebanow)

- **Interactive prompts no longer open with a blank line**: `wt config shell install`, `wt config plugins claude install`, and the commit-message setup offer in `wt merge` began with one. ([#4059](max-sixty/worktrunk#4059))

- **`wt config show` gives a single `wt config shell install` hint**: an outdated wrapper, a fish wrapper at the deprecated `conf.d` path, and missing fish completions each printed their own hint. The zsh `compinit` snippet is now syntax-highlighted. ([#4059](max-sixty/worktrunk#4059))

- **`wt config update --output <path>` confirms the write**: it now prints `✓ Wrote user config migration @ ~/migrated.toml` where it printed nothing. `--output=-` stays silent. ([#4053](max-sixty/worktrunk#4053))

### Fixed

- **Removal no longer discards untracked files hidden by `status.showUntrackedFiles = no`**: under that setting, a worktree holding only untracked files looked clean, so `wt remove`, `wt merge`, and `wt step prune` removed it without `--force`. Safety checks now always count untracked files, and auto-staging warnings list every file they stage. ([#4111](max-sixty/worktrunk#4111), thanks @Duang777)

- **`wt remove` and `wt merge` check the right worktree under an inherited `GIT_DIR`**: run from a `!wt` git alias or a git hook, which pass `GIT_DIR` down, `wt remove` could delete a dirty worktree without `--force`, and `wt merge` could refuse a clean merge. Both now check the worktree they act on. ([#4082](max-sixty/worktrunk#4082), thanks @Duang777)

- **`wt merge` no longer deletes a worktree locked with `git worktree lock`**: the merge completes and prints `Worktree preserved (locked)`. Every Worktrunk removal refuses a locked worktree, even with `--force`; run `git worktree unlock <path>` first. ([#4073](max-sixty/worktrunk#4073), thanks @Duang777)

- **`wt config update` no longer overwrites a config edited while its prompt is open**: it wrote the pre-prompt snapshot over the newer file and reported success. It now fails with the path and leaves the newer file; re-running previews the current contents. ([#4127](max-sixty/worktrunk#4127), thanks @zach-hammad-vs for reporting)

- **`wt step prune` no longer deletes a branch created minutes ago from an older commit**: `--min-age` aged a branch without a worktree by its commit's date, so a new branch off a day-old commit was pruned on the next run. Age now comes from the branch's oldest reflog entry. ([#4077](max-sixty/worktrunk#4077))

- **A comment or blank line above an inline config section no longer breaks the config**: a save or migration that rewrote `commit = { … }` as `[commit]` put that line inside the brackets. `wt switch`, `wt merge`, `wt remove`, and several `wt step` commands then failed with `Failed to load config`; `wt list` warned and ran without the config. Saves also dropped unrecognized keys from inline sections. ([#4120](max-sixty/worktrunk#4120), thanks @zach-hammad-vs for reporting)

- **Config saves keep the trailing comment on a value they rewrite**: a save such as answering the commit-generation offer dropped the comment after each value it rewrote, including one after an inline section's closing brace. ([#4138](max-sixty/worktrunk#4138))

- **Ignored project-config keys warn from every worktree**: an unknown key in `.config/wt.toml`, or one that belongs in user config such as `[merge]`, warned only in the main worktree, so `wt merge` from a linked worktree ignored it silently. ([#4145](max-sixty/worktrunk#4145), thanks @ee-prog for reporting)

- **`wt merge` skips `post-commit` when it removes that hook's worktree**: before, the hook ran in the primary worktree when the removed one sat inside the repository, and otherwise didn't run. The merge now prints `▲ Skipped post-commit`; move work that must finish there to `pre-remove`. ([#4049](max-sixty/worktrunk#4049))

- **`wt switch` recovers from a removed worktree in a bare repository**: `wt switch` and the picker surfaced git's raw `fatal: Unable to read current working directory` instead, and the removed-directory message lacked `wt switch ^`. ([#4067](max-sixty/worktrunk#4067))

- **`wt config shell install fish` puts the wrapper where fish reads it under a custom `$XDG_CONFIG_HOME`**: the wrapper always went to `~/.config/fish/functions/`, so install reported success while `wt switch` changed no directory. On Windows, the fish completion moves from `%APPDATA%\fish\completions` to the wrapper's directory. ([#4107](max-sixty/worktrunk#4107))

- **`wt config shell install zsh` honours `$ZDOTDIR` only when it is absolute**: an empty or relative value resolved against the current directory, so install appended to a `.zshrc` under the current directory and reported success while the file zsh reads went untouched. A non-absolute value now falls back to `$HOME`. ([#4085](max-sixty/worktrunk#4085))

- **`wt config shell install` for Nushell no longer deletes a `wt.nu` under the current directory**: an empty or relative `$XDG_CONFIG_HOME` resolved against it, so install removed a `nushell/vendor/autoload/wt.nu` beneath it unread, as a stale wrapper. It now falls back to `~/.config`, which also fixes unread `tea` logins that let `wt switch pr:<n>` treat a Gitea host as GitHub. ([#4104](max-sixty/worktrunk#4104))

- **`wt switch --create` names the branch a failed worktree add leaves behind**: `git worktree add -b` writes the branch ref before populating the worktree, so a failure in between left the branch with no worktree, and the next attempt reported a name collision. The error now says how to delete or reuse it. ([#4109](max-sixty/worktrunk#4109), thanks @technicalpickles for reporting)

- **`wt config shell install` no longer tells an already-wrapped shell to restart**: reinstalling from a shell with the wrapper loaded, such as after a version bump, printed `↳ Restart shell to activate shell integration`. ([#4059](max-sixty/worktrunk#4059))

- **`wt config shell install` migrates a deprecated `conf.d` fish wrapper when `~/.config/fish/functions` is missing**: before, only `wt config shell install fish` migrated it. `wt config show` now reports that wrapper even when fish isn't on `PATH`. ([#4059](max-sixty/worktrunk#4059))

- **Plugin status and uninstall checks ask the agent CLIs**: `wt config show` could list an installed Claude Code plugin or Gemini CLI extension as not installed, and `wt config plugins claude|codex uninstall` could report success over a marketplace still configured. A repeat Claude uninstall now runs both removals instead of stopping at `Plugin not installed`. ([#4048](max-sixty/worktrunk#4048), [#4054](max-sixty/worktrunk#4054))

- **`wt config plugins opencode install` no longer writes the plugin into the current directory**: with `OPENCODE_CONFIG_DIR` set but empty, it wrote `plugins/worktrunk.ts` there, typically inside a repository, reporting success though OpenCode never saw it. An empty value now counts as unset. ([#4084](max-sixty/worktrunk#4084))

- **The OpenCode plugin clears its activity marker when OpenCode 1 disposes it**: only explicit session deletion cleared it, so a finished session kept its `💬` and `wt list` showed it as active until `wt config state marker clear` was run by hand. ([#4129](max-sixty/worktrunk#4129), thanks @drewdas for reporting)

- **`wt config update` migrates `[ci] platform` into a `[forge]` section that only sets `hostname`**: that config, common with GitHub Enterprise and self-hosted GitLab, kept the deprecated key with no deprecation warning. ([#4061](max-sixty/worktrunk#4061))

- **Deprecated keys in an inline `[projects]` entry now migrate**: `"example.com/org/repo" = { merge = { no-ff = true } }` skipped the migration the section form got, so the per-project setting was ignored. ([#4122](max-sixty/worktrunk#4122), thanks @zach-hammad-vs for reporting)

- **A deprecated config section the migration can't rewrite now warns**: `select = "not a table"`, or a `[select]` whose `[switch.picker]` destination is already set, was ignored without a message. It now reports `unknown field select (will be ignored)`. ([#4121](max-sixty/worktrunk#4121), thanks @zach-hammad-vs for reporting)

- **`wt config update` no longer changes what a template renders**: it could rename `{{ repo_root }}` inside a quoted s

See merge request: Harmonybrew/homebrew-core!20435
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.

Config save drops unknown fields inside inline tables

2 participants