Skip to content

fix(tui): replace provider template chip row with a template field and grouped picker - #428

Merged
SaladDay merged 1 commit into
mainfrom
fix/issue-416-template-picker
Aug 23, 2026
Merged

fix(tui): replace provider template chip row with a template field and grouped picker#428
SaladDay merged 1 commit into
mainfrom
fix/issue-416-template-picker

Conversation

@SaladDay

Copy link
Copy Markdown
Owner

Closes #416. Thanks @LeonardoTan19 for the report and the offer to help — this ended up as a UX redesign rather than a scroll fix, details below.

Problem

The provider Add form rendered every template as one horizontal chip row. With 3 built-ins + 10 sponsor presets (~135 columns), the row overflows any realistic terminal width, and the overflow was silently clipped: the selected chip — and the sponsor entries — could become invisible and unreachable.

Approach

Instead of adding horizontal scrolling (which would keep most sponsors hidden behind the fold), template selection now follows the same pattern the Usage Query page already uses — a field whose Enter opens a picker:

  • Template is a regular field at the top of the Fields table: chip-styled current selection + dim ▾ (N) count, followed by a divider. Label-first degradation at narrow widths (count dropped first, then the caret, then the label truncates). Nothing can overflow horizontally anymore.
  • Enter opens a grouped vertical picker (ProviderTemplatePicker): Built-in / Sponsors sections (Codex's DeepSeek stays under Built-in), ↑/↓ skip section headers, selection kept in view via the shared scroll window on short terminals.
  • Apply semantics unchanged: apply_template with existing provider ids (id de-confliction covered by a test), common-snippet quick-config refresh, warning toast on failure — then the cursor lands on the first real field. Esc changes nothing, including typed API keys and usage-query settings.
  • Simpler focus model: the dedicated Templates pane and focus stop are gone; Tab cycles Fields ↔ JSON preview (Codex: Fields → Auth preview → Config preview). The MCP form and the CLI chooser are untouched.
  • Copy-provider flow opens on the first real field instead of the template row, so copied values are not one accidental Enter-Enter away from being reset.
  • ? help rewritten (EN + ZH) to document the picker keys, the sponsor grouping, and — precisely — what applying a template does and does not reset (it deliberately avoids over-promising: some previously typed values survive a template switch, so the help now says not to rely on templates to clear secrets).

Screenshot-able flow

Providers → a → first row is Template [ Custom ] ▾ (13) → Enter opens the grouped list → pick → cursor lands on Name.

Validation

  • cargo fmt --check clean; no new clippy warnings in touched files.
  • cli::tui suite: 1799 passed (≈20 new behavior tests: no-apply-on-open, header skipping incl. Codex display-order divergence, id de-confliction, Esc purity with typed secrets, warning-toast path, scroll-into-view at 100×13, narrow-width degradation ladder, copy-flow initial focus, help routing). Full-suite failures are byte-identical to the pre-change baseline on this machine (pre-existing umask/sandbox failures, none in cli::tui).
  • Change went through multiple rounds of independent blind review (correctness, regression, security, UX, i18n accuracy, test quality) until convergence; the ? help text was additionally fact-checked claim-by-claim against apply_template.

Note: cargo clippy currently cannot exit clean on main due to a pre-existing reversed_empty_ranges deny error in src/cli/tui/ui/home_chart.rs:806 (untouched here) — worth a separate small fix.

…d grouped picker

The provider Add form rendered all templates as a single horizontal chip
row. With three built-ins plus ten sponsor presets the row overflows any
realistic terminal width, and the overflow was silently clipped: the
selected chip and the sponsor entries could become invisible and
unreachable (#416).

Template selection is now a regular field at the top of the Fields
table, mirroring the Usage Query page pattern:

- The Template field shows only the current selection as a chip-styled
  value with a dim caret and total count, degrading label-first at
  narrow widths. Nothing can overflow horizontally anymore.
- Enter on the field opens a new ProviderTemplatePicker overlay: a
  vertical list grouped into Built-in and Sponsors (Codex's DeepSeek
  stays under Built-in), with section headers skipped by Up/Down and
  the selection kept in view via the shared scroll window.
- Applying keeps the exact legacy semantics (apply_template with
  existing ids, common-snippet quick-config refresh, warning toast on
  failure) and lands the cursor on the first real field. Esc changes
  nothing.
- The dedicated Templates pane and focus stop are gone for the provider
  form; Tab now cycles Fields <-> JSON preview (Codex: Fields -> Auth
  preview -> Config preview). The MCP form and the CLI chooser are
  untouched.
- The copy-provider flow opens on the first real field instead of the
  template row, so its copied values stay one keypress away from harm.
- The contextual ? help documents the picker keys, the sponsor
  grouping, and precisely what applying a template does and does not
  reset, in both English and Chinese.

Closes #416
@SaladDay
SaladDay merged commit 39654ae into main Aug 23, 2026
6 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.

[Bug] Provider template selection does not scroll into view when overflowing horizontally

1 participant