Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): one-letter link schemes no longer become file links on Windows #24006

MergedZacharon(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/24006/headmerged by juliusmarminge View on GitHub

Problem

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:foo and x:y become file:///D:/alert(1), file:///C:/foo and file:///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 schemes fails because the output contains href="D:/alert(1)"; the other 5 pass. With the fix, 6/6 pass.
  • Related tests pass with the fix: shared fileLinks, markdownLinks and path (63), client-runtime markdownImages (12), web unit markdown-links and terminal-links (48), and the three markdown browser test files (12).
  • vp run check:changed: format, lint, knip, typecheck (28 packages) and the fileLinks test pass. On Windows this needed a local workaround for check:changed spawning vp.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

    2. Approvability

      Verdict: Approved at eb2e68f

      Macroscope'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 file: URL handling. It affects only existing markdown/file-link parsing paths and introduces no schema, deployment, default, or static-analysis changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      parseFileUrlHref now checks that the trimmed, lowercased input starts with file: before parsing. A regression test verifies that a one-letter scheme returns null.

      Changes: File URL Validation

      Layer / File(s)Summary
      Validate the file URL prefix
      packages/shared/src/fileLinks.ts, packages/shared/src/fileLinks.test.ts
      parseFileUrlHref rejects inputs without a file: prefix. A regression test verifies rejection of d:x when 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 to 10b97

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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

      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.ts
      • packages/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.

    4. maria-rckscommented

      Note

      Written by gpt-6.1-sol on behalf of Maria

      Verified in a real dev environment

      verified the linux web path at exact head eb2e68f35a5dac7fe2c919bc3d4c4f23ea268fa8, after running github/main (5ef56853ef) in a separate worktree first. used vp 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-sol turns 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, and x:y rendered without an href. clicking them did not navigate or open a file.
      • file:///home/user/link-verification/README.md#L3 rendered as a file chip. clicking it loaded the real file in the panel and highlighted line 3.
      • https://example.com retained 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 807319c276c6831b2c219640e9da5b38019a8f1d passed 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:

      main linux baseline with real codex link response

      pr head with matching prompt and data:

      pr head linux codex response with blocked schemes and valid file chip

      pr head opens the real readme and highlights line 3

      pr head link clicks and file panel interaction

      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, and x:y unchanged from new URL(...).href; it does not convert them to file: 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.

    5. Native Windows check at eb2e68f35a5dac7fe2c919bc3d4c4f23ea268fa8

      Host: 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, using vp run dev / vp run dev:desktop with an isolated T3CODE_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:foo and x:y as file chips (D:/alert(1), C:/foo, X:/y). Clicking alert(1) opens the file panel with "could not be accessed or read" and the attempted path D:/alert(1).
      • ChatMarkdown.browser.test.tsx: still rejects unsafe schemes fails 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 as javascript: links already do on main.
      • The README chip opens the file with line 3 highlighted. https://example.com opens 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.

    6. tanstack-source added labelsbug

    7. juliusmarminge added labelstakeover:in-progress

    8. 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.

      BeforeAfter
      86d49daf8210b97feb21
      Before: one-letter schemes become file chipsAfter: one-letter schemes are not file chips
      Before: clicking the first link opens the D drive file errorAfter: clicking the first link opens no file panel
      Before: explicit README file link opens successfullyAfter: explicit README file link still opens successfully
      Before interaction recordingAfter interaction recording

      Base rendered file chips targeting D:/alert(1), C:/foo, and X:/y, requested metadata for those paths, and sent projects.readFile for D:/alert(1) after the click. Head rendered the labels one, two, and three as 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.
    9. juliusmarminge added labelstakeover:ready

    10. juliusmarminge removed labelstakeover:in-progress

    11. juliusmarminge merged thisa61291e

    12. juliusmarminge closed this

    13. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.