Skip to content

fix(session-ui): keep file:// hrefs in chat markdown so authored file links open (#2117) - #2175

Open
jacktrnr wants to merge 1 commit into
mainfrom
fix/2117-chat-file-links
Open

jacktrnr wants to merge 1 commit into
mainfrom
fix/2117-chat-file-links

Conversation

@jacktrnr

Copy link
Copy Markdown
Contributor

Closes #2117

Root cause (the [name](file:///…) form)

Click path: marked renders every link as <a class="external-link" href=…> → sanitizeMarkdown (DOMPurify) → setupExternalLinks routes a file:// href to open-file over the iframe→parent bridge → the webview relay → chat_bridge.ts → Preview, or a named toast.

The chain breaks at the sanitizer. DOMPurify's default ALLOWED_URI_REGEXP does not allow the file: scheme, so the href was stripped. The anchor kept its external-link class but had no href, and setupExternalLinks returned before posting anything. The result was total silence: no message reached the extension, so the #1845 named-outcome toasts never had a chance to fire. Authored file:// links have never worked. The earlier fixes (#1839, #1845) covered only resolver-produced anchors, whose href is set after sanitization.

Fix

  • Add packages/session-ui/src/components/markdown-cache.tsx to the overlay with one change: ALLOWED_URI_REGEXP is DOMPurify's default plus file. javascript:, vbscript: and data: hrefs stay stripped. The extension still validates the path (absolute, bounded, on disk or resolved through the posture) before opening anything.
  • Regenerated the manifest. The drift gate passes.

Tests

  • RED → GREEN: markdown-file-refs.test.ts gets a new "chat sanitizer keeps file:// links (BUG: file paths in chat output do nothing when clicked (inline-code pills and file:// links), v0.4.0 #2117)" case. happy-dom's DOMPurify tree walker never visits attributes during sanitize(), so it would keep any href and could not discriminate. The test therefore checks the URI policy through DOMPurify.isValidAttribute, which runs the same attribute check sanitize does in a real browser, under the config the chat sanitizer just applied.
  • session-ui suite (materialized tree): 517 pass, 1 fail. The failure is the pre-existing, unrelated editable-diff-view.test.ts "selection highlight visibility" case. It also fails when that file runs alone and does not import either changed file.

Not covered (inline-code pill form)

I traced the pill path statically: markInlineCode → markFileLinks → the app resolver → GET /amicode/resolve-file → file:// anchor → the same bridge. I found no code break on a local loopback engine. The pill becomes a link only when the server resolves it. It stays a plain pill, by design ("never a dead anchor"), in these cases:

  • the engine is not bound to loopback, as with the hub-client posture (browseAllowed → forbidden unless AMICO_VAULT_BROWSER=1);
  • the file is not on the server's disk;
  • the path contains whitespace (inlineCodeKind rejects it).

Whichever applies, the click then does nothing. Telling these apart needs the reporter's posture, using the #1845 debug kit. The stale-bundle theory is not supported by the code: release.yml runs build:app fresh for every tag, and dist/app/deploy.json records built_at and the commit for confirmation.

🤖 Generated with Claude Code

… links open (#2117)

DOMPurify's default URI allow-list drops the file: scheme, so an authored
`[name](file:///abs/path)` link rendered as an anchor with no href. The
click handler (setupExternalLinks) then saw an empty href and returned
without posting open-file: no open, no toast, no error.

Overlay markdown-cache.tsx and extend ALLOWED_URI_REGEXP with `file:`.
javascript:, vbscript: and data: hrefs stay stripped. The extension's
open-file handler still validates the path before opening anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6ba55bb1-2ca1-4130-b3f2-c39eee1e7985
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jacktrnr
jacktrnr marked this pull request as ready for review November 23, 2026 21:56
@jacktrnr

Copy link
Copy Markdown
Contributor Author

Verified hands-on in the combined 0.4.1-beta test build (test/0.4.1-beta, Developer Tools → Rebuild Locally, macOS arm64) on 2026-11-23: all checks in this PR's manual checklist pass.

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.

BUG: file paths in chat output do nothing when clicked (inline-code pills and file:// links), v0.4.0

1 participant