Skip to content

fix(desktop): make file:// chat links clickable - #39206

Open
tauseefkhan-max wants to merge 1 commit into
anomalyco:devfrom
tauseefkhan-max:fix/desktop-clickable-file-links
Open

fix(desktop): make file:// chat links clickable#39206
tauseefkhan-max wants to merge 1 commit into
anomalyco:devfrom
tauseefkhan-max:fix/desktop-clickable-file-links

Conversation

@tauseefkhan-max

@tauseefkhan-max tauseefkhan-max commented Jul 27, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #37891

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

In the desktop app, file:// links and absolute paths in chat looked clickable but did nothing.

Two causes:

  1. DOMPurify dropped file: hrefs (default URI allowlist is web-only).
  2. The desktop click handler always called shell.openExternal via open-link, which is the wrong path for local files (and fix(desktop): restrict external links #38914 is tightening that further to http(s)-only).

This PR:

  • Allows file: through the sanitizer only on desktop (oc:// renderer / desktop API present). Web is unchanged.
  • On click: file:// and absolute-path hrefs go through existing openPath / revealPath IPC (already used by the session header). Modifier-click (⌘/Ctrl/Alt) reveals in Finder/Explorer; plain click opens with the OS default app.
  • Hardens open-link to http(s) only so local paths never hit openExternal.
  • Turns absolute path chips in assistant markdown into file:// links on desktop.

Workspace-relative path chips and opening in the built-in editor tab are out of scope here.

How did you verify your code works?

cd packages/desktop && bun test src/main/external-link.test.ts src/renderer/file-link.test.ts
cd packages/session-ui && bun test src/components/markdown-desktop.test.ts

All 15 tests pass. Unit coverage includes URI parsing (unix/windows/file:/line:col suffixes), safeExternalUrl rejection of non-http(s), and desktop path→href conversion.

Screenshots / recordings

N/A — behavior change on click; no visual layout change beyond links remaining present after sanitize (they were stripped before).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

DOMPurify was stripping file: hrefs, and the desktop click handler always
routed through openExternal. Keep file: links on desktop, open them via
the existing openPath/revealPath IPC (http(s) still go through openLink,
hardened to http(s)-only).

Fixes anomalyco#37891
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Related PRs Found:

  1. PR #38645: feat(tui): make file paths in read/grep/glob tool output clickable

  2. PR #36862: fix(desktop): validate openExternal URLs by protocol

These are complementary improvements rather than duplicates—one covers TUI file path clickability while the other validates URL protocols on desktop.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Desktop: make file paths in chat clickable (open in editor / reveal in Finder)

1 participant