fix(desktop): open page links without blanking the page

Merged
KI
2mo ago
+285-3

What & why

Clicking a URL in a Page navigated its iframe to the destination. Sites that reject embedding left the Page pane blank. Forward supported link clicks to the desktop so they open through the existing terminal URL actions while the Page remains loaded.

Workspace Pages honor configured URL actions and modifier shortcuts, with a browser-pane fallback for plain clicks when the terminal plain-click action is unset. Standalone Pages open links externally. In-page anchors, downloads, and comment selection retain their existing handling. The frame bridge is opt-in and checks the message source and origin.

Requires both the desktop change and the updated usercontent runtime. The runtime has a five-minute browser cache.

How I tested it

  • Reproduced before and after in this worktree's real Electron app over CDP, using a local copy of the reported page and real mouse input.
  • Before: plain-clicking a LinkedIn profile link replaced the Page iframe with LinkedIn's auth wall and blanked the pane; no browser pane opened.
  • After: the same link and click coordinates opened a separate browser pane. The original Page retained its URL, title, scroll position (630), and 133 links. No renderer console errors occurred during the click.
  • Also checked Command-click, in-page anchor navigation, comment selection, and closing/reopening the Page. Before/after screenshots captured locally; they contain private workspace content.
  • Targeted runtime and zoom regression tests: 30 passed. Added cases for bare/empty/whitespace/absolute anchors, SVG links, document base URLs, query/path changes, malformed URLs, cancelled events, and right clicks.
  • Follow-up CDP verification with a local fixture in the real Page pane: before the fix, href="#" opened a duplicate browser pane; afterward, it returned scrollY from 1492.5 to 0 with no link message. Empty href stayed in-frame; an SVG text link forwarded exactly https://example.com/svg. Screenshots captured locally.
  • Follow-up shared typecheck and changed-file lint: passed.
  • Shared, UI, and desktop typechecks: passed.
  • Repository-wide lint: passed.
  • Repository-wide typecheck: passed (42 tasks).
  • Full bun run test: failed in the desktop suite, including unchanged git task handlers and external worktree import tests receiving empty git command output. Rerunning git-task-handlers.test.ts in isolation passed all 12 tests. The targeted page regression tests pass.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs (not applicable: same-repository branch)

Summary by CodeRabbit

  • New Features

    • Added link handling in page views, including regular, middle-click, and modifier-key interactions.
    • Links can open externally, navigate within the workspace, or follow configured link actions.
    • Added support for email and telephone links.
    • Improved handling for downloads, in-page anchors, relative links, and links used while commenting.
  • Bug Fixes

    • Prevented unsupported, malformed, cancelled, or invalid links from triggering unintended navigation.