Skip to content

fix(native-chat): underline only file links a click can act on - #22370

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/chat-file-links-open
Sep 23, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/chat-file-links-open

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​321 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​318
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​134 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​115

ELI5

The chat sometimes underlined a bare file name like deck.md as if it were a link, but clicking it did nothing, so it looked broken. Now the chat only underlines file references that name a path, and clicking any underlined file link always does something: it opens the file, or says why it can't.

What Changed

This covers both chat views (structured, and the one backed by a terminal agent); they share one link handler.

Before:

  • Inline code and quoted text such as `deck.md` were turned into links even with no folder in them. On click, the chat looked for the file only at the workspace root. If it wasn't there, the file opener caught the failed check and returned, so nothing happened. That's the reported bug: an underlined .md name in a Claude chat that couldn't be opened, Cmd+click included.
  • Plain prose already required a folder separator; only inline code and quoted text skipped that check.

After:

  • What gets underlined: inline code and quoted text now follow the same rule as prose. They become a file link only when they name a path, meaning they contain a / or \ (relative, absolute, ~/, or a Windows drive path). A bare `deck.md` stays plain code.
  • Every click answers. The shared opener gains an opt-in onOpenFailure callback, and only the chat passes one. It reports whether the file is verifiably missing or the host couldn't answer (a dropped SSH connection, a refused path). The chat then shows one of:
    • "File not found: …"
    • "Couldn't check …: " (a lost connection is not evidence the file is gone)
    • "Couldn't resolve … in this workspace", for example ~/x when the home folder can't be determined
      Terminal links don't pass the callback, so their behavior is unchanged.
  • Explicit markdown links:
    • [x](README.md:5) used to be read as a web address with the scheme README.md:, so it did nothing. It now opens the file at that line.
    • A linked path containing #, ? or %20 is kept literally instead of being cut at the # or decoded twice.

Why

An underline promises that clicking does something. There were two ways to keep that promise for a bare name:

  1. Don't underline what the click can't resolve (chosen). A bare file name has no single correct location. Well-established agent chat UIs leave a bare file name in inline code as plain code, and Orca's own terminal only underlines a bare name after confirming the file exists where the terminal is running. Making the chat's inline-code rule match its prose rule removes the false promise, with no filesystem work per render.
  2. Make the click find the file by searching the workspace. This was considered and rejected. It guesses at what the agent meant, can open the wrong file when names repeat, and adds a workspace listing on every miss.

Where a path is named properly but the file isn't there, the click now says so instead of doing nothing.

Linked Issue

No GitHub issue. Reported internally as a P0: "unable to click open markdown files in Claude chat" (1.4.208-hourly). The raw text the agent wrote is still being confirmed with the reporter; this change removes the underline-without-click either way.

Visual Proof

Before, on main: the bare name in inline code is underlined as a link, and clicking it (or the missing path) does nothing, with no message.

before on main: clicking the bare name does nothing

After: the bare name is plain code; the relative path, line and column, missing path, file:// link and explicit link are underlined.

after: bare name is plain code

Clicking the missing path shows "File not found".

after: missing path shows File not found

Testing

  • Manual, macOS: tested in an isolated background dev build of this commit, using a Claude transcript attached to a terminal-backed chat and driven through the real UI.

    • The bare name renders as plain code, not inside a link, with no underline.
    • The relative path opened the nested file.
    • The missing path showed "File not found: …".
    • [root notes](root.md:1) opened root.md.
  • Automated tests cover:

    • bare names in inline code and quotes not rendering as links;
    • not-found, couldn't-check and couldn't-resolve messages from real rendered markdown;
    • explicit links with :line, #L7 and %20;
    • literal # in a linked path;
    • the opener's missing-versus-unverifiable verdict, and a superseded click staying silent.
  • Ablation: I reverted each source file to main and confirmed its tests fail.

  • Checks passing locally: pnpm lint (including the localization gates), pnpm tc, check:code-quality:changed, and the sidebar, native-chat, terminal-pane and shared suites.

  • Not tested live: SSH and remote-runtime workspaces. The couldn't-check message is covered by unit tests.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Known remaining gap: on SSH and remote-runtime workspaces, an underlined folder link (e.g. `src/components/`) still does nothing when clicked. The shared opener returns without a message when the local OS can't open a remote folder. Fixing it changes that opener, which terminal links also use, so it's left for a follow-up.
  • Mobile: it shares the href router. A README.md:5 markdown link on mobile now routes as a file instead of doing nothing; mobile's file opener already accepts path:line.
  • Cross-platform: Windows drive paths and backslash separators count as paths.
  • Security and performance: no new schemes, no new IPC, and no per-render filesystem work.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

Native chat file-link routing and linkification now preserve literal path text and apply updated rules for bare filenames and line suffixes. File-open failures are reported as missing or unverifiable, while unresolved workspace paths use a separate toast. English messages and tests cover routing, link clicks, and failure classification.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to ddcd9

Chat file links now either open or clearly report why they could not, and the earlier workspace-search concerns no longer apply because that search was removed. One small gap remains: a bare filename in inline code, such as README-dup.md, is not clickable even when it exists at the workspace root. The change is mergeable with that follow-up in mind.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 18 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: native chat now underlines only file links that support an actionable click.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, visual proof, testing, platform considerations, known gaps, and checklist. It does not provide the required linked is…
Full details: Docstring Coverage

Explanation

Docstring coverage is 28.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 18 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1d56d113-42ca-46f4-bb55-656958425514

📥 Commits

Reviewing files that changed from the base of the PR and between 1b85be6 and 670b26d.

📒 Files selected for processing (15)
  • src/renderer/src/components/QuickOpen.tsx
  • src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link-search.ts
  • src/renderer/src/components/native-chat/native-chat-file-link.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link.ts
  • src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-file-link-click.ts
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/components/quick-open-file-listing-request.ts
  • src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-link-missing-file-open.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/native-chat-href-routing.test.ts
  • src/shared/native-chat-href-routing.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

...(excludePaths.length > 0 ? { excludePaths } : {})
}
)
return listing.files

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not discard listing truncation before deciding that a match is unique.

Remote search is limited to 32 results. Local listing is also bounded. If a truncated result contains one exact suffix match, another exact match can exist outside the returned page. The current code opens the visible match as if it were unique.

Return the full QuickOpenFileListing. Open directly only when truncated is false and matches.length === 1.

Comment on lines +105 to +110
const state = useAppStore.getState()
if (state.activeWorktreeId !== context.worktreeId) {
// Why: Quick Open lists the active workspace.
activateAndRevealWorkspace(context.worktreeId)
}
useAppStore.getState().openModal('quick-open', { initialQuery: searchPath })

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,180p' src/renderer/src/components/native-chat/native-chat-file-link-search.ts
sed -n '80,150p' src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
sed -n '1,100p' src/renderer/src/components/quick-open-file-listing-request.ts

Repository: stablyai/orca

Length of output: 8364


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- test outline and focused remainder ---'
ast-grep outline src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
sed -n '1,260p' src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
printf '%s\n' '--- focused references ---'
rg -n -C 3 'truncated|showFileLinkNotFoundToast|File not found|openFileLinkBySearch|requestQuickOpenFileListing' src/renderer/src/components src/shared

Repository: stablyai/orca

Length of output: 45463


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- focused test file ---'
wc -l src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
cat -n src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
printf '%s\n' '--- focused source references ---'
rg -n -C 8 'QuickOpenFileListing|requestQuickOpenFileListing|truncated|listWorkspaceFiles|openFileLinkBySearch' \
  src/renderer/src/components/native-chat/native-chat-file-link-search.ts \
  src/renderer/src/components/quick-open-file-listing-request.ts

Repository: stablyai/orca

Length of output: 18542


Show “File not found” only for a complete listing.

When requestQuickOpenFileListing succeeds with zero exact suffix matches and truncated is false, call showFileLinkNotFoundToast(searchPath). When the listing is truncated with zero visible matches, or when listing fails, keep Quick Open. Preserve truncated instead of returning only listing.files.

Suggested fix
-import { requestQuickOpenFileListing } from '`@/components/quick-open-file-listing-request`'
+import {
+  requestQuickOpenFileListing,
+  type QuickOpenFileListing
+} from '`@/components/quick-open-file-listing-request`'
...
-): Promise<string[]> {
+): Promise<QuickOpenFileListing> {
...
-  return listing.files
+  return listing
 }
