Repository navigation
workspaces: PR badges in the sidebar and creation from GitHub issues/PRs - #100
Merged
Merged
Conversation
Mount the previously unused PullRequestBadge on the row's metadata line and sweep PR info for all local worktrees in the background (one gh process at a time, 60s per-worktree throttle) instead of fetching only for the selected worktree. Badge styling drops the old selected-row white overlay, which predates the subtle selection background.
List/object parsing of gh issue/pr JSON, GitHub URL recognition, and issue-<n>-<slug> branch naming (degrades to issue-<n> for CJK/empty titles), with executable tests.
CowCloner.resetForPullRequestCheckout drops inherited worktree registrations and tracked dirty state (never untracked files) so an external 'gh pr checkout' can run cleanly; GitBackend.addWorktreeDetached provides the detached base for the worktree fallback. CowCloner stays free of any GitHub knowledge.
Typing # in the creation panel filters a keyboard-navigable list of open issues and PRs (prefetched via gh, local projects only); pasting a GitHub issue/PR URL resolves directly. An issue creates a new branch off the selected base named issue-<n>-<slug>; a PR checks out its head branch (gh pr checkout) on both the COW-clone and git-worktree paths, so the sidebar PR badge lights up immediately. Non-git and SSH projects reject or never enter the GitHub mode.
Replace the per-worktree 'gh pr view' sweep (N calls/min, serial, up to 60s + queue latency per badge) with a single 'gh pr list' per local project every ~20s, mapped onto worktrees by head branch. A badge that says open but whose branch left the list just got merged/closed; its terminal state is resolved once via the per-branch view path, which sees non-open PRs. A failed list fetch keeps existing badges instead of clearing them. Selection still force-refreshes via 'gh pr view'. Tradeoff: after a relaunch, a merged/closed PR badge appears on a row only once it is selected (the dict is not persisted and the list query returns open PRs only).
Second line appears only for agent activity, merge conflicts, creating, or a PR badge; 'Ready to merge' and last-activity timestamps move into the row tooltip along with the full branch title. Diff counts drop the bordered pill for quiet dimmed mono text, and quick-jump hints render only while Cmd is held, as an overlay chip so rows never reflow.
One question — which branch will the new workspace check out — split across two tabs. New Branch: name + base, with GitHub issues as a name-filler; an existing name silently switches to checkout instead of blocking. Check Out Existing: one filtered list of local branches and open PRs, excluding branches already backing a workspace, with no default selection so Enter can't fire on an arbitrary row. Fixed 520×420 frame: popup widths derive from the container (compression resistance below the window's frame-holding priority) so long branch names truncate instead of resizing the panel.
The two-tab creation panel only submits PRs from the prefetched 'gh pr list' (which carries headRefName), so the 'gh pr view' recovery for URL-pasted PRs outside the list became unreachable. Remove GitHubBackend.pullRequest(number:), GitHubWorkItem.parse(objectJSON:) and its tests; an empty head ref now fails fast with pullRequestUnavailable. Also drop the panel's unreachable cancelOperation branches (the local event monitor already owns Esc).
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.
What
Two features that tie workspaces to their GitHub context:
1. Pull request badge on sidebar rows (
4f15b72)PullRequestBadgeon each workspace row's metadata line:#number+ CI status glyph in a state-colored capsule, with PR state/title/URL in the tooltip (all localized).gh pr listper project every ~20s, mapped onto worktrees by head branch — instead of only the selected one. A badge whose branch leaves the open list (just merged/closed) is resolved once via the per-branchgh pr viewpath; a failed fetch keeps existing badges..creatingplaceholders are skipped.2. Workspace creation redesigned as a two-tab dialog (
bfa4b39..3288059)The panel answers one question — which branch will the new workspace check out — split across two tabs (fixed 520×420 dialog with a header project popup and a constant Create Workspace button; Enter / ⌘⏎ confirm, Esc closes):
checkout -boff a chosen Base, or pick an open GitHub issue to auto-name the branchissue-<n>-<title-slug>(slug degrades toissue-<n>for CJK/empty titles; unit-tested). If the name already matches an existing branch, an inline hint appears and the panel checks it out instead of blocking.#123— routes to the right tab: issues fill the name field, PRs jump to Check Out Existing and select the PR.git reset --hard(drops inherited tracked dirty state, preserves untracked files) →gh pr checkout <n>; the git-worktree fallback uses a detached base worktree + the same checkout. The record's branch is the PR head ref, so the new badge lights up immediately.Implementation notes
GitHubWorkItem(MoriCore) carries list parsing, URL recognition, and slug naming — pure and unit-tested;CowClonerstays free of GitHub knowledge (resetForPullRequestCheckoutonly preps the clone).#-prefixed branch names can't be typed as new branch names (routed as issue/PR references).Verification
mise run test: all 6 packages green (1407 assertions).swift build -c release --product Moriandswift build --build-path .build-cli -c release --product mori: both pass.3. Sidebar row declutter (
30cc370)Rows stay single-line unless something needs attention: the status line appears only for agent activity, merge conflicts, creating, or a PR badge. "Ready to merge" and last-activity timestamps moved into the row tooltip (with the full branch title); diff counts render as quiet dimmed text instead of a bordered pill; ⌘1–9 hints show only while ⌘ is held (overlay chip, no reflow).