Repository navigation
fix(shared): thread search indexes percent-encoded Windows file links as file chips - #43738
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
EvidenceCreated a fresh project and thread on each commit. The user prompt held the target Markdown only inside backticks; the replay assistant replied verbatim with Environment: real web app, isolated fresh database per commit, replay assistant, 1280×800 viewport, light theme.
The scenario runner exited 0: failed on base and passed on head. Not shown:
|


Problem
Percent-encoded Windows drive file links in assistant messages and plans (such as
[report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>), emitted bycodexFileCitationMarkdown/renderCodexDirectivesForCopyandserializeComposerFileLink) lose theirhrefduringCHAT_MARKDOWN_REHYPE_PLUGINSsanitization. BecauseremarkNormalizeLinksAndTagInlineCodeonly tests/^[A-Za-z]:[\\/]/without decoding%5C,rehypeSanitizetreatsC:as a disallowed URL scheme and stripshref, so thread search fails to index their line numbers and folder disambiguation labels even though web renders them as file chips viawordsHast.ts.Deterministic repro on
origin/main(a066eb0935da44bbb16571638138c218bfdbf775):See [report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>) for details., wait for the renderedreport.md · L7chip, open Find in thread (Ctrl+F/Cmd+F), and search forreport.md · L7(or run frompackages/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 })));').origin/main: The web UI renders thereport.md · L7chip, but Find in thread reports0/0(CHAT_MARKDOWN_REHYPE_PLUGINSstripshreftoproperties: {}, andsearchableMessageSegmentsreturns["report.md"]).remarkNormalizeLinksAndTagInlineCoderewrites the link tofile:///C:/Users/test/report.md#L7sohrefsurvives sanitization, Find in thread matches1/1and highlightsreport.md · L7, andsearchableMessageSegmentsreturns["report.md · L7"].Change
In
remarkNormalizeLinksAndTagInlineCode(packages/shared/src/markdownPipeline.ts), replace/%5C/giwith\\before matching/^[A-Za-z]:[\\/]/and rewriting link and definition URLs tofile:///${path.replaceAll("\\", "/")}, matchingapps/web/src/markdown/wordsHast.ts. This preserveshrefthroughrehypeSanitizefor every client backed by server-sideThreadFind(web, desktop, and mobile); web rendering (wordsHast.ts) and mobile rendering (parseMarkdownFileLink) already handle percent-encoded Windows paths. Added a focused regression test inpackages/shared/src/markdownPipeline.test.ts.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
vp run scenarios:proveagainstorigin/maina066eb0935davs0c320f468afc): Exited0— seeded an assistant reply containingSee [report.md](<C:%5CUsers%5Ctest%5Creport.md#L7>) for details.via a local ACP fixture, confirmed the renderedreport.md · L7chip, and searchedreport.md · L7in Find in thread (Control+f):a066eb0935da): Failed (expected "0/0" to be "1/1").0c320f468afc): Passed (1/1, chip highlighted).a066eb0935da) —0/00c320f468afc) —1/1packages/shared/src/markdownPipeline.test.ts): Failed on unmodifiedorigin/main(received[undefined, undefined, "file:///C:/Users/test/report.md", undefined]); passed 3/3 consecutive runs on0c320f468afc(27/27 tests each run).vp run check:changedexited0on0c320f468afc(format, lint, knip 1/2 & 2/2, typecheck across 37 packages, and 2 affected test files / 29 tests).ThreadFind->@t3tools/shared/threadFindText->markdownPipeline.tsindexing path verified above).Authored by Gemini 4 Neon (Antigravity); reviewed by GPT-6.1 Sol (Codex).