Skip to content

refactor(picker): unify worktree and PR rows into one PickerRow - #3259

Merged
max-sixty merged 1 commit into
mainfrom
picker-filter-pr-number
Jun 26, 2026
Merged

max-sixty merged 1 commit into
mainfrom
picker-filter-pr-number

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Collapse the picker's two SkimItem types into one. WorktreeSkimItem (a checked-out worktree row) and PrSkimItem (a listed --prs row) become a single PickerRow whose only branching axis is local: Option<LocalCheckout> — Some for a worktree row, None for a listed PR. This is the type-level completion of #3252, which made the two row kinds behave identically; they now share one text(), display(), output(), preview(), and PR-pane renderer instead of two parallel implementations.

What changed

  • PrSkimItem and its standalone impl SkimItem are deleted. Listed --prs rows are built by prs::listed_pr_row (shared by fetch_and_stream and the row tests) as PickerRow { local: None, … } with a static pr_status slot pre-filled by the new PrEntry::display_status().
  • The worktree-only fields (has_upstream, summaries_enabled, local_content) move into a LocalCheckout sub-struct behind local. The frozen Arc<ListItem> handle is gone, replaced by a precomputed output_token.
  • pr_status and the preview cache are shared by both row kinds, keyed by PickerRow::preview_key() — the branch for a worktree row, pr:N/mr:N for a listed PR. A --prs row's pr pane is memoized in that session-long cache, so listed_pr_row drops the prior (pr:N, Pr) entry on each build; an alt-r reload then re-renders the freshly fetched PR metadata instead of the pre-reload pane (the worktree-row analog of on_update's invalidation).

Behavior change

A worktree row tracking a draft PR now shows a state: draft line in its pr pane. Previously only --prs rows surfaced draft state. This falls out of both kinds sharing render_pr_pane_body.

Reviewer orientation

  • src/commands/picker/items.rs — the unified PickerRow/LocalCheckout, preview_key(), render_pr_pane_body(), render_listed_pr_mode().
  • src/commands/picker/prs.rs — PrSkimItem removed; PrEntry::display_status() and the listed_pr_row constructor (with its cache invalidation).
  • src/commands/picker/progressive_handler.rs — worktree-row construction with local: Some(LocalCheckout { … }).
  • The remaining files are call-site and doc renames.

Rendered output is unchanged — the integration snapshots still pass, and the loading_placeholder snapshots change only their expression: metadata line. Rebased on main's #3253 (the ↳ loading-placeholder glyph), which is preserved.

This was written by Claude Code on behalf of max

Collapse the picker's two SkimItem types — WorktreeSkimItem (a checked-out worktree row) and PrSkimItem (a listed --prs row) — into one PickerRow whose only branching axis is `local: Option<LocalCheckout>` (Some = worktree row, None = listed PR). This is the type-level completion of #3252, which made the two row kinds behave identically: they now share one text(), display(), output(), preview(), PR-pane renderer, and pr_status slot plus preview cache.

PrSkimItem and its standalone SkimItem impl are gone; a shared `listed_pr_row` constructor (used by fetch_and_stream and the row tests) builds listed PRs from a static pr_status slot. The worktree-only fields move into a new LocalCheckout, and the frozen ListItem handle is replaced by a precomputed output_token.

A --prs row's pr pane is memoized in the session-long shared preview cache; listed_pr_row drops the prior (pr:N, Pr) entry on each build so an alt-r reload re-renders the freshly fetched metadata, the worktree-row analog of on_update's invalidation. A worktree row tracking a draft PR now shows a draft line in its pr pane, falling out of both kinds sharing render_pr_pane_body.
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Approved. The three red checks are all the same pre-existing PTY test timing out, not a regression from this refactor — leaving the approval in place and re-running the failed jobs.

integration_tests::switch_picker::test_switch_picker_preview_auto_refreshes_when_compute_lands failed identically on test (windows), affected tests (windows, advisory), and code-coverage with Timed out after 30s waiting for the cursor (> pointer) on row "Not checked out". It passed on test (linux), test (macos), and both non-Windows advisory legs.

Why this reads as a timing flake, not a logic break
  • Failure mode is cursor positioning, not content. The captured screen shows the # flaky PR row rendered fine, but skim's > cursor never moved off @ main onto it. The test times out at the \x1b[B (down-arrow) nudge precondition — before it ever reaches the AUTOREFRESHMARK auto-refresh assertion this PR's code governs. wait_for_cursor_on_row re-issues the arrow because an async list refresh resets skim's cursor to the top; under slow execution the cursor never lands.
  • It failed only in the two slowest environments — Windows PTY, and Linux under llvm-cov instrumentation (code-coverage, which runs --features shell-integration-tests ~3–5× slower). The normal-speed test (linux) / test (macos) runs passed. That split is the signature of a timing-sensitive PTY test, not a deterministic logic bug (which would fail on all platforms).
  • This PR doesn't touch the path the test exercises. The test is pre-existing and unchanged. For a listed --prs row, the unified PickerRow::preview_key() returns output_token (pr:N) — byte-identical to the old PrSkimItem's note_awaiting(&self.output_token) and its (output_token, mode) comments-cache key. The auto-refresh notifier path for --prs rows is behaviorally unchanged.

No existing flake-tracking issue for this test. If it recurs on main I'll open one.

@max-sixty
max-sixty merged commit 4d644d0 into main Jun 26, 2026
44 of 47 checks passed
@max-sixty
max-sixty deleted the picker-filter-pr-number branch June 26, 2026 18:18
max-sixty added a commit that referenced this pull request Jun 27, 2026
#3259 renamed WorktreeSkimItem to PickerRow (and the morphed flag moved to
LocalCheckout); four doc comments still linked the old type, failing
`cargo doc -Dwarnings` on the branch's first CI run.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.

2 participants