Skip to content

fix(native-chat): link a bare file name once the chat's folder has it - #28818

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/sta-10392-chat-bare-filename-links
Oct 16, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/sta-10392-chat-bare-filename-links

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24

ELI5

An agent in a chat made a web page, decision-explainer.html, and its reply named the file in a code span. You couldn't click the name to open it, because chat only made file names clickable when they had a folder in front (src/x.html or ./x.html). Now a plain file name written as code becomes clickable too, but only when that file really exists in the chat's folder.

What Changed

The problem (STA-10392). OpenCode in the Chat UI created decision-explainer.html in the workspace root and replied "Done. decision-explainer.html is in the worktree root". The name showed as plain code: no underline, no click, no way to reach the HTML preview from the reply. This happens for every chat agent, not just OpenCode. Chat's link rule (isLinkifiableFile in comment-markdown-native-chat-file-links.ts) threw out any candidate without a / or \ before asking whether the file exists. #26675 did that on purpose, because it wasn't clear which folder a bare name refers to.

Chat does know the folder. Every chat agent runs in one fixed folder, and Orca already knows which one. Claude, Codex, the ACP agents (OpenCode, Grok and others) and Pi all launch through resolveAgentSessionLaunchDirectory on the host, and the chat window works out the same folder (resolveNativeChatTabDirectory). Chat already resolves ./x.html and src/x.ts against it and asks the host that owns the chat (this computer, an SSH host or a paired Orca server, with WSL paths mapped first) whether they exist. Unlike a terminal, a chat agent's folder never changes with cd, so a bare name has one meaning: the file in that folder.

What is different for you (desktop chat only):

