Skip to content

feat(session): let me filter saved sessions by branch #1701

Description

@Harshal96

Problem Statement

Problem Statement

I'm trying to find a saved review for one branch. ocr session list gives me the latest 20 sessions from every branch in the repo. The branch isn't in the table, either. So now I'm opening sessions one by one to figure out which run I actually want.

And if I've done enough reviews on other branches? The session I'm looking for doesn't even make the list. Great. Time to raise the limit and go digging.

We already save gitBranch in the session metadata. Can we let the CLI filter on it?

Proposed Solution

Add --branch <name> to ocr session list and its existing aliases:

ocr session list --branch feat/my-feature
ocr session list --branch feat/my-feature --limit 5
ocr session list --repo /path/to/repo --branch main --json

The details that matter:

  • Match the saved branch name exactly, including case.
  • Filter before applying --limit. Otherwise, we still miss older matching sessions, which is the whole problem.
  • Keep newest-first ordering and support both table and JSON output.
  • Leave the current behavior alone when --branch is omitted or empty.
  • Skip sessions without a recorded branch when filtering.
  • If nothing matches, include the requested branch in the text message and return [] in JSON.
  • Use the saved metadata. An archived checkout or a deleted branch should still be searchable.

This helps find a session. Whether that session can actually be resumed is still up to the existing resume checks.

Alternatives Considered

I can use --limit 0 --json and pipe the output through jq. That works. It also means bringing another tool into a task where the CLI already has the information it needs. Filtering the default 20 results won't reliably work, either; the matching session might already have been cut off.

A branch column would help me read the list, but wouldn't stop other branches from pushing the session I want out of it.

Automatically using the current branch would change the default behavior and require a usable Git checkout. I'd keep this explicit: ask for a branch, get that branch's sessions.

Affected Area

CLI / Commands, Documentation

Additional Context

If this sounds good, please assign the issue to me, I'll open a PR by tomorrow

Activity

  1. added
    enhancement
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions