Skip to content

test(pty): keep the shell's failed-setpgid diagnostic out of PTY snapshots - #4136

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-35065804093
Sep 16, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-35065804093

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

test (macos) failed on main at 41af9ba (run 35065804093) with one snapshot mismatch in integration_tests::shell_wrapper::unix_tests::test_readme_example_switch_back: a line the shell wrote about its own job-control bookkeeping had landed in the captured PTY output.

   1     1 │
         2 │+bash: child setpgid (42242 to 42242): Operation not permitted
   2     3 │ ␛[2m○␛[22m Switched to worktree for ␛[1mfeature-api␛[22m @ ␛[1m_REPO_.feature-api␛[22m␊

The line is bash's, not wt's. exec_in_pty_shell runs the wrapper tests under bash -i, which turns job control on so the suite can catch leaked job notifications, and the bash arm of build_shell_script folds stderr into stdout (exec 2>&1) so those leaks are visible to the assertions. An interactive bash puts each child it forks into its own process group; when that setpgid loses its race against the child's own setpgid/exec it prints this diagnostic and carries on. Whether the race is lost is up to host scheduling, so the line shows up in an occasional run and in none of the others — the same test passed on the preceding and following runs of the same workflow on main, on the same code path, and the offending output is not something wt produced.

So this is a snapshot-normalization gap rather than a behavior change: the capture is meant to hold what a user would see from wt, and it is already filtered for host-dependent PTY artifacts (add_pty_filters strips the ^D + backspace sequence macOS PTYs emit at EOF and Linux ones don't). This adds the shell's failed-setpgid diagnostic to the same place, so every PTY snapshot test gets it rather than the one test that happened to catch it.

The filter is deliberately narrow. Job-control notifications — [1] 12345 and [1]+ Done, the leaks assert_no_job_control_messages and test_bash_job_control_suppression exist to catch — do not match it and stay in the output; the new test in tests/common/mod.rs pins both halves by running a capture containing all three lines through the filters and snapshotting what survives.

Verified locally: the new filter test passes, and cargo clippy --tests --features shell-integration-tests and cargo fmt --check are clean. The shell-wrapper PTY tests themselves cannot run in this sandbox — test_readme_example_switch_back fails there on unmodified main too, at the "Shell integration hint should be suppressed" assertion that precedes the snapshot — so the macOS/Linux/Windows legs of this PR are where the wrapper suite actually gets exercised.

@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Sep 16, 2026
@max-sixty
max-sixty merged commit 421b7db into main Sep 16, 2026
37 of 47 checks passed
@max-sixty
max-sixty deleted the fix/ci-35065804093 branch September 16, 2026 17:14
max-sixty added a commit that referenced this pull request Sep 16, 2026
Brings in #4124 (template-variable scanner), #4122 (deprecated keys in an
inline [projects] scope), #4136 (PTY snapshot diagnostic), and #4134 (tend
workflows).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 16, 2026
The #4136 filter matched the diagnostic only at a line start. On macOS CI
(actions/runs/35132033122) bash wrote it straight after the capture's
trailing `\x1b[0m`, with no newline between, so
test_bash_shell_integration_hint_suppressed failed on a snapshot diff.
The filter now also matches right after an SGR escape and keeps the
escape. The filter test gains that shape, and fails on the old pattern.

Also, in the changelog, note that a #4124 template binding a retired
name gets no deprecation warning.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty max-sixty mentioned this pull request Sep 16, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants