feat(desktop): show all pull requests linked to a worktree

MO
1mo ago
+1751-201

What & why

Fixes #8895.

A worktree can accumulate several PRs as its branch changes, and one head branch can have PRs against several base branches. The desktop currently exposes only the current PR. This adds a compact PR-count menu to workspace rows and both sidebar layouts, showing each associated PR's number, title, status, and own link. Selecting a historical PR opens that PR in the worktree; the existing current-PR action remains unchanged.

  • Preserve every exact-head match through paginated gh/Octokit discovery and the existing worktree association table. No schema migration or new dependency.
  • Return the host collection additively alongside the existing singular response, with an older-host fallback. Carry the existing cloud PR collection through workspace-list, project, and pinned sidebar rows.
  • Refresh historical PR status without moving the current pointer; keep unlink suppression and archive behavior intact, including changes made during an in-flight lookup. Closed history is checked at most daily unless explicitly refreshed; completed terminal details are reused by head/state, while pending checks and failed detail requests keep their TTL/backoff.
  • Reuse the existing dropdown, status badges, link policy, and sidebar hover suppression. Keyboard opening, Escape/focus return, and independent row actions are covered.

Association scope is this worktree's recorded PR history and its matching upstream head.

How I tested it

  • bun run lint — pass, 10,977 files.
  • bun run typecheck — pass, all 40 tasks.
  • bun run check:i18n — extraction and strict compilation pass for all 17 locales; existing translated messages are reused, so no catalog diff.
  • cd packages/host-service && bun test src/runtime/pull-requests — 135 pass. Includes multi-PR persistence, paging through both transports, automatic historical open→merged and closed→open refresh, suppression, archive/unlink during a deferred lookup, terminal detail reuse, failed-detail retries, pending CI completion, the 24-hour closed-history boundary, historical pending/failed details across cache restarts, and real conditional-GET 304 reuse.
  • Focused React collection/menu/hover tests — 10 pass; cloud builder/helper/decoration suite — 25 pass. Includes old-host fallback, URL-based identity, the selected PR's repository, keyboard/focus behavior, and the pending-hover/menu race.
  • cd apps/desktop && bun run compile:app — production main/preload/renderer, bundled CLI, and daemon bundle validation pass.
  • Real desktop at this branch, renderer localhost:3005, CDP 9335, authenticated local development session: opened the menu in the workspace list and expanded/collapsed sidebar, checked all three URLs/statuses, closed with Escape, and selected #8926. Its real PR pane loaded with the correct title, merged status, repository, and GitHub link.

The screenshots use a seeded local history fixture with real public PR metadata; these PRs are not claimed to share an actual worktree. Discovery/persistence is verified separately by the real-SQLite runtime tests. Cloud collection propagation is covered by regression tests; no live cloud sandbox was exercised. Screenshot context.

Expanded sidebar PR history

Workspace list, collapsed sidebar, and selected historical PR

Workspace list
Collapsed sidebar
Selected historical PR

Latest checks at 426f0786: host-service suite 2,684 pass / 8 existing todo / 1 fail. The failure is in the unchanged worker phase-timeout test; its full file passes independently (14 tests) with the original timeouts. The focused PR-runtime suite passes 135 tests / 443 assertions. Full repository lint, all 40 typecheck tasks, and the production desktop build pass. The earlier desktop suite at 0ddbd32a had 8,686 pass / 1 fail in the unchanged shell PATH test, independently reproduced on this machine. No desktop source changed in this latest follow-up. Two independent source reviews found no remaining required changes; all five inline threads have been answered and resolved.

Checklist

  • PR title follows conventional commits.
  • bun run lint and bun run typecheck pass.
  • Allow edits from maintainers is enabled.
  • CLA signature confirmed by the CLA bot.

Summary by CodeRabbit

  • New Features
    • View a workspace’s associated pull requests from the dashboard, including historical requests and their current states.
    • Open a pull request from the menu; requests from archived workspaces open externally.
  • Improvements
    • Workspaces retain multiple pull requests associated with the same branch, with duplicate entries avoided.
    • Historical pull request details can refresh without changing the request currently linked to a workspace.
    • Unlinking a pull request no longer removes it from workspace history.
    • Closed pull request history is periodically rechecked for status changes.