fix(desktop): open a workspace's pull request in the browser on modifier-click

Merged
KI
1mo ago
+315-129

Problem

In a v2 workspace, every pull request link opens the built-in PR pane. There is no quick way to open the PR on github.com. Cmd-click and Ctrl-click do the same thing as a plain click.

The affected links are:

  • The "Open PR #N" button in the Diff pane header.
  • The PR title in the sidebar Review tab.
  • The "Open pull request" item in the PR status menu.
  • The PR icon on a sidebar workspace row.

Root cause

#7244 routed every PR link to the pane with no modifier check. Later changes (#8090, #8528) did the same for the sidebar row icon. None of these click handlers read metaKey, ctrlKey or shiftKey.

Fix

The PR links now resolve clicks through the existing click policy framework (renderer/lib/clickPolicy). A fixed tier map, PULL_REQUEST_LINKS, is built with buildPolicy:

ClickAction
PlainPR pane, split beside the active pane
ShiftPR pane in a new tab
Cmd or CtrlDefault browser
Cmd+ShiftDefault browser
  • Shift opens a new tab, as on the other 4-tier maps (URL links, sidebar files).
  • The browser path uses external.openUrl.
  • The new-tab placement reaches the pane through the onOpenPullRequest callbacks and the sidebar's pull request pane intent.
  • The policy hint shows on the Diff pane link and sidebar icon tooltips, and on the Review title through ClickHint. The hint reads "⇧ click: new tab · ⌘ click: external browser · ⌘⇧ click: external browser".
  • The Diff pane header gets a "View on GitHub" button. It reuses the translated label from the PR status menu.
  • The legacy sidebar row tooltip said "Click to open on GitHub", but a plain click opens the pane. It now uses the expanded row's existing "Click to open the pull request" message. check:i18n drops the unused entry. No new strings need translation.

There is no new persisted setting. The Settings > Links maps cover links in terminal output and markdown. A PR map there would also need a settings row and a plain-click default that those maps do not have.

Verification

I drove the dev desktop app over CDP with real mouse input. A browser open is counted as a new tab on the PR URL in the default browser.

Before the fix, Cmd-click on the Review tab title and on the Diff pane link opened the PR pane.

After the fix, on main with #8651:

  • PR status menu, "Open pull request": Cmd opens the browser and no pane. Shift opens a new tab. Plain opens a split. Main's new menu entries still render.
  • Diff pane "Open PR" link: the hint shows on hover. Cmd opens the browser and no pane. Shift opens a new tab. Plain opens a split.
  • Earlier rounds, same code: Review tab title (Cmd, plain, hint), legacy sidebar row icon (Cmd, Shift, plain, hint), and the "View on GitHub" button.

Not covered: the flag-gated expanded sidebar row, which has the same change. The dev app renders the legacy row.

Checks:

  • bun test for clickPolicy, lib/github and the touched components: 510 pass, 0 fail. The new policy test fails when Cmd is remapped to the pane.
  • bun run lint:fix and bun run check:i18n pass, with 0 missing translations.
  • bun run typecheck in apps/desktop shows the same 27 better-auth errors as origin/main. There are no new errors.

Fixes #8472


Summary by cubic

Fixes PR links in v2 workspaces so Cmd/Ctrl-click opens the PR in the browser instead of always opening the built-in PR pane, with regression tests covering every click action.

  • Plain click opens the PR pane, Shift opens it in a new tab, and Cmd/Ctrl opens the default browser.
  • Adds a "View on GitHub" button to the Diff pane header and modifier-key hints to PR link tooltips.
  • Makes the browser opener injectable so the tests need no tRPC client.
  • Adds a source scan asserting every PR link surface routes through openPullRequestLink.
  • The legacy sidebar row tooltip now reads "Click to open the pull request"; its old "Click to open on GitHub" translation was removed.

Summary by CodeRabbit

  • New Features
    • Pull request links now respond consistently to click modifiers: click to open in the app, Shift-click to open in a tab, and Command/Ctrl-click to open in your browser.
    • Added a dedicated “View on GitHub” option for pull requests.
  • Improvements
    • Pull requests can open in a split pane or tab, with tooltips reflecting the available click actions across workspace and review views.
    • Link handling now provides consistent behavior for recognized and external pull request URLs.