CLI: add `--from-pr` to `codex resume` and `codex exec resume`

Resolved 💬 4 comments Opened Jan 31, 2026 by pygarap Closed Mar 14, 2026

What feature would you like to see?

Summary

Add a --from-pr flag that resumes a Codex CLI session associated with a GitHub Pull Request, selected by PR number, PR URL, or an interactive picker.

This is for the Codex CLI and should integrate with the existing codex resume and codex exec resume flows documented in the CLI reference.

Problem

Today, resuming requires a SESSION_ID or using the session picker (codex resume / codex exec resume --last), which makes it hard to jump back into "the session that produced PR X" without manually tracking session IDs.

Proposed UX

Support the flag on both commands:

  • codex resume --from-pr 123
  • codex resume --from-pr https://github.com/ORG/REPO/pull/123
  • codex exec resume --from-pr 123
  • codex exec resume --from-pr https://github.com/ORG/REPO/pull/123

Interactive mode when no value is provided:

  • codex resume --from-pr
  • Show a list of PRs that have linked sessions (scoped to the current repo by default, consistent with how --last is CWD scoped unless --all is used).
  • After selecting a PR, if multiple sessions are linked, pick the most recent or show a second picker (implementation choice).

Accepted identifiers:

  • 123
  • #123
  • Full PR URL (https://github.com/.../pull/123)

Additional information

Session auto-linking

Sessions should automatically store PR linkage metadata when a PR is created during the session (for example, when the workflow creates a PR via tooling like GitHub CLI). The --from-pr flag should use that stored metadata to resolve the target session(s).

Expected behavior

  • If exactly 1 session matches the PR, resume it immediately.
  • If multiple sessions match, prefer the most recent, or prompt to select one.
  • If no session matches, exit non-zero with a clear message (include the parsed PR identifier and suggest codex resume as a fallback).

Acceptance criteria

  • codex resume --from-pr ... works for number, # number, and PR URL.
  • codex exec resume --from-pr ... behaves the same.
  • --from-pr integrates cleanly with existing --all behavior (global search when requested).
  • Help text and the CLI reference docs are updated to include --from-pr.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