Skip to content

Refresh demo and listen workflow#203

Merged
maxktz merged 13 commits into
mainfrom
feat/demo-refresh
Jun 30, 2026
Merged

Refresh demo and listen workflow#203
maxktz merged 13 commits into
mainfrom
feat/demo-refresh

Conversation

@maxktz

@maxktz maxktz commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a random demo account signup path that copies generated credentials and shows toasts
  • migrate demo command orchestration to pnpm while keeping Bun as the PayKit CLI runtime where needed
  • simplify demo PayKit config discovery and remove local tunnel/env-sourcing scripts
  • add paykitjs listen -- <command> support with prefixed output, clean non-spinner status lines, and fast single Ctrl-C shutdown
  • document the combined listen/run workflow

Checks

  • pnpm --filter paykitjs typecheck
  • pnpm exec oxlint packages/paykit/src/cli/commands/listen.ts
  • node ./node_modules/vitest/vitest.mjs run --config vitest.unit.config.ts packages/paykit/src/cli/__tests__
  • pnpm exec oxfmt --check packages/paykit/src/cli/commands/listen.ts packages/paykit/package.json pnpm-lock.yaml
  • git diff --check
  • manually verified pnpm paykitjs listen -- pnpm dev in the demo app with clean output and single Ctrl-C shutdown

Summary by cubic

Refreshes the demo app and expands paykitjs listen to run your app and webhook listener together with clean, prefixed logs and quick Ctrl‑C shutdown.

  • New Features

    • paykitjs listen -- <command> runs your dev server and listener together with prefixed output (pay/app), non‑spinner status lines, clean Ctrl‑C, and correct exit codes.
    • Random demo signup: generates email/password, copies to clipboard, and shows toasts; falls back gracefully if clipboard fails.
    • Docs: added CLI and webhook local dev examples, plus options (--config, --retry, --forward-to).
  • Refactors

    • Demo: moved orchestration to pnpm; removed tunnel/env scripts; switched Vercel build/install to pnpm; removed custom paykit.config.ts via default config discovery.
    • CLI: improved config loading (default export interop); init now detects local paykitjs and suggests package‑manager‑aware paykitjs listen -- <dev> or falls back to stripe listen; tests updated.
    • Dependencies: added concurrently to power the combined workflow.

Written for commit 5fbd747. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Added paykitjs listen for local webhook development, including replaying missed events and forwarding.
    • Added one-click random test account creation with credential copy in the demo auth form.
  • Bug Fixes
    • Improved CLI webhook command generation to better match the active package manager.
    • Enhanced the webhook listener to shut down cleanly on abort, including clearer output when the spinner is disabled.
  • Documentation
    • Expanded CLI and webhook docs with local development instructions and command examples.
  • Chores
    • Updated demo deploy/push/sandbox scripts to use pnpm and streamlined the demo push flow.

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
paykit Skipped Skipped Jun 30, 2026 4:46am

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 44aeb902-3894-472f-856a-fd14e9e36702

📥 Commits

Reviewing files that changed from the base of the PR and between e1d18c1 and 5fbd747.

📒 Files selected for processing (2)
  • packages/paykit/src/cli/__tests__/init.test.ts
  • packages/paykit/src/cli/commands/init.ts

📝 Walkthrough

Walkthrough

The PR updates paykitjs listen for abort-aware shutdown and optional concurrent command execution, changes init-time listen command generation, migrates demo scripts to pnpm, adds random test account creation, and refreshes docs and package metadata.

Changes

paykitjs listen command flow

Layer / File(s) Summary
Abort-aware listen loop
packages/paykit/src/cli/commands/listen.ts, packages/paykit/src/cli/utils/dev-logger.ts
sleep, consumeTunnelSocket, and listenAction gain AbortSignal handling and early-abort checks, and createDevLogger adds a spinner-disabled status output mode.
Concurrent command wiring
packages/paykit/src/cli/commands/listen.ts
listenCommand accepts an optional [command...] argument and routes execution through listenWithRunCommand, which uses concurrently and maps close events to exit behavior.

Init listen command generation

Layer / File(s) Summary
Listen command helpers and init flow
packages/paykit/src/cli/commands/init.ts
The init flow now builds package-manager-aware paykitjs listen commands, falls back to stripe listen, and updates the next-steps text.
Init command tests
packages/paykit/src/cli/__tests__/init.test.ts
The init tests now assert the pnpm/npm listen command variants, the stripe fallback command, and project-directory CLI detection.

