Skip to content

fix(native-chat): underline a file path only once its workspace confirms it exists - #26675

Merged
brennanb2025 merged 11 commits into
mainfrom
brennanb2025/sta-9683-click-file
Oct 9, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
brennanb2025/sta-9683-click-file

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​797 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​776
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​803 $\color{#cf222e}{\Huge{\mathbf{−}}}$​231 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​572

ELI5

When an agent's chat reply mentions a file, Orca underlines it so you can click it. It underlined anything that looked like a file path, even a made-up example, and clicking one showed "File not found." Now chat asks the workspace whether the file is really there before underlining it, the same way Orca's terminal already does.

What Changed

The problem. In a native chat, Codex explained something using src/app.ts as an example name. Chat underlined it, and clicking it showed "File not found: …/src/app.ts". The file never existed (the real one was src/renderer/src/App.tsx). Chat decided what to underline from the shape of the text alone (a folder plus a file extension). No shape rule can tell a real path from an example that is valid path syntax, so earlier shape fixes (#22370) could not catch this.

What is different for you (chat only):

In a chat reply Before After
src/app.ts, which doesn't exist Underlined; click shows "File not found" Plain text
src/renderer/src/App.tsx, which exists Underlined Underlined, opens the file
A file the agent deletes or renames during the turn Stayed underlined Loses its underline when the turn ends
A file the agent creates during the turn Underlined Underlined once the turn ends
A path in a reply still streaming in Underlined as it arrived Underlined once the reply has finished drawing
I changed /abs/path/a.ts to use src/b.ts. One long broken link Both paths link
A markdown link the agent wrote, e.g. [app](src/app.ts) Link Still a link (not checked)
Bare names (package.json) and folders (src/components) Not underlined Still not underlined
A network-share path such as //server/share/notes.md outside the workspace Underlined; nothing sent until a click Plain text; Orca never looks it up
Path on an SSH host that can't be reached right now Underlined Plain until the host answers; never reported as missing

Chat can only underline less than before (apart from the second path in a sentence like the one above). The terminal looks and behaves the same as before.

The mechanism.

  • Which text can be a link is unchanged: chat keeps its existing shape rules. Each candidate is then checked for existence on the machine that owns the workspace (this computer, an SSH host, or a remote Orca server; WSL paths are mapped first), using the terminal's existing batched check. Only paths the host confirms are underlined.
  • terminal-pane/terminal-file-link-target.ts is the one shared step that turns detected text into the workspace path and asks whether it exists. The terminal's hover underline and its click fallback now both use it instead of two copies.
  • native-chat/native-chat-file-link-existence.ts keeps one set of answers per open chat. Each answer records when it was checked. At the end of every turn, and when the SSH connection or remote server comes back, every path on screen is asked about again; the old answer stays visible until the new one arrives, and only messages whose answer changed re-render. A machine that can't answer means "unknown", never "missing": it is retried after 2, 10 and 30 seconds and then waits for the next turn end or reconnect.
  • While a reply is still arriving, chat only uses answers it already has, so half-typed paths are never sent to the host.
  • Chat never checks a network-share path (\\server\share, //server/share) outside the workspace on its own, on this machine or on an SSH host. On Windows, looking such a path up connects to that server and can send the user's sign-in credentials, and an agent can be steered into writing one. Paths inside the workspace, including a workspace that itself lives on a share, and the workspace's own WSL distro are still checked.

Why

  • It fixes the cause, not one shape. Shape rules can't tell a made-up path from a real one. Asking the workspace can.
  • One code path for chat and terminal. The terminal already solved existence checks, including SSH and WSL, so chat reuses its code and the two can't drift apart.
  • Differences from the common pattern, each labeled:
    • Intended: the common pattern underlines paths by shape and reports a missing file only after a click. Orca checks first, as its terminal already does, because the bug is exactly a link that promises a click it can't keep.
    • Intended: paths in a reply that is still streaming in stay plain until it finishes, so half-typed paths are never sent to the host.
    • Intended: a network-share path outside the workspace is never checked without a click, so showing a reply can't make the computer contact another server.
    • Temporary: mobile chat still decides by shape alone (mobile/src/components/markdown-file-path-detection.ts); it needs a way to ask the host from the phone. Follow-up.

Split out: underlining bare file names (package.json) and folders when they exist, as the terminal does, moves to a separate PR. It has open questions of its own: in a monorepo a bare name can match the wrong file, and clicking a folder over SSH currently does nothing.

Linked Issue

Fixes STA-9683

Visual Proof

Recorded in a hidden Orca build on the M4Air (desktop) and against a throwaway Linux SSH host from this laptop, with a seeded chat reply (no real agent run). Before = main at bb44f74d009; after = d3d4ad6dde0 (desktop) and 13004c4d3fe (SSH; the later commits change only the network-share rule).

Before (main): src/app.ts (missing) and src/missing/gone.ts (missing) are underlined; the "I changed …" sentence is one long broken link.

desktop-before-reply

After: both missing paths are plain; existing paths stay underlined; the sentence links its two paths separately; the network-share line is plain.

desktop-after-reply

After, clicking src/real/present.ts: the right file opens.

desktop-after-opened-file

SSH: a file that exists only on the remote host is underlined and opens the remote file; the missing path stays plain.

ssh-reply

ssh-opened-remote-file

Testing

  • New and updated unit tests: the ticket's case (made-up inline-code path stays plain, real one links); the chat checker asks once, rechecks every shown path at turn end and on reconnect, keeps the old answer until the new one arrives, retries an unreachable host three times, ignores late answers from an older check, and catches up a message whose answer arrived before it subscribed; paths are never asked about while a reply is still drawing; network-share paths outside the workspace are never asked about (this machine and SSH); WSL paths only for the workspace's own distro.

  • The terminal's link tests (300+) pass unchanged, so the shared resolve step didn't change the terminal.

  • pnpm tc:web and the CI static checks pass locally.

  • Manual: desktop and SSH as shown above. Not run by hand: Windows/WSL, deleting a file and watching its underline go at turn end (covered by unit tests), and an SSH disconnect/reconnect.

  • I manually tested these changes locally

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

Review

See the review summary comment on this PR.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote SSH: the check runs on the machine that owns the workspace, through the same route as terminal links. A machine that doesn't answer leaves paths plain and is never reported as "missing".
  • Cross-platform: paths are resolved by the terminal's existing resolver (Windows drive paths and WSL included). The network-share rule applies on every OS; on macOS and Linux a path written as //x/y outside the workspace simply stays plain.
  • Performance: checks are batched, cached per chat (up to 1,024 paths), not sent while text streams, and only messages whose answer changed re-render.
  • Not covered here: mapped network drives (Z:\), and the terminal checking a network-share path while you hover over it (already the case before this PR). Both need a check in the main process; follow-up.

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)

Author: Brennan Benson (@BrennanKB5)

…rms it exists

Chat underlined any path-shaped text, so an example path an agent made up
(`src/app.ts`) looked clickable and a click said "File not found". The
terminal already checks a path on its host before underlining it; chat now
goes through that same code: the terminal's path finder, one shared
resolve-and-check step (terminal-file-link-target.ts), and the same
longest-match rule. The terminal's hover and click fallback use the shared
step too.

Fixes STA-9683
…he host returns

Chat only forgot "missing" answers at turn end, so a file deleted or renamed
during a turn kept its underline, and a path the host could not answer
stayed plain until the message remounted.

Each answer now records the recheck generation it was asked in. A turn end,
or a reconnect / re-pair of the host answering for the workspace, starts a
new generation and re-asks only the paths shown by mounted messages; old
answers keep showing until the host replies, and only messages whose answer
changed re-render. A reply to an older question cannot overwrite a newer
answer. A host that cannot answer keeps the previous answer and is retried
three times with backoff, ending when no message shows the path or at the
next recheck. While an SSH workspace's connection is unresolved, paths are
treated as unknown instead of being checked on this machine, and the chat
starts over once the connection resolves.
…ce on top

Chat detection goes back to main's rules: a candidate needs a folder plus a
rooted prefix, a line suffix or an extension, and prose spans are split into
tokens as before. Bare names and folders are not underlined, and ordinary
prose no longer sends word prefixes to the host. Existence is required on top,
so the underlined set only shrinks compared with main.

A rooted spaced span ("/Users/me/repo/src/x.ts to use src/app.ts") now also
offers its tokens, so both real paths link; a real spaced rooted path still
wins as the longest one that exists.

Tests: bare names and folders stay plain even when they exist, slash tokens
and versions stay plain when everything exists, `My Notes.md:7` is rejected by
shape, explicit links and fenced code never reach the existence check, plus
the rooted-then-relative and longest-span cases.
…ter recheck triggers

- A message renders (and asks) before it subscribes; an answer landing in
  between was never shown. Each message records the answer its render used,
  and on subscribe it re-renders if the answer differs and re-asks outdated
  paths. A failure for a path no message shows yet no longer arms a retry.
- A rooted path ending a sentence ("/Users/me/r/a.ts.") inside a longer span
  now links, with the punctuation kept outside the link. Unrooted spans are
  unchanged, matching main.
- The checker takes the workspace's SSH connection id and decides
  "connection not known yet" from it, so the provider memo needs no lint
  suppression.
- SSH reconnects recheck only when the connection reaches connected or gets
  a new generation, not on every intermediate status.
Resolves conflicts with #26238 (paced, block-by-block reply rendering) in
NativeChatMarkdown.tsx and CommentMarkdown.tsx: keep fadeWords/growing and
the fileLinkExists plumbing together. Adds tests that a paced reply asks the
host only once fully revealed, and that block-split rendering re-renders when
existence answers change.
…ithout a click

Chat checks every path in a finished reply on its own. On Windows, a local
check of a path like \\server\share\a.ts or //server/share/notes.md opens an
SMB connection to that server and sends the user's credentials, and agent
text can be steered by prompt injection. Such a path is now never asked
about and stays plain text, unless it is inside the workspace or is a known
workspace root. WSL paths (\\wsl$, \\wsl.localhost) and checks made by an SSH
or remote runtime host are unaffected. Terminal hover and click behaviour is
unchanged.
…ns.ts

The merge commit's format hook dropped one blank line in this unrelated file.
Committed without the hook so the file matches main byte for byte.
…ot each chat view

The provider now sits where NativeChatView picks the chat view, and derives
the file-link context from the tab id. The two chat views keep only a
one-line turn-end hook, since only they know whether a turn is running.
Same lifetime as before: inside the session-keyed owner for structured
chats, and per resolution for terminal-backed ones. No behaviour change;
it keeps NativeChatResolvedView under its line limit after main's find-in-chat.
Final sync before landing. No conflicts. Committed without the format hook so
main's files are taken byte for byte.
…the workspace's WSL distro

- The "no network share outside the workspace" rule now applies to SSH
  targets as well: a Windows SSH host's relay would otherwise stat
  //server/share/... and open SMB with no click. Remote runtime paths stay
  exempt, since they are always inside the worktree.
- WSL paths are allowed only for the workspace's own distro (from the pane
  runtime or the worktree path, via the same helper the path mapping uses),
  after `..` is normalized, so `//wsl.localhost/../x` or another distro is
  refused.
- Drop the \\?\UNC\ chat test case: the real detector never produces it.
…flow

terminal-file-link-target imported its pure path helpers from
terminal-file-open-routing, which also opens files and so loads worktree
activation, launch and the agent catalog. Since NativeChatView now hosts the
chat file-link checker, that chain reached tests that render NativeChatView
with a minimal i18n mock (native-chat-view-file-drop.test.tsx failed in CI).

getTerminalFileContext, mapTerminalFilePath, terminalLinkWslDistro and
terminalPathWslDistro move unchanged to terminal-file-path-mapping.ts;
terminal-file-open-routing imports and re-exports them, so its callers and
their mocks are unchanged.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review summary

The problem. In native chat, a reply that used src/app.ts as a made-up example got underlined as a file link, and clicking it showed "File not found" (STA-9683). Chat picked links by the shape of the text alone, and no shape rule can tell an example path from a real one.

What changes for you. Chat now underlines a path only after the workspace's machine (this computer, an SSH host or a remote Orca server) confirms the file exists, the way the terminal already does. Made-up paths stay plain. Real ones still link and open. A file deleted during a turn loses its underline when the turn ends. Paths in a reply that's still arriving become links once it has finished drawing. Chat never underlines more than before: it keeps its existing rules for what can be a path. Bare names like package.json and folders still don't link.

Fixed during review (the PR changed substantially):

  • Scope narrowed. The first version also started underlining bare file names and folders. That has its own problems: in a monorepo a bare name can open the wrong file, and clicking a folder over SSH does nothing. It moves to a separate PR.
  • Security. Checking paths automatically meant that showing a reply containing //server/share/x made Windows connect to that server and offer the user's sign-in credentials, with no click. That was reproduced on a Windows machine against a reserved test address. Chat now never checks a network-share path outside the workspace without a click, on this machine or on an SSH host. The workspace's own WSL distro is still allowed.
  • Stale links.
    • Confirmed answers were kept for the chat's whole life, so a deleted file stayed underlined, which is the original symptom.
    • An unreachable host was never asked again.
    • Now every path on screen is rechecked at turn end and on reconnect. A host that doesn't answer gets three spaced retries, after which the path waits for the next turn end or reconnect.
  • Host traffic. The first version sent every run of prose words to the host. Back on chat's existing rules, a typical reply checks about one path per path mentioned.
  • Smaller fixes:

Deferred (not caused by this PR, or minor):

  • Terminal hover: the terminal also looks up a network-share path as soon as you hover over it, without a click. It did this before this PR. It needs the same rule in the main process, along with mapped network drives (Z:\) and links inside the workspace that point at a share.
  • Mobile: mobile chat still decides links by shape alone (temporary; it needs a way to ask the host).
  • Pre-existing shape gaps:
    • - src/a.ts: added … (a path followed by a colon) never links.
    • ~/… doesn't resolve when the workspace isn't under a home folder.
    • A spaced absolute path followed later on the line by another path isn't picked up.
  • Performance: the existence check waits for its slowest path, so one slow network drive delays every underline in that batch.
  • Minor: past 1,024 different paths in one chat, older answers get asked again.
  • File-length limit: NativeChatResolvedView.tsx is at exactly 400 of 400 lines once merged with main (main alone is at 398), so the next addition there needs a split.

Verified:

  • Unit tests: the PR's tests, the terminal link suites and the chat view tests all pass.
  • Typecheck and static checks: tc:web and the CI static checks pass.
  • Review rounds: three rounds of independent reviewers, plus narrow reviews of each later fix.
  • Desktop app (M4Air): a hidden build with a seeded reply, before on main and after on this branch: missing paths plain, real paths underlined, the click opens the right file, and the network-share line stays plain.
  • SSH: a throwaway Linux host with a real repo: a remote-only file links and opens the remote copy, and a missing path stays plain.

CI on 2052411a302: all checks pass (13 passed, 17 skipped). One Windows packaging test in unrelated CLI preflight code timed out once and passed on re-run. The PR is still a draft, so some checks only run once it's marked ready.

Not verified by hand:

  • Windows and WSL in the app. The network-share rule is covered by unit tests, and the underlying Windows behaviour was reproduced on its own.
  • An SSH disconnect and reconnect.
  • Watching an underline disappear after a real deletion (covered by unit tests).
  • SSH on the final commit. It ran on 13004c4d3fe; later commits only touch the network-share rule and move path helpers into their own file with no behaviour change.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 9, 2026 06:20
@brennanb2025
brennanb2025 merged commit d273d85 into main Oct 9, 2026
75 of 77 checks passed
brennanb2025 added a commit that referenced this pull request Oct 11, 2026
…26819)

Command-, route-, version- and host-shaped text stays plain unless the
host confirms the path, in chat and terminal alike, since #26675.

Co-authored-by: Kelvin Amoaba <[email protected]>
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