Skip to content

fix(chunkers): preserve FAQ prose in docs chunks - #6383

Merged
j15z merged 3 commits into
stagingfrom
feat/docs-chunker-prose
Aug 7, 2026
Merged

fix(chunkers): preserve FAQ prose in docs chunks#6383
j15z merged 3 commits into
stagingfrom
feat/docs-chunker-prose

Conversation

@j15z

@j15z j15z commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What

The docs chunker's cleanContent deletes every FAQ section before embedding:

  • The multiline tag regex swallows entire <FAQ items={[...]}/> blocks — it matches from <FAQ to the first >, which is often inside an answer string — and the brace strip eats any surviving { question: ..., answer: ... } items.
  • Net effect: 637 Q&As across the docs never reach the search index, and mangled JSX fragments get embedded in their place.

This PR makes the chunker consume FAQ components whole (before the tag strip runs) and emit their question/answer text as plain prose. The extraction is escape-aware, so quotes and braces inside answers survive intact. Tag and brace stripping are otherwise byte-identical to today — a corpus survey confirmed FAQ props are the only place real page prose lives inside JSX syntax on searchable pages, so nothing else needed rescuing.

Why it matters

FAQ answers are the docs' most retrieval-shaped content — literal user questions paired with concrete answers ("What is the maximum file size for uploads?" → "20 MB"). Today a semantic search for exactly that question cannot match it, because the text isn't in the index. This fix applies to the existing docs_embeddings pipeline, so current production search benefits on the next index rebuild — no dependency on other in-flight work.

Testing

  • New docs-chunker.test.ts: the 20 MB regression on the real page shape, nested-brace and angle-token answers, multiline item formatting, escaped quotes, unchanged scaffolding strips.
  • Full-corpus validation: 637/637 FAQ questions preserved in cleaned output across apps/docs/content/docs/en, zero JSX debris.
  • Full local reindex ran clean: 402 pages / 0 failures.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 7, 2026 7:59pm

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to docs chunking/cleaning for embeddings; no auth or runtime API changes, with tests locking FAQ extraction behavior.

Overview
Docs search indexing was dropping FAQ content: cleanContent ran generic tag and brace stripping on <FAQ items={[...]} /> blocks, so multiline FAQ JSX (often ending at > inside answers) and { question, answer } objects were removed instead of embedded.

This change extracts FAQ blocks first—before the existing tag/brace passes—and writes question/answer strings as plain text. Parsing is escape-aware for single/double quotes, multiline items, and optional trailing commas; emitted text strips <, >, {, } wrappers so later strips cannot eat answers that mention tokens like data:{mime} or <gmail.attachments[0]>.

Adds docs-chunker.test.ts covering regression shapes, nested tokens in answers, and unchanged behavior for imports, exports, comments, and other JSX scaffolding.

Reviewed by Cursor Bugbot for commit b71444b. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates docs chunk cleaning to preserve FAQ questions and answers as searchable prose while retaining the existing cleanup behavior for other JSX scaffolding.

  • Extracts double- and single-quoted FAQ item strings before generic tag and brace removal.
  • Handles multiline items, trailing commas, escaped quotes, braces, and angle-bracket tokens.
  • Adds focused regression coverage for production FAQ shapes and unchanged scaffolding removal.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/chunkers/docs-chunker.ts Adds escape-aware extraction for both quote styles before existing JSX cleanup, and the previously reported single-quote omission is corrected.
apps/sim/lib/chunkers/docs-chunker.test.ts Adds regression tests covering production FAQ syntax, difficult inline tokens, escaped quotes, and preservation of existing cleanup behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Raw MDX documentation] --> B[Extract FAQ components]
  B --> C[Emit question and answer prose]
  C --> D[Strip remaining JSX scaffolding]
  D --> E[Split cleaned content into chunks]
  E --> F[Generate and persist docs embeddings]
Loading

Reviews (3): Last reviewed commit: "fix(chunkers): accept single-quoted FAQ ..." | Re-trigger Greptile

Comment thread apps/sim/lib/chunkers/docs-chunker.ts Outdated
Comment thread apps/sim/lib/chunkers/docs-chunker.ts Outdated
Comment thread apps/sim/lib/chunkers/docs-chunker.ts Outdated
@j15z
j15z force-pushed the feat/docs-chunker-prose branch from 58af8aa to cce016d Compare August 7, 2026 19:27
@j15z j15z changed the title fix(chunkers): preserve FAQ and component-attribute prose in docs chunks fix(chunkers): preserve FAQ prose in docs chunks Aug 7, 2026
cleanContent deleted every FAQ section from the embedding index: the
multiline tag strip swallows an entire <FAQ items={[...]}/> block (it
matches from <FAQ to the first ">", often inside an answer string), and
the brace strip eats any surviving { question, answer } items — 637
Q&As across the docs never reached search, with mangled JSX fragments
embedded in their place. Consume FAQ blocks whole before the tag strip
and emit their question/answer text as plain prose, escape-aware so
braces and quotes inside answers survive. Tag and brace stripping are
otherwise unchanged — a corpus survey showed FAQ props are the only
place real page prose lives inside JSX syntax on searchable pages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@j15z
j15z force-pushed the feat/docs-chunker-prose branch from cce016d to 0a03670 Compare August 7, 2026 19:32
session-policies.mdx and verified-domains.mdx write FAQ items with
single-quoted multiline values and trailing commas; the double-quote-only
item pattern matched nothing there, so the component consumer replaced
those whole FAQ blocks with a space. Capture either quote style
escape-aware (quotes of the other style inside a value are fine) and
allow the trailing comma; captured values keep their quotes and are
unquoted before unescaping.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@j15z

j15z commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/chunkers/docs-chunker.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e814d46. Configure here.

@j15z

j15z commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e814d46. Configure here.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@j15z
j15z merged commit 9b80fdd into staging Aug 7, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant