Skip to content

docs: preload and accelerate local search - #2569

Closed
karakanb wants to merge 1 commit into
mainfrom
codex/optimize-search-speed-in-docs
Closed

docs: preload and accelerate local search#2569
karakanb wants to merge 1 commit into
mainfrom
codex/optimize-search-speed-in-docs

Conversation

@karakanb

Copy link
Copy Markdown
Contributor

Motivation

  • The docs site uses VitePress local search which lazily loads the search component and index and uses a 200ms debounce, causing noticeable delay for our large local index when opening the search popup and when typing queries.

Description

  • Add a Vite transform plugin fastLocalSearch in docs/.vitepress/config.mjs that injects an idle-time import('./VPLocalSearchBox.vue') to warm the local-search chunk so search UI opens without lazy-load delay.
  • Preload the local search index by invoking all localSearchIndex loaders while the reader is browsing so the ~2MB index is available before the user opens search.
  • Reduce the search debounce from { debounce: 200, immediate: true } to { debounce: 25, immediate: true } to tighten query-response latency.
  • Add defensive checks that throw clear build-time errors if upstream VitePress internal strings change, preventing silent regressions.

Testing

  • Ran npm run docs:build to validate the site build and asset generation, and it completed successfully.
  • Ran git diff --check and git status --short to validate the working tree and produced no actionable issues.
  • Attempted an automated search-performance measurement with Playwright (node .search-perf.cjs), but the headless Chromium/Playwright launch was blocked by the environment (snap/chromium and network-proxy download issues), so end-to-end timing could not be collected here.

Codex Task

@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Fix all with Greploop

Fix All in Conductor

Prompt To Fix All With AI
### Issue 1
docs/.vitepress/config.mjs:52
**Handle preload loader rejections**

A failed background index import rejects without a handler, producing an unhandled promise rejection even though search can retry the loader when opened.

```suggestion
                    `${searchIndexDeclaration}\n\n// Download the index while the reader is browsing instead of after search opens.\nObject.values(localSearchIndex).forEach((load) => load().catch(() => {}))`,
```

### Issue 2
docs/.vitepress/config.mjs:22-25
**Shorten the plugin commentary**

This four-line comment restates the upstream behavior, motivation, and implementation effects rather than providing the repository-required concise, location-specific explanation.

```suggestion
// Preload and tune VitePress local search for the large documentation index.
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "docs: preload and accelerate local searc..." | Re-trigger Greptile

return code
.replace(
searchIndexDeclaration,
`${searchIndexDeclaration}\n\n// Download the index while the reader is browsing instead of after search opens.\nObject.values(localSearchIndex).forEach((load) => load())`,

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.

P2 Handle preload loader rejections

A failed background index import rejects without a handler, producing an unhandled promise rejection even though search can retry the loader when opened.

Suggested change
`${searchIndexDeclaration}\n\n// Download the index while the reader is browsing instead of after search opens.\nObject.values(localSearchIndex).forEach((load) => load())`,
`${searchIndexDeclaration}\n\n// Download the index while the reader is browsing instead of after search opens.\nObject.values(localSearchIndex).forEach((load) => load().catch(() => {}))`,
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/.vitepress/config.mjs
Line: 52

Comment:
**Handle preload loader rejections**

A failed background index import rejects without a handler, producing an unhandled promise rejection even though search can retry the loader when opened.

```suggestion
                    `${searchIndexDeclaration}\n\n// Download the index while the reader is browsing instead of after search opens.\nObject.values(localSearchIndex).forEach((load) => load().catch(() => {}))`,
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Conductor

Comment on lines +22 to +25
// VitePress intentionally lazy-loads local search and waits 200 ms after each
// keystroke. That is a good default for small sites, but our large local index
// made opening and using search feel sluggish. Keep the search code and index
// warm, and use a short debounce so interaction stays below a frame or two.

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.

P2 Shorten the plugin commentary

This four-line comment restates the upstream behavior, motivation, and implementation effects rather than providing the repository-required concise, location-specific explanation.

Suggested change
// VitePress intentionally lazy-loads local search and waits 200 ms after each
// keystroke. That is a good default for small sites, but our large local index
// made opening and using search feel sluggish. Keep the search code and index
// warm, and use a short debounce so interaction stays below a frame or two.
// Preload and tune VitePress local search for the large documentation index.

Rule Used: What: Comments should be concise and targeted to s... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/.vitepress/config.mjs
Line: 22-25

Comment:
**Shorten the plugin commentary**

This four-line comment restates the upstream behavior, motivation, and implementation effects rather than providing the repository-required concise, location-specific explanation.

```suggestion
// Preload and tune VitePress local search for the large documentation index.
```

**Rule Used:** What: Comments should be concise and targeted to s... ([source](https://app.greptile.com/bruin/-/custom-context?memory=6adfbd2b-1b23-4560-9e00-6254e7cb7c70))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Conductor

@karakanb karakanb closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant