# How to Use the Inline Commit Selector for Multi-Commit Reviews in Tuicr

> Master the inline commit selector in Tuicr for efficient multi-commit reviews. Navigate commits, scope comments to SHAs, and persist your selections. Boost your workflow today.

- Repository: [Almog Gavra/tuicr](https://github.com/agavra/tuicr)
- Tags: how-to-guide
- Published: 2026-08-07

---

**The inline commit selector is a navigable pane above the diff that lets you cycle through individual commits or ranges, scope comments to specific SHAs, and persists your selection across sessions.**

The inline commit selector is the primary interface for reviewing pull requests or local commit ranges spanning multiple changes in the `agavra/tuicr` TUI. When you open a multi-commit review, this component renders above the diff display and drives which commit content and comments are visible. According to the tuicr source code, the selector manages state through the `commit_selection_range` field and integrates with the commenting system to support commit-specific feedback.

## Enabling and Toggling the Inline Commit Selector

### Configuration Options

The selector’s default visibility is controlled by the `show_commits` boolean in your configuration file. As implemented in [`src/config/mod.rs`](https://github.com/agavra/tuicr/blob/main/src/config/mod.rs) (lines 107-112), this option defaults to `true`, meaning the pane appears automatically when reviewing multi-commit diffs.

You can also configure the presentation order via the `commit_order` setting. Note that the underlying storage in `review_commits` is always newest-first; the `ascending` or `descending` setting only affects display, handled by `commit_data_index()` in [`src/app/commits.rs`](https://github.com/agavra/tuicr/blob/main/src/app/commits.rs) (lines 21-27).

```toml

# ~/.config/tuicr/config.toml

show_commits = true          # show the pane on startup

commit_order = "descending"  # newest commit on top (default)

```

### Runtime Visibility Controls

To toggle the selector after startup, press `<leader>s` or execute `:set commits!` in the command line. These bindings are documented in [`src/ui/help_popup.rs`](https://github.com/agavra/tuicr/blob/main/src/ui/help_popup.rs) and provide immediate visibility control without restarting the TUI.

## Navigating Commits in Multi-Commit Reviews

### Basic Navigation Keys

The `(` and `)` keys cycle through the commit list when the selector is active. Mapped in [`src/input/keybindings.rs`](https://github.com/agavra/tuicr/blob/main/src/input/keybindings.rs) (lines 97-99), these actions move to the previous and next commit respectively, updating the inline selection rather than the historical commit selector used for local repository browsing.

```text
)   # move to next (newer) commit

(   # move to previous (older) commit

```

### Selection Range Mechanics

The selector stores the full commit list in `review_commits` (newest-first) and tracks your current view via `commit_selection_range: Option<(usize, usize)>`. When you navigate with `(` or `)`, the core logic in [`src/app/commits.rs`](https://github.com/agavra/tuicr/blob/main/src/app/commits.rs) (lines 29-85) automatically adjusts this tuple to reflect your new position. For single-commit selections, the tuple contains identical start and end indices; for ranges, it marks the inclusive bounds of the subset you wish to review.

## Persisting Selection Across Sessions

Your selected range is automatically saved when exiting the TUI. The `session.commit_selection_range` field in [`src/model/review.rs`](https://github.com/agavra/tuicr/blob/main/src/model/review.rs) (lines 111-119) persists this state to disk. On the next load, tuicr restores the exact indices unless the underlying PR was rebased—in which case the system validates that the saved range does not exceed the new commit count before applying it.

You can manually preset a range by editing the session file directly:

```json
{
  "commit_selection_range": [2, 4]
}

```

This JSON array selects commits 3 through 5 (using 0-based indices) the next time the review loads.

## Scoping Comments to Specific Commits

When the selector isolates a single commit, the `App::save_comment` method stamps the comment with that commit’s SHA (`commit_id`). As defined in [`src/model/comment.rs`](https://github.com/agavra/tuicr/blob/main/src/model/comment.rs) (lines 187-197), this scoping ensures the comment only appears when that specific commit is selected, enabling precise feedback on individual changes rather than the entire PR.

```rust
// When you press Ctrl-S to save a comment, the app internally calls:
// self.commit_selection_range is used to attach the correct SHA
let comment = Comment::new(text, commit_id);

```

## Display and Status Indicators

The method `commit_selection_summary()` in [`src/app/commits.rs`](https://github.com/agavra/tuicr/blob/main/src/app/commits.rs) (lines 44-60) generates the status text shown in the UI. For a single commit, it displays formats like *"commit 3/7"*; for sub-ranges, it shows *"3 of 7 commits"*. When you select the entire range (the default full-PR view), the summary disappears to indicate no filtering is active.

## Programmatic Interaction Examples

To inspect the current selection programmatically within the application context:

```rust
let summary = app.commit_selection_summary();
println!("Current selection: {:?}", summary);
// Example output: Some("commit 2/5")

```

When initializing a PR review via `tuicr pr …`, the system calls `apply_pr_commit_selector()` to populate the selector, set the initial range (either "oldest", "all", or auto-scoped to your last reviewed position), and optionally focus the selector panel.

## Summary

- The inline commit selector appears above the diff in multi-commit reviews and is controlled by the `show_commits` configuration option in [`src/config/mod.rs`](https://github.com/agavra/tuicr/blob/main/src/config/mod.rs).
- Navigate individual commits using the `(` and `)` keys mapped in [`src/input/keybindings.rs`](https://github.com/agavra/tuicr/blob/main/src/input/keybindings.rs), which update the `commit_selection_range` tracked in [`src/app/commits.rs`](https://github.com/agavra/tuicr/blob/main/src/app/commits.rs).
- Selection ranges persist across sessions via [`src/model/review.rs`](https://github.com/agavra/tuicr/blob/main/src/model/review.rs), with automatic revalidation if the commit history changes.
- Comments saved while viewing a single commit are scoped to that commit’s SHA through the logic in [`src/model/comment.rs`](https://github.com/agavra/tuicr/blob/main/src/model/comment.rs).
- The display order is configurable but storage remains newest-first, with `commit_data_index()` handling the conversion in [`src/app/commits.rs`](https://github.com/agavra/tuicr/blob/main/src/app/commits.rs).

## Frequently Asked Questions

### How do I hide the inline commit selector after starting a review?

Press `<leader>s` or type `:set commits!` in the command line. This toggles the pane visibility at runtime without affecting the permanent configuration stored in [`config.toml`](https://github.com/agavra/tuicr/blob/main/config.toml).

### Why do my comments disappear when I switch commits?

Comments are scoped to specific commit SHAs when the selector isolates a single commit. As implemented in [`src/model/comment.rs`](https://github.com/agavra/tuicr/blob/main/src/model/comment.rs), the `commit_id` field ensures feedback only appears when that exact commit is active. To see comments across all commits, expand your selection range to include the full PR.

### Can I review commits in chronological order instead of reverse chronological?

Yes. Set `commit_order = "ascending"` in your [`config.toml`](https://github.com/agavra/tuicr/blob/main/config.toml). The underlying storage in `review_commits` remains newest-first for consistency, but `commit_data_index()` in [`src/app/commits.rs`](https://github.com/agavra/tuicr/blob/main/src/app/commits.rs) handles the presentation conversion automatically.

### What happens to my selection if the PR is rebased before I return?

The system validates saved indices against the current commit count when loading a session from [`src/model/review.rs`](https://github.com/agavra/tuicr/blob/main/src/model/review.rs). If the saved range exceeds the available commits (indicating a rebase or force-push), tuicr resets to the default full-range view to prevent index errors.