Skip to content

feat: manual OAuth code paste#496

Merged
gewenyu99 merged 10 commits into
mainfrom
posthog-code/disable-ci-prod-and-manual-oauth-paste
Jun 3, 2026
Merged

feat: manual OAuth code paste#496
gewenyu99 merged 10 commits into
mainfrom
posthog-code/disable-ci-prod-and-manual-oauth-paste

Conversation

@gewenyu99
Copy link
Copy Markdown
Collaborator

@gewenyu99 gewenyu99 commented Jun 1, 2026

Problem

OAuth can't complete on headless/remote machines. The wizard opens a browser that redirects back to a local callback server (http://localhost:8239/callback?code=...). On a remote/SSH/headless box the browser can't reach that local server, so auth never completes and there's no way to finish by hand.

Changes

  • On the auth screen, while waiting for OAuth, pressing p opens a modal (ManualAuthCodeScreen) with a text input.
  • The user can paste either the full callback URL the browser landed on, or just the codeextractOAuthCode() (in oauth.ts) handles both, plus bare query strings, with URL-decoding.
  • performOAuthFlow races the local callback server against the manually-entered code (getUI().waitForManualAuthCode()), exchanging whichever arrives first using the in-scope redirect_uri so the token exchange stays valid.
  • Wired through the WizardUI interface: InkUI delegates to new store methods (showManualAuthCode / submitManualAuthCode / dismissManualAuthCode / waitForManualAuthCode); LoggingUI returns a never-resolving promise (CI bypasses OAuth entirely).
remote.oauth.flow.mp4

Two changes to the wizard:

1. Disable `--ci` mode in published builds. PostHog's LLM gateway doesn't
   grant the required scopes to personal API keys for most users yet, so
   non-interactive CI runs fail at the gateway. `--ci` now exits with a
   clear error in the published package (gated on `IS_PRODUCTION_BUILD`,
   which tsdown inlines as true only in `dist/`), and stays available for
   dev/test runs. README updated to note CI mode is unsupported.

2. Add a manual OAuth code-entry fallback. On the auth screen, pressing `p`
   while waiting for OAuth opens a modal where the user can paste either the
   full callback URL the browser landed on
   (`http://localhost:8239/callback?code=...`) or just the code. This lets
   headless/remote shells finish auth when the browser can't reach the local
   callback server. The OAuth flow races the local callback server against
   the manually-entered code.

Generated-By: PostHog Code
Task-Id: a42d87b2-d4a1-4f4a-9180-ea1d2ed40657
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@gewenyu99 gewenyu99 changed the title feat: disable --ci in published builds + manual OAuth code paste feat: manual OAuth code paste Jun 1, 2026
@gewenyu99 gewenyu99 requested a review from a team June 1, 2026 23:51
@gewenyu99 gewenyu99 marked this pull request as ready for review June 1, 2026 23:53
Copy link
Copy Markdown
Member

@edwinyjlim edwinyjlim left a comment

Choose a reason for hiding this comment

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

this is really slick

Comment thread src/ui/tui/screens/ManualAuthCodeScreen.tsx
@edwinyjlim
Copy link
Copy Markdown
Member

/wizard-ci basic-integration/next-js

@wizard-ci-bot
Copy link
Copy Markdown

wizard-ci-bot Bot commented Jun 2, 2026

🧙 Wizard CI Results

Trigger ID: c45edc2
Workflow: View run

App Confidence PR YARA
basic-integration/next-js/15-app-router-saas N/A Failed (logs)
basic-integration/next-js/15-app-router-todo N/A Failed (logs)
basic-integration/next-js/15-pages-router-saas pending
basic-integration/next-js/15-pages-router-todo N/A Failed (logs)

Configuration

Setting Value
Wizard ref posthog-code/disable-ci-prod-and-manual-oauth-paste
Context Mill ref main
PostHog ref master

Search for trigger ID c45edc2 in wizard-workbench PRs.

@gewenyu99
Copy link
Copy Markdown
Collaborator Author

/wizard-ci basic-integration/next-js

@gewenyu99
Copy link
Copy Markdown
Collaborator Author

Screen.Recording.2026-06-02.at.10.00.37.PM.mov

I really stripped it down. It is really ugly still but I think more clear (?)

It is a back up thing that (hopefully) most people will not need to see.

@gewenyu99 gewenyu99 enabled auto-merge (squash) June 3, 2026 12:59
@gewenyu99 gewenyu99 merged commit 0e43025 into main Jun 3, 2026
17 checks passed
@gewenyu99 gewenyu99 deleted the posthog-code/disable-ci-prod-and-manual-oauth-paste branch June 3, 2026 13:01
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