Repository navigation
Link inline-code file references only when the file exists - #6830
Merged
Merged
Conversation
Inline code such as `scheduler.py` or `thread.idle` became a file link whenever it looked like a path, so clicking it opened a file preview that failed with "Path does not exist". Local file link routing now carries the machine its files live on, and inline-code candidates are checked there through the existing pathsExist API, batched per render tick. They stay plain code unless the file exists, and never link when the machine is unknown. Explicit Markdown links are unchanged. Fixes #6664 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Inline code that looks like a file name (
scheduler.py,thread.idle,bb.app) became a file link, resolved against the workspace root, whenever it matched the path rule: a file extension, a:linesuffix, or a./or/prefix. Nothing checked whether the file existed, so clicking such a link opened a preview that failed with "HTTP 404: Path does not exist" (#6664).What changed
Inline code becomes a file link only if the resolved path exists on the machine the files live on. Otherwise it stays plain code. Explicit Markdown links
[text](path)are unchanged. This is the fix the issue preferred.The routing carries the machine.
MarkdownLocalFileLinkRoutinghas a newhostId, set where routing is built:useMessageLinkRouting, through theThreadTimelineNavigationcontext, which the thread view and plugin chat provide.buildMarkdownFileRouting, which every file preview and plugin document uses.When
hostIdisnull, inline code never auto-links.The existence check.
MarkdownCodekeeps the same path rule. Each match rendersMarkdownInlineCodeFileLink, which uses a newuseHostPathExists(hostId, path)hook. The hook is a React Query query per path, backed by a per-host batcher: every path asked for in the same render goes out as onesdk.hosts.pathsExistrequest, split atPATHS_EXIST_MAX_PATHS. Answers are cached for 10 seconds, like the existing existence checks. A match renders as plain code until the answer istrue.No wire changes. This reuses the existing
POST /api/v1/hosts/:id/paths/existendpoint. There are no protocol, SDK, CLI or server changes.Trade-offs:
How you verified
markdown-preview.test.tsx:src/app.ts:4(exists) links tofile:///workspace/src/app.ts#L4, whilescheduler.py,thread.idleandbb.appstay<code>, and all four paths go out in onepathsExistcall. This fails on main, where all four are links.pnpm exec turbo run typecheck lint test --filter=@bb/apppasses (652 test files).pnpm start:worktree, real Claude Code turn, fixture repo withREADME.mdandsrc/app.ts):README.md,src/app.ts:2and./src/app.tslink.scheduler.py,missing/file.ts:10,thread.idle,bb.appand127.0.0.1:8791stay code. OnepathsExistrequest carried every path.src/app.ts:2opens the preview at line 2.README.mdfile preview,src/app.ts:3links andnope.pystays code.Fixes #6664
🤖 Generated with Claude Code