fix(shared): one-letter link schemes no longer become file links on Windows #24006
main fromrefs/pull/24006/head·merged by juliusmarminge View on GitHubProblem#
On Windows, Chromium's URL parser reads a one-letter scheme as a drive letter.
In Chrome, Edge and the Electron desktop app on Windows, new URL("d:alert(1)").href
is file:///D:/alert(1). Node and Chromium on other platforms keep d:alert(1).
parseFileUrlHref parses first and checks the protocol after, so on Windows
rewriteMarkdownFileUriHref turns a chat link like [unknown](d:alert(1)) into a
file chip for D:/alert(1). The existing browser test
ChatMarkdown Windows file links > still rejects unsafe schemes fails on a Windows
host for this reason. CI runs on Linux, so it never sees the failure.
Change#
parseFileUrlHref returns null unless the href starts with file:, before it
calls new URL. Two of its three callers (parseMarkdownFileLink and
client-runtime's markdownImages) already check this first. The web markdown link
rewrite did not.
Scope and approval#
Small, focused fix for an obvious bug: one guard in a shared helper, so links render the same on every client OS. This isn't script execution. The chip only opens a path, but it shouldn't exist at all.
Verification#
Windows 10 (19045), Node 26.12.1, Vite+ 1.3.0, Playwright Chromium headless shell 148.
- Parser difference, from Playwright's Chromium on Windows:
d:alert(1),c:fooandx:ybecomefile:///D:/alert(1),file:///C:/fooandfile:///X:/y. Node returns them unchanged. - From
apps/web:vp test run --project browser src/components/ChatMarkdown.browser.test.tsx. On main,still rejects unsafe schemesfails because the output containshref="D:/alert(1)"; the other 5 pass. With the fix, 6/6 pass. - Related tests pass with the fix: shared
fileLinks,markdownLinksandpath(63), client-runtimemarkdownImages(12), web unitmarkdown-linksandterminal-links(48), and the three markdown browser test files (12). vp run check:changed: format, lint, knip, typecheck (28 packages) and thefileLinkstest pass. On Windows this needed a local workaround forcheck:changedspawningvp.cmd, which isn't part of this PR.
No new test. The existing browser test is the regression test and fails on main on Windows. A Node unit test can't reproduce Chromium's parsing.
Fix written by Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
eb2e68fMacroscope's review found this PR approvable — This is a focused four-line bug fix that prevents one-letter schemes from being misclassified as file links on Windows while preserving valid
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).file:URL handling. It affects only existing markdown/file-link parsing paths and introduces no schema, deployment, default, or static-analysis changes.No actionable comments were generated in the recent review.
Walkthrough
-
parseFileUrlHrefnow checks that the trimmed, lowercased input starts withfile:before parsing. A regression test verifies that a one-letter scheme returnsnull.Changes: File URL Validation
Layer / File(s) Summary Validate the file URL prefix
packages/shared/src/fileLinks.ts,packages/shared/src/fileLinks.test.tsparseFileUrlHrefrejects inputs without afile:prefix. A regression test verifies rejection ofd:xwhen the mocked URL parser interprets it as a Windows-style file URL.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge,voltcrash
Merge Risk:
Minimal · up to10b97-
This change stops one-letter schemes such as d:alert(1) from being rendered as file links on Windows Chromium. It is a small, low-risk hardening and appears ready to merge.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the actual change: one-letter link schemes no longer become file links on Windows. It follows the conventional commit form and matches the guard added to parseFileUrlHref in packages/s… Description check The description follows the repository template. It has a clear Problem section with the Chromium drive-letter parsing cause and reproduction details. The Change section explains the guard and why it … Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title names the actual change: one-letter link schemes no longer become file links on Windows. It follows the conventional commit form and matches the guard added to parseFileUrlHref in packages/shared/src/fileLinks.ts. At 75 characters it is slightly long but still clear.
Full details: Description check
-
Explanation
The description follows the repository template. It has a clear Problem section with the Chromium drive-letter parsing cause and reproduction details. The Change section explains the guard and why it sits in the shared helper. The Scope section explains why no linked issue is needed for this small bug fix. The Verification section lists specific commands, platforms, and observed before/after results, and it states what was not checked, including the Windows-only workaround. It does not include a separate issue link, but the Scope section gives a reason, which the template allows. The agent attribution line is present.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 86d49da
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0b0de536-2bb9-4f51-9c71-56a97a39a15f
Commits-
Reviewing files that changed from the base of the PR and between eb2e68f35a5dac7fe2c919bc3d4c4f23ea268fa8 and 10b97feb213edf91166dd2c050b51c152eb59ed8.
Files selected for processing: 2-
packages/shared/src/fileLinks.test.tspackages/shared/src/fileLinks.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified the linux web path at exact head
eb2e68f35a5dac7fe2c919bc3d4c4f23ea268fa8, after runninggithub/main(5ef56853ef) in a separate worktree first. usedvp i, one background dev server at a time, playwright from the repo dependencies, and/usr/bin/google-chrome. final verification used fresh isolated state at/home/user/t3code/.t3/verify.created a real git repository, added its project through the web app, and submitted real codex
gpt-6.1-solturns through the composer and local provider proxy. the provider returned the requested markdown on both revisions. no mocks, fixtures, replay provider, or source changes.d:alert(1),c:foo, andx:yrendered without an href. clicking them did not navigate or open a file.file:///home/user/link-verification/README.md#L3rendered as a file chip. clicking it loaded the real file in the panel and highlighted line 3.https://example.comretained its destination and opened an external tab with example-domain content.- 39 focused parser, markdown-link, and markdown-image tests passed through blacksmith-check.
vp run check:changed 807319c276c6831b2c219640e9da5b38019a8f1dpassed through blacksmith-check: format, lint, knip, 28 affected package typechecks, and 18 parser tests. the explicit ref is the pr's base; the shallow worker needed its ancestry fetched first.
main baseline with the same prompt and data:

pr head with matching prompt and data:



short runtime transcript, including selected real provider events
Not verified#
the windows-specific regression remains unverified. on this linux vm, chrome returns
d:alert(1),c:foo, andx:yunchanged fromnew URL(...).href; it does not convert them tofile:urls. the original bug therefore did not reproduce on main. the linux before/after captures prove the exercised paths still work, but cannot prove the windows fix. no url-parser shim or simulated platform was used.windows chrome/edge and electron still need the same real-chat scenario on windows. native desktop shells, macos, ios/android, remote relay/tunnel connections, and other providers were not exercised here.
Native Windows check at
eb2e68f35a5dac7fe2c919bc3d4c4f23ea268fa8Host: Windows 10 Pro 10.0.19045 x64. Node 26.12.1, Vite+ 1.4.0. Edge 156.0.4314.56, Chrome for Testing 148.0.7778.96 (Playwright's Chromium, since stable Chrome isn't installed), and the desktop dev app (Electron 44.10.0). I ran main (
6575ce32508b) first, then the same checkout with this PR's commit applied, usingvp run dev/vp run dev:desktopwith an isolatedT3CODE_HOME. I added a real git repo as a project and sent a real Codex turn. The reply matched the prompt exactly:[one](d:alert(1)) [two](c:foo) [three](x:y),[readme](file:///C:/t3-linktest/README.md#L3),[site](https://example.com).On Windows the bug shows in the user message, not in Codex's reply. User messages render with
parseRawHtml={false}. The assistant's raw-HTML path already drops these hrefs on main, so the reply looks clean on both revisions. The browser test covers both modes.On main:
- In the user message, Edge, Chrome for Testing and the desktop app render
d:alert(1),c:fooandx:yas file chips (D:/alert(1),C:/foo,X:/y). Clickingalert(1)opens the file panel with "could not be accessed or read" and the attempted pathD:/alert(1). ChatMarkdown.browser.test.tsx:still rejects unsafe schemesfails and 10 others pass.
With this PR:
- In all three, none of the three schemes renders as a file chip. In the desktop app, clicking them does nothing. In the browsers, the user-message ones keep
href=""and open the current page in a new tab, the same asjavascript:links already do on main. - The README chip opens the file with line 3 highlighted.
https://example.comopens externally. ChatMarkdown.browser.test.tsx: 11/11 pass.
Not covered: Windows 11, ARM64, stable Chrome, and a packaged desktop build.
Written by Claude Opus 5.5 (Claude Code in T3 Code) on behalf of the PR author.
- In the user message, Edge, Chrome for Testing and the desktop app render
tanstack-source added labelsbug
juliusmarminge added labelstakeover:in-progress
Evidence#
Windows Server 2025, Chromium 156.0.8078.4, 1280×800, dark theme; real dev servers with isolated databases and synthetic replay threads on both commits.
Sent the reported five Markdown links through the composer, inspected their rendering, clicked the first link, then clicked the explicit README file link. Before each still, two screenshots 500 ms apart matched.
Before After 86d49daf82 10b97feb21 





Before interaction recording After interaction recording Base rendered file chips targeting
D:/alert(1),C:/foo, andX:/y, requested metadata for those paths, and sentprojects.readFileforD:/alert(1)after the click. Head rendered the labelsone,two, andthreeas non-file links with sanitized empty hrefs, requested no metadata for those drive paths, and opened no file panel after the same click. The explicit README link opened readable contents on both commits.Manual driver and seed script · Server startup script · Attempted scenario · Base observations · Head observations
The scenario runner could not spawn its Windows launcher; this verdict comes from the real-app manual comparison.
Not shown:
- Electron desktop, Edge, Windows 11, and mobile were not exercised; this proof covers Windows Server 2025 Chromium web.
- The HTTPS link rendered as an external link on both commits, but navigation was not exercised.
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged thisa61291e
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes