Skip to content

fix(auth): define page before use in overview example#338

Open
dprevoznik wants to merge 4 commits intomainfrom
hypeship/fix-auth-overview-page-var
Open

fix(auth): define page before use in overview example#338
dprevoznik wants to merge 4 commits intomainfrom
hypeship/fix-auth-overview-page-var

Conversation

@dprevoznik
Copy link
Copy Markdown
Contributor

@dprevoznik dprevoznik commented Apr 21, 2026

Summary

The Step 3 ("Use the Profile") code snippet in auth/overview.mdx calls page.goto(...) but never defines page. Copy-pasting the snippet produces an immediate NameError (Python) / ReferenceError (TypeScript).

Fix

Mirror the canonical CDP connection pattern used in browsers/create-a-browser.mdx:

  • Rename the Kernel browser handle to kernelBrowser / kernel_browser so it does not collide with the Playwright Browser object.
  • Connect to the Kernel browser over CDP via Playwright.
  • Grab the first context and page, then call page.goto(...).

The snippet is now runnable as-is (assuming playwright is installed and the surrounding async context).

Test plan

  • Render auth/overview.mdx locally and confirm the Step 3 code block looks correct in both TypeScript and Python tabs.
  • Copy-paste each snippet into a fresh file and confirm no NameError/ReferenceError.

Note

Low Risk
Low risk: documentation-only changes that adjust example code, with no production logic or API behavior changes.

Overview
Fixes auth/overview.mdx examples so they run as-copied.

Updates the TypeScript and Python snippets to properly initialize the Kernel client, and changes the “Use the Profile” step to connect to the Kernel-launched browser via Playwright CDP (connectOverCDP/connect_over_cdp) and derive context/page before calling page.goto().

Reviewed by Cursor Bugbot for commit be1dc86. Bugbot is set up for automated code reviews on this repo. Configure here.

The 'Use the Profile' example called page.goto() without ever defining
page, causing a NameError/ReferenceError on copy-paste. Mirror the CDP
connection pattern from browsers/create-a-browser so the snippet is
runnable as-is.
@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented Apr 21, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Kernel 🟢 Ready View Preview Apr 21, 2026, 2:20 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Matches the dominant pattern across the docs (sync Kernel client with
async Playwright). Keeps the Step 3 Playwright block async, since that
mirrors browsers/create-a-browser.mdx.
@dprevoznik dprevoznik marked this pull request as ready for review April 21, 2026 17:41
@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: This PR modifies documentation (auth/overview.mdx) and does not change any API endpoints or Temporal workflows in the kernel repo.

To monitor this PR anyway, reply with @firetiger monitor this.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Risk assessment: Very Low.

I reviewed the diff directly. The PR only updates auth/overview.mdx and fixes the example snippets by creating/deriving page from the Playwright CDP connection before calling page.goto(...) (in both TypeScript and Python examples).

Why this is very low risk:

  • Scope is limited to one documentation file.
  • No production runtime code, auth logic, permissions, infra, or config changed.
  • Blast radius is documentation correctness only.

Approving accordingly.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Risk assessment after re-review: Very Low.

I evaluated the current diff directly. The PR only modifies auth/overview.mdx to fix example correctness (initializing SDK/client objects and defining page from the Playwright CDP connection before goto in TypeScript and Python snippets).

Why this remains very low risk:

  • Single documentation file changed
  • No production runtime code, auth enforcement, permissions, infra, or config changes
  • Blast radius is limited to docs/example accuracy

Current approval status is already APPROVED, so no additional approval action was taken.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Risk assessment after re-evaluating current diff: Very Low.

I assessed the code changes directly from the PR diff. The change scope is limited to auth/overview.mdx and updates example snippets to define SDK/browser/page objects before use.

Why this remains very low risk:

  • Only one documentation file changed
  • No production runtime codepaths modified
  • No auth enforcement, permissions, infrastructure, or configuration changes
  • Blast radius is limited to example correctness in docs

Current PR state is already approved, so no additional approval action was taken.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@dprevoznik dprevoznik requested a review from masnwilliams April 21, 2026 20:50
Copy link
Copy Markdown
Contributor

@masnwilliams masnwilliams left a comment

Choose a reason for hiding this comment

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

lgtm — pulls auth/overview.mdx into line with .docs/code-example-guide.md and the canonical browsers/create-a-browser.mdx CDP pattern.

heads up that the same class of bugs still exists in the sibling auth docs and isn't covered by this PR:

  • auth/hosted-ui.mdx — "Use the Profile" (step 5, ~L109) calls await page.goto(...) with no page defined, same as the bug this PR fixes. The "Complete Example" (~L173) also does kernel = Kernel() (sync client) followed by await kernel.auth.connections.create(...), which fails at runtime.
  • auth/programmatic.mdx — "Complete Example" (~L169) has the same sync-client-with-await issue.
  • auth/profiles.mdx — L32-37 does kernel = Kernel() then await kernel.profiles.create(...), same issue.

after this lands, auth/overview.mdx will be sync Python while the other three auth pages are still async, so the auth folder will be temporarily inconsistent. worth a follow-up PR to migrate the rest.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Risk assessment after reviewing the current diff: Very Low.

Assessment is based on the code changes themselves:

  • Only auth/overview.mdx is modified
  • Changes are limited to documentation example snippets (object initialization and variable definition before use)
  • No production runtime codepaths, auth enforcement, permissions, infrastructure, or config are changed
  • Blast radius is limited to docs/example correctness

The PR is already in an approved state, so I did not add another approval.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

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