Skip to content

[0.1.0] Help/which-key overlay is Core-drawn presentation #2397

Closed
bitty-terminal/bitty-terminal-docs
#403

Description

@Xuepoo

Priority: P2 | Area: architecture/ui | Labels: chore,area:architecture,area:ui,P2 | Milestone: v0.1.0 | RFC: ADR-0014 | Task: CTX-1431

Why

crates/bitty-runtime/src/runtime/help.rs paints a product surface in Core: a
titled floating panel ("Keyboard shortcuts"), one row per bound action from
help_rows_from_keymaps, a footer, its own palette tokens
(help_panel_border_in / help_panel_bg_in / help_panel_fg_in), and a
toggle_help chrome action. That is presentation. Core's accepted role is the
mechanism: the keymap/command registry, overlay geometry and stacking, and
click/key routing; the decision what a help/which-key surface shows belongs to
a plugin.

This predates 0.0.25 (only re-themed there), so it is not a release
regression. It is the largest remaining Core-drawn product surface after the
workspace bar/tab/statusline retirements.

Blocker

No plugin can replace it today: there is no bounded read-only keymap/action
registry API exposed to Lua (rg -n 'keymap' crates/bitty-lua/src/lib.rs crates/bitty-runtime/src/plugin_runtime/services.rs finds none). Moving the
panel without that API would either keep a private first-party channel or ship
a help plugin with no data.

Scope

  1. Add a bounded, read-only keymap/action registry read API (own issue if it
    needs its own contract; OQ-056-style spelling discipline).
  2. Add a first-party help/which-key presentation plugin over that API plus the
    generic overlay mechanism; keep behavior parity for:
    • regeneration from the live registry on every show;
    • Esc dismissal that does not consume the press unless a real
      confirmation gate (paste, workspace close, view close) also coincides;
    • the toggle_help binding and aliases;
    • bounded rows and clipping.
  3. Remove the Core paint path (paint_help_panel, help_rows, help_panel_*
    tokens) once the plugin covers it; keep the overlay mechanism and the
    keymap registry.
  4. Update bitty-terminal-docs/specifications/input-pointer-rfc.md
    (implementation-evidence section) and the manual actions catalog.

Acceptance criteria

  • Zero-plugin baseline and bitty --safe draw no help panel; toggle_help
    remains a plugin command, not a Core action.
  • No private API: the help plugin uses the same capability-gated surface as a
    third party.
  • Existing help-popup and Esc-routing tests pass against the plugin path or
    become plugin tests; no coverage deleted.
  • Docs no longer describe help.rs as the shipped surface.

Out of scope

  • The Esc/confirmation-gate precedence (Core safety, unchanged).
  • The which-key Leader candidate (still unimplemented).

Activity

  1. added this to the v0.1.0 milestone on Oct 21, 2026
  2. added
    chore
    area:ui
    P2
    on Oct 21, 2026
  3. Xuepoo commented on Oct 21, 2026

    @Xuepoo
    ContributorAuthor

    Design recorded (docs-only, no Core product code changed): the help/which-key panel is plugin presentation over Core mechanisms.

    • Design note: help-overlay-ownership-design.md (docs PR docs(architecture): decide notification banner and help overlay ownership bitty-terminal-docs#281).
    • Read API: bitty.keymaps.list({ offset, limit }) gated by the closed runtime.keymaps.read capability (candidate spelling under OQ-056), returning canonical { chord, action, source, context, title?, command? } rows. Caps: 256 rows/call, 1024 total, 64 KiB response, per-field bounds, deterministic tail truncation. No string input exists, so the call cannot become a path/exec/network primitive; no config path, argv, env, URL, terminal content, or diagnostics are returned. Safe mode has no caller and a VM under safe policy denies.
    • Presentation: a paint-only bitty.ui.overlay.show/hide session over the existing overlay slot (NonModal on Popup, no capture, no modal_active), with Esc dismissal that routes the press onward and emits a queued overlay.dismissed observation. Confirmation gates keep the consume.
    • Plugin surface: bitty-terminal.help, command toggle_help, grants only runtime.keymaps.read, ui.rich, and ui.overlay; four historical chords; regeneration on every show; bounded rows/clipping; no private API.
    • Removal plan covers paint_help_panel, help_rows, help_panel_*, ChromeAction::ToggleHelp, the four default chords, show_help, the render/theme helpers, tests, and the docs/reference updates.
    • Second blocker found in source: match_plugin_binding always returns None; bitty.keymaps.suggest captures suggestions but they are never published, so the default chords need the reserved DispatchPriority::Plugin layer.

    Follow-ups (all 0.0.26):

    This issue stays open: the acceptance criteria require shipped code, zero-plugin and bitty --safe drawing no help panel, and no coverage loss.

  4. Xuepoo commented on Nov 1, 2026

    @Xuepoo
    ContributorAuthor

    Blocker cleared, split recorded.

    The "no bounded read-only keymap/action registry API" blocker no longer holds: bitty.keymaps.list() landed with bitty#2405 (canonical rows, 256-row pages, truncated), bitty.ui.overlay.* is available for the non-modal surface (CTX-0941, ui.rich + ui.overlay), and plugin-suggested bindings are captured with a bounded admission set (CTX-0707).

    The presentation half is planned as an upstream extension instead of Core work: bitty-terminal/bitty-plugins#122 (first-party help plugin, identity bitty-terminal.help, exactly the three grants runtime.keymaps.read, ui.rich, ui.overlay). This issue keeps only the Core half: remove paint_help_panel / help_rows / help_panel_* and the toggle_help chrome action once the plugin reproduces the parity matrix, and keep the keymap registry plus the overlay mechanism.

  5. Xuepoo commented on Nov 1, 2026

    @Xuepoo
    ContributorAuthor

    Concrete Core mechanism gap split out as bitty#2849: the only overlay a plugin can mount today (overlay slot + bitty.ui.overlay.acquire) is exclusive, focusable and input-capturing, which a non-modal help/which-key surface must not be. bitty#2849 defines a presentation-only overlay session (draw above the focused view, no capture, no focus change, dismiss-edge observation without consuming Esc, focus-follow, unload/revoke teardown, bounded budgets, and a capability spelling separate from ui.overlay).

    Ordering: bitty#2849 unblocks bitty-terminal/bitty-plugins#122; the Core paint removal in this issue follows the plugin parity run.

  6. Xuepoo commented on Nov 5, 2026

    @Xuepoo
    ContributorAuthor

    Audit: bitty origin/main @ 1008890a786e1d6840a0118d753471a74bdbc720 (2026-11-06)

    Headline: the blocker named in the body ("no bounded read-only keymap/action registry API") is gone, and the whole help.rs product surface is now expressible over the public Plugin API v1. What is not shipped is the removal half of this issue: help.rs, ChromeAction::ToggleHelp, the four default chords, help_panel_*, and the Core tests are all still present at HEAD, and input-pointer-rfc.md still calls help.rs the shipped surface. So this issue is no longer blocked, but it is not done.

    1. Blocker status — cleared

    Blocker at filing Shipped artifact Evidence at 1008890a
    No bounded read-only keymap/action registry read for Lua bitty#2424 (merged 2026-10-21, ctx-2405/feat-keymaps-read) — bitty.keymaps.list({offset, limit}) crates/bitty-lua/src/host.rs:4853 (bridge registration), :4872 (state.services.keymaps_list), :4878 (64 KiB refusal); implementation crates/bitty-lua/src/keymaps.rs:1-40
    — capability gate runtime.keymaps.read, deny-by-default, safe-mode first crates/bitty-runtime/src/plugin_runtime/services.rs:6213-6230 (`safe_mode
    — bounds 256 rows/call, 1024 addressable, 64 KiB/page, per-field caps, whole-row tail drop crates/bitty-lua/src/keymaps.rs:44,47,52,55,58,61,64,67; page assembly :303-345
    — returned fields entries[{chord, action, source, context, title?, command?}], total, offset, truncated crates/bitty-lua/src/keymaps.rs:148-165 (row), :282-296 (page), :359-372 (to_lua)
    No presentation-only overlay (v1 overlay slot only painted under capture) bitty#2849 → bitty#2856 (merged 2026-11-03, ctx-1673/feat-presentation-overlay) — bitty.ui.present.show/hide (+ bitty.ui.overlay.show/hide alias) crates/bitty-runtime/src/plugin_runtime/presentation_overlay.rs:1-35,42-43 (NonModal/Popup), crates/bitty-lua/README.md:43-70; tests crates/bitty-runtime/tests/presentation_overlay_api.rs:173,227,292,364,430,472,519,588
    Plugin-suggested bindings inert (match_plugin_binding → None) bitty#2407 → bitty#2552 (merged 2026-10-24, ctx-1431/feat-plugin-keybinding-dispatch) crates/bitty-terminal/src/chrome_keys.rs:874 (priority doc), :1047 (DispatchPriority::Plugin), :3212 (dispatch arm)

    2. Can a plugin reproduce help.rs's product surface on accepted v1 only?

    help.rs element Plugin-reachable equivalent Evidence
    Titled floating panel + rounded surface/border ring Core draws the chrome card for a presented overlay with the same border token the help panel uses (chrome_border_in → palette.border_idle) crates/bitty-render/src/grid.rs:459-470 ("One shared resolver for normal chrome surfaces (help/which-key, palette, presentation/plugin overlays)"); crates/bitty-runtime/src/runtime/present.rs:5900-5913 (paint_presentation_overlay → paint_overlay_surface, ChromeState::Normal)
    Title "Keyboard shortcuts", footer "Esc closes | repeat toggle closes" Text scene nodes (plugin-owned content) help.rs:19,22; accepted restriction to Text|Row|Column|List at bitty-plugins-docs/sdk/plugin-api-v1-lua-surface-rfc.md:354
    Rows from help_rows_from_keymaps (live registry, every show) bitty.keymaps.list per open (page while truncated), command: rows joined with bitty.commands.list for titles (ungated: services.rs:5839-5857) help.rs:127; crates/bitty-lua/src/host.rs:2268; no row cache by contract (keymaps.rs:1-30)
    Palette tokens help_panel_fg_in / _bg_in / _border_in foreground / selection scene tokens + the Core card border grid.rs:454-489 (fg = palette.foreground, bg = palette.selection, border = border_idle); closed token table crates/bitty-runtime/src/runtime/band_host.rs:768-785 (foreground, background, cursor, selection, accent)
    Centering, clip to frame, tiny-view skip, +N more clipping, Esc-not-consuming, focus-follow, teardown Core-owned by the presentation session; overlay.dismissed{owner,handle,reason} for "escape" / "view-closed" presentation_overlay.rs:1-35; present.rs:5889-5913; EventKind crates/bitty-plugin-host/src/event.rs:237
    toggle_help + four chords (alt+` , alt+?, alt+shift+?, alt+shift+/) plugin command + bitty.keymaps.suggest published at DispatchPriority::Plugin; user binding wins keymap.rs:1786-1789 (current); chrome_keys.rs:1047,3212

    No element is excluded by an accepted document. Two exact deltas remain, neither of which is a missing mechanism:

    1. The presentation session needs a fourth grant, ui.present. bitty.ui.present.show fails closed without it (services.rs:2758; catalog capability.rs:160,498 "Draw a non-focusable presentation panel above the focused view (no input capture)"; manifest spelling manifest.rs:358; bitty.ui.overlay.show is gated by the same head, crates/bitty-lua/README.md:60). [0.0.26] First-party help/which-key plugin over the keymap read API and presentation overlay #2408's "exactly the three named grants" is therefore unsatisfiable as written and needs amending.
    2. The +N more count has no plugin-reachable input. Today the tail count is derived from the view height (help.rs:82-95, body = view_h - 4); v1 exposes no viewport/frame geometry to plugins (the only size-bearing read is bitty.terminal.snapshot, which needs terminal.semantic-read and reports the terminal grid, not the view frame). Core instead truncates a presented overlay at a fixed 64 rows / 16 KiB (present.rs:154,163,172) and accounts the dropped tail host-side. A plugin must pick its own fixed row cap, so the literal +N more number is approximate, not identical.

    3. Acceptance criteria

    Criterion (from body) Status Evidence
    Zero-plugin baseline and bitty --safe draw no help panel; toggle_help is a plugin command, not a Core action NOT MET help.rs exists in full (:19,22,30,180), painted at present.rs:5433; ChromeAction::ToggleHelp at keymap.rs:696 with parse arms :962-964, canonical :1123, hint :1257, four default chords :1786-1789; app arm chrome_keys.rs:2402; Esc branch selection.rs:2674. Safe mode has no bearing on it — it is Core paint.
    No private API: same capability-gated surface as a third party MET (mechanism), unexercised runtime.keymaps.read gate services.rs:6213-6230; ui.rich+ui.overlay at mount services.rs:4775; ui.present services.rs:2758. No first-party channel exists in the tree.
    Existing help-popup / Esc-routing tests pass against the plugin path or become plugin tests; no coverage deleted NOT MET Still Core-only: crates/bitty-runtime/tests/help_popup.rs (8 tests incl. :41,63,126,148,271) and crates/bitty-runtime/tests/esc_routing.rs:78. Nothing moved.
    Docs no longer describe help.rs as the shipped surface NOT MET bitty-terminal-docs/specifications/input-pointer-rfc.md:346-357 — "Help overlay ownership transition (decided direction, not implemented)… help.rs remains the shipped surface and this evidence section stays".

    Remaining slice

    1. Stage 4 — publish the plugin: bitty-terminal/bitty-plugins#122 is open, no plugins/help submodule and no registry/official/help.toml in bitty-plugins (tracked by [0.0.26] First-party help/which-key plugin over the keymap read API and presentation overlay #2408).
    2. Stage 5 — delete crates/bitty-runtime/src/runtime/help.rs, the Runtime help state/methods, the paint call at present.rs:5433, and the dismissal branch at selection.rs:2674.
    3. Stage 6 — retire ChromeAction::ToggleHelp, the toggle_help/show_help parse arms, KNOWN_ACTIONS_HINT entry, the four default chords, and the chrome_keys.rs:2402 arm (fail closed with a migration pointer to command:bitty-terminal.help:toggle_help).
    4. Stage 7 — delete help_panel_bg_in/help_panel_border_in/help_panel_fg_in (grid.rs:454-489) and their tests (grid/tests.rs:2295-2309).
    5. Stage 8 — docs: input-pointer-rfc.md:346-357 + implementation-evidence table, the design doc's current-state table, configuration action catalog, shipped-defaults reference, release notes.
    6. Coverage move — help_popup.rs / esc_routing.rs help cases into plugin tests or presentation-overlay mechanism tests; the Core Esc/confirm matrix stays.
    7. Amend [0.0.26] First-party help/which-key plugin over the keymap read API and presentation overlay #2408 — grant list must be four (runtime.keymaps.read, ui.rich, ui.overlay, ui.present).

    CLOSE-ELIGIBLE: NO (blocked on stage 4 first-party plugin + Core removal stages 5-8; the original API blocker is cleared)

  7. Xuepoo commented on Nov 10, 2026

    @Xuepoo
    ContributorAuthor

    Guard tick 2026-11-10 — Core half landed

    #3105 merged as 3101ab26 ([CTX-1784], task CTX-1784 completed). Parity was proven before any deletion: every painted element of crates/bitty-runtime/src/runtime/help.rs (title, registry-derived rows and ordering, footer, +N more tail, empty state, the four chords, Esc dismissal) is reproduced by the shipped bitty-terminal.help plugin (lua/help/init.lua + tests/spec/help_spec.lua).

    Removed from Core: help.rs (paint + rows + toggle + layout), help_panel_*/HELP_PANEL_* render tokens, ChromeAction::ToggleHelp with the four default chords, the A::ToggleHelp dispatch arm and the Esc help-dismiss branch. Kept: the keymap/command registry, overlay geometry/stacking and bitty.keymaps.list.

    Two blocking review findings were fixed before merge: retired toggle_help/show_help bindings are now dropped per-binding with a diagnostic naming bitty-terminal.help (previously the whole keymaps table was salvaged away, losing every sibling binding), and the official catalog was regenerated (SOURCE_REVISION 2da1c875) so bitty plugin install bitty-terminal.help resolves to pin ae1d8a9.

    Remaining acceptance gap (issue stays open): docs sync — bitty-terminal-docs (input-pointer-rfc.md and friends) and bitty-docs still describe help.rs as the shipped surface. Second independent review: VERDICT: APPROVE on head 4fc555bb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2area:architecturearea:uichore

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions