Skip to content

fix(shared): thread search indexes percent-encoded Windows file links as file chips - #43738

Merged
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
saphid:hunter/c-759b394751
Nov 26, 2026
Merged

juliusmarminge merged 1 commit into
pingdotgg:mainfrom
saphid:hunter/c-759b394751

Conversation

@saphid

@saphid saphid commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Percent-encoded Windows drive file links in assistant messages and plans (such as [report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>), emitted by codexFileCitationMarkdown / renderCodexDirectivesForCopy and serializeComposerFileLink) lose their href during CHAT_MARKDOWN_REHYPE_PLUGINS sanitization. Because remarkNormalizeLinksAndTagInlineCode only tests /^[A-Za-z]:[\\/]/ without decoding %5C, rehypeSanitize treats C: as a disallowed URL scheme and strips href, so thread search fails to index their line numbers and folder disambiguation labels even though web renders them as file chips via wordsHast.ts.

Deterministic repro on origin/main (a066eb0935da44bbb16571638138c218bfdbf775):

  • In a thread with an assistant reply containing See [report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>) for details., wait for the rendered report.md · L7 chip, open Find in thread (Ctrl+F / Cmd+F), and search for report.md · L7 (or run from packages/shared: node --input-type=module -e 'import { searchableMessageSegments } from "./src/threadFindText.ts"; console.log(JSON.stringify(searchableMessageSegments({ role: "assistant", text: "[report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>)", streaming: false })));').
  • Observed on origin/main: The web UI renders the report.md · L7 chip, but Find in thread reports 0/0 (CHAT_MARKDOWN_REHYPE_PLUGINS strips href to properties: {}, and searchableMessageSegments returns ["report.md"]).
  • Expected: remarkNormalizeLinksAndTagInlineCode rewrites the link to file:///C:/Users/test/report.md#L7 so href survives sanitization, Find in thread matches 1/1 and highlights report.md · L7, and searchableMessageSegments returns ["report.md · L7"].

Change

In remarkNormalizeLinksAndTagInlineCode (packages/shared/src/markdownPipeline.ts), replace /%5C/gi with \\ before matching /^[A-Za-z]:[\\/]/ and rewriting link and definition URLs to file:///${path.replaceAll("\\", "/")}, matching apps/web/src/markdown/wordsHast.ts. This preserves href through rehypeSanitize for every client backed by server-side ThreadFind (web, desktop, and mobile); web rendering (wordsHast.ts) and mobile rendering (parseMarkdownFileLink) already handle percent-encoded Windows paths. Added a focused regression test in packages/shared/src/markdownPipeline.test.ts.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Real-app proof (vp run scenarios:prove against origin/main a066eb0935da vs 0c320f468afc): Exited 0 — seeded an assistant reply containing See [report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>) for details. via a local ACP fixture, confirmed the rendered report.md · L7 chip, and searched report.md · L7 in Find in thread (Control+f):
    • Base (a066eb0935da): Failed (expected "0/0" to be "1/1").
    • Head (0c320f468afc): Passed (1/1, chip highlighted).
Base (a066eb0935da) — 0/0 Head (0c320f468afc) — 1/1
Base: Find in thread reports 0/0 for report.md · L7 Head: Find in thread matches 1/1 and highlights report.md · L7
  • Unit test (packages/shared/src/markdownPipeline.test.ts): Failed on unmodified origin/main (received [undefined, undefined, "file:///C:/Users/test/report.md", undefined]); passed 3/3 consecutive runs on 0c320f468afc (27/27 tests each run).
  • Changed-files gate: vp run check:changed exited 0 on 0c320f468afc (format, lint, knip 1/2 & 2/2, typecheck across 37 packages, and 2 affected test files / 29 tests).
  • Before/after transcript & captures: https://gist.github.com/saphid/5e8f006f332c3467558921bcd720dac9
  • Not shown: Native desktop Electron wrapper and iOS/Android mobile UI walkthroughs (both use the same server-side ThreadFind -> @t3tools/shared/threadFindText -> markdownPipeline.ts indexing path verified above).

Authored by Gemini 4 Neon (Antigravity); reviewed by GPT-6.1 Sol (Codex).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Markdown link processing now decodes percent-encoded backslashes before checking for Windows drive paths. Tests cover raw and encoded paths in inline and reference links, including preserved fragments.

Changes: Windows link path normalization

Layer / File(s) Summary
Decode and test Windows link paths
packages/shared/src/markdownPipeline.ts, packages/shared/src/markdownPipeline.test.ts
Link and definition URLs decode %5C sequences before the Windows drive-path check. Tests cover raw and encoded paths and verify normalized file:/// URLs with fragments.

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

Change: Bug fix

Suggested reviewers: juliusmarminge, matthewcosier

Merge Risk: Minimal · up to 0c320

Percent-encoded Windows file links now index correctly for thread search. The change is small and tested, and no actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (percent-encoded Windows file links indexed by thread search as file chips) and the changed area (shared package). It matches the main change: replacing %5C decoding in remarkN…
Description check Passed The description follows the template's main sections: Problem, Change, Scope, and Verification. The Problem section gives a clear root cause (the regex does not decode %5C, so rehypeSanitize strips hr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (percent-encoded Windows file links indexed by thread search as file chips) and the changed area (shared package). It matches the main change: replacing %5C decoding in remarkNormalizeLinksAndTagInlineCode so href survives sanitization. The title is long at 83 characters and uses 'thread search indexes' in a way that is slightly awkward, but it is related to the changeset.

Full details: Description check

Explanation

The description follows the template's main sections: Problem, Change, Scope, and Verification. The Problem section gives a clear root cause (the regex does not decode %5C, so rehypeSanitize strips href) and a reproduction path. The Change section names the function, file, and the rewrite rule. The Scope section explains why no issue is linked, as the template allows for small obvious fixes. Verification gives concrete before/after results, a unit test result, and a check run, and it states what was not shown (native Electron and iOS/Android walkthroughs). The template's opening comment asks for a conventional commit title in plain language; the title meets that. The description does not contain a model and harness attribution line at the end, but it does name the authoring model (Gemini 4 Neon, reviewed by GPT-6.1 Sol), so that requirement is met. Minor gaps: the Problem section is detailed rather than a sentence or two, and the verification evidence depends on an external gist.

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 a066eb0 and 0c320f4.

Files selected for processing: 2

  • packages/shared/src/markdownPipeline.test.ts
  • packages/shared/src/markdownPipeline.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created a fresh project and thread on each commit. The user prompt held the target Markdown only inside backticks; the replay assistant replied verbatim with See [report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>) for details. Opened the thread, pressed Ctrl+F, and searched report.md · L7.

Environment: real web app, isolated fresh database per commit, replay assistant, 1280×800 viewport, light theme.

Before After
a066eb0935 0c320f468a
Visible chip; search returns 0/0 Search returns 1/1 and highlights the chip
Before: chip visible but search returns zero matches After: one match with highlighted assistant chip
Before recording After recording

Reproduction scenario

The scenario runner exited 0: failed on base and passed on head.

Not shown:

  • Folder disambiguation and lowercase/reference-link variants were not exercised; this scenario covers the reported assistant chip and line-number search.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 26, 2026
@juliusmarminge
juliusmarminge merged commit 9b4943f into pingdotgg:main Nov 26, 2026
74 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants