Skip to content

show / bundle: respect the requested draft index when opening the TUI#56

Merged
KaluJo merged 1 commit into
mainfrom
show-respects-requested-index
Apr 26, 2026
Merged

show / bundle: respect the requested draft index when opening the TUI#56
KaluJo merged 1 commit into
mainfrom
show-respects-requested-index

Conversation

@KaluJo
Copy link
Copy Markdown
Collaborator

@KaluJo KaluJo commented Apr 26, 2026

pcr show 448 always landed on draft #1 because the TUI hardcoded focus = 0 and the show command never plumbed the user's argument through. Same pattern in reverse for pcr bundle: it opened the same TUI on the oldest draft when the newest is what users almost always want to triage first.

Add tui::screens::show::run_focused(drafts, initial_focus) and route both call sites through it. Out-of-range indices clamp to the last valid row.

  • pcr show <n> → focuses on n - 1
  • pcr bundle (no args, TUI-eligible) → focuses on the newest draft (drafts.len() - 1)

run becomes a thin wrapper around run_focused(drafts, 0) so the public API stays compatible.

Verification: 84 tests + 9 golden, clippy + fmt clean.

Made with Cursor

`pcr show 448` always landed on draft #1 because `tui::screens::show::run`
hardcoded `focus = 0` and the show command never plumbed the user's
argument through to the TUI. Same pattern, opposite direction, in
`pcr bundle`: it opens the same TUI but on the oldest draft, when
the newest is what the user almost always wants to triage first.

Add `tui::screens::show::run_focused(drafts, initial_focus)` and
route both call sites through it:

  - `pcr show <n>` passes `n - 1` so the TUI opens on the requested
    draft.
  - `pcr bundle` (no args, TUI-eligible) passes `drafts.len() - 1`
    so the most recent draft is highlighted on open.

Out-of-range indices are clamped to the last valid row (defensive;
the show command already validates `n <= all.len()` before this
point, but the helper is now safe to call from anywhere).

`run` becomes a thin wrapper around `run_focused(drafts, 0)` so any
existing callers (none today, but the API was public) keep working.

Made-with: Cursor
@KaluJo KaluJo merged commit 2acde4f into main Apr 26, 2026
@KaluJo KaluJo deleted the show-respects-requested-index branch April 26, 2026 00:11
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