Skip to content

fix(tui): two-step failure screen for runs and logins, opt-in log report - #1612

Merged
johncwaters merged 18 commits into
mainfrom
johnw/task-failure-outro
Nov 27, 2026
Merged

johncwaters merged 18 commits into
mainfrom
johnw/task-failure-outro

Conversation

@johncwaters

@johncwaters johncwaters commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a run fails because a task failed, the wizard says it's busy. A customer ran it on a plain HTML site, init failed (PHW_AGENT_ORCHESTRATOR_TASKS_FAILED), and they saw "The Wizard's a little busy" with an exit line saying the wizard is unavailable. Over the last 14 days, 246 of the 481 runs that landed on that screen were blocked tasks, and only 78 were mint refusals. Reporting it meant emailing us the log by hand.

Stacked on #1610 (pnpm pin), so review that first. This also takes over #1613's login fixes from @rafaeelaudibert, so that PR can close once this merges.

Changes

  • Two steps, plain copy: both steps keep the same red headline under a dim "Step N of 2". Step 1 gives a plain cause, "We got the error automatically.", and asks whether to send the log too: Send log and continue / Continue without sending. Step 2 lists the ways to finish as bullets, with npx @posthog/wizard@latest on its own line, then Open in Claude Code, Open in Codex, Save skill, Exit. No error codes or runner text. Capacity failures (AgentRateLimit, AgentApiError, GatewayMintRefused, GatewayMintFailed, EnvServiceOutage) get "The wizard is busy right now" and "in a few minutes". Every other run failure gets "PostHog isn't set up yet". The exit line uses the same headline and cause.
  • Failed logins: a failed login ended on the generic outro with the raw error and OAuth bug-report details, and a failed project or user fetch after login ended the run as completed with exit 0. From fix(auth): end a failed login as failed and say why #1613: the fetch failure now ends the run as failed, the OAuth failure carries its reason, and the paste-code overlay closes once the login settles. On top of that, the OAuth abort passes PHW_AUTH_ACCESS_DENIED (new) or PHW_AUTH_LOGIN_FAILED (new), and the fetch throws PHW_AUTH_PROJECT_FETCH_FAILED. Login and fetch failures take the same two steps with their own copy, and step 2 offers only Exit, since the agent handoff needs a project. Access denied is a decision: one screen, no log question. Only the run's login aborts on the fetch error; wizard slack and the MCP tutorial still show it inline with a retry. Timeouts keep their own overlay, and other login aborts keep their specific outro.
  • Log is opt-in: the screen event and the error reach us without asking. The log stays on the machine unless they pick Send log, and the prompt says we mask the keys and tokens we recognize. "Report this issue" and the email line are gone.
  • What Send log sends: wizard: failure reported with the error code, message, is_capacity and up to 64 KB of this run's own log lines. Every run appends to one shared log file, so the run keeps its lines in memory as it writes them and never reads another run's.
  • Redaction: the message and the log both go through redactSecrets and scrubHomePaths. Secrets logged as JSON values are masked whole, raw or escaped, including escapes, quotes and newlines. pha_/phr_ tokens and JSON-escaped Windows home paths are covered too, which also tightens the other callers.
Before (main) Step 1: a task failed
main-busy r-run-1
Step 2: after Send log Step 2: busy, without sending
r-run-2 r-busy-2
Login failed, step 1 Login failed, step 2
r-login-1 r-login-2
Access denied
r-denied

Rendered from the real MintFailureScreen in a PTY at 90x30.

Test plan

  • pnpm typecheck and lint pass, and vitest --project tui --project shared passes (goldens updated), and the full suite passes (4795 tests)
  • New cases in results.test.ts fail on the old redaction and pass now: JSON keys raw and escaped, values with a backslash, a quote and a multiline key, pha_, and an escaped Windows path
  • oauth-flow.test.ts checks the code on an access_denied and an invalid_scope callback. ci-region.test.ts checks a failed fetch throws the coded error without aborting, which fails on fix(auth): end a failed login as failed and say why #1613's version, and login.test.ts checks the run's login aborts on it and passes other errors through
  • A test writes another run's line into the shared log between two of this run's and checks the report leaves it out
  • Running the redaction over the customer's real 32 KB log leaves 0 phc_ tokens and 0 home paths
  • MintFailureScreen.test.tsx walks both steps: Send log then save and continue, continue without sending then exit, the step 1 headline for a task failure against a mint refusal, and a failed login with no credentials reaching this screen with only Exit after the log question

pnpm 12 refuses the pinned 10.34.5 with "High-risk trust downgrade
(possible package takeover)": 10.34.6 and later are published through
GitHub trusted publishing, and 10.34.5 was not. Local installs on current
pnpm stopped before resolving anything.

