Skip to content

feat: better, faster search#167

Open
dcrawbuck wants to merge 6 commits intomainfrom
duncan/sw-5048-docs-improve-search-speed-and-quality
Open

feat: better, faster search#167
dcrawbuck wants to merge 6 commits intomainfrom
duncan/sw-5048-docs-improve-search-speed-and-quality

Conversation

@dcrawbuck
Copy link
Copy Markdown
Collaborator

@dcrawbuck dcrawbuck commented Apr 13, 2026

This switches production docs search to a prebuilt static FlexSearch index while keeping the API-backed path for development. It also adds SDK tag-aware indexing, reduces the search debounce, and generates the search bundle during normal and staging Cloudflare builds. The branch includes an end-to-end browser benchmark script that measures both API-backed and static-index search behavior against a supplied URL. Validation: bun test, bun run build:cf, and a local production-preview search smoke test.


Note

Medium Risk
Changes the docs search architecture and build pipeline (new static index generation and client-side loading), which could affect search correctness and deploy-time artifacts if misconfigured.

Overview
Production docs search now uses a prebuilt static FlexSearch index: a new build step generates dist/client/docs/search-index.json, and the search UI loads it via a new static search client instead of calling the search API.

Search indexing is updated to be scope/tag-aware (shared + SDK scopes), the search debounce is reduced, and the dev path continues to use the API route (now backed by the new FlexSearch-based docs search builder).

Adds tooling to evaluate search performance/behavior: a new benchmark:search script using agent-browser, plus dev-only Agentation integration for debugging.

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

@linear
Copy link
Copy Markdown

linear bot commented Apr 13, 2026

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 13, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
superwall-docs-staging 97dfa66 Apr 14 2026, 12:46 AM

const grouped = new Map<string, StaticSearchDocument[]>();

for (const id of results) {
const doc = index.get(id) as StaticSearchDocument | null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FlexSearch Document likely lacks get() method

High Severity

searchStaticSearchIndex calls index.get(id) to retrieve stored documents, but FlexSearch's Document class does not have a documented get() method. The documented API includes add, update, remove, search, and searchAsync, but no get(). If this method doesn't exist at runtime, it will throw a TypeError, completely breaking static search. Stored documents are typically accessed via index.store[id] or by using the enrich option in search.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 41dbe6a. Configure here.

@dcrawbuck dcrawbuck changed the title SW-5048 Use static FlexSearch for docs search feat: better, faster search Apr 14, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 97dfa66. Configure here.

await runAgentBrowser(sessionName, profileDir, cwd, ["fill", inputRef, currentValue]);
if (!currentValue.endsWith(char)) {
throw new Error("failed to update search input during typing simulation");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Benchmark typing validation checks local variable, not browser

Low Severity

The validation currentValue.endsWith(char) is a tautology — currentValue was just set to ${currentValue}${char} on line 443, so it always ends with char. This error is never thrown. The intent was likely to verify the browser input state was updated, not the local variable. As written, the typing simulation silently proceeds even if the browser fill command fails.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 97dfa66. Configure here.

"flutter",
"expo",
"react-native",
] as const;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Exported constants only used within defining module

Low Severity

SHARED_SEARCH_GROUP, COMMUNITY_SEARCH_GROUP, and SDK_SEARCH_GROUPS are all exported but never imported by any other file in the codebase. They're only referenced internally within search.shared.ts itself (in the type definitions and helper functions). These exports expand the module's public API surface without any consumers.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 97dfa66. Configure here.

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