-
Notifications
You must be signed in to change notification settings - Fork 3
feat: faster search #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dcrawbuck
merged 11 commits into
main
from
duncan/sw-5048-docs-improve-search-speed-and-quality
Apr 16, 2026
Merged
feat: faster search #167
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
41dbe6a
Use static FlexSearch for docs search
dcrawbuck fa01d4a
Scope SDK search and add Superchat shortcut
dcrawbuck bb31011
Shorten search scope labels
dcrawbuck 436f881
Close Superchat from search hotkeys
dcrawbuck cc2bc61
Polish docs AI entry and add Agentation
dcrawbuck 97dfa66
Fix static search parity and index serialization
dcrawbuck c89d158
Simplify docs search to a strict static monolith
dcrawbuck c18f2af
Fix static search filtering and cache freshness
dcrawbuck 5b5fc72
Move agentation to dev dependencies
dcrawbuck 1b23c07
Fix scoped static search retrieval
dcrawbuck bebda95
Harden static search scoring and export
dcrawbuck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import fs from "node:fs/promises"; | ||
| import path from "node:path"; | ||
| import { createServer } from "vite"; | ||
| import react from "@vitejs/plugin-react"; | ||
| import mdx from "fumadocs-mdx/vite"; | ||
| import tsConfigPaths from "vite-tsconfig-paths"; | ||
|
|
||
| const DIST_CLIENT = path.join(process.cwd(), "dist/client"); | ||
|
|
||
| async function main() { | ||
| console.log("Generating static search index…"); | ||
|
|
||
| const server = await createServer({ | ||
| configFile: false, | ||
| logLevel: "error", | ||
| server: { port: 0, host: "127.0.0.1" }, | ||
| resolve: { | ||
| alias: { "@": path.resolve(process.cwd(), "./src") }, | ||
| }, | ||
| plugins: [ | ||
| mdx(await import("../source.config")), | ||
| tsConfigPaths({ projects: ["./tsconfig.json"] }), | ||
| react(), | ||
| ], | ||
| }); | ||
|
|
||
| try { | ||
| const { buildDocsSearchDocuments } = await server.ssrLoadModule( | ||
| "./src/lib/search", | ||
| ); | ||
| const { SEARCH_INDEX_FILENAME } = await server.ssrLoadModule( | ||
| "./src/lib/search.shared", | ||
| ); | ||
| const { buildStaticSearchIndex, exportStaticSearchIndex } = await server.ssrLoadModule( | ||
| "./src/lib/search-index", | ||
| ); | ||
|
|
||
| const outputDir = path.join(DIST_CLIENT, "docs"); | ||
| const outputPath = path.join(outputDir, SEARCH_INDEX_FILENAME); | ||
| const documents = await buildDocsSearchDocuments(); | ||
|
|
||
| await fs.rm(path.join(outputDir, "assets", "search"), { force: true, recursive: true }); | ||
| await fs.mkdir(outputDir, { recursive: true }); | ||
| const index = buildStaticSearchIndex(documents); | ||
| const payload = JSON.stringify(await exportStaticSearchIndex(index)); | ||
|
|
||
| await fs.writeFile(outputPath, payload); | ||
|
|
||
| const bytes = Buffer.byteLength(payload); | ||
| console.log( | ||
| ` ✓ search index written to ${path.relative(process.cwd(), outputPath)} (${bytes.toLocaleString()} bytes)`, | ||
| ); | ||
| } finally { | ||
| await server.close(); | ||
| } | ||
| } | ||
|
|
||
| main().catch((err) => { | ||
| console.error("Static search index generation failed:", err); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.