Moves packageManager (with its sha512), the volta pins and every CI pin to
10.34.9. pnpm install --frozen-lockfile on 10.34.9 leaves pnpm-lock.yaml
unchanged.
A run that failed for any reason other than a deliberate stop showed
"The Wizard's a little busy", and the exit line said the wizard was
unavailable, even when a task failed (init on a plain HTML site ends in
PHW_AGENT_ORCHESTRATOR_TASKS_FAILED). Reporting it meant emailing the log by
hand.

Only capacity codes (rate limit, API error, mint refused or failed, service
outage) keep the busy copy. Every other failure shows "The wizard couldn't
finish setup" with the failure message, and the exit line starts with
"Setup did not finish:".

The handoff screen asks once whether to send the report. Send report
captures "wizard: failure reported" with the error code, message, a
capacity flag and up to 64 KB of this run's log, read from where this
process started writing, with recognized secrets and home paths masked.
The manual report option and the email line are gone; the exit line keeps
the log path.

redactSecrets now masks secrets logged as JSON keys (raw or escaped) and
pha_/phr_ tokens, and scrubHomePaths handles JSON-escaped Windows paths,
which also tightens the other places that scrub through them.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: moderate
@github-actions

Copy link
Copy Markdown

🧙 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 ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /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 feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/go-sdk
  • /wizard-ci mcp-analytics/python-sdk
  • /wizard-ci mcp-analytics/ruby-sdk
  • /wizard-ci mcp-analytics/rust-sdk
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@johncwaters
johncwaters requested a review from a team as a code owner November 25, 2026 16:14
Comment thread src/tui/mint-failure.ts Resolved
Comment thread src/shared/mcp-clients/results.ts Resolved
Comment thread src/tui/mint-failure.ts Resolved
Comment thread src/shared/mcp-clients/results.ts Resolved
@veria-ai

veria-ai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 4 · PR risk: 0/10

Reviews

The failure screen stacked a headline, the runner's technical message, a
send-or-not question and a second menu. It is now one red card with a plain
cause and a suggested fix, a line saying the wizard team already knows, and
one menu: Send log to the wizard team, Open in Claude Code, Open in Codex,
Save skill, Exit. The log stays opt-in, and the item greys out once sent.
Capacity failures and every other failure share the same shape with their
own copy, and the exit line uses the same words.

The report's message now goes through redactSecrets and scrubHomePaths, and
secrets logged as JSON values are masked whole, raw or escaped, including
escapes, quotes and newlines inside the value.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: moderate
@johncwaters johncwaters changed the title fix(tui): show what failed and offer to send the report fix(tui): plain failure card, busy copy only for capacity, opt-in log report Nov 25, 2026
…e log

The red border made the screen busy; the red headline already marks the
error. "We've let the wizard team know" read as if the log had gone too,
next to the opt-in Send log item, so the note now says the error came in
automatically but not the log. The exit line keeps only the first half,
which holds whether or not the log was sent.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: narrow
Comment thread src/tui/mint-failure.ts Resolved
One screen held what happened, the log question and every way to finish,
which read as busy. Step 1 says what happened, that the error already
reached us, and asks Send log or Don't send. Either answer moves to step 2,
"Finish setting up PostHog": run the wizard again (in a few minutes when
busy), or hand the setup to your own agent, with Open in Claude Code, Open
in Codex, Save skill and Exit. The log prompt says we mask the keys and
tokens we recognize, which is what the redaction covers.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: narrow
@johncwaters johncwaters changed the title fix(tui): plain failure card, busy copy only for capacity, opt-in log report fix(tui): two-step failure screen, busy copy only for capacity, opt-in log report Nov 25, 2026
Review found the two steps read as two screens and leaned on sub-headers.
Both steps now keep the same red headline under a dim "Step N of 2",
bullets replace the numbered list, the command sits on its own line, and
the log choices read "Send log and continue" / "Continue without sending",
since "try again" sounded like the wizard would retry.

A failed login ended on the generic outro with the raw error and OAuth
bug-report details. Login failures with PHW_AUTH_LOGIN_FAILED or
PHW_AUTH_PROJECT_FETCH_FAILED now take the same two steps, minus the agent
handoff, which needs a project. PHW_AUTH_ACCESS_DENIED is a decision: one
screen, no log question. The two new codes are for the login abort to emit.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: moderate
@johncwaters johncwaters changed the title fix(tui): two-step failure screen, busy copy only for capacity, opt-in log report fix(tui): two-step failure screen for runs and logins, opt-in log report Nov 25, 2026
Brings in #1613's login fixes, written by Rafa (@rafaeelaudibert): a failed project or user fetch
after login ended the run as completed with exit 0, a failed OAuth login
showed only "Wizard setup cancelled.", and the paste-code overlay could
cover the screens after login.

The OAuth abort now carries PHW_AUTH_ACCESS_DENIED or PHW_AUTH_LOGIN_FAILED,
so those logins reach the two-step failure screen. The project fetch throws
PHW_AUTH_PROJECT_FETCH_FAILED and only the run's login aborts on it, since
`wizard slack` and the MCP tutorial show that error inline with a retry.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: moderate
#1607 removed signup from WizardRunOptions, but this test from #1598 still
passed it, so tsc -b failed on main and on every branch synced with it.

Confidence: high
Scope-risk: narrow
Every run appends to one shared log file, so reading it from this run's
starting offset also picked up a concurrent run's prompts and tool output.
The run now keeps its own last 64K of log lines as it writes them, and Send
log uploads that, still masked.

Ticket: task-failure-outro/U2
Confidence: high
Scope-risk: narrow

@gewenyu99 gewenyu99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🥸 Reviewed by NotVincent, totally not Vincent. The real Vincent will review it separately. Probably slop, please disregard.

Hey, this looks generally good. There are two things to address: the post-login exit deadlock on non-program tools like wizard doctor, and MintFailureScreen overriding dedicated auth and abort screens. The rest are suggestions.

Comment thread src/tui/mint-failure.ts Resolved
Comment thread src/tui/mint-failure.ts Resolved
Comment thread src/tui/mint-failure.ts Resolved
Comment thread src/shared/mcp-clients/results.ts Resolved
Comment thread src/shared/mcp-clients/results.ts Resolved
Comment thread src/tui/store.ts Resolved
Comment thread src/shared/utils/debug.ts Resolved
Comment thread src/shared/mcp-clients/results.ts Resolved
Comment thread src/tui/mint-failure.ts Resolved
Comment thread src/shared/utils/debug.ts Resolved
@johncwaters
johncwaters requested a review from a team November 25, 2026 19:17
johncwaters and others added 4 commits November 27, 2026 06:59
The failure screen took any logged-in error. A tool such as wizard doctor
never waits on the handoff, so Exit left a blank terminal, and auth errors
and tailored abort outros (missing SDK, missing scope, settings conflict)
lost the screen that names their fix.

Only a registered program shows it now, every error code has a route the
compiler checks, and overlays resolve first. GatewayMintRefused and
AgentApiError no longer show busy copy. Programs other than the integration
say the wizard did not finish and name their own rerun command, or ask for
the same command when they have none.

Ticket: failure-routing-review-fixes/U1
Confidence: high
Scope-risk: moderate
The opt-in failure log now masks minted phe_ gateway tokens, PEM private
keys (including a block the log tail cut), and secret-named values that are
JSON-escaped, quoted, or carry punctuation, without crossing a line or
re-matching an earlier mask. Windows user paths nested in JSON are scrubbed.

A failed login reports error status and is captured once, through the abort,
with its OAuth fingerprint. The failure reported event carries the session
properties like the events beside it.

Ticket: failure-routing-review-fixes/U2
Confidence: high
Scope-risk: narrow

@gewenyu99 gewenyu99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🥸 Reviewed by NotVincent, totally not Vincent. The real Vincent will review it separately. Probably slop, please disregard.

Comment thread src/tui/auth/login.ts Resolved
Comment thread src/shared/utils/debug.ts Resolved
Comment thread src/tui/screens/MintFailureScreen.tsx Resolved
An uncoded error from the OAuth login (no callback ports, a port loop
that exits) reached the TUI host with no credentials, so the run ended as
completed with exit 0. The login now aborts it as AuthLoginFailed, which
shows the login failure screen; coded errors pass through.

A single log line over the 64K tail emptied the failure report log_tail;
the tail keeps the end of that line. A test pins the access-denied screen
skipping the log question.

Confidence: high
Scope-risk: narrow
Comment thread src/shared/utils/debug.ts Resolved
Keeping the end of a line longer than the 64K tail could keep a secret
value without the PASSWORD= name that gets it masked, since masking runs
after the cut. Such a line is now replaced with a note.

Confidence: high
Scope-risk: narrow
@johncwaters
johncwaters deleted the branch johnw/pnpm-10-34-9 November 27, 2026 21:57
Base automatically changed from johnw/pnpm-10-34-9 to main November 27, 2026 21:57
@johncwaters johncwaters reopened this Nov 27, 2026
@johncwaters
johncwaters merged commit ae3685b into main Nov 27, 2026
21 checks passed
@johncwaters
johncwaters deleted the johnw/task-failure-outro branch November 27, 2026 22:20
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