Demo app script and auth changes

Layer / File(s) Summary
pnpm script migration
apps/demo/package.json, apps/demo/scripts/push-sandbox.ts, apps/demo/scripts/deploy-sandbox.ts, apps/demo/scripts/sandbox.ts
Demo scripts and sandbox command generation switch from bun/bunx to pnpm, and the explicit paykit.config.ts argument is removed from the push flow.
Random test account flow
apps/demo/src/app/_components/auth-form.tsx
AuthForm adds random credential generation, clipboard copy helpers, toast feedback, and a secondary button that creates a random test account.

Package metadata, config loading, and docs

Layer / File(s) Summary
Package metadata and config loading
packages/paykit/package.json, packages/paykit/src/cli/utils/get-config.ts, AGENTS.md
Package export field ordering changes, concurrently is added, Jiti default-export interop is enabled, and AGENTS guidance adds two behavior bullets.
Listen docs updates
apps/web/content/docs/cli.mdx, apps/web/content/docs/webhook-events.mdx
The CLI and webhook-events docs add local-development usage for paykitjs listen, including options and example commands.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • getpaykit/paykit#173: Both PRs modify the core webhook listen workflow in packages/paykit/src/cli/commands/listen.ts and related webhook handling paths.
  • getpaykit/paykit#188: Both PRs change packages/paykit/src/cli/commands/listen.ts and its tunnel/websocket control flow.
  • getpaykit/paykit#195: Both PRs touch the PayKit CLI init/listen command wiring that decides between paykitjs listen and stripe listen.

Poem

🐇 I hopped through tunnels, soft and bright,
With pnpm footprints in the night.
A random account sprang up to play,
And webhooks hummed in dev today.
The logs stayed calm, the signals knew,
This little PR felt neat and new.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately captures the main theme of the changes: refreshing the demo and listen workflow.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/demo-refresh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
apps/web/content/docs/cli.mdx (1)

46-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider updating the example to use pnpm dev to align with the pnpm migration.

The PR migrates demo scripts to pnpm. While this is general documentation, using pnpm dev instead of bun dev in the example would be more consistent with the current project state and avoids implying Bun is required for the app command.

-npx paykitjs listen -- bun dev
+npx paykitjs listen -- pnpm dev
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/content/docs/cli.mdx` around lines 46 - 47, The CLI docs example
still shows a Bun-based app command, which is inconsistent with the pnpm
migration. Update the example in the docs content to use pnpm dev instead of bun
dev, keeping the surrounding listen command intact so the documented workflow
matches the current project scripts and terminology.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/demo/src/app/_components/auth-form.tsx`:
- Around line 90-92: The auth flow is still racy because only the buttons are
disabled; the <form onSubmit={handleSubmit}> path can still start while the
random-account flow in handleRandomAccount is in progress. Add guard clauses at
the start of both handleSubmit and handleRandomAccount in auth-form.tsx so they
return immediately if either loading state is already true, or otherwise ensure
the entire form surface is disabled while one auth action is active.
- Around line 25-31: The copy flow in copyCredentials currently returns
immediately after navigator.clipboard.writeText succeeds, but it does not handle
the case where writeText rejects while navigator.clipboard still exists. Update
copyCredentials to wrap the clipboard write in a try/catch and, on failure,
continue to the textarea fallback logic instead of exiting early so the fallback
is used on the exact error path.

In `@packages/paykit/src/cli/commands/init.ts`:
- Around line 85-92: The getWebhookListenCommand helper is no longer consistent
with its port argument because the returned PayKit CLI command does not vary by
port. Update getWebhookListenCommand so the generated command either includes
the provided port in the paykitjs listen flow or remove port from the function
signature and its callers if listen no longer uses it; use the existing
getExecPrefix, getDevCommand, and hasPaykitCli branching to keep the onboarding
command aligned with the selected port.

In `@packages/paykit/src/cli/commands/listen.ts`:
- Around line 457-458: The onAbort handler in listen.ts is waiting on
processing.finally(...) before settling, which can delay shutdown behind an
in-flight request. Update onAbort to settle the consumer immediately via
settle(() => resolve({ code: 1000, reason: "aborted" })) first, then perform the
socket close/cleanup separately so the existing processing.catch(...) path can
handle any late failure. Use the onAbort and processing symbols to locate and
adjust this shutdown flow.

---