In a chat reply Before After
decision-explainer.html in a code span, and the file exists in the chat's folder Plain code Underlined; click opens the usual file actions (HTML opens in Orca's preview)
package.json, Makefile:7 in a code span, when they exist there Plain Underlined
not-here.html in a code span (doesn't exist) Plain Plain
v1.2.3, 1.0, glm-5.3 in a code span, even if something by that name exists Plain Plain; never sent to the host
package.json or "decision-explainer.html" in ordinary prose Plain Plain (unchanged)
Paths with a slash (src/a.ts) and explicit links Unchanged Unchanged

The mechanism.

  • Which names qualify. A bare name qualifies only when it is the whole code span and the terminal's own bare-filename detector accepts it (no spaces, plus either an extension or one of its known names like Makefile). A name with a dot must also pass the shape rule chat already applies to code spans with a slash: a letter-led extension or a :line suffix. That one rule is what keeps v1.2.3 and glm-5.3 plain for bare names and slash paths alike. Such a name then takes the existing route: resolve against the chat's folder, ask the host with the existing yes/no existence check (batched, cached per chat, not while the reply is still streaming), and underline only if the host says it is there. The click handler already opened bare names correctly; it never got the chance.
  • A cache fix. native-chat-file-link-existence.ts keeps answers for names still shown on screen beside its 1,024-entry cache instead of inside it. Before, a chat showing more names than that pushed shown answers out, and they were checked again on every render. Answers move back into the cache when nothing shows them any more.

Why

  • The terminal's rule, with nothing new beside it. Chat reuses the terminal's detector, the existing resolver and the existing existence check. No new message types between the window and the host, no new saved data.
  • Code spans only. In a code span the agent clearly meant one token. Prose is full of dotted words (Node.js, e.g.); checking each would cost a lookup per word, often over SSH, for almost no benefit. Admitting only the whole span also matches the common pattern for linking code spans.
  • Nothing is underlined that the host hasn't confirmed. A missing name, or a host that can't answer, leaves the name plain and never calls it missing. No new host capability is needed, so older paired Orca servers answer bare names the same way.
  • No new network-share exposure. A bare name always resolves inside the chat's own folder, so the guard that keeps chat from looking up \\server\share paths without a click is unaffected.
  • Labelled differences:
    • Intended: a bare name means the file in the chat's own folder. In a monorepo, a reply about packages/a that names package.json links the root package.json if one exists, which is also what the agent's own tools open for that name.
    • Intended: prose bare names stay plain (see above). The terminal links them; chat links only code spans.
    • Intended, small cost: dotted identifiers in code spans (console.log, process.env) now each cost one existence check per chat. Checks are batched and cached, and these stay plain unless a file by that name exists in the chat's folder.
    • Intended: a bare name means the chat's folder only, so Button.tsx living in src/components/ stays plain. Searching subfolders would guess between same-named files.
    • Temporary (follow-up): names whose extension starts with a digit (archive.7z, libfoo.so.1) stay plain, both bare and as src/archive.7z, as on main. Fixing this belongs in one change to the shared shape rule for both spellings.
    • Temporary (follow-up): the existence check answers only "exists", not "file or folder". A folder whose name looks like a file (say docs.html/) can be underlined, and on a remote host the click can do nothing. Slash paths already behave this way on main; the follow-up is a file-or-folder answer from the host.
    • Temporary: mobile chat still decides links by shape alone and doesn't link bare names, the existing mobile follow-up from fix(native-chat): underline a file path only once its workspace confirms it exists #26675.

Linked Issue

Fixes STA-10392

Visual Proof

Recorded on a second Mac in hidden Orca windows (each with a throwaway home), built from main and from this branch at 15ae03a, with real OpenCode 2.0.21 and the same reply on both. The chat folder held decision-explainer.html, package.json, Makefile, src/a.ts, a folder named v1.2.3 and a file named 1.0. The reply was: Done. decision-explainer.html is here. Also Makefile:1, package.json, not-here.html, v1.2.3, 1.0, glm-5.3, src/a.ts. In prose: package.json and "decision-explainer.html".

Before (main): only src/a.ts is underlined.

main reply

After (this branch): decision-explainer.html, Makefile:1, package.json and src/a.ts are underlined. not-here.html, v1.2.3, 1.0 and glm-5.3 stay plain even though v1.2.3 and 1.0 exist, and so do the prose and quoted names.

branch reply

After, clicking decision-explainer.html and choosing Open file: the page opens in Orca's HTML preview.

branch preview

Whole windows

main window

branch window

Testing

  • CommentMarkdown.link-click.test.tsx and use-native-chat-file-link-click.test.tsx (63 tests) pass: the ticket's reply links decision-explainer.html and Makefile:7 and clicking opens <chat folder>/decision-explainer.html; prose package.json and folders stay plain; the existing "numeric versions stay plain even when they exist" test passes unchanged.

  • native-chat-file-link-existence.test.ts adds one test: more shown names than the cache holds are not checked again on re-render.

  • CI runs lint, typecheck and the full suite on the head commit.

  • Manual: hidden-window comparison of main and this branch on macOS with real OpenCode, as in Visual Proof above. Sending, the tab and the Working/Done status matched main.

  • Not run by hand: SSH, WSL and Windows. They use the same resolve-and-check path fix(native-chat): underline a file path only once its workspace confirms it exists #26675 verified, unchanged here.

  • I manually tested these changes locally

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

Review

Four rounds of adversarial review, each by fresh reviewers, plus an architecture challenge that weighed the design against the common pattern. Findings, fixes and what is deferred are in the status comment below.

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 / paired servers: the existence check runs on the host that owns the chat, exactly as it does for paths with a slash.
  • Cross-platform: bare names join the chat folder through the existing resolver (Windows and WSL included).
  • Folder workspaces: the chat folder comes from the same workspace lookup the host uses, so folder workspaces and git worktrees behave the same.

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)

…as it

An agent's reply naming a file it created in its own folder, e.g.
`decision-explainer.html`, stayed plain inline code: chat required a
slash before it would even ask the host whether the path exists. Every
chat agent runs in one known folder (the host's launch directory, which
chat already resolves its links against), so a bare name the terminal's
bare-word detector accepts now goes through the same host existence
check and links only when the file is there. Version-like names (v1.2)
and spaced names are still never asked about.

Fixes STA-10392
Bare names with a dot now pass chat's existing inline-code shape rule, so v1.2.3 and 1.0 stay plain as on main.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for merge review (code reviewed, QA passed, CI green on 15ae03a)

