show / bundle: respect the requested draft index when opening the TUI#56
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pcr show 448always landed on draft #1 because the TUI hardcodedfocus = 0and the show command never plumbed the user's argument through. Same pattern in reverse forpcr 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 onn - 1pcr bundle(no args, TUI-eligible) → focuses on the newest draft (drafts.len() - 1)runbecomes a thin wrapper aroundrun_focused(drafts, 0)so the public API stays compatible.Verification: 84 tests + 9 golden, clippy + fmt clean.
Made with Cursor