Skip to content

workspaces: PR badges in the sidebar and creation from GitHub issues/PRs - #100

Merged
vaayne merged 8 commits into
mainfrom
github-workspaces
Jul 23, 2026
Merged

vaayne merged 8 commits into
mainfrom
github-workspaces

Conversation

@vaayne

@vaayne vaayne commented Jul 23, 2026 •

Copy link
Copy Markdown
Owner

What

Two features that tie workspaces to their GitHub context:

1. Pull request badge on sidebar rows (4f15b72)

  • Mounts the previously unused PullRequestBadge on 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).
  • PR info now refreshes for all local workspaces via a background sweep — one repo-wide gh pr list per 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-branch gh pr view path; a failed fetch keeps existing badges. .creating placeholders are skipped.
  • Drops the badge's old selected-row white-overlay styling, which predates the current subtle selection background and would be unreadable in light themes.

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):

  • New Branch (default): type a name to checkout -b off a chosen Base, or pick an open GitHub issue to auto-name the branch issue-<n>-<title-slug> (slug degrades to issue-<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.
  • Check Out Existing: one filterable list of local branches (recency-sorted) and open PRs — a PR is just someone else's existing branch. Branches already backing a workspace (and their PRs) are excluded. No default selection on an empty filter, so Enter can never fire on an arbitrary row.
  • Pasting a GitHub issue/PR URL — or typing #123 — routes to the right tab: issues fill the name field, PRs jump to Check Out Existing and select the PR.
  • Issue → new branch off the selected base. PR → works on the PR's head branch: COW clone → 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.
  • SSH projects never enter GitHub mode (gh is local-only); a PR against a non-git project fails with a clear error before any side effect.
  • Popup widths derive from the container with compression resistance below the window's frame-holding priority, so long branch names truncate instead of resizing the panel.

Implementation notes

  • GitHubWorkItem (MoriCore) carries list parsing, URL recognition, and slug naming — pure and unit-tested; CowCloner stays free of GitHub knowledge (resetForPullRequestCheckout only preps the clone).
  • Known edges: cross-fork PRs may get a local branch name differing from the API head ref (badge lookup still works); literal #-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 Mori and swift build --build-path .build-cli -c release --product mori: both pass.
  • Manual testing of picker, badges, and PR checkout flows.

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).

vaayne added 8 commits July 23, 2026 10:16
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).
@vaayne
vaayne merged commit 825d53a into main Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant