Repository navigation
fix(frontend): recognize tab-separated web fetch headings - #6923
Conversation
willem-bd
left a comment
There was a problem hiding this comment.
Clean change, verified against head 44709da. The delimiter widening (# → #[ \t]) matches CommonMark: a reference parser (markdown-it, commonmark mode) accepts #\tReport as an ATX heading while still rejecting #NoSpace, tab/mixed-indent code blocks, and NBSP/EM-space/VT/FF separators — exactly what the new tests pin. The backwards closing-hash scan, the zero-to-three-space indentation rule, and the level-1-only restriction are unchanged, and I simulated the head helper against all 38 pre-existing plus new test expectations with no failures. The frontend/AGENTS.md guide update stays in sync with the new delimiter rule, the added cases live in the right node-project test file (tests/unit/core/utils/markdown.test.ts), and the only caller (message-group.tsx) degrades gracefully to the URL on undefined. The anchored bounded regex stays linear, so no backtracking or security concerns.
Why
extractTitleFromMarkdown()accepts only a literal space after the opening#. CommonMark also allows a tab. Aweb_fetchresult beginning with#\tReporttherefore falls back to displaying its URL rather than the document title in the tool step.Reproduced on upstream
2768b86fff918d55459dbcb3f38272cfff049143. This is a small title-display bug; fetched content is not lost. I searched existing issues/PRs for the helper name, ATX headings and tab-separated titles; I found no matching open fix. Related merged title work (#5560, #6103) addresses other cases.What changed
#.Surface area
Screenshots / Recording
No browser screenshot captured. This changes title text, not layout. Deterministic helper result:
#\tReportundefined(UI uses URL)Report#\tReport\r\nbodyundefinedReport#\tReport ###undefinedReport\t# Report(indented code)undefinedundefinedBug fix verification
Test:
frontend/tests/unit/core/utils/markdown.test.ts.With the new tests and the original production helper: 4 failed, 33 passed.
With the fix: 37 passed, no skips.
Validation
Validated with Node 24.9.0 and pinned pnpm 10.26.2 on WSL Linux:
pnpm install --frozen-lockfile— passed; lockfile unchanged.pnpm exec rstest run tests/unit/core/utils— 58 passed, no skips.pnpm check— full ESLint and TypeScript checks passed.pnpm exec prettier --check src/core/utils/markdown.ts tests/unit/core/utils/markdown.test.ts— passed.BETTER_AUTH_SECRET=local-dev-secret pnpm build— passed; shallow-clone modified-time warning from Nextra.pnpm exec rstest run— 3246 assertions passed, but exits nonzero becausesidecar-delete-gating.dom.test.tsxreports unhandledECONNREFUSED 127.0.0.1:3000errors fetching mock history. Restoring the original production helper and rerunning that file reproduces the same file-level failure (its 3 assertions pass). No unrelated test code was changed to conceal it.git diff --check— passed.Full lint/typecheck/build were run in a Linux-filesystem validation checkout with the identical three-file patch, after the first mounted-Windows-filesystem check timed out. Browser E2E and live-model workflows were not run.
AI assistance
Tool(s) used: OpenAI coding assistant via pi CLI.
How you used it: AI inspected current source and related PRs, reproduced the delimiter bug, added the tests, made the minimal fix and ran the checks above. The account owner authorized preparing and submitting this contribution. The account owner has confirmed personally reading and understanding every line of the diff and taking responsibility for the change.