Repository navigation
Description
Priority: P2 | Area: ui | Labels: feat,P2,area:ui,area:architecture | Milestone: v0.1.0 | RFC: ADR-0014 / OQ-056 | Task: TBD
Core mechanism gap found while splitting the help/which-key presentation out of Core (bitty#2397, bitty#2408, upstream bitty-terminal/bitty-plugins#122).
Problem
The only overlay a plugin can mount today is the overlay slot plus bitty.ui.overlay.acquire, and that surface is exclusive, focusable and input-capturing by contract (crates/bitty-lua/src/host.rs: "Claim the Core-owned exclusive focusable-overlay input capture for one transient interaction"; a second acquire fails closed with E_UI_ALREADY_CAPTURED).
A help/which-key surface is the opposite: it is non-modal, must not take focus or capture input, must follow the focused view, and must dismiss on Esc without consuming the press unless a real confirmation gate also coincides. Expressing it through the capture overlay would either take input authority a help panel must not hold, or require a private Core channel - exactly what the ownership split exists to prevent.
Nothing in bitty-runtime/bitty-lua draws a plugin scene above the focused view without a capture session today (grep for presentation-only finds only config chrome).
Required mechanism (Core)
- A presentation-only overlay session a granted plugin can mount into: drawn above the focused view's content, bounded to the view rectangle, clipped, and stacked deterministically with chrome bands.
- No input capture: the session never receives key/mouse events, never takes focus, and never changes the focus ring. The only observation it gets is the dismiss edge it asks for (for example "the user pressed Esc / the view lost focus"), delivered as an event, not as a consumed press.
- Focus-follow: the surface tracks the focused view and disappears (or reports a bounded unavailable state) when that view closes; unload/revoke tears it down with no residue.
- Bounded resource profile: at most one presentation overlay per view per generation, bounded rows/bytes, render budget accounted like a chrome band, and no terminal-content reads.
- Capability spelling that separates "draw above the view" from "capture input": the existing
ui.overlaygrant stays capture-only; the presentation surface needs its own name (for exampleui.present) so a manifest cannot gain capture by asking to draw. - Safe mode: no presentation overlay when plugins are disabled; a revoked generation drops its surface on the next present.
Acceptance criteria
- A bounded Lua API for the session plus the dismiss/observed-edge event, documented in the plugin API reference and the manual.
- Headless tests: draw above the focused view, clipping at the view rectangle, Esc dismissal without consuming the press, no focus change, focus-follow on view close, unload/revoke teardown, safe-mode absence.
- An independent security review records that the surface cannot read terminal content, cannot capture input, and cannot outlive its generation.
bitty.ui.overlay.*behaviour and itsE_UI_ALREADY_CAPTUREDcontract unchanged.
Why this is Core
Placement, stacking, budgets, hit-testing, capability enforcement and teardown are Core mechanism per ADR-0014. What the surface shows stays with the plugin; this issue does not decide any help-panel content or styling.
Activity
Xuepoo commentedon Nov 1, 2026
Cross-links: parent ownership split bitty#2397, plugin half bitty-terminal/bitty-plugins#122, composition umbrella bitty#2191. The Core-drawn help panel and its
toggle_helpchrome action stay in place until the plugin reproduces the parity matrix over this session.Xuepoo commentedon Nov 3, 2026
Independent review by agent-reviewer (cron guard tick), 2026-11-03
Read-only review of
origin/main@8108e4f7(squash of #2856) in a detached worktree; no code or branch was modified. Docs checked in the canonical repos at their currentmain(bitty-plugins-docs#182 merged 2026-11-03T11:33:21Z,bitty-manual#108 merged 2026-11-03). This tick had no compositor access, so paint behaviour is verified from the headless test harness and code paths, not a live window.Criteria
bitty.ui.presentis a read-only table with exactlyshow/hide—crates/bitty-lua/src/host.rs:6439-6494(no acquire/poll/register, no callback). Both verbs route to the same Core session as the CTX-1431bitty.ui.overlay.show/hidespelling (host.rs:6332-6428). Dismiss edge is an accepted event kindoverlay.dismissed(crates/bitty-plugin-host/src/event.rs:235-237,268-270), payload is exactly{owner, handle, reason}(crates/bitty-terminal/src/terminal_app.rs:2666-2679). Reference:bitty-plugins-docs/sdk/reference/ui.md:323(§Presentation-only overlay (ui.present)), errors:363, observation:386. Manual:bitty-manual/en/api/ui.md:272(§Presentation-Only Overlay) and:350(§Dismissal observation); thezh-CN/api/ui.mdpage was not updated (see gaps).crates/bitty-runtime/src/runtime/present.rs:8617(+ paint order:3087-3092). Clipping to the frame:present.rs:8948(clip rect built fromframe.contentat:5857-5871). Esc without consume:crates/bitty-terminal/src/tests.rs:17351(assertsintercept_chrome_keyreturns false and0x1breaches the PTY). No focus change:present.rs:9063. Focus-follow on view close:tests.rs:17437+ unit testspresentation_overlay.rs:482-535. Unload/revoke teardown:crates/bitty-runtime/tests/presentation_overlay_api.rs:397,tests.rs:17547. Safe-mode absence:presentation_overlay_api.rs:513. Row/byte budgets:present.rs:8989,9019. Lua round trip:crates/bitty-lua/tests/ui_bridge.rs:769.specifications/presentation-overlay-session-ctx-1673-evidence.md:102-105("Independent security review is pending … does not self-certify them"), and the PR body leaves the same box unchecked. Noui.presentsecurity-review record exists inbitty,bitty-plugins-docs,bitty-manual, orbitty-terminal-docs(code search + tree reads). Missing artifact: a committed security-review record (e.g.specifications/security-review-presentation-overlay-ctx-1673.mdor abitty-docsreview) by a non-author covering the three properties and the residual risks; a comment alone is not the record this criterion asks for.bitty.ui.overlay.*behaviour and itsE_UI_ALREADY_CAPTUREDcontract unchangedplugin_runtime/overlay.rsis not in the diff andE_UI_ALREADY_CAPTUREDis still raised atoverlay.rs:214(overlay.rs:193-215);cargo test -p bitty-runtime --test plugin_ui overlay_capture_is_single_owner_and_release_is_idempotentpasses. But onebitty.ui.overlay.*verb changed behaviour:bitty.ui.overlay.showwas gated onui.rich+ui.overlaybefore this commit (f0a6d252:crates/bitty-runtime/src/plugin_runtime/services.rs:2741-2760) and is now gated onui.presentalone (crates/bitty-runtime/src/plugin_runtime/services.rs:2750-2759). A manifest holding only the old mount grants now getsE_CAPABILITY_DENIED ui.present; that is asserted as intended bypresentation_overlay_api.rs:293-330.hideis unchanged (ungated/idempotent). The re-gate is coherent with the capability split and is unreleased (v0.0.31does not containf0a6d252, so no shipped plugin breaks), but it is literally a behaviour change tobitty.ui.overlay.showand it left two stale doc comments (below).Specific checks requested by the guard tick
ui.presentis its own capability head; cannot imply or be implied byui.overlay/ui.overlay.focuscrates/bitty-plugin-host/src/capability.rs:151-162,crates/bitty-package/src/manifest.rs:352-359(three-way head-equality testcapability.rs:1148-1160passes). Grant resolution is an exact string compare, no expansion:crates/bitty-runtime/src/plugin_runtime/mod.rs:2770-2772, consumed aspresentat:2897. Draw gate requires onlyui.present(services.rs:2757); mount gate still requiresui.rich(+ui.overlayfor the overlay slot) and is untouched (services.rs:4772-4776). Cross-grant denial is pinned bypresentation_overlay_api.rs:289-347(ui.rich+ui.overlaynever implyui.present;ui.presentdraws with noui.overlay.focus).ui.overlay'sE_UI_ALREADY_CAPTUREDsingle-owner contract untouchedoverlay.rsunmodified by #2856 (git diff --stat f0a6d252..8108e4f7touches onlyhost.rsandservices.rsof this area). Single-owner refusal atoverlay.rs:193-215; const atbitty-lua/src/host.rs:935; test passes. Presentation admits into its ownOverlayManager(presentation_overlay.rs:105-113,160-176), so it cannot consume or steal the capture owner's slot.plugin_runtime/mod.rs:3335-3338; dispose/unload/crash::3453-3456; failed activation rollback::4445-4447. Revoke funnels throughclear()which dismisses the admitted slot:presentation_overlay.rs:200-209,355-360. Paint content is re-resolved per tick from the live generation's retained blocks, so a revoked generation yieldsNone:mod.rs:1920-1940+terminal_app.rs:2782-2790. Esc clears the paint copy synchronously (terminal_app.rs:2622-2632). Caveat: suspend/dispose detected on the cold path can leave the clonedRuntimesurface painted for at most one frame until the nextupdate_plugin_overlay; session state and slot are already gone.require_presentation_overlaycheckssafe_modefirst and returnsE_UI_UNAVAILABLEbefore the grant check and beforePresentationOverlay::showis called (services.rs:2750-2759; call order inui_overlay_show_with_expiryservices.rs:5120-5154). The flag is set on the generation at build time (mod.rs:2903). Note the test only exercises the "no generation admitted in safe mode" path (presentation_overlay_api.rs:513-540); the in-gate branch itself has no direct test.Verification actually run in the review worktree
PR #2856's own CI at
8108e4f7is green on Linux X11/Wayland, macOS, Windows, MSRV, CodeQL and supply chain.Residual risks and gaps
specifications/presentation-overlay-session-ctx-1673-evidence.md:102-105still lists it as pending; nothing in the four doc repos supersedes it.bitty.ui.overlay.showre-gate (criterion 4). The grant moved fromui.rich+ui.overlaytoui.present; if the intent was literal "unchanged", this needs an explicit scope decision in the issue (or a compatibility alias that still accepts the old grants, which would weaken the split).crates/bitty-lua/src/host.rs:1989-1992still says the caller "must holdui.richandui.overlay";crates/bitty-runtime/src/plugin_runtime/presentation_overlay.rs:11-14still says "It needs only the v1ui.rich+ui.overlaygrants".DismissedEventdocs also say the reason is"escape"today (presentation_overlay.rs:60-64) althoughview-closedexists.{owner, handle, reason}only (terminal_app.rs:2672-2676); no key code, text, modifiers, or coordinates. TheEscitself still reaches the focused PTY by design (tests.rs:17386-17390) — that is normal routing, not a plugin-visible leak. A plugin that also wants raw keys still needs a separateterminal.input.*grant.UiNode(present.rs:5739), and the dismiss payload carries no content. It does touch Core'slayers.combined_glyphsto occlude underlay glyphs inside the card (present.rs:5897-5904) — Core-only geometry used to hide text under the card, never exposed to the plugin.Runtimepaint copy clears on the next tick (terminal_app.rs:2764-2790); the unload test only asserts clearance after adrive_tick(tests.rs:17547-17596).view-closed.Runtime::is_live_viewchecks only the active layout, pinned leaves and floats (runtime/layout_focus.rs:3060-3064);observe_focustests liveness before re-binding (presentation_overlay.rs:236-260), so switching to another workspace can dismiss a panel whose view still exists in an inactive workspace, with theview-closedreason.present.rs:3087-3092paints chrome bands → presentation → capture modal, but no test builds all three layers and asserts stacking; the "draw above the focused view" tests assert placement/layer membership only.OverlayManageris its own instance (presentation_overlay.rs:105-113), so "consumes one non-modal slot underMAX_OVERLAYS_PER_WINDOW" does not bound overlays held by the window's live manager.bitty-manual/zh-CN/api/ui.mdhas noui.presentsection; the English page does).Verdict
NOT READY TO CLOSE — mechanism and tests are sound (criteria 1-2 and both capability-split/revoke checks PASS), but the required independent security-review record is still missing (criterion 3 PARTIAL) and
bitty.ui.overlay.show's required grant changed (criterion 4 PARTIAL).[CTX-1677] style(docs): align the evidence tables for MD060
[CTX-1677] fix(runtime,lua): close the ui.present acceptance gaps (bi…
Xuepoo commentedon Nov 3, 2026
Closed by the CTX-1677 closeout wave.
bitty.ui.present(show/hide, read-only table) draws above the focused view's content, clipped to the view rectangle,OverlayKind::NonModalonOverlayTier::Popup, never hit-tested, never takes focus; the dismiss edge is delivered asoverlay.dismissed{owner, handle, reason}instead of a consumed press — bitty PR [CTX-1673] feat(runtime,lua): presentation-only overlay session with ui.present (bitty#2849) #2856, closeout PR [CTX-1677] fix(runtime,lua): close the ui.present acceptance gaps (bitty#2849) #2857 (squash7ac871d4).crates/bitty-runtime/src/runtime/present.rs), clipping, Esc-without-consume (crates/bitty-terminal/src/tests.rs), no focus change, focus-follow on view close, unload/revoke teardown, safe-mode absence, and the four-grant-shape gate test (crates/bitty-runtime/tests/presentation_overlay_api.rs).bitty-terminal-docssecurity/audits/presentation-overlay-2026-11.md(PR [CTX-0214] feat(rich): streaming kitty chunked intake with 320MB ledger #376) records properties 1–3 (no terminal-content read, no input capture, cannot outlive its generation) against8108e4f7.bitty.ui.overlay.*and itsE_UI_ALREADY_CAPTUREDcontract are unchanged;ui.overlaystays capture-only andui.presentneither implies nor is implied byui.overlay.focus.Follow-up tracked elsewhere: help/which-key consuming surfaces stay with #2397 / #2408.