Skip to content

Provide current page to integration block webframes#4362

Open
gregberge wants to merge 4 commits into
mainfrom
greg/rnd-11604-provide-current-page-pathid-to-webframe-in-integration-block
Open

Provide current page to integration block webframes#4362
gregberge wants to merge 4 commits into
mainfrom
greg/rnd-11604-provide-current-page-pathid-to-webframe-in-integration-block

Conversation

@gregberge

@gregberge gregberge commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Exposes the current page and a navigation capability to integration block webframes, over the client-only webframe state / postMessage channel (the same channel as adaptive visitor claims):

  • state.page — the current page as { id, path, title }, injected unconditionally (no dedicated scope — path/id/title are non-sensitive, with no shareKey or token).
  • @webframe.navigate — a webframe can post this action to navigate the reader to another page in the site (any section or space). Resolved client-side against the site base path via the Next.js router, so navigation stays in-site.

Both are delivered client-side (never through the integration render request), so the integration render cache is unchanged.

Why

RND-11604 — integrations (e.g. harness) need the current page inside a webframe and the ability to navigate to sibling pages within the space. Docs: GitbookIO/integrations#1230.

Notes

  • Per review, we dropped the dedicated site:page:context scope (avoiding another customer-specific integration scope). No @gitbook/api or backend change is needed — the gitbook-x companion PR was closed.
  • Known limitation: inside reusable content, contentContext.page resolves to the source content, so page may be null there.

Test plan

  • bun run typecheck — 27/27
  • bun test on adaptive.test.ts — 5/5
  • biome check on changed files — clean

🤖 Generated with Claude Code

gregberge and others added 2 commits July 3, 2026 14:07
Expose the current page (id, path, title) to integration block webframes via the client-only webframe state, reusing the same postMessage channel as adaptive visitor claims. The page is sourced from the block's server-side content context rather than the integration render request, so the integration render cache is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Only expose the current page to a webframe when the integration's render output declares it can access page context (canAccessPageContext), mirroring canAccessVisitorClaims. The @gitbook/api type does not yet include the flag, so the read is temporarily annotated with @ts-expect-error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 3, 2026

Copy link
Copy Markdown

RND-11604

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 31a53a7

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

This PR includes changesets to release 2 packages
Name Type
@gitbook/react-contentkit Patch
gitbook Patch

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

argos-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

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

Build Status Details Updated (UTC)
customers-v2-cloudflare (Inspect) ⚠️ Changes detected (Review) 25 changed Jul 3, 2026, 1:16 PM
customers-v2-vercel (Inspect) ⚠️ Changes detected (Review) 2 changed, 1 ignored Jul 3, 2026, 1:14 PM
v2-cloudflare (Inspect) ⚠️ Changes detected (Review) 1 changed, 2 ignored Jul 3, 2026, 1:17 PM
v2-vercel (Inspect) ✅ No changes detected - Jul 3, 2026, 1:15 PM

Per review (avoid another customer-specific integration scope): expose the current page to webframes unconditionally, since path/id/title are non-sensitive (no shareKey or token). Also add a @webframe.navigate action so a webframe can navigate the reader to another page within the space, resolved client-side against the space base path via the router.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address review: resolve the @webframe.navigate action against the site base path (toPathInSite) rather than the current space, so a webframe can navigate to a page in any section or space of the site.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant