Skip to content

Open local file links from chat replies in the Aiden browser and Files - #566

Merged
sambitcreate merged 4 commits into
mainfrom
claude/project-thread-3qua0q
Oct 21, 2026
Merged

sambitcreate merged 4 commits into
mainfrom
claude/project-thread-3qua0q

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Requested by sbt · project thread

Problem

File links in agent replies (index.html, style.css, script.js, folders) did nothing when clicked. Link opening from #486 (shipped in v0.57.0) only routed relative .html/.htm/.pdf paths. Two other gaps made most agent file links dead:

  • react-markdown 9's defaultUrlTransform blanks file: hrefs (and name.ext:12, which it reads as a URL scheme), so [index.html](file:///…/index.html) rendered with an empty href.
  • The router returned null for file: URLs and for every non-HTML/PDF file, so those clicks were dropped with no feedback.

Changes

  • renderer/components/markdown.tsx: a urlTransform that keeps file: and name.ext:12 link targets and leaves everything else to the default sanitizer.
  • renderer/lib/browser-link-routing.ts: file:// URLs (empty host or localhost), absolute paths and relative paths of any type now resolve to { kind: "file", path, preview, workspacePath }. Line suffixes (:12, :12:4) are dropped. workspacePath is the path relative to the active workspace folder, or null when the path is outside it (this covers .. escapes and ~/). Absolute paths with no extension outside the workspace (app routes like /settings) are still ignored.
  • renderer/lib/link-opener.tsx: HTML/PDF go to the existing open_file preview in the Aiden browser. Other workspace files and folders go to a new onOpenWorkspaceFile callback. Paths outside the workspace show a toast instead of failing silently.
  • Right-click menu on file links: Open in Aiden browser (HTML/PDF) or Open in Files, plus Open in system browser for workspace HTML (Open in default app for PDF), plus Copy path. The new browser:open-file-external IPC (main/handlers/browser.ts) accepts only HTML/PDF regular files that still resolve inside the workspace after realpath (main/services/browser/external-document.ts), then calls shell.openPath.
  • renderer/components/environment-panel.tsx: passes the workspace folder and openFile (Files tab) to the provider.
  • renderer/components/files-panel.tsx: a requested path that the index lists as a directory is expanded and focused in the tree. A path the index doesn't list triggers one refresh before it's classified, so a newly created folder isn't read as a file.

Terminal links share the router, so terminal file paths of any type can now open in Files too.

Tests

  • renderer/lib/browser-link-routing.test.ts: file://, absolute, relative, folder, file:line, outside-workspace, and app-route cases, plus workspaceRelativePath containment.
  • renderer/lib/link-opener.test.tsx: the left-click flow (file:// HTML sends open_file; CSS and folder links reach Files with workspace-relative paths; an outside file shows the toast) and the right-click menu.
  • renderer/components/files-panel.test.tsx: a folder newer than the loaded index expands after the refresh, and an indexed file opens without an extra refresh.
  • main/services/browser/external-document.test.ts: workspace containment, symlink escapes, a symlinked workspace folder, and the type and folder checks.
  • tests/e2e/browser.spec.ts: an agent reply with a file:// HTML link, a folder link and a relative CSS link opens a browser tab, the expanded and focused folder, and the Files editor.

Ran locally: type-check, type-check:e2e, eslint on the touched files, and the router/provider/Files/markdown/environment/terminal suites. In test:browser, the one failure is Chromium previews load exact assets…, which fails identically on main in this Linux container. The Electron e2e suite can't launch in the container (the fixture is macOS-only), so the e2e spec runs on macOS CI.

Docs

docs/environment-browser.md (Links/files row), the docs/plans/README.md link-opening row, and .memory/link-opening.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LtHWujhdbTBrQC56sMBXMR

Agent replies often link files as file:// URLs, absolute paths, or
name.ext:12. react-markdown's default URL sanitizer blanked file: hrefs,
and the link router only handled relative .html/.pdf paths, so clicking
most file links did nothing.

- markdown: keep file: and name.ext:12 link targets
- router: file:// URLs, absolute and relative paths of any type become
  file routes with a workspace-relative path; line suffixes are dropped
- opener: HTML/PDF preview in the Aiden browser, other files open in the
  Files editor, folders expand in the Files tree, and files outside the
  workspace show a notice instead of failing silently
- docs and link-opening notes updated; router, provider and e2e tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LtHWujhdbTBrQC56sMBXMR
@sambitcreate sambitcreate self-assigned this Oct 21, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Folder links can open an error instead of expanding the folder when Files has a cached index. This should be addressed before merging.

Reviewed changes Reviewed local-file link sanitization, path classification, browser/Files dispatch, and directory reveal behavior, including downstream preview confinement and the added tests.

  • Local link parsing: Preserves file: and file-and-line Markdown targets and resolves workspace-relative paths for local files and folders.
  • Opening destinations: Routes HTML/PDF to the Aiden browser and other workspace paths to Files, with feedback for unsupported outside-workspace paths.
  • Folder reveal: Expands and focuses directory entries in Files; adds routing/provider tests, an Electron E2E scenario, and documentation.

Validation: 74 focused tests passed. A separate mounted-component probe reproduced the cached-index folder failure described inline. Electron E2E was not run on this Linux runner because the fixture requires macOS.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

Comment thread renderer/components/files-panel.tsx Resolved

@very-hermes-bot very-hermes-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline review — 1 finding(s) anchored to the diff. See the pinned summary comment for the overview.

Comment thread tests/e2e/browser.spec.ts Resolved
@very-hermes-bot

very-hermes-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Hermes Review Bot

Confidence: 5

Engine: agy/gemini-3.8-flash-high
Review mode: full
Head: 8d0a8c0c0f0cf875c79fa516c22674343c1b6d6f
Generated: 2026-10-21T06:36:36+00:00
Reviews: 1

Summary

Chat replies from agents frequently include references to created or inspected files (file:// URLs, workspace-relative paths, folders, and file:line references) that were previously dropped or blanked by URL sanitization. This change introduces targeted URL bypass for local file targets in Markdown rendering, routes local paths through LinkOpenerProvider to either the Aiden browser (for HTML/PDF) or the Files panel (for other files and directories), adds a right-click context menu with external system-browser opening, and guards the external document IPC handler with strict realpath workspace containment. Maintainers should double-check that external document launches via browser:open-file-external properly handle OS-specific path resolution across all supported host configurations (e.g. symlinked workspace roots).

Confidence Score: 5/5

Fully traced and verified end-to-end: verified Markdown sanitization logic, router pathname normalization, Files panel index refresh state machine, IPC security invariants, and unit/e2e test coverage.

📁 Important Files Changed
  • renderer/components/markdown.tsx: Preserves file: schemes and bare name.ext:12 links through a custom urlTransform, preventing react-markdown from stripping local file link targets while keeping default sanitization for untrusted schemes.
  • renderer/lib/browser-link-routing.ts: Expands link routing to resolve file://, absolute, and relative paths to { kind: "file", path, preview, workspacePath }, stripping :line suffixes and computing workspace-relative containment.
  • renderer/lib/link-opener.tsx: Handles click and contextmenu actions for file routes, delegating HTML/PDF to the Aiden browser and all other workspace files or folders to onOpenWorkspaceFile, with user-facing toasts for outside-workspace targets.
  • renderer/components/files-panel.tsx: Classifies requested paths against the workspace file index, dynamically refreshing stale indexes to reveal and expand newly created agent folders rather than attempting to read them as regular files.
  • main/services/browser/external-document.ts & main/handlers/browser.ts: Introduces browser:open-file-external IPC with strict realpath workspace-containment validation and file extension whitelisting (.html, .htm, .pdf) before handing the file to shell.openPath.
  • renderer/components/environment-panel.tsx: Binds active workspace folder path and openFile navigation to LinkOpenerProvider.
  • main/services/browser/external-document.test.ts, renderer/components/files-panel.test.tsx, renderer/lib/browser-link-routing.test.ts, renderer/lib/link-opener.test.tsx, tests/e2e/browser.spec.ts: Unit and e2e test suites validating containment, link routing, folder expansion, context menus, and chat link navigation.

Findings

No findings.

📊 Sequence Diagram
sequenceDiagram
  autonumber
  actor User
  participant LinkOpener as LinkOpenerProvider
  participant Browser as Browser Service
  participant Files as FilesPanel
  participant Main as Main Process (IPC)
  participant OS as Operating System

  User->>LinkOpener: Click local file link in chat
  alt Preview file (HTML / PDF)
    LinkOpener->>Browser: open_file (browser:command)
    Browser-->>User: Preview document in Aiden browser tab
  else Workspace file / folder
    LinkOpener->>Files: onOpenWorkspaceFile(workspacePath)
    Files-->>User: Focus/expand folder tree or open editor
  else Right-click -> "Open in system browser"
    LinkOpener->>Main: browser:open-file-external(workspaceId, path)
    Main->>Main: resolveExternalWorkspaceDocument(realpath verification)
    Main->>OS: shell.openPath(target)
    OS-->>User: Open document in OS default app
  end
Loading

Machine-Readable Findings

[]

Last reviewed commit: 8d0a8c0c0f0c
Reviews (1) · Comment /hermes review to trigger a new review · /hermes review full for full re-review

Copy link
Copy Markdown
Owner Author

Desktop tests (renderer-other) failed on c4216fe with one test, renderer/main/remote-bot-chat-view.test.tsx › "live frames from the host stream into the chat, and a deny-only approval answers by wait id". The cause: findByText("Looking at your calendar") timed out after 1,090 ms (the default waitFor window is 1 s).

I don't think this PR caused it. The diff doesn't touch the remote Bot chat view or its stream handling; it only changes the Markdown URL transform for file: hrefs and the link router. The test passes 3/3 locally on this branch, and so does the full renderer-other lane (the only local failure is the macOS-only plutil test). I don't have a fix for the timing yet. I'm re-running the failed job once. If it fails again I'll treat it as real and dig in.


Generated by Claude Code

A link to a folder created after Files loaded its index was read as a
file and the request consumed before the refresh arrived. Refresh once
when the index doesn't list the path and decide on the fresh result.
The e2e spec now clicks the folder link before style.css so the folder
assertion doesn't pass from expandAncestors alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LtHWujhdbTBrQC56sMBXMR
On the test window the floating environment panel covers the transcript,
so the style.css link click was intercepted after the browser opened.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LtHWujhdbTBrQC56sMBXMR

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes Reviewed the two follow-up commits since the prior Pullfrog review, focusing on stale-index request handling and the revised end-to-end scenario.

  • Fixed folder classification: Waited for index loading and refreshed unlisted paths before consuming their requests, preventing newly created folders from being read as files.
  • Added behavioral coverage: Tested deferred folder discovery and immediate opening of already indexed files, and registered the suite in test:browser.
  • Strengthened E2E checks: Opened the folder before its child file, verified folder focus, and closed the floating panel between chat-link clicks to prevent interception.

Validation: 29 focused tests passed, along with application and E2E type-checks and targeted ESLint. A separate mounted-component probe also confirmed the original hidden-panel reactivation failure is fixed. Electron E2E execution remains unverified locally because its fixture requires macOS.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

File links get their own context menu: Open in Aiden browser (HTML/PDF)
or Open in Files, Open in system browser for workspace HTML (default app
for PDF), and Copy path. browser:open-file-external accepts only HTML or
PDF regular files that still resolve inside the workspace and hands them
to shell.openPath.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LtHWujhdbTBrQC56sMBXMR

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes Reviewed 8d0a8c0 since the prior Pullfrog review, focusing on file-link context menus and the new desktop file-opening IPC.

  • Added file-link menus: Offered Aiden previews or Files navigation, OS opening for workspace HTML/PDF documents, and path copying while retaining existing web-link actions.
  • Confined external documents: Added active-document and workspace-access checks, canonical-path containment, symlink-escape rejection, regular-file and extension validation, and OS error reporting.
  • Extended coverage and documentation: Added context-menu and filesystem-resolver tests and documented the new actions.

Validation: 32 focused behavior tests, 11 IPC contract checks, and 15 CI-inventory checks passed, along with application type-checking and targeted ESLint. Actual OS application launching and Electron E2E were not exercised on this Linux runner.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@sambitcreate
sambitcreate merged commit e30ae26 into main Oct 21, 2026
27 checks passed
@sambitcreate
sambitcreate deleted the claude/project-thread-3qua0q branch October 21, 2026 13:47
sambitcreate pushed a commit that referenced this pull request Oct 21, 2026
…the Bots branch

Brings in chat file links that open in Aiden Browser or Files (#566) and the
iOS paced streaming and Markdown tail healing (#572).

- ios/CHANGELOG.md: union of both sides (the rev 37 Bots entry, then main's
  "Smoother chat streaming").
- docs/environment-browser.md: the Bot browser's "Where it shows" row now says
  chat links never open in a Bot's browser, web links go to the system
  browser, and local file links don't open on a Bot's page.
- .memory/link-opening.md: notes the Bot boundary for the new file routes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FTLKrZsPKZM2hnxHVxEnak
sambitcreate pushed a commit that referenced this pull request Oct 22, 2026
The partial "Looking at your calendar" has no block boundary, so the
streaming reveal holds it for STREAMING_REVEAL_MAX_WAIT_MS (1s), the same
second findByText waits by default. The test passed only while the reveal's
timer fired a few milliseconds before the wait gave up, and failed on a busy
CI runner (here and on #566). The test is about live frames reaching the
chat, not the reveal's pacing, so it turns on Reduce Motion, which shows the
words at once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CkwDBzVQkZrymewb2q975S
sambitcreate pushed a commit that referenced this pull request Oct 26, 2026
The partial "Looking at your calendar" has no block boundary, so the
streaming reveal holds it for STREAMING_REVEAL_MAX_WAIT_MS (1s), the same
second findByText waits by default. The test passed only while the reveal's
timer fired a few milliseconds before the wait gave up, and failed on a busy
CI runner (here and on #566). The test is about live frames reaching the
chat, not the reveal's pacing, so it turns on Reduce Motion, which shows the
words at once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CkwDBzVQkZrymewb2q975S
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.

3 participants