Skip to content

feat(search): let Site search ask a SearchSocket service - #1746

Merged
gregpriday merged 6 commits into
developfrom
feature/issue-1403-support-searchsocket-as-an-external
Nov 28, 2026
Merged

gregpriday merged 6 commits into
developfrom
feature/issue-1403-support-searchsocket-as-an-external

Conversation

@gregpriday

Copy link
Copy Markdown
Member

Site settings gain a Site search section that chooses between the site's own index and a SearchSocket service the author hosts. With SearchSocket chosen, the website's Site search sections and the WebMCP search_site tool ask the service's public search address, optionally scoped to one part of the site and opening each result at the words found. The exported site holds no secret: it only ever asks the public address, and the keys stay with the SearchSocket deployment.

Resolves #1403

Changes

  • Settings. site.search (src/shared/site-search.ts) holds provider, endpoint, pathPrefix and scrollToText, set through site.update and checked the same way in the engine and in Site settings. The address must be a literal https:// address with a host and no credentials, stored as browsers read it. Going back to the site's own index keeps the SearchSocket fields for a later switch, and null clears them all. Held edits during an AI turn read the settings one by one, History names the change, and the agent's project summary shows the settings while SearchSocket is chosen.
  • Generated search code. searchJs(state) binds site-search.js to the configured service, so code that imports it can't point it anywhere else, and the new searchSite(query, { signal, limit }) calls either the index or the service. The service is asked with POST {q, topK, groupBy: 'page', pathPrefix} and credentials: 'omit'. Results it can't link to are dropped: other origins, addresses outside the site's sub-path, // paths, escaped slashes, and anything SvelteKit's resolve() would read as route syntax. Each remaining page gets its closing slash once. An unreachable or malformed answer fails the search instead of quietly searching the local index. With scroll-to-text on, a result link carries a #:~:text= fragment and data-sveltekit-reload, so the browser opens the page at the matching heading or passage.
  • Foundation site.search (both committed releases; lock digests refreshed). The component calls searchSite with an AbortController. A newer search, a reset, a Back/Forward restore, a page change or leaving the page all stop a request in flight. The results body carries data-search-ignore. Like the earlier direct edits to these releases, this one needs mirroring in builder-components before the next pack refresh.
  • Markup for indexers.
    • Pages and posts hidden from site search carry <meta name="searchsocket:noindex" content="true" data-search-noindex />, and so do old-address redirects and the not-found page.
    • The header and footer roots, the skip link, the search form and every page or shell layer hidden at every size carry data-search-ignore.
    • These are emitted whatever the provider, so any indexer can use them.
  • Source export scaffold. A Source export of a site that asks SearchSocket adds searchsocket.config.ts (static-output over build/, respectRobotsNoindex: false so site search follows Builder's own switch, and notes on env keys, CORS and project ID). An existing file is never overwritten.
  • Editor preview. Instrumented output always uses the plain built-in search code: the preview's form-practice bridge answers requests that carry typed text, so a live request there can't be trusted. Site settings tells the author that the preview searches the site's own index.
  • codecheck's fetch ban is unchanged. The network call lives in the generated, settings-bound helper, not in authored code.

Not changed

  • A SearchSocket search reports the number of pages the service returned (at most 20) through the existing "N pages match" wording. The service has no exhaustive match count, and new wording would need en/ar/he translations.
  • Component placements hidden only by a root override, rather than by their own layer styles, aren't marked data-search-ignore.
  • A design's own layers are never marked data-search-ignore, because a placement or a variant can show them again.
  • An absolute current-origin result URL in a Source project's dev server (base '') under a sub-path site is dropped. Root-relative URLs, which SearchSocket's static-output mode writes, are unaffected.
  • A service heading that contains an ellipsis is never used as the scroll target. With no plain passage either, the result opens at its address.

Testing

  • New tests/unit/site-search-socket.test.ts (20 tests) runs the generated helper against a fake service and covers the settings, markup, scaffold and held edits.
  • The new SearchSocket block in tests/unit/site-search-visitor.test.ts runs in headless Chromium. It covers a semantic hit from ?q= with a base-path link, a text fragment and reload; a failed service; an overtaken search; and leaving the page, with the stopped requests seen as aborted. Both of its tests fail on the previous Foundation source.
  • The Site search render tests in tests/unit/site-settings-agents-text.test.ts.
  • Adjacent tests: 21 files, 570 tests.
  • Impact: 71 of 685 suite files (69 selected, with committed-packs, code-manifest and generation-cache swapped in for the lowest-ranked; plus history-steps and ai-turn-review after the fixes), all green.
  • Flaky: tests/unit/asset-files.test.ts (damaged smaller copy, Damaged responsive image copies go undetected in Assets and editable export #1459) failed twice under load and passes alone; this change doesn't reach it.
  • npm run typecheck:changed green.

- Site settings choose the site's own index or a SearchSocket search address, with an optional section and scroll-to-text
- The generated search code binds the chosen service; Foundation's Site search and the WebMCP tool call searchSite, with an abort signal
- Results are kept to links the site can take, each opened at the words found with a text fragment and a fresh load
- Pages hidden from site search, old addresses and the not-found page carry searchsocket:noindex with data-search-noindex
- The shell, the skip link, the search form and page layers hidden at every size carry data-search-ignore
- A Source export of a SearchSocket site adds searchsocket.config.ts
- Refresh the Foundation pack digests
…-support-searchsocket-as-an-external

# Conflicts:
#	src/agent/context.ts
#	src/agent/report.ts
#	src/engine/apply.ts
#	src/shared/ops.ts
# Conflicts:
#	resources/packs-dev/foundation-alt/pack.json
#	resources/packs.lock.json
#	resources/packs/foundation/pack.json
#	src/generator/index.ts
#	src/generator/search.ts
@gregpriday
gregpriday merged commit 2033ffa into develop Nov 28, 2026
1 of 3 checks passed
@gregpriday
gregpriday deleted the feature/issue-1403-support-searchsocket-as-an-external branch November 28, 2026 16:21
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.

Support SearchSocket as an external semantic search provider for Site search

1 participant