fix(markdown): open file links at source locations - #847
Open
Harry19081 wants to merge 1 commit into
Open
Conversation
Pre-commit hook ran. Total eslint: 5, total circular: 0
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.
Problem
Agent-authored markdown file links such as
/repo/src/View.tsx:220passed the trailing source location into filesystem lookup and tab creation as part of the filename. The editor therefore tried to open a nonexistentView.tsx:220file instead ofView.tsxat line 220. React Markdown also removed supportedfile://, Windows drive-letter, and Tauri asset hrefs before the local-link click handler could classify them.Solution
Parse trailing
:lineand:line:columnsyntax at the markdown file-reference boundary, keep the filesystem path clean, and pass the 1-based line through the existing editor target-line option. Apply the same parser to inline-code file navigation. Preserve supported local filesystem references during URL transformation only forhref; non-link attributes and unsupported schemes continue through React Markdown's default sanitizer.The resulting invariant is that markdown navigation sends path and source location as separate values. No persisted data or historical cleanup is involved.
Potential risks
A POSIX filename that legitimately ends in
:<positive integer>will be interpreted as a source-location reference when opened from chat markdown. Optional columns are accepted so the path is parsed correctly, but navigation currently targets the line only because the WorkStation tab contract has no target-column field. Workspace-relative markdown href behavior is unchanged.Rollback is a straight revert of commit
04250d017; there are no schema, dependency, persistence, API, or wire-format changes.Audit
Reviewed the adjacent markdown link pipeline for absolute POSIX paths,
file://URLs, Windows drive-letter paths, Tauri asset URLs, home-relative paths, inline code, remote schemes, and non-href URL attributes. Relative href resolution remains intentionally out of scope because the current renderer does not infer a workspace root for links.Verification
npx vitest run src/components/MarkDown/markdownFileRef.test.ts src/components/MarkDown/MarkdownLocalImage.test.ts src/components/MarkDown/markdownUtils.test.ts src/components/MarkDown/markdownUrlTransform.test.ts— 4 files, 28 tests passed.npx prettier --check <8 changed files>— passed.npx eslint <8 changed files>— passed.npm run typecheck— passed.git diff --check— passed.No screenshot is included because this changes click navigation and target-line behavior without changing rendered appearance. The owning parser and editor-opening boundary are covered by regression tests.