Skip to content

feat: add rag option to search#22

Merged
dcrawbuck merged 1 commit intomainfrom
duncan/sw-3952-docs-make-search-results-actually-useful
Oct 24, 2025
Merged

feat: add rag option to search#22
dcrawbuck merged 1 commit intomainfrom
duncan/sw-3952-docs-make-search-results-actually-useful

Conversation

@dcrawbuck
Copy link
Collaborator

No description provided.

@linear
Copy link

linear bot commented Oct 24, 2025

@dcrawbuck
Copy link
Collaborator Author

@cursor @codex review plz

@cursor
Copy link

cursor bot commented Oct 24, 2025

High-level

Nice addition. The SEARCH_MODE switch with a clean fallback to Fumadocs, the title map for better labels, and the SearchDialog SDK dropdown/debounce UX are all solid.

Blockers

  • API route path mismatch
    • The API route exists at /api/search (src/app/api/search/route.ts), but the client calls /docs/api/search.
    • Update both occurrences to /api/search:
  const { search, setSearch, query } = useDocsSearch({
    type: 'fetch',
-   api: '/docs/api/search'
+   api: '/api/search'
  }, undefined, selectedSdk || undefined, SEARCH_DEBOUNCE_MS);
- const { search: defaultSearch, setSearch: defaultSetSearch, query } = useDocsSearch({ type: 'fetch', api: '/docs/api/search' });
+ const { search: defaultSearch, setSearch: defaultSetSearch, query } = useDocsSearch({ type: 'fetch', api: '/api/search' });
  • Missing dependency for generate-title-map
    • scripts/generate-title-map.ts imports from glob, but glob isn’t in devDependencies (repo has fast-glob).
    • Either add glob to devDependencies, or switch to fast-glob:
// scripts/generate-title-map.ts
import fg from 'fast-glob';
// ...
const files = await fg('**/*.{md,mdx}', { cwd: contentDir, absolute: false });

Suggestions (non-blocking)

  • Avoid double fetching: SearchDialog still calls useDocsSearch even when wrapped; consider making it purely presentational and let SearchDialogWrapper own data.
  • RAG transform: dedupe by URL to avoid multiple hits for the same file:
const seen = new Set<string>();
// before pushing
if (seen.has(url)) continue;
seen.add(url);
  • On RAG error, consider falling back to Fumadocs results instead of returning empty.
  • Add Cache-Control: no-store to search responses to prevent caching of queries.

Test plan

  • Fumadocs mode (default): SEARCH_MODE unset or fumadocs; query with/without SDK filter; verify results and tag badges.
  • RAG mode: set SEARCH_MODE=rag; verify POST to https://mcp.superwall.com/docs-search, titles resolve via title-map.json, links route correctly (strip /index, root index).
  • Title map generation: run bun run build:prep after removing src/lib/title-map.json; ensure file is regenerated and build succeeds.

If you want, I can push the two essential fixes (API path + fast-glob swap).


Open in Cursor Open in Web

Learn more about Cursor Agents

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1 to +4
import fs from 'fs';
import path from 'path';
import { glob } from 'glob';

Choose a reason for hiding this comment

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

P1 Badge Declare dependency for glob used in title map script

The new title map generator imports glob but package.json still has no glob dependency. Because build:prep now runs tsx scripts/generate-title-map.ts before every build/dev, a fresh install will raise Cannot find module 'glob' under bun/pnpm (which do not allow undeclared transitive deps). Add glob (or switch to the existing fast-glob) to the manifest to avoid a build-prep failure.

Useful? React with 👍 / 👎.

@dcrawbuck dcrawbuck added the preview Preview deploy for this PR (Superwall team only) label Oct 24, 2025
@dcrawbuck dcrawbuck merged commit 217f459 into main Oct 24, 2025
4 checks passed
@dcrawbuck dcrawbuck deleted the duncan/sw-3952-docs-make-search-results-actually-useful branch October 24, 2025 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Preview deploy for this PR (Superwall team only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant