Skip to content

feat(cli): redesign onboarding wizard around the input field - #1181

Merged
Astro-Han merged 4 commits into
mainfrom
feat/cli-onboarding-input-wizard
Jul 18, 2026
Merged

Astro-Han merged 4 commits into
mainfrom
feat/cli-onboarding-input-wizard

Conversation

@Astro-Han

Copy link
Copy Markdown
Contributor

Summary

The first-run / /setup onboarding wizard pushed its prompt, verifying, and failure notices into the transcript entry flow, and the provider picker had no search — both defeated a focused, input-driven configuration experience (#1098).

This redesign makes one overlay span provider search → API key entry, driven by the input field itself:

  • Searchable picker. Typing filters the provider list live (editor.onChange rebuilds the SelectList, which exposes no setItems).
  • Status beside the input, not in the transcript. The prompt, verifying, and failure states render in a single status line next to the key field. Only the completed-configuration event reaches the transcript on /setup; first-run success still closes the TUI so the host rebinds the new connection.
  • One overlay throughout. An internal search → key state machine replaces the old SelectList picker plus a one-shot editor.onSubmit interception, so there is no longer a split between "picker UI" and "key UI." Slash commands still route from the key field (/exit escapes the wizard).

The wizard replaces showSetupPicker + pendingKeyEntry in the runner. MakaOnboardingSurface / setupApiKeyConnection are unchanged, so the upsert-by-slug key rotation, atomic secret-write rollback, and probe-error retry all carry over.

A standalone full-screen wizard was considered and rejected: it would reimplement TUI primitives (raw mode, render loop, layout) to delete the ~30-line first-run stub driver — a net complexity increase for no correctness gain. Reusing the existing runMakaPiTui frame and rendering the wizard as a bottom overlay keeps the change inside the runner layer.

Refs #1098.

Verification

  • npm run typecheck (all workspaces) — clean.
  • packages/cli: node --test "dist/**/*.test.js" — 525 pass, 0 fail.
  • New coverage in pi-tui-runner.test.ts:
    • onboarding wizard filters the provider list as you type in the search field
    • onboarding wizard keeps verifying/failure status beside the input, out of the transcript
    • onboarding wizard key Esc returns to the provider search
  • The pre-existing /setup + first-run journey tests (provider list, key collection, probe-failure retry, slash-command routing, no-surface guard, first-run cancel/auto-open) pass unchanged against the new wizard — the search → key path is interaction-compatible.

No screenshot attached; the wizard is exercised through the FakeTerminal TUI harness that drives the rest of the runner suite. One live visual pass during review is worthwhile.

Astro-Han added a commit that referenced this pull request Jul 18, 2026
Codex + Kimi K3 parallel review of #1181 surfaced three regressions and
three polish items; all accepted at their natural owner.

P1 — first-run input admission (runner): restore the editor.onSubmit
firstRun guard removed in the redesign. After a slash command escapes the
key field (/help etc.), a later submit now reopens the wizard instead of
handing control to a connection-less driver whose turns only hard-error.

P1 — overlay cancel contract (OnboardingWizard): Ctrl+C was dead — the
wizard handled only Escape while pi-tui's `tui.select.cancel` is
[escape, ctrl+c] and the Editor returns early ("let parent handle").
handleInput now treats Ctrl+C like Esc (search cancels, key returns).

P2 — async setup attempt lifecycle (runner): the setup continuation only
guarded `!wizard`, so a probe settling after Esc + re-pick clobbered the
newer attempt (wrong-provider error, wiped key text, or a close under the
user). submitWizardKey now captures the wizard instance + a monotonic
attempt id; onPick/onBack/close invalidate it.

P3 — verifying locks the key field's input too (not just Enter); the dead
`ok` status kind is removed; the no-match row reads "没有匹配的服务商"
instead of SelectList's default "No matching commands".

Coverage: first-run slash-escape guard, Ctrl+C cancel, and the stale-
attempt race each get a regression test; packages/cli is 528 pass / 0 fail.
The onboarding wizard now spans provider search → API key entry in one
overlay, driven by the input field itself, instead of a SelectList picker
plus a one-shot editor.onSubmit interception. Typing filters the provider
list live; the prompt, verifying, and failure states render in a status
line beside the key field instead of the transcript entry flow (#1098 UX).

- Add OnboardingWizard: editor.onChange filters providers in place; an
  internal search→key state machine keeps the same overlay throughout.
- Runner: showSetupWizard replaces showSetupPicker; pendingKeyEntry and
  the editor.onSubmit onboarding/first-run branches are gone. Slash
  commands still route from the key field (/exit escapes the wizard).
- In-flight status (verifying/failure) stays in the overlay; only the
  completed-configuration event reaches the transcript on /setup. First-
  run success still closes the TUI for the host to rebind.
Codex + Kimi K3 parallel review of #1181 surfaced three regressions and
three polish items; all accepted at their natural owner.

P1 — first-run input admission (runner): restore the editor.onSubmit
firstRun guard removed in the redesign. After a slash command escapes the
key field (/help etc.), a later submit now reopens the wizard instead of
handing control to a connection-less driver whose turns only hard-error.

P1 — overlay cancel contract (OnboardingWizard): Ctrl+C was dead — the
wizard handled only Escape while pi-tui's `tui.select.cancel` is
[escape, ctrl+c] and the Editor returns early ("let parent handle").
handleInput now treats Ctrl+C like Esc (search cancels, key returns).

P2 — async setup attempt lifecycle (runner): the setup continuation only
guarded `!wizard`, so a probe settling after Esc + re-pick clobbered the
newer attempt (wrong-provider error, wiped key text, or a close under the
user). submitWizardKey now captures the wizard instance + a monotonic
attempt id; onPick/onBack/close invalidate it.

P3 — verifying locks the key field's input too (not just Enter); the dead
`ok` status kind is removed; the no-match row reads "没有匹配的服务商"
instead of SelectList's default "No matching commands".

Coverage: first-run slash-escape guard, Ctrl+C cancel, and the stale-
attempt race each get a regression test; packages/cli is 528 pass / 0 fail.
setupApiKeyConnection called setDefault before probing models, so a
typo'd first-run key was already the default when the probe failed.
Cancelling the wizard then let the host read getDefault() !== null and
proceed into a broken default, and the next launch no longer re-triggered
onboarding (isFirstRun turned false). Move setDefault after a successful
fetchModels so getDefault() stays an accurate success signal; the
connection is still saved so retrying rotates the key.
- submitPrompt is now the single first-run choke point: move the guard
  out of editor.onSubmit and place it after handleSlashCommand so
  Alt+Enter (and any future idle-submit path) reopens the wizard instead
  of opening a turn against the stub driver, while /exit still exits.
- OnboardingWizard key phase: Ctrl+C cancels the wizard (overlay cancel
  contract) and Esc returns to search, instead of both going back.
- Drop the dead requiresBaseUrl description branch (providers needing a
  base URL are filtered out before the picker) and add a `closed` guard
  to the setup continuations so a late settlement after beginClose no
  longer touches a stopped TUI.
@Astro-Han
Astro-Han force-pushed the feat/cli-onboarding-input-wizard branch from 672202f to 64de2f2 Compare July 18, 2026 03:49
@Astro-Han
Astro-Han merged commit 7e5b8a1 into main Jul 18, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the feat/cli-onboarding-input-wizard branch July 18, 2026 03:50
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