Skip to content

fix(web): resolve preview inline code paths from the workspace root - #16756

Closed
macodev00 wants to merge 1 commit into
pingdotgg:mainfrom
macodev00:cursor/md-preview-inline-code-root-e2ea
Closed

macodev00 wants to merge 1 commit into
pingdotgg:mainfrom
macodev00:cursor/md-preview-inline-code-root-e2ea

Conversation

@macodev00

Copy link
Copy Markdown
Contributor

What Changed

resolveInlineCodeFileLinkMeta still receives the open file's directory as baseDir. Multi-segment inline-code paths that do not start with ./ or ../ now join onto the workspace root when that directory is inside the workspace. Single-segment spans (design.md:12, Makefile:12), ./ and ../ paths, and files outside the workspace keep resolving from the file's directory. Explicit markdown links and images still use imageBaseDir unchanged, with no filesystem existence check.

Why

Fixes #16348.

In a rendered file preview, `docs/ai/design.md` inside docs/ai/plans.md was joined onto docs/ai, so the chip targeted docs/ai/docs/ai/design.md and the click could not open the file. Chat already resolves that span from the workspace root.

Verification

  • Base: upstream/main 0f4f02abb6ab5428c06a7e4b6c76b3ec84c62498 (merges cleanly with current main)
  • Head: 7adee01ad34cb17b1c58dff3e141718b0383e8c0
  • Platform: Linux 6.12.94+, Node v24.13.1
Command Result
vp test run apps/web/src/markdown-links.test.ts 1 file, 72 tests passed
vp run --filter @t3tools/web typecheck tsc --noEmit passed
cd apps/web && vp test run --passWithNoTests --project unit 457 files, 6143 tests passed
vp check 0 errors, 893 warnings in 4848 files
vp run knip:check passed

vp run --filter @t3tools/web test was also run; in that environment 16 suites failed to load because the global vp vitest could not resolve jsdom (434 files / 5834 tests passed). The project-local unit run above loads all 457 files and passes.

Manual check: in the Files panel rendered preview of docs/ai/plans.md, on main the `docs/ai/design.md` chip tooltip is /tmp/fx/docs/ai/docs/ai/design.md, and clicking it shows "The file could not be accessed or read" for that path. With this change the tooltip is /tmp/fx/docs/ai/design.md and the click opens docs/ai/design.md. The single-segment `design.md:12` chip stays on the sibling and opens it at line 12.

Limitations: desktop uses this web view and was not captured separately. Mobile file preview does not use this resolver. A package README's src/index.ts resolves from the workspace root; ./src/index.ts stays file-relative. A bare design.md span is still not a chip. The provider status banner in the captures comes from the capture environment having no provider CLI.

UI Changes

Before After
before: plans rendered after: plans rendered
before: hover root path chip after: hover root path chip
before: click root path chip after: click root path chip
before: hover sibling chip after: hover sibling chip
before: click sibling chip after: click sibling chip
before recording after recording
before.mp4 after.mp4

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Inline code in a markdown file preview was joined onto the open file's
directory, so `docs/ai/design.md` inside docs/ai/plans.md pointed at
docs/ai/docs/ai/design.md. Multi-segment inline-code paths now resolve
from the workspace root. Single-segment names, ./ and ../ paths, files
outside the workspace, and explicit markdown links stay file-relative.
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 7, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 7adee01

Macroscope's review found this PR approvable — This is a focused, well-tested correction to inline-code file paths in workspace previews. Existing explicit links, single-segment references, outside-workspace files, and chat behavior remain unchanged, with no product-default or static-analysis configuration changes.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54fa7e53-b9db-490a-bac6-1e249097aab5
📥 Commits

Reviewing files that changed from the base of the PR and between 4b063a0 and 7adee01.

📒 Files selected for processing (2)
  • apps/web/src/markdown-links.test.ts
  • apps/web/src/markdown-links.ts

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


📝 Walkthrough

Walkthrough

Inline-code paths now resolve from the workspace root when they have multiple segments and do not begin with an explicit relative prefix. Single-segment paths, explicitly relative paths, and paths from files outside the workspace remain relative to the host file.

Changes

Inline-code path resolution

Layer / File(s) Summary
Resolution rules and validation
apps/web/src/markdown-links.ts, apps/web/src/markdown-links.test.ts
The resolver selects the base directory based on workspace membership and path form. Tests cover workspace-root resolution, file-relative cases, and unchanged explicit Markdown link resolution.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 7adee

The preview-link fix appears ready to merge after normal checks.

Architecture Summary

Architecture risk: 🟡 Medium · up to 7adee

The change affects 1 system.

Changed systems: apps/web

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/web (ui) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/web/src/markdown-links.test.ts: Adds expectations that multi-segment inline-code paths resolve from the workspace root, including line-suffixed paths and backslash-separated paths.
  • observed — Modified behavior in apps/web/src/markdown-links.test.ts: Adds expectations that explicit Markdown links remain relative to the host file’s directory, including multi-segment paths.
  • observed — Modified behavior in apps/web/src/markdown-links.test.ts: Adds expectations that single-segment inline-code names with line references resolve beside the host file, while a name without a line suffix returns null.
  • observed — Modified behavior in apps/web/src/markdown-links.test.ts: Adds expectations that inline-code paths beginning with ./ or ../ remain relative to the host file, including backslash-form ./ paths.

Reliability and maintainability

  • inferred — Risk-relevant change factors for apps/web: blast_radius_2; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #16348 says bare inline-code paths in workspace files resolve from the workspace root, with ./ and ../ as the stated file-relative exceptions. The implementation resolves multi-segment paths… Update inlineCodeFileLinkBaseDir so non-./ and non-../ relative inline-code paths in workspace files resolve from cwd, including single-segment paths. Update the single-segment tests to match.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: resolving preview inline-code paths from the workspace root.
Description check ✅ Passed The description explains the problem, the change, and the verification results. It also includes before-and-after UI evidence. It references issue #16348 but does not include a separate Scope and appr…
Out of Scope Changes check ✅ Passed The changes in apps/web/src/markdown-links.ts and apps/web/src/markdown-links.test.ts implement or test issue #16348. The tests cover workspace-root inline paths, file-relative explicit links and …
Approvability ✅ Passed This is a focused fix to inline-code path resolution in apps/web/src/markdown-links.ts, with tests in apps/web/src/markdown-links.test.ts. The diff changes no setting default, static-analysis supp…
Full details: Linked Issues check

Explanation

Issue #16348 says bare inline-code paths in workspace files resolve from the workspace root, with ./ and ../ as the stated file-relative exceptions. The implementation resolves multi-segment paths from cwd, but isWorkspaceRootInlineCodePath rejects single-segment paths. The tests also require design.md:12 and Makefile:12 to resolve beside the open file. This leaves part of the stated path rule unmet.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@juliusmarminge

Copy link
Copy Markdown
Member

Note

Grok responding on behalf of Julius.

Closing as superseded. #16348 was fixed by #16950 (merged), which applies the same workspace-root resolution for multi-segment inline-code paths in file previews. Thanks for the focused PR and tests — the fix landed via that other change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Inline code paths in a markdown file preview resolve from the file's directory

2 participants