Skip to content

Add Search tab to Docs Embed, refactor search into an embeddable frame#4185

Open
zenoachtig wants to merge 4 commits intomainfrom
zeno/rnd-9784-add-search-tab-to-docs-embed
Open

Add Search tab to Docs Embed, refactor search into an embeddable frame#4185
zenoachtig wants to merge 4 commits intomainfrom
zeno/rnd-9784-add-search-tab-to-docs-embed

Conversation

@zenoachtig
Copy link
Copy Markdown
Contributor

@zenoachtig zenoachtig commented Apr 14, 2026

This PR refactors search so it can be rendered as a reusable embeddable frame, while preserving the existing docs-site search experience.

CleanShot 2026-04-14 at 11 12 01@2x

On the docs site, search still uses the current model:

  • the input lives outside the results surface
  • focusing the input opens the existing popover-based results UI

Inside the docs embed, search can now be mounted as a first-class search tab:

  • the frame owns its own input
  • the same search core is reused instead of maintaining a separate embed-specific UI path

The main goal here was structural. We wanted search to stop being tightly coupled to one popover presentation, so we can support other layouts later without reworking the search logic again.

What changed

Search is now organized around a shared frame/controller split:

  • SearchFrame owns the frame-level UI
  • useSearchController owns search behavior and derived search state
  • SearchContainer keeps the existing docs-site input + popover composition
  • EmbeddableSearch renders the same frame directly as an embed tab

This also adds search as an embed tab and includes it in the default embed tab set.

Navigation and embed behavior

A large part of this work was simplifying how embedded navigation works.

The initial version introduced client-side search href rewriting to reinterpret site links inside the embed. That worked, but it pushed search-specific navigation logic into the render tree and expanded LinkContext in a way that felt too foundational for a narrow use case.

This PR aligns Search with AIChat instead:

  • search result fetches now accept asEmbeddable
  • the shared search route uses an embeddable linker when requested
  • the Ask server action also accepts asEmbeddable
  • Ask answer body links, Ask source links, and search result links are now generated correctly at the source

This keeps the client simpler and makes Search and AIChat consistent: both now treat embeddable mode as a server-side render/output option.

@linear
Copy link
Copy Markdown

linear bot commented Apr 14, 2026

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: 9d7d930

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
gitbook Minor
@gitbook/embed Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@argos-ci
Copy link
Copy Markdown

argos-ci bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2-cloudflare (Inspect) ✅ No changes detected - Apr 14, 2026, 2:33 PM
customers-v2-vercel (Inspect) ✅ No changes detected - Apr 14, 2026, 2:32 PM
v2-cloudflare (Inspect) ⚠️ Changes detected (Review) 12 changed Apr 14, 2026, 2:39 PM
v2-vercel (Inspect) ⚠️ Changes detected (Review) 36 changed Apr 14, 2026, 2:37 PM

Copy link
Copy Markdown

@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.

Reviewed commit: 6bc204541a

ℹ️ 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".

@zenoachtig zenoachtig force-pushed the zeno/rnd-9784-add-search-tab-to-docs-embed branch from 6bc2045 to 183ba55 Compare April 14, 2026 09:09
@@ -0,0 +1,16 @@
import type { RouteLayoutParams } from '@/app/utils';
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.

Why do we need a dynamic version of this page ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From Codex, please call its bluff because I don't know static vs dynamic well enough:

We need the dynamic page for route parity with the rest of the embed surface. Search is now a first-class embed tab, so it needs to exist in both the static and dynamic site trees, just like embed docs and embed assistant. It’s not additional behavior, just the dynamic route entry point using getEmbeddableDynamicContext().

@zenoachtig
Copy link
Copy Markdown
Contributor Author

@gitbook review

@zenoachtig
Copy link
Copy Markdown
Contributor Author

@gitbook review and update the docs

@zenoachtig
Copy link
Copy Markdown
Contributor Author

@gitbook-bot review and update docs

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.

2 participants