Repository navigation
fix(native-chat): underline a file path only once its workspace confirms it exists - #26675
Conversation
…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.
Review summaryThe problem. In native chat, a reply that used 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 Fixed during review (the PR changed substantially):
Deferred (not caused by this PR, or minor):
Verified:
CI on Not verified by hand:
|
…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]>
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.tsas an example name. Chat underlined it, and clicking it showed "File not found: …/src/app.ts". The file never existed (the real one wassrc/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):
src/app.ts, which doesn't existsrc/renderer/src/App.tsx, which existsI changed /abs/path/a.ts to use src/b.ts.[app](src/app.ts)package.json) and folders (src/components)//server/share/notes.mdoutside the workspaceChat 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.
terminal-pane/terminal-file-link-target.tsis 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.tskeeps 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.\\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
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 =
mainatbb44f74d009; after =d3d4ad6dde0(desktop) and13004c4d3fe(SSH; the later commits change only the network-share rule).Before (main):
src/app.ts(missing) andsrc/missing/gone.ts(missing) are underlined; the "I changed …" sentence is one long broken link.After: both missing paths are plain; existing paths stay underlined; the sentence links its two paths separately; the network-share line is plain.
After, clicking
src/real/present.ts: the right file opens.SSH: a file that exists only on the remote host is underlined and opens the remote file; the missing path stays plain.
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:weband 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
Notes
//x/youtside the workspace simply stays plain.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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: Brennan Benson (@BrennanKB5)