feat(ui): add Cmd+P pull request dropdown#309
Conversation
When the focused terminal sits inside a GitHub-cloned repo, ⌘P now expands a pill that lists open pull requests fetched via `gh pr list` on a worker thread. Selecting an entry sends `gh pr checkout <N>` to the focused shell. The collapsed pill shows the current branch's PR number (e.g. #123) when the HEAD ref matches a fetched PR's head branch. Detection of the GitHub origin and current branch is done synchronously on the main thread from `.git/config` and `.git/HEAD` (including worktree indirection), so the pill is hidden cheaply when the cwd is not a GitHub repo. Listing PRs hits the network through gh, so that work runs on a per-open std.Thread with results delivered via a mutex-guarded slot and an atomic completion flag, matching the spirit of ADR-009. https://claude.ai/code/session_01BUkFdLJ8vdB36bfZ13MksA
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb76d7cfb4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.overlay.state != .Closed and | ||
| self.fetch_thread == null and | ||
| self.fetchIsStale(host.now_ms)) |
There was a problem hiding this comment.
Ignore in-flight fetch when focused repo changes
When focus moves from one GitHub repo to another while a gh pr list thread is still running, this branch skips starting a fetch for the new repo (fetch_thread != null), so the old repo’s result is later applied to the new context and can be shown/used for checkout for up to the TTL window. This produces incorrect PR entries and can trigger gh pr checkout with PR numbers from the wrong repository. The update path should invalidate or discard stale thread results tied to the previous repo and immediately schedule a fetch for the newly focused repo.
Useful? React with 👍 / 👎.
| // Re-detect the repo when the focused cwd changes. | ||
| const new_cwd = host.focused_cwd; | ||
| if (cwdChanged(self.last_cwd_seen, new_cwd)) { | ||
| self.applyCwd(new_cwd); |
There was a problem hiding this comment.
Refresh current branch outside cwd transitions
The current branch is only re-read when focused_cwd changes, so the collapsed pill’s #<PR> badge goes stale after branch switches that keep the same directory (for example after selecting a PR, or running git checkout in place). This breaks the advertised behavior of showing the current branch’s PR number and can leave the UI displaying an incorrect badge until the cwd changes.
Useful? React with 👍 / 👎.
When the focused terminal sits inside a GitHub-cloned repo, ⌘P now expands a
pill that lists open pull requests fetched via
gh pr liston a workerthread. Selecting an entry sends
gh pr checkout <N>to the focused shell.The collapsed pill shows the current branch's PR number (e.g. #123) when the
HEAD ref matches a fetched PR's head branch.
Detection of the GitHub origin and current branch is done synchronously on
the main thread from
.git/configand.git/HEAD(including worktreeindirection), so the pill is hidden cheaply when the cwd is not a GitHub
repo. Listing PRs hits the network through gh, so that work runs on a
per-open std.Thread with results delivered via a mutex-guarded slot and an
atomic completion flag, matching the spirit of ADR-009.
https://claude.ai/code/session_01BUkFdLJ8vdB36bfZ13MksA