Nitpick comments:
In `@apps/web/content/docs/cli.mdx`:
- Around line 46-47: The CLI docs example still shows a Bun-based app command,
which is inconsistent with the pnpm migration. Update the example in the docs
content to use pnpm dev instead of bun dev, keeping the surrounding listen
command intact so the documented workflow matches the current project scripts
and terminology.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7cc5dc72-72c2-491d-bf19-2814334c75fb

📥 Commits

Reviewing files that changed from the base of the PR and between 0689e65 and f50b360.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • AGENTS.md
  • apps/demo/package.json
  • apps/demo/paykit.config.ts
  • apps/demo/scripts/deploy-sandbox.ts
  • apps/demo/scripts/push-sandbox.ts
  • apps/demo/scripts/sandbox.ts
  • apps/demo/src/app/_components/auth-form.tsx
  • apps/web/content/docs/cli.mdx
  • apps/web/content/docs/webhook-events.mdx
  • packages/paykit/package.json
  • packages/paykit/src/cli/__tests__/init.test.ts
  • packages/paykit/src/cli/commands/init.ts
  • packages/paykit/src/cli/commands/listen.ts
  • packages/paykit/src/cli/utils/dev-logger.ts
  • packages/paykit/src/cli/utils/get-config.ts
💤 Files with no reviewable changes (1)
  • apps/demo/paykit.config.ts

Comment thread apps/demo/src/app/_components/auth-form.tsx
Comment thread apps/demo/src/app/_components/auth-form.tsx
Comment thread packages/paykit/src/cli/commands/init.ts Outdated
Comment thread packages/paykit/src/cli/commands/listen.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

7 issues found across 16 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/web/content/docs/cli.mdx
Comment thread packages/paykit/src/cli/utils/dev-logger.ts
Comment thread packages/paykit/src/cli/commands/listen.ts Outdated
Comment thread packages/paykit/src/cli/commands/init.ts Outdated
Comment thread apps/demo/src/app/_components/auth-form.tsx
Comment thread apps/demo/src/app/_components/auth-form.tsx Outdated
Comment thread apps/web/content/docs/webhook-events.mdx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/paykit/src/cli/commands/init.ts`:
- Around line 579-581: The listen command selection in init.ts is using
detectPaykitCli() against the running process instead of the target project,
which can pick the wrong command. Update the webhookCommand decision to use a
project-scoped install check for the target cwd, or thread cwd into the
detection helper, before falling back to getStripeListenCommand. Keep the change
localized around detectPaykitCli(), getPaykitListenCommand(), and
getStripeListenCommand() so the command choice reflects the actual project
install.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6bcde055-b8d9-4ed9-b43d-b958aada02df

📥 Commits

Reviewing files that changed from the base of the PR and between f50b360 and 1bffcd8.

📒 Files selected for processing (7)
  • apps/demo/src/app/_components/auth-form.tsx
  • apps/web/content/docs/cli.mdx
  • apps/web/content/docs/webhook-events.mdx
  • packages/paykit/src/cli/__tests__/init.test.ts
  • packages/paykit/src/cli/commands/init.ts
  • packages/paykit/src/cli/commands/listen.ts
  • packages/paykit/src/cli/utils/dev-logger.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/web/content/docs/webhook-events.mdx
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/web/content/docs/cli.mdx
  • apps/demo/src/app/_components/auth-form.tsx
  • packages/paykit/src/cli/utils/dev-logger.ts
  • packages/paykit/src/cli/commands/listen.ts

Comment thread packages/paykit/src/cli/commands/init.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/paykit/src/cli/commands/init.ts`:
- Around line 67-69: The current detectPaykitCli() check only reflects
package.json presence via isPackageInstalled(), so it can falsely treat paykitjs
as runnable even when the binary is not available. Update detectPaykitCli() to
verify the executable can actually be resolved for the given cwd, or otherwise
use the result of the successful paykitjs install path before selecting the
onboarding command. Make the choice in init.ts based on real CLI availability,
not just a declared dependency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1bc24b3f-6539-4d89-86c6-6dcf438e4e4b

📥 Commits

Reviewing files that changed from the base of the PR and between 1bffcd8 and e1d18c1.

📒 Files selected for processing (2)
  • packages/paykit/src/cli/__tests__/init.test.ts
  • packages/paykit/src/cli/commands/init.ts

Comment thread packages/paykit/src/cli/commands/init.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/paykit/src/cli/commands/init.ts Outdated

@maxktz maxktz left a comment

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.

lgtm

@maxktz maxktz merged commit 46ea216 into main Jun 30, 2026
7 checks passed
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