The problem. In the Chat UI, OpenCode created decision-explainer.html and replied "Done. decision-explainer.html is in the worktree root". The name showed as plain code with no way to open it. Chat refused to link any file name without a / in front, so it never asked whether the file existed. This affects every chat agent.

What changes for users. In a chat reply, a file name written as code on its own (decision-explainer.html, package.json, Makefile:7) is now underlined and opens like any other file link, but only after the computer or server running the chat confirms the file exists in the chat's folder. Everything else looks the same as before: names that don't exist, file names in ordinary sentences or quotes, version numbers like v1.2.3 or 1.0, and paths with a slash.

What review changed (four rounds of fresh reviewers plus an architecture challenge):

  • The first version also linked bare names in ordinary sentences and was later widened to a 19-file change that taught the host to tell files from folders. Both were dropped. The PR now links only whole code spans and uses the existing yes/no existence check, with no new messages between window and host and no new saved data.
  • Version numbers in code (v1.2.3, 1.0, glm-5.3) briefly became links when something by that name existed, which broke an existing test. Fixed by running dotted bare names through the rule chat already uses for code with a slash, so one rule covers both spellings.
  • Fixed a cache problem: a chat showing more than 1,024 names checked them again on every render. Answers for names on screen are now kept until nothing shows them.

Deferred, labelled in the PR body:

  • Names whose extension starts with a digit (archive.7z) stay plain, bare or with a slash, as on main. The follow-up changes the shared rule for both spellings at once.
  • The existence check can't tell a file from a folder, so a folder named like a file can be underlined and, on a remote host, its click may do nothing. Slash paths already behave this way on main. The follow-up is a file-or-folder answer from the host.
  • Dotted code like console.log now costs one batched, cached existence check per chat. That cost was counted from the source, not measured. A paired server too old to batch checks gets one request per name at each turn end.
  • Mobile chat doesn't link bare names yet, the existing follow-up from fix(native-chat): underline a file path only once its workspace confirms it exists #26675.

Verified:

  • Hidden-window QA on a second Mac comparing main with this branch at 15ae03a, using real OpenCode and the same reply on both. main linked only src/a.ts. This branch also linked decision-explainer.html, Makefile:1 and package.json, and kept missing names, version numbers (even ones that exist), prose and quoted names plain. Open file showed the HTML preview. Sending, tabs and Working/Done status matched main. Screenshots are in the PR body.
  • The focused chat-link tests pass (63/63), and the full PR workflow is green on 15ae03a: lint, typecheck, all five unit-test shards, relay integration, and the macOS and Windows packages.

Not verified by hand: SSH, WSL and Windows chats. They use the same resolve-and-check path #26675 verified, and this PR doesn't change it. A remote host's click on a folder named like a file was not exercised live.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 00:46
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb4efe5a-1300-43c5-859e-729cdcb04770
📥 Commits

Reviewing files that changed from the base of the PR and between b0308f2 and 15ae03a.

📒 Files selected for processing: 5
  • src/renderer/src/components/native-chat/native-chat-file-link-existence.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link-existence.ts
  • src/renderer/src/components/native-chat/use-native-chat-file-link-click.test.tsx
  • src/renderer/src/components/sidebar/CommentMarkdown.link-click.test.tsx
  • src/renderer/src/components/sidebar/comment-markdown-native-chat-file-links.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

File-link recognition now applies different path-shape rules to prose and inline code. Path answers for watched paths are retained in holder entries, with cache lookup and storage used when no holder answer applies. Tests cover link behavior and rechecking more paths than the shared cache limit.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 15ae0

The reviewed changes are mergeable after normal checks; no actionable issue remains in the supplied evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: linking bare file names when the chat folder contains them.
Description check Passed The description covers the required sections, including the user impact, implementation, rationale, linked issue, visual proof, testing, platform considerations, and checklist. It also documents untes…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

❤️ Share

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

@brennanb2025
brennanb2025 merged commit fb09949 into main Oct 16, 2026
77 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/sta-10392-chat-bare-filename-links branch October 16, 2026 01:54
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