...
-  let matches: string[] = []
+  let listing: QuickOpenFileListing | null = null
   try {
-    matches = findFileLinkSearchMatches(await listWorkspaceFiles(context, searchPath), searchPath)
+    listing = await listWorkspaceFiles(context, searchPath)
   } catch {
     // Quick Open below reports its own listing error.
   }
   if (!args.isCurrent()) {
     return
   }
+  const matches = listing
+    ? findFileLinkSearchMatches(listing.files, searchPath)
+    : []
+  if (listing && !listing.truncated && matches.length === 0) {
+    showFileLinkNotFoundToast(searchPath)
+    return
+  }

@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.

ℹ️ Minor suggestions only.

Reviewed changes

Initial review of the full PR (670b26d, 15 files).

  • Chat file-link search fallback — new openFileLinkBySearch lists the workspace when an unrooted link misses at the root, opens a unique trailing-segment match (keeping line and column), and otherwise hands off to Quick Open prefilled with the link path, guarded by a superseded-click check.
  • Shared file opener — openDetectedFilePath gains an opt-in onMissingPath(isCurrent) callback, fired only on a stat miss and suppressed when a later click supersedes it; terminal callers pass nothing.
  • Href routing — routeNativeChatHref now treats wrapped/decoded hrefs as literal text (so #, ?, %XX survive as filename characters) and adds BARE_FILE_LOCATION_PATTERN so bare README.md:5 routes as a file; transformFileLinks resolves explicit-link URL syntax once.
  • Quick Open refactor — the listing request moves to requestQuickOpenFileListing/usesRuntimeQuickOpenPathSearch, and Quick Open accepts an initialQuery carried through openModal.

Local run: pnpm test on the native-chat folder, the shared href-routing suite, and CommentMarkdown.link-click — 172 files / 1756 tests pass.

ℹ️ Nitpicks

  • findFileLinkSearchMatches (native-chat-file-link-search.ts:37-39) compares case-sensitively, while the SSH/runtime server ranking lowercases (quick-open-path-search.ts). A casing-only link like Readme.md for README.md is returned by the server and then rejected, so it never direct-opens on a case-sensitive host — it degrades to Quick Open.
  • The multi-match handoff (native-chat-file-link-search.ts:110) prefills Quick Open with the path but carries no line/column, so foo.md:42 loses its line whenever the name is ambiguous.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

const WEB_SCHEME_PATTERN = /^(?:https?|mailto):/i
const SCHEME_PATTERN = /^[A-Za-z][A-Za-z0-9+.-]*:/
// Why: `README.md:5` is a file location; the scheme pattern alone reads `README.md:` as a scheme.
const BARE_FILE_LOCATION_PATTERN = /^[^\s:/\\?#]+\.[\p{L}\p{N}_+-]+:\d+(?::\d+)?$/u

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.

BARE_FILE_LOCATION_PATTERN also matches a dotted host with a port — example.com:8080, api.example.com:3000, 1.2.3.4:8080 — because [\p{L}\p{N}_+-]+ accepts any TLD. A scheme-less URL like [docs](example.com:8080), or `example.com:8080` in prose, now routes as a file: it resolves to /repo/example.com at line 8080 (or a "File not found" toast) across the renderer, mobile, and use-native-chat-link-actions. The test only pins the dotless localhost:3000, so nothing catches this class.

Technical details
# `BARE_FILE_LOCATION_PATTERN` over-matches host:port

## Affected sites
- `src/shared/native-chat-href-routing.ts:12` — the new pattern bypasses the `SCHEME_PATTERN` rejection at lines 108-114 for any dotted `host:digits`.
- `src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts:20-28` — inline code like `` `example.com:8080` `` now passes `isLinkifiableFile` (`hasAlphabeticExtension` matches `.com`) and is wrapped.
- `mobile/src/components/markdown-href-routing.ts:12-18` and `src/renderer/src/components/native-chat/use-native-chat-link-actions.ts:53-56` — both now see `kind === 'file'` where they previously saw `none`.

## Required outcome
- `README.md:5` / `App.tsx:12:3` keep routing as files, while a host-with-port shape (`example.com:8080`, `1.2.3.4:8080`) stays `none`.

## Suggested approach (optional)
- Require a path separator or a bounded file-extension set before the `:digits`, or reject a host:port shape explicitly. Add `example.com:8080 → none` next to the `localhost:3000` assertion at `src/shared/native-chat-href-routing.test.ts:103`.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/chat-file-links-open branch from 670b26d to f0ff0ec Compare September 23, 2026 04:00

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 71f59c82-1e43-473a-86c5-1cdbd55b3424

📥 Commits

Reviewing files that changed from the base of the PR and between 670b26d and f0ff0ec.

📒 Files selected for processing (5)
  • src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link-search.ts
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/components/quick-open-file-listing-request.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +63 to +68
{
query: basename(searchPath),
// Why: a large local workspace caps its listing; filtering by name keeps the match in it.
nameFilter: basename(searchPath),
...(excludePaths.length > 0 ? { excludePaths } : {})
}

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

sed -n '43,115p' src/renderer/src/components/native-chat/native-chat-file-link-search.ts
sed -n '1,100p' src/renderer/src/components/quick-open-file-listing-request.ts
sed -n '165,280p' src/renderer/src/components/quick-open-file-list.ts
rg -n 'cancelRuntimeFileList|requestToken|searchRuntimeFilePaths' src/renderer/src/runtime/runtime-file-search-client.ts src/renderer/src/runtime/runtime-file-client.ts

Repository: stablyai/orca

Length of output: 10452


🏁 Script executed:

#!/bin/bash
printf '%s\n' '--- quick-open lifecycle ---'
sed -n '220,380p' src/renderer/src/components/quick-open-file-list.ts
printf '%s\n' '--- runtime file search client ---'
sed -n '1,235p' src/renderer/src/runtime/runtime-file-search-client.ts
printf '%s\n' '--- runtime file client and bindings ---'
sed -n '1,180p' src/renderer/src/runtime/runtime-file-client.ts
rg -n -g '*.ts' -g '*.tsx' 'listFiles|searchRuntimeFilePaths|cancelListFiles|requestToken|AbortSignal' src/renderer/src/runtime src/renderer/src | head -240

Repository: stablyai/orca

Length of output: 38556


🏁 Script executed:

#!/bin/bash
printf '%s\n' '--- filesystem list/cancel bindings ---'
rg -n -g '*.ts' -g '*.tsx' -g '*.js' 'cancelListFiles|listFiles:|listFiles\(' src | head -260
printf '%s\n' '--- chat search callers and current-state wiring ---'
rg -n -g '*.ts' -g '*.tsx' 'openFileLinkBySearch|isCurrent:|isCurrent\(' src/renderer/src/components/native-chat src/renderer/src | head -220
printf '%s\n' '--- file-link search module context ---'
sed -n '1,145p' src/renderer/src/components/native-chat/native-chat-file-link-search.ts

Repository: stablyai/orca

Length of output: 38336


🏁 Script executed:

#!/bin/bash
printf '%s\n' '--- native chat click lifecycle ---'
sed -n '1,125p' src/renderer/src/components/native-chat/use-native-chat-file-link-click.ts
printf '%s\n' '--- filesystem IPC listing and cancellation ---'
sed -n '180,275p' src/main/ipc/filesystem/filesystem-search-handlers.ts
sed -n '600,650p' src/main/ipc/filesystem.test.ts
printf '%s\n' '--- SSH provider token and cancellation ---'
sed -n '285,370p' src/main/providers/ssh-filesystem-provider.ts
sed -n '90,125p' src/main/providers/filesystem-provider-contract.ts
printf '%s\n' '--- terminal context binding ---'
rg -n 'function getTerminalFileContext|const getTerminalFileContext|getTerminalFileContext' src/renderer/src/components/terminal-pane src/renderer/src | head -30

Repository: stablyai/orca

Length of output: 13798


🏁 Script executed:

#!/bin/bash
sed -n '1,190p' src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
sed -n '1,115p' src/renderer/src/components/native-chat/native-chat-file-link-search.test.ts

Repository: stablyai/orca

Length of output: 11207


Cancel superseded chat listing requests.

When a missing-link search runs in an SSH workspace, openFileLinkBySearch starts listFiles without a request token or abort signal. isCurrent() runs only after the listing completes, so a later click does not stop the earlier scan. The SSH filesystem handler can abort these scans by request token, and the repository documents that abandoned scans can stack and starve interactive filesystem operations.

Give each chat search the same token and signal lifecycle as Quick Open. Cancel the previous search when a new link supersedes it, and pass the token and signal through requestQuickOpenFileListing. Environment-runtime requests already have a 15-second timeout, but they should also receive the abort signal.

@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 in the incremental changes.

Reviewed changes

Incremental review of the delta since the prior pullfrog review (670b26d → f0ff0ec).

  • Added a local-only nameFilter to requestQuickOpenFileListing and passed the link's basename from the chat search fallback, so a capped local scan keeps the matching file.
  • Consolidated useRuntimeFileListForWorktree's local and server-search branches onto requestQuickOpenFileListing, dropping the duplicated listing/truncation code and the local debounceRuntimeFilePathSearch helper.
  • Rebased the branch onto current main, absorbing #22369's name-filter-when-capped flow without changing the local listing branch's behavior.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@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 critical issues — one minor observation inline.

Reviewed changes

Incremental review of the delta since the prior pullfrog review (f0ff0ec → 5937c8f).

  • Honest failure verdicts — openDetectedFilePath replaces the onMissingPath(isCurrent) callback with an opt-in onOpenFailure(failure, signal), classifying the failed existence check as missing (the host answered "no such file") or unverifiable (the host could not answer), and handing back an abort signal that fires once a later open supersedes this one. Terminal callers pass nothing and are unchanged.
  • Chat surfaces the verdict — the click hook searches only on missing, shows a "Couldn't check …" toast on unverifiable without starting a search, and shows "Couldn't resolve … in this workspace" for a link it cannot turn into a path.
  • Cancellable search fallback — openFileLinkBySearch takes an AbortSignal, threads it through requestQuickOpenFileListing, and calls cancelRuntimeFileList on abort so a superseded click stops the host-side scan, not just its result.
  • Toast module — the three link-failure toasts move into native-chat-file-link-toasts.ts; toFileLinkSearchPath moves into native-chat-file-link.ts.
  • Quick Open seeding — QuickOpen derives initialQuery from the modal data and re-seeds the input when a new query arrives while the palette is already open.
  • i18n — components.native-chat.fileLinks.unverifiable and .unresolved added.

Local run: the six changed suites pass (41 tests), pnpm tc:web, and pnpm run verify:localization-coverage.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

latestOpenFailureController = controller
// Why: loss of contact with the host is not evidence the file is gone.
deps.onOpenFailure(
{ verdict: isMissingRuntimePathError(error) ? 'missing' : 'unverifiable', error },

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.

The new verdict trusts a message-substring helper: isMissingRuntimePathError returns missing for any error text containing not found / enoent / no such file. That is right for a real stat miss, but it also absorbs host errors that are not absence — an SSH relay without fs.stat answers Method not found: fs.stat (SshFilesystemProvider.stat forwards it verbatim, unlike lstat, which special-cases it), and Windows surfaces an unreachable WSL 9P route as ENOENT. In those corners the chat reports "File not found" and starts a workspace search against the host instead of the "Couldn't check …" this PR promises.

Technical details
# `missing` verdict can absorb non-absence host errors

## Affected sites
- `src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts:190` — `isMissingRuntimePathError(error) ? 'missing' : 'unverifiable'` is the only gate for the new verdict.
- `src/renderer/src/runtime/runtime-file-metadata-client.ts:46-51` — substring match on the message, ignoring any structured `.code`.
- `src/main/providers/ssh-filesystem-provider.ts:226-228` — `stat` returns the relay's `method_not_found` error unchanged; `lstat` (lines 230-248) detects it, `stat` does not.
- `src/main/worktree-retirement-discovery.ts:87-90` — in-repo note that an unreachable WSL 9P route surfaces as `ENOENT` and must not be trusted.

## Required outcome
- A host that could not answer `stat` (relay capability mismatch, unreachable WSL distro) should reach `unverifiable`, so the chat offers "Couldn't check …" rather than claiming the file is missing and searching.

## Suggested approach (optional)
- Prefer a structured signal (`RuntimeRpcCallError.code`, `NodeJS.ErrnoException.code`) when present, falling back to the message heuristic only for the legacy wrapped-ENOENT shape.
- At minimum, keep `Method not found` / WSL-UNC-ENOENT shapes out of `missing`.

## Open questions for the human (optional)
- Is `fs.stat` guaranteed on every supported relay version, or can `method_not_found` reach this path in practice?

A chat message could underline a bare file name such as `deck.md` that
resolved nowhere, and clicking it did nothing, so it read as a broken link.

- Inline code and quoted text become file links only when they name a path
  (contain a `/` or `\`), matching plain prose; a bare file name stays plain code.
- Every file link click now answers: it opens, or says the file was not found,
  that the host could not be checked, or that the path could not be resolved.
- Explicit links like [x](README.md:5) route as files, and linked text keeps
  `#`, `?` and `%XX` literally instead of re-parsing them as URL syntax.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/chat-file-links-open branch from 5937c8f to ddcd9d7 Compare September 23, 2026 18:14
@brennanb2025 brennanb2025 changed the title fix(native-chat): make file links open instead of failing silently fix(native-chat): underline only file links a click can act on Sep 23, 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.

ℹ️ No new issues in this delta — the rewrite simplifies the approach and the changed paths are covered by tests.

Reviewed changes

The PR was rewritten since the previous pullfrog review (5937c8f → ddcd9d7): the workspace-search fallback is gone, replaced by a stricter underline rule.

  • Replaced the search fallback with a stricter underline rule — isLinkifiableFile now requires a path separator for inline code and quoted text, so a bare `deck.md` stays plain code while docs/deck.md remains a link.
  • Deleted the search machinery (native-chat-file-link-search.ts, quick-open-file-listing-request.ts) and reverted the QuickOpen initialQuery seeding and quick-open-file-list.ts refactor introduced by earlier commits.
  • Made every resolved link answer a click — the opt-in onOpenFailure(failure) on openDetectedFilePath drives "File not found" (missing) and "Couldn't check …" (unverifiable), and a file-routed href that cannot resolve shows "Couldn't resolve … in this workspace".
  • Dropped the abort-signal plumbing from onOpenFailure now that no host-side scan needs cancelling; the stale-click guard is the requestId check alone.
  • transformFileLinks resolves explicit-link URL syntax once before wrapping, so #, ? and %20 survive and [x](README.md:5) reaches the file.

Local run: the four changed suites pass (43 tests) and pnpm tc:web is clean.

Two earlier review threads remain open on code this commit did not change — the host:port routing over-match (native-chat-href-routing.ts:12) and the message-substring missing verdict (terminal-file-open-routing.ts:185) — both still present. I left them open rather than re-raising them here.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4cff2934-03d7-4078-8a4a-93dbdef0dcc4

📥 Commits

Reviewing files that changed from the base of the PR and between 5937c8f and ddcd9d7.

📒 Files selected for processing (7)
  • src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-file-link-click.ts
  • src/renderer/src/components/sidebar/CommentMarkdown.link-click.test.tsx
  • src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts
  • src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-link-missing-file-open.test.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

(hasRootedPrefix ||
hasLineSuffix ||
(requireSeparator ? hasPathExtension : hasAlphabeticExtension)) &&
/[\\/]/.test(link.pathText) &&

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,60p' src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts
sed -n '60,75p' src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx

Repository: stablyai/orca

Length of output: 3047


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- relevant symbols ---'
rg -n -C 4 "isLinkifiableFile|exactFileLink|transformFileLinks|routeNativeChatHref|useNativeChatFileLinkClick|workspace lookup|missing relative path|not found|toast" src/renderer/src src/shared --glob '*.{ts,tsx}'
printf '%s\n' '--- candidate file outlines ---'
ast-grep outline src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts
ast-grep outline src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
printf '%s\n' '--- focused source ---'
sed -n '1,260p' src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts
sed -n '1,260p' src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
printf '%s\n' '--- base to head summary and focused diff ---'
git diff --stat 641a7f36d98af01d9ebf53ceceae6a3fe0ba2b10 ddcd9d79826804d63665fddfc3c6145c7417ed65
git diff --unified=35 641a7f36d98af01d9ebf53ceceae6a3fe0ba2b10 ddcd9d79826804d63665fddfc3c6145c7417ed65 -- src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
printf '%s\n' '--- head commits ---'
git log --oneline --decorate -12 ddcd9d79826804d63665fddfc3c6145c7417ed65

Repository: stablyai/orca

Length of output: 45468


🏁 Script executed:

set -o pipefail
rg -n -C 5 "isLinkifiableFile|exactFileLink|transformFileLinks|routeNativeChatHref|useNativeChatFileLinkClick|missing relative path|not found|toast" src/renderer/src src/shared --glob '*.{ts,tsx}'
printf '%s\n' '--- file ---'
sed -n '1,260p' src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts
printf '%s\n' '--- tests ---'
sed -n '1,280p' src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
printf '%s\n' '--- diff ---'
git diff --unified=25 641a7f36d98af01d9ebf53ceceae6a3fe0ba2b10 ddcd9d79826804d63665fddfc3c6145c7417ed65 -- src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
printf '%s\n' '--- commits ---'
git log --oneline --decorate -12 ddcd9d79826804d63665fddfc3c6145c7417ed65

Repository: stablyai/orca

Length of output: 45484


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- exact click hook and context ---'
sed -n '1,260p' src/renderer/src/components/native-chat/use-native-chat-file-link-click.ts
sed -n '1,220p' src/renderer/src/components/native-chat/native-chat-file-link.ts
printf '%s\n' '--- file-open routing declarations and implementation ---'
rg -n -C 8 "export .*openDetectedFilePath|function openDetectedFilePath|const openDetectedFilePath|openDetectedFilePath\\(" src/renderer/src/components/terminal-pane src/renderer/src --glob '*.{ts,tsx}' | head -n 220
sed -n '1,280p' src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
printf '%s\n' '--- href routing and location parsing ---'
sed -n '1,260p' src/shared/native-chat-href-routing.ts
sed -n '1,260p' src/shared/file-link-location.ts
printf '%s\n' '--- focused tests and head commit metadata ---'
rg -n -C 8 "bare|README|workspace|search|lookup|not found|unresolved|underline" src/renderer/src/components/sidebar src/renderer/src/components/native-chat src/shared --glob '*.{test.ts,test.tsx,ts,tsx}' | head -n 320
git show --no-ext-diff --format=fuller --stat ddcd9d79826804d63665fddfc3c6145c7417ed65
git show --no-ext-diff --format= -- src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx ddcd9d79826804d63665fddfc3c6145c7417ed65 | head -n 260

Repository: stablyai/orca

Length of output: 42818


🏁 Script executed:

set -o pipefail
sed -n '1,240p' src/renderer/src/components/native-chat/use-native-chat-file-link-click.ts
printf '%s\n' '--- routing files ---'
fd -t f 'terminal-file-open-routing|native-chat-file-link' src/renderer/src/components
for f in $(fd -t f 'terminal-file-open-routing|native-chat-file-link' src/renderer/src/components | head -n 8); do
  printf '\n--- %s ---\n' "$f"
  rg -n -C 6 "openDetectedFilePath|search|lookup|worktree|not.?found|unresolved" "$f"
done

Repository: stablyai/orca

Length of output: 27796


Allow bare inline-code filenames to use worktree-relative resolution.

The separator check also runs for inlineCodeFileLink, so README-dup.md remains code and never reaches the click handler. resolveNativeChatFileLink supports bare relative names and resolves them against the current worktree. Remove the separator requirement for inline code only. Keep it for prose.

Suggested fix
-function isLinkifiableFile(link: ParsedTerminalFileLink, isProse: boolean): boolean {
+function isLinkifiableFile(
+  link: ParsedTerminalFileLink,
+  isProse: boolean,
+  allowBareFilename = false
+): boolean {
...
-    /[\\/]/.test(link.pathText) &&
+    (allowBareFilename || /[\\/]/.test(link.pathText)) &&
...
-function exactFileLink(value: string, allowSpacedRelative: boolean): ParsedTerminalFileLink | null {
+function exactFileLink(
+  value: string,
+  allowSpacedRelative: boolean,
+  allowBareFilename = false
+): ParsedTerminalFileLink | null {
...
-  if (exactLink && isLinkifiableFile(exactLink, false)) {
+  if (exactLink && isLinkifiableFile(exactLink, false, allowBareFilename)) {
...
-  return isLinkifiableFile(explicitLink, false) ? explicitLink : null
+  return isLinkifiableFile(explicitLink, false, allowBareFilename) ? explicitLink : null
...
-  return exactFileLink(value, true) ? createFileLinkNode(value, node) : null
+  return exactFileLink(value, true, true) ? createFileLinkNode(value, node) : null

Add a click test that expects README-dup.md to call openDetectedFilePath with the current worktree path.

…text still open

Linkified prose, quoted text and inline code wrapped their display text, which the
literal wrapped-href route no longer URL-parses, so file:///... resolved as a relative
path under the worktree. Wrap pathText[:line[:col]] from the parsed link instead.

@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 in the incremental changes.

Reviewed changes

Incremental review of the delta since the prior pullfrog review (ddcd9d7 → 1b21bbd).

  • Wrapped the parsed location instead of the display text — createFileLinkNode now takes the ParsedTerminalFileLink and builds the internal href from formatFileLinkLocation(link), so a file:///... URI in inline code, quoted text or prose no longer lands in the literal wrapped href as a scheme (which routed it as a relative path under the worktree).
  • Added formatFileLinkLocation — the inverse of parseFileLinkLocation in src/shared/file-link-location.ts. transformFileLinks reuses it for explicit markdown links, replacing the inline pathText[:line] join with no behavior change.
  • Added a regression test — opens file:///repo/src/app.ts and file:///repo/docs/release%20notes.md#L4 from inline code and prose, asserting the decoded path and line; it fails against the pre-fix wrapping.

Local run: the three changed suites pass (40 tests) and pnpm tc:web is clean.

Two earlier review threads remain open on code this commit did not touch — the host:port routing over-match (src/shared/native-chat-href-routing.ts:12) and the message-substring missing verdict (terminal-file-open-routing.ts:185). I left them open rather than re-raising them here.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready to merge

Head: 1b21bbdb64. CI green (21 pass, 15 skipped). Mergeable.

Summary

  • The reported bug is fixed. The chat no longer underlines a bare file name like `deck.md`.
  • Every underlined file link now opens the file or shows a message saying why it can't.
  • Review found one regression, fixed in 1b21bbdb64. A second full review found nothing further.

The fix added during review (1b21bbdb64)

A file:// path written in chat text (inline code, quoted text or prose) was broken by the first commit.

  • Symptom: clicking it showed "File not found" and pointed inside the workspace (<workspace>/file:/…). On main it opened the file.
  • Cause: the link stored its visible text, which the new literal-path routing no longer parses as a URL.
  • Fix: it now stores the parsed path[:line[:col]], the same way explicit markdown links already did. The formatter is formatFileLinkLocation, placed next to the existing parseFileLinkLocation.
  • Test: a new test fails without the fix and passes with it.

Behavior worth knowing

  • Bare names with a line number in inline code, such as `my_file.ts:12`, are no longer links. This applies the same "must name a path" rule, and it keeps host-and-port text like example.com:8080 from being underlined. `README.md:12` was never a link on main.
  • Explicit links shaped like [x](example.com:8080) now route as a file and show "File not found". On main they did nothing.
  • Inline code with %20, such as `docs/a%20b.md`, is now read literally, because % is a legal filename character. Markdown links and file:// links still decode %20.
  • Known gap, unchanged from main: folder links on SSH/remote workspaces still do nothing when clicked. This is noted in the PR body as a follow-up.

Validation at 1b21bbdb64

  • Checks: pnpm tc, oxlint on changed files, check:code-quality:changed and the localization gates all pass.
  • Tests: 149 targeted desktop tests pass, and 37 mobile routing tests pass locally.
  • Load flakes: some WorktreeCard and remote-terminal tests fail in broad directory runs. They pass when run alone and don't touch this code.
  • Manual, macOS (hidden background dev build of this commit): a terminal-backed Claude chat, driven through the real UI. All 8 checks passed:
    • The bare name renders as plain code.
    • The relative path opens the nested file.
    • src/a.ts:12:5 opens at line 12, column 5.
    • The missing path shows "File not found".
    • A file:// link opens the file.
    • [root notes](root.md:1) and a link with an encoded space open their files.
    • The web link stays a web link.
    • No console errors.
  • Not tested live: SSH/remote-runtime workspaces (unit tests only) and the mobile app (routing unit tests only).
  • Note: mobile CI doesn't run on this PR, because its path filter doesn't include src/shared/native-chat-href-routing.ts. That gap predates this PR.

Bare name renders as plain code; path, line/column, missing, file:// and explicit links are underlined:
after-links.png

Missing path shows "File not found":
after-missing-toast.png

A file:// path in inline code opens the file:
after-file-uri.png

@brennanb2025
brennanb2025 merged commit 845db9e into main Sep 23, 2026
36 checks passed
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.

1 participant