Skip to content

Expose the current page context to integration block webframes#4411

Merged
gregberge merged 4 commits into
mainfrom
greg/rnd-12101-allow-webframe-in-integration-block-to-be-aware-of-the-full
Jul 17, 2026
Merged

Expose the current page context to integration block webframes#4411
gregberge merged 4 commits into
mainfrom
greg/rnd-12101-allow-webframe-in-integration-block-to-be-aware-of-the-full

Conversation

@gregberge

@gregberge gregberge commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What

Bring back the current-page context for integration block webframes: a webframe now receives the current page as state.page = { id, path, title } over the client-only postMessage channel (the same channel as adaptive visitor claims).

This was added in #4362 but removed before merge (commit a5f3b7e) as part of a scope reduction. This PR restores it.

Why

RND-12101 — an integration's webframe needs to be aware of the page it is rendered on (e.g. to build links to sibling pages, or adapt its content to the current page).

How it's wired

  • The page is sourced from the block's server-side content context (getWebframePageContext), not the integration render request, so the integration render cache is unaffected.
  • ContentKitWithClientContext exposes it through getPageContext; ElementWebframe merges it into the webframe state as state.page, alongside visitor claims.
  • Page context is non-sensitive (id/path/title, no token or shareKey), so it is always exposed — no new integration scope.

Usage (from inside a webframe)

window.addEventListener("message", (event) => {
    const state = event.data?.state;
    if (state?.page) {
        const { id, path, title } = state.page;
        // e.g. build a link to a sibling page from `path`
    }
});

Notes

Test plan

  • bun test on adaptive.test.ts — 5/5
  • bun run typecheck — no new errors from this change
  • biome check on changed files — clean

🤖 Generated with Claude Code

gregberge and others added 2 commits July 17, 2026 09:56
A webframe receives the current page (id, path, title) as `state.page`
through the client-only webframe state, sourced from the block's
server-side content context so the integration render cache is unaffected.
This restores the page context that was removed before #4362 merged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 17, 2026

Copy link
Copy Markdown

RND-12101

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 54e4602

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 17, 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) 👍 Approved by Greg Bergé 53 changed, 4 removed, 3 ignored Jul 17, 2026, 9:58 AM
customers-v2-vercel (Inspect) 👍 Approved by Greg Bergé 6 changed, 4 removed, 6 ignored Jul 17, 2026, 9:56 AM
v2-cloudflare (Inspect) 👍 Approved by Greg Bergé 12 changed, 3 ignored Jul 17, 2026, 9:59 AM
v2-vercel (Inspect) 👍 Approved by Greg Bergé 4 changed, 6 ignored Jul 17, 2026, 9:58 AM

`state.page.path` now includes the section and variant (site-relative)
instead of being space-relative, so it matches how `@webframe.navigate`
resolves a path and can be passed straight back to it. Resolved through the
linker's `toRelativePathInSite(toPathInSpace(...))`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The site no longer exists, so its visual test errors out and blocks CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gregberge
gregberge merged commit 6083a88 into main Jul 17, 2026
17 checks passed
@gregberge
gregberge deleted the greg/rnd-12101-allow-webframe-in-integration-block-to-be-aware-of-the-full branch July 17, 2026 10:06
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