Skip to content

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

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

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-maxtauseefkhan-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).
Fixesanomalyco#37891
@github-actionsgithub-actionsBot 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-actionsgithub-actionsBot 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. 👍

@100kristine

Copy link
Copy Markdown

this would be amazing, hope it can ship soon! one of the biggest problems with the desktop app rn

@wulinsekai

Copy link
Copy Markdown

+1 for this — exactly the gap we're hitting on a daily basis. Our agents produce a lot of file:// links in handover docs and PR summaries, and on desktop they currently render as chips that do nothing on click, so I fall back to copy-paste or open -R.

Two quick notes:

  1. The DOMPurify allowlist + shell.openExternal analysis matches what I see: local files should never go through the external-browser path. Scoping the file: allow to desktop only (as this PR does) is the right call.
  2. Once this lands, the TUI side is covered by feat(tui): make file paths in read/grep/glob tool output clickable #38645, so the whole surface area (desktop + TUI + web) would have a consistent answer. Would it make sense to also handle the web renderer in a follow-up?

Happy to test the desktop build once it's merged.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

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)

3 participants

@tauseefkhan-max@100kristine@wulinsekai