Skip to content

fix: open local file links with Ctrl/Cmd-click - #708

Merged
agegr merged 3 commits into
agegr:mainfrom
Zhangs-11:fix/primary-modifier-local-file-links
Sep 5, 2026
Merged

fix: open local file links with Ctrl/Cmd-click#708
agegr merged 3 commits into
agegr:mainfrom
Zhangs-11:fix/primary-modifier-local-file-links

Conversation

@Zhangs-11

@Zhangs-11 Zhangs-11 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve file:// Markdown destinations when Pi Web has an in-app file handler
  • open local files through the existing preview pane for plain clicks, macOS Command-clicks, and Windows/Linux Ctrl-clicks
  • apply the same behavior to chat messages and Markdown file previews
  • keep external links and secondary click modifiers on their existing browser paths

Problem

Pi Web already resolves local Markdown links into its allow-listed file preview, but two guards prevented the reported interaction:

  1. React Markdown's default URL transform replaced file:// destinations with an empty href before Pi Web could resolve them.
  2. Both local-link click handlers ignored metaKey and ctrlKey, leaving the browser to navigate from an HTTP page to a file:// URL, which browsers block.

As a result, Command-clicking a local HTML report on macOS or Ctrl-clicking it on Windows/Linux appeared to do nothing.

Behavior

A primary-modifier left click now uses the same in-app preview as a plain click. Shift/Alt clicks, middle clicks, already-prevented events, and external links remain unchanged.

Security

file:// destinations are preserved only when the renderer has Pi Web's onOpenFile handler. The existing file resolver and /api/files allow-list remain the authorization boundary; this change does not grant access to additional filesystem paths.

Testing

  • npm test — 847 tests passed
  • node_modules/.bin/tsc --noEmit
  • npm run lint
  • real Pi Web development server and real GPT-5.6 Sol round on commit 113dad6f1be8babb12a1b3f0bddae283d3995843
  • browser verification: macOS Command-click opened the generated local HTML report in Pi Web's preview pane; unit coverage verifies both metaKey and ctrlKey

Demo

Command-click opens a synthetic local HTML report in Pi Web

Recorded from commit 113dad6f1be8babb12a1b3f0bddae283d3995843 using that worktree’s real Next.js development server, a fresh isolated agent directory, workspace, and browser context. A real GPT-5.6 Sol round ran through Pi Web’s normal RPC transport; no fixtures, mock transport, synthetic events, personal sessions, or project documents were used.

Zhangs-11 added a commit to Zhangs-11/pi-web that referenced this pull request Sep 4, 2026
Zhangs-11 added a commit to Zhangs-11/pi-web that referenced this pull request Sep 4, 2026
Zhangs-11 added a commit to Zhangs-11/pi-web that referenced this pull request Sep 4, 2026
@agegr
agegr merged commit 5f8056d into agegr:main Sep 5, 2026
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.

2 participants