Skip to content

fix(frontend): recognize tab-separated web fetch headings - #6923

Merged
WillemJiang merged 3 commits into
bytedance:mainfrom
JY-M666:fix/web-fetch-tab-heading
Oct 16, 2026
Merged

WillemJiang merged 3 commits into
bytedance:mainfrom
JY-M666:fix/web-fetch-tab-heading

Conversation

@JY-M666

@JY-M666 JY-M666 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Why

extractTitleFromMarkdown() accepts only a literal space after the opening #. CommonMark also allows a tab. A web_fetch result beginning with #\tReport therefore 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

  • Accept either an ASCII space or tab after a single level-1 #.
  • Cover tab/mixed separators, three-space indentation, CRLF, closing hashes and empty titles; explicitly reject non-ATX whitespace separators.
  • Keep indented-code rejection, heading-level restrictions and the linear closing-hash scan unchanged.
  • Align the existing frontend guide with this delimiter rule. No dependencies or shared Markdown parser changes.

Surface area

  • Frontend UI — web-fetch tool-step title extraction
  • Backend API
  • Agents / LangGraph
  • Sandbox
  • Skills
  • Dependencies
  • Default behavior change — no new setting or provider default
  • Docs / tests / CI only

Screenshots / Recording

No browser screenshot captured. This changes title text, not layout. Deterministic helper result:

Input Before After
#\tReport undefined (UI uses URL) Report
#\tReport\r\nbody undefined Report
#\tReport ### undefined Report
\t# Report (indented code) undefined undefined

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

cd frontend
pnpm exec rstest run tests/unit/core/utils/markdown.test.ts

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 because sidecar-delete-gating.dom.test.tsx reports unhandled ECONNREFUSED 127.0.0.1:3000 errors 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.

  • I've read and understand every line of this change and take responsibility for it — it's not unreviewed AI output.

@JY-M666
JY-M666 marked this pull request as ready for review October 15, 2026 08:08
@github-actions github-actions Bot added area:docs Documentation and Markdown only area:frontend Next.js frontend under frontend/ risk:medium Medium risk: regular code changes size/S PR changes 20-100 lines labels Oct 15, 2026

@willem-bd willem-bd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@WillemJiang WillemJiang added this to the 2.2.0 milestone Oct 16, 2026
@WillemJiang
WillemJiang merged commit ec07de9 into bytedance:main Oct 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentation and Markdown only area:frontend Next.js frontend under frontend/ risk:medium Medium risk: regular code changes size/S PR changes 20-100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants