Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

docs(picker): record why the picker is shaped as it is, and what is still open

Jack Rudenkoad6137b4f608
diff --git a/CLAUDE.md b/CLAUDE.md
index f623cc06..6c28a187 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -25,6 +25,9 @@ lives in `ROADMAP.md`.
children finish, idle time as information, why `outputSize` reads 0 on a RUNNING slot and
what to read instead, and why `keepUnrecognizedJson` is an option
rather than one rule for both the channel and `team`
+- `picker.md` — the OpenTUI model picker: a dialog, not a dashboard; the provider list first
+ with nothing prefetched; why an empty list must say WHY; the no-terminal gate; capture and
+ compiled-binary traps. Read before editing `picker/` or `selectModel`
- `context-window.md`, `theming.md`, `debugging.md`, `testing.md`
Evidence behind them: `ai-docs/reports/`. Evals: `ai-docs/benches/`. User-facing site: `docs/`.
diff --git a/ai-docs/architecture/README.md b/ai-docs/architecture/README.md
index 98c37e1f..f87213f5 100644
--- a/ai-docs/architecture/README.md
+++ b/ai-docs/architecture/README.md
@@ -30,6 +30,7 @@ three earlier write-ups this material cites were lost.
| [`behavior-layer.md`](behavior-layer.md) | Layer 4, the harness-convention SUPERVISOR: the rule engine, the four hooks, the 115-call plan-mode measurement it was built on, and opt-in telemetry | write a `behavior/` rule, or change harness-conformance handling |
| [`advisor.md`](advisor.md) | `--advisor` for any main model: why it is independent of `--monitor` yet keeps four of its launch bits, the decorator around the ROUTED handler, id capture by tool name (the `toolu_` prefix that made it a no-op on every foreign provider), the tee and retained session-keyed state, the ten stub paths and advice origin, Claude Code's advisor gates, metered panel billing, and the inherited-placeholder 401 | touch `--advisor`, `advisor-decorator.ts`, `native-handler-advisor.ts`, `advisor-startup.ts`, monitor-gated launch code, or native auth in `claude-runner.ts` |
| [`headless-vs-interactive.md`](headless-vs-interactive.md) | Why `-p` is NOT interactive-without-a-TTY: `--agent` validation is SILENTLY skipped under `--input-format stream-json` (measured, exit 0, no stream frame, `result: success`), upstream closed it as not planned, and why magmux is in the dependency tree | drive Claude Code headlessly, add a child-spawn flag, or assume a headless run behaves like an interactive one |
+| [`picker.md`](picker.md) | The OpenTUI model picker: why it is an inline dialog and not a dashboard (the density gate that manufactured the rejected build), the provider list as the default screen with nothing prefetched (3915 → 1436 ms), the discovery outcome that stopped `[]` meaning five things, the local served-by index (22 network queries measured at 10 018 ms), the no-terminal gate's complement law, and the capture and compile traps | change `picker/`, `selectModel`, discovery outcomes or fetchers, `should-open-picker.ts`, or a TUI test that asserts on a frame |
| [`context-window.md`](context-window.md) | Why setting one env lever accomplishes nothing, why the status line reports the ENFORCED window, and local-model token accounting | change context-window resolution, the status line, or token accounting |
| [`theming.md`](theming.md) | One detected theme for every surface, and the module-load palette-snapshot bug class it keeps producing (found six times) | add a colored CLI line or TUI surface |
| [`mcp-channel.md`](mcp-channel.md) | The 12-tool MCP surface, the channel wire format, the client-side conditions gating channel rendering, and the `notifications/progress` keepalive | add or rename an MCP tool, or change channel notifications |
diff --git a/ai-docs/architecture/picker.md b/ai-docs/architecture/picker.md
new file mode 100644
index 00000000..2e390edb
--- /dev/null
+++ b/ai-docs/architecture/picker.md
@@ -0,0 +1,117 @@
+# The interactive model picker
+
+What bare `claudish` shows when no model was given: an OpenTUI dialog, in
+`packages/cli/src/picker/`, launched by `selectModel` in `model-selector.ts`. This file records
+why it has the shape it has. Colour and chip construction live in [`theming.md`](theming.md);
+the provider list's derivation lives in [`routing.md`](routing.md).
+
+## It is a dialog, not a dashboard
+
+The first OpenTUI build was a full-screen two-pane dashboard: a provider rail beside a model
+list, gradient context and price meters on every row, an aggregate panel. The owner rejected
+it — *"no no no this is super unclear what is happening, that should be dialog style"* — and a
+blind three-model panel agreed the FORM was the defect.
+
+The cause is measurable. The house TUI guidance requires over half of a frame to be graphics
+rows. On a screen whose content is a list, a row counts only if it carries a bar, so the gate
+did not permit a meter per row, it required one. On the rejected capture 19 of 32 visible rows
+read `1M`, and their meters were indistinguishable. **That density gate is for monitoring
+surfaces a user lives in. A picker is a one-shot question; do not apply the gate to it.**
+
+Three structural rules follow, and each removes a class of defect:
+
+1. **Inline** — `screenMode: "main-screen"`, never the alternate screen. The shell prompt and
+ the claudish banner stay above the dialog. (`@opentui/[email protected]` renamed
+ `useAlternateScreen` to `screenMode`; the old key is silently ignored.)
+2. **One list, one cursor.** Two panes meant two cursors and only a border colour to say which
+ one the keys drove — the literal cause of "unclear". A test counts exactly one `▶`.
+3. **No per-row graphics.** Plain aligned columns; colour carries meaning only. The one meter
+ left is the credential sweep's `done/total`, which is real progress over countable work.
+
+## The provider list is the default screen, and nothing is prefetched
+
+An intermediate build opened on a flat cross-provider list and warmed the cloud models catalog
+plus every credentialled provider's dynamic models catalog to fill it. The owner's
+corrections: *"why we prefetching? we should not, as we show on demand"* and *"we should show a
+list of providers by default and only when we go inside we load"*.
+
+So startup does ONE thing — probe credentials, streaming each answer into the provider list as
+it settles. `⏎` on a provider fetches that provider's models. `a` opens the cross-provider list
+from one cached catalog fetch. Measured when the prefetch was removed: time to first screen
+3915 ms → 1436 ms (commit `ff00f56`).
+
+Only providers with a credential are listed. `k` reveals the rest, each saying why it is hidden
+(`needs X_API_KEY`, or `not enabled in config` for a local provider, which is opt-in).
+
+## An empty list must say WHY it is empty
+
+The founding complaint: when discovery failed, the old picker showed *"fewer model names, like
+the provider does not have any models"*. `buildDiscoveredModelRows` returned `[]` for five
+different states, and the caller fell back to the catalog silently for all of them.
+
+Two layers now carry the distinction instead of destroying it:
+
+- **Discovery** returns a `ModelsCatalogOutcome` (`providers/model-discovery.ts`) —
+ `served` (non-empty by construction), `failed` with one of seven failure kinds, or
+ `unsupported` (nothing attempted, nothing wrong). `discoverProviderModelsCatalog` never
+ rejects: every await is inside a `try`, because a live renderer has no stderr to absorb a
+ rejection, and a stuck promise leaves a spinner running forever.
+- **The registered fetchers** (Devin, Antigravity, Ollama) return a `FetcherResult`, not a bare
+ array. As arrays they could only ever say "empty", so a stopped Ollama daemon and a
+ logged-out Antigravity account both read as "this provider serves nothing".
+
+The picker maps the outcome to a `PickerDiscoveryOutcome` and renders the non-`rows` variants
+through `DiscoveryNotice.tsx` in three tiers: error (red), notice (warn), and nothing at all
+for `unsupported` — about 25 providers declare no discovery, and a panel on the majority case
+teaches users to ignore the panel. A fallback list says so three ways that derive from one
+value: the dialog title (`live model list unavailable`), a per-row `catalog` mark, and a
+sentence stating the rows *do not confirm access, so launching one may still fail*.
+
+## The cross-provider list never leaves the machine
+
+The flat list asks about every provider at once. Asking the network per provider was measured
+at 10 018 ms for 22 concurrent queries, every one aborting on its shared timeout and returning
+zero rows — "this provider has no models", manufactured by the fix for it (commit `43218b4`).
+`CatalogClient.servedByVendor` answers from the local slim-catalog cache instead, using the
+same route-binding rule as `modelsByVendor`'s own served-by filter, so the two cannot disagree.
+
+## Never open without a terminal
+
+`cli.ts` sets `interactive` whenever no prompt was given, which includes `claudish < /dev/null`,
+a CI runner and a detached run. Measured before the fix: a piped bare `claudish` wrote 195
+bytes of menu and a cursor-hide escape into stdout, then blocked until killed at 45 s.
+
+`tui/runtime/should-open-picker.ts` holds the gate as two pure predicates that are exact
+complements over runs that need a model: `shouldOpenPicker` and `requiresExplicitModel`. No
+input can skip the picker silently AND keep the error quiet. Every reason a run needs no model
+(`--monitor`, a native `--advisor` session, `--model`, profile tiers) lives inside the shared
+`noModelConfigured`, never as an extra condition at one call site — a term on one gate only is
+how the two drift apart. The test enumerates the full 32-cell grid.
+
+## Testing a TUI here
+
+- **A `<span>` outside a `<text>` renders an error page while the process exits 0.** Only a
+ screenshot catches it, so visual changes are verified by capture, not by exit code.
+- Captures run with `CLAUDISH_DISABLE_OP=1 CLAUDISH_DISABLE_KEYCHAIN=1` so they cannot raise a
+ 1Password or Keychain prompt on the desktop. That leaves few providers with credentials.
+- `CLAUDISH_PICKER_FIXTURE=<name>` swaps in `picker/fixtures/fixture-source.ts` to force the
+ states a live provider cannot be made to produce (a held credential sweep, a discovery that
+ never lands, a timeout). It forges the OUTCOME, never the data, and is reached only through a
+ dynamic import, so `bun build --compile` never bundles it.
+- `picker/no-terminal-writes.test.ts` forbids `process.stdout.write`, `process.stderr.write`
+ and `console.*` inside `picker/` and `tui/`. A write behind a live renderer leaves ghost
+ cells OpenTUI cannot invalidate, silently — and `setStderrQuiet(true)` is not a defence, as
+ it gates only `logStderr`.
+- `picker/import-direction.test.ts` keeps OpenTUI out of processes whose stdout is a
+ protocol: `tui/` never imports `picker/`, and `model-selector.ts` reaches `picker/` only
+ through a dynamic `await import()`.
+- `C.*` and `tokens.*` are read at render time; see `theming.md` for why a module-level
+ snapshot takes the dark palette on a light terminal.
+
+## The compiled binary
+
+OpenTUI is pinned at `0.1.107` because `release.yml` builds with `bun build --compile`, which
+requires it. A locally compiled binary on Apple Silicon is killed on launch (`Killed: 9`, exit
+137) until it is ad-hoc signed — `codesign --force --deep --sign - <binary>` — the same step
+`release.yml` runs. That is macOS, not claudish. Verified 2026-09-23: the signed compiled
+binary draws the picker.
diff --git a/ai-docs/reports/picker-open-findings-20260923.md b/ai-docs/reports/picker-open-findings-20260923.md
new file mode 100644
index 00000000..14eba005
--- /dev/null
+++ b/ai-docs/reports/picker-open-findings-20260923.md
@@ -0,0 +1,62 @@
+# Picker release — open findings (2026-09-23)
+
+Defects and decisions still open when the OpenTUI picker shipped in v10.1.0. Each was
+re-checked against the code on the release candidate, not carried over from notes.
+
+## 1. Realtime models return to the Codex list — a decision, not a bug
+
+The picker once excluded `gpt-live-1` and the `gpt-realtime-*` family from the OpenAI Codex
+list, because the owner saw them offered as launchable coding models. Since v10.0.0 the cloud
+models catalog decides chat capability first (`classifyChatCapability`,
+`providers/transport/probe-discovery.ts`), and it publishes these ids with output modalities
+`["audio","text"]`. The classifier's rule is "output INCLUDES text → chat model", so on any
+machine with the v3 catalog cached they are offered again. The name rules that excluded them
+now run only for models the catalog does not describe.
+
+Two statements in the repository disagree about which answer is right:
+
+- the classifier's comment: *"`["audio", "text"]` speaks AND writes, so it can answer a chat
+ turn"*;
+- the thesaurus in `CLAUDE.md`: a chat model *"takes text in and gives only text out"*.
+
+Settling it means choosing one and changing the other. What was observed, on catalog
+generation `g-20260923015912067-d8c0c200`: the `gpt-realtime-*` catalog description says
+"realtime VOICE interactions ... audio and text inputs over WebRTC, WebSocket, or SIP"; and
+36 of the 1000 rows read (the first page of 1137) publish an output list containing both
+`audio` and `text` — the `gpt-realtime-*` family and `gpt-live-1`, `gpt-audio` and
+`gpt-audio-mini`, Qwen omni, audio and livetranslate models (realtime and not), and Google
+Lyria. Whether those answer an ordinary `/v1/chat/completions` turn was NOT tested. A rule on
+output modality alone treats all 36 identically, so choosing "only text" drops every one.
+
+## 2. The config TUI's status strip has no error tier
+
+`tui/components/TabBar.tsx:68` colours a status message green when the string starts with one
+of a fixed list of prefixes (`"Key saved"`, `"Rule added"`, …) and yellow otherwise. There is
+no red tier, so a hard failure and a routine save differ only between yellow and green. Choosing
+severity by the prefix of a human sentence also breaks silently when a message is reworded.
+Pre-existing; the picker did not touch it. The picker's `ErrorBanner` three-tier model is the
+shape a fix would reuse.
+
+## 3. `--free` always throws
+
+`getFreeModels` (`model-selector.ts:521`) is a stub returning `[]`, and `selectModel` throws
+`"No free models available"` whenever `--free` is set. The flag is reachable from the CLI, and
+the catalog does carry free models (`FREE` rows are visible in the picker), so the data exists
+while the feature does not. Implement it against the catalog's free rows, or remove the flag.
+
+## 4. One unreproduced test failure
+
+`ModelPicker.test.tsx` "has EXACTLY ONE cursor" failed once in about 23 runs of the file,
+on the first run after that file's module was rewritten on disk, and passed the next 20 runs,
+including 12 in isolation. No failure message was captured, so whether it saw 0 cursors (a
+frame caught before paint — timing) or 2 (a real defect) is unknown. If it recurs, capture the
+assertion message before touching the test.
+
+## 5. No test pins the `video` rule's removal
+
+During the v10 merge, a `\bvideo\b` rule this branch had added to `NON_CHAT_PATTERNS` was
+removed: it ran before the `videoOutputKnown` guard and would have excluded a model that only
+READS video despite a published `videoOutput: false`. No row in the real catalog has the shape
+that distinguishes the two behaviours (video in the name, `videoOutput` published, no output
+modality list), so no test pins it, and a hand-built fixture would break the rule that
+fixtures come from real data. Add the test when such a row exists.