Skip to content

docs(list): correct main_state priority order in field docstring - #3531

Merged
max-sixty merged 1 commit into
mainfrom
nightly/status-symbols-doc-29809337058
Jul 21, 2026
Merged

docs(list): correct main_state priority order in field docstring#3531
max-sixty merged 1 commit into
mainfrom
nightly/status-symbols-doc-29809337058

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

The StatusSymbols.main_state field docstring in src/commands/list/model/status_symbols.rs listed the priority as:

IsMain (^) > Orphan > WouldConflict (✗) > Empty (_) > SameCommit (–) > Integrated (⊂) > Diverged (↕) > Ahead (↑) > Behind (↓)

This contradicts the canonical order documented on the MainState enum in state.rs, where Empty and Integrated both outrank WouldConflict (a branch already integrated into the default branch is safe to delete regardless of a vacuous re-merge conflict). It also disagreed with this same file's own type-level docstring (^ > _ > ⊂ > ✗ > – > …).

A maintainer reading the field doc to reason about an already-integrated branch with a vacuous merge-tree conflict would expect , whereas the code correctly renders .

Fix

Documentation only — corrects the field docstring to match the canonical order (IsMain > Orphan > Empty > Integrated > WouldConflict > SameCommit > Diverged > Ahead > Behind) and points at MainState in state.rs as the source of truth. No behavior change, so no test.

Found during the nightly code-quality survey.

The StatusSymbols.main_state field docstring listed the priority as
IsMain > Orphan > WouldConflict > Empty > SameCommit > Integrated > …,
which contradicts the canonical MainState order in state.rs (Empty and
Integrated both outrank WouldConflict) and this file's own type-level
docstring. Correct it to match: IsMain > Orphan > Empty > Integrated >
WouldConflict > SameCommit > Diverged > Ahead > Behind.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Jul 21, 2026
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

The test (windows) failure here is unrelated to this change — this PR only edits a doc comment. The failing test is test_switch_picker_prs_shows_loading_marker, which timed out in the PTY screen-stabilization helper (switch_picker.rs:746) waiting for the picker's loading marker to render — a timing-sensitive interactive-picker test, not touched by this diff. A rerun of the Windows job should clear it.

I didn't rerun it from here: gh run rerun --failed returns 403 while other jobs in the run are still in progress, and I can't reproduce a Windows PTY flake from the Linux CI sandbox to verify a fix.

@max-sixty
max-sixty merged commit 65f0269 into main Jul 21, 2026
50 of 61 checks passed
@max-sixty
max-sixty deleted the nightly/status-symbols-doc-29809337058 branch July 21, 2026 19:58
@max-sixty

Copy link
Copy Markdown
Owner

please fix flake

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Opened #3532 to fix it.

The test_switch_picker_prs_shows_loading_marker flake was a transient-frame race: the mocked gh pr list held the Loading open PRs… state for only 3s, and on a loaded Windows runner the PTY boot (skim-ready wait + initial stabilize) plus async column churn could eat that whole window before the helper first polled — so the rows had already streamed in and the wait timed out at 30s. The fix bumps the hold to 30s, which is free because the capture aborts the instant the marker settles and abort doesn't join the background fetch.

max-sixty pushed a commit that referenced this pull request Jul 25, 2026
#3532)

## Problem

`test_switch_picker_prs_shows_loading_marker` intermittently times out
on `test (windows)` — it flaked on #3531 (a docs-only change), which is
what prompted this fix.

The test asserts a *transient* frame: while a mocked, delayed `gh pr
list` is in flight, the picker header shows `↳ Loading open PRs…` and
the `#42` row has not yet streamed in. The mock held that loading state
for a fixed time (originally 3s). On a loaded Windows runner, the PTY
boot sequence — `boot_picker_pty`'s skim-ready wait plus its initial
`wait_for_stable`, together with the async worktree-column churn (`·`
placeholders resolving) — can consume that whole window. By the time the
stabilization helper first polls for `Loading open PRs`, the mocked
fetch has already returned and the rows have streamed in, so the marker
is gone and the wait times out at `STABILIZE_TIMEOUT` (30s).

## Fix

Per review feedback
([comment](#3532 (comment))),
tie the marker's lifetime to the picker's, with **no timing number at
all** — the file's "poll, don't pick a time" rule applied to the
producer side.

`mock-stub` gains a `hold_until_parent_exit` response mode: the mocked
`gh pr list` holds until `wt` exits instead of sleeping a fixed
`delay_ms`. Detection needs no platform primitive (`getppid` /
`OpenProcess`):

- While `wt` lives, its `--prs` fetch thread runs the mock with a piped
stdout and blocks reading that pipe to EOF, so as long as the mock
neither writes a full response nor exits, the loading marker stays.
- When the picker aborts, `wt` detaches the fetch thread
(`drop(prs_handle)`) and exits, which closes the read end of the mock's
stdout pipe. The mock's next write then fails with `BrokenPipe` (Rust
ignores `SIGPIPE`, so the broken write surfaces as an `Err` rather than
killing the process), and the mock exits.

Polling for that write error is a **causal** parent-death signal —
release is tied to `wt` exiting, not to a timer — and it behaves
identically on Unix and Windows, so there's no platform-specific FFI to
get right. The one-byte probes written into stdout are never observed
(this mode's contract is that the parent aborts without parsing the
response, and the fetch thread drains the pipe until process exit). A
60s poll cap bounds a stuck orphan if the pipe somehow never breaks.

This removes the race the earlier 30s bump only widened: the marker is
present for the entire window the poll could observe it, on any boot
latency, and no orphaned sleeper is left behind — the mock exits the
moment the picker does.

## Testing

`cargo test --test integration --features shell-integration-tests
test_switch_picker_prs_shows_loading_marker` passes in ~1.3s, confirming
the capture-and-abort path stays fast and the mock releases promptly on
`wt` exit. The sibling `--prs` tests
(`test_switch_picker_prs_{github,gitlab}_list`,
`..._rows_survive_alt_x_removal`) still pass through the refactored
`mock_forge_env` helper. Reasoning is documented inline at the mock-stub
call site and in `wait_for_parent_exit`.

---------

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants