Skip to content

Let widgets own keyboard context bindings and hints - #1654

Merged
max-sixty merged 7 commits into
mainfrom
codex/widget-context-keys
Oct 3, 2026
Merged

max-sixty merged 7 commits into
mainfrom
codex/widget-context-keys

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Ask currently assigns digits from its available actions, so a widget depends on Ask for numeric shortcuts and removing an action can change another action’s number. This change gives widgets explicit contextKeys and stable numeric assignments, then forwards references to their original commands at the question opening, margin representatives, and Ask-associated threads. Page-level a/A navigation remains the same.

The shared keyboard layer now drives dispatch, inline hints, the shortcut bar, the command reference, and ARIA from one availability reading. Native editing takes priority over context aliases, unavailable bindings reserve their key, and replacing or disconnecting a source withdraws its routes. Generic hints work with both the default annotation overlay and page-owned annotations.

  • Command rows use required title, optional description, and boolean decision roles; all bundled providers are converted.
  • Options own stable 1–9 slots, including generated choices and undo; other answering widgets declare their own aliases. Answering widgets also work without an Ask wrapper.
  • Browser regressions cover source lifetime, native editing, modal precedence, canonical route identity, command-reference policy, disabled keys, and synchronized hint presentation. The package contract, registry reference, gallery corpus, and still scenarios are updated.

Focused browser verification covers keyboard scoping, shared draft editing, native digit entry, forwarded Save/Cancel, and control replacement. The integrated runtime passes 194 runtime tests, TypeScript checks, a reproducible vendor rebuild, and pre-commit checks; the browser-framework and worker suites passed 74 and 66 cases respectively. The 56 instruction-runner tests pass, and the targeted authoring comparison scored base 0/1 versus candidate 1/1 with zero execution errors. Served startup profiles both reach authoritative presentation without browser errors; the shared hint renderer adds one JavaScript request and 10,100 JavaScript bytes. The corpus matches its canonical generator. CI runs the current merge’s everyday and changed nightly gate plus website delivery checks.

This was written by Codex on behalf of max-sixty

Move badge and accessible route presentation from Ask to the shared keyboard layer. Declared bindingBadge seats and explicit null corner requests work for widget-owned commands, including forwarded scopes, without Decision metadata.

Native and ARIA disabled controls make commands unavailable at the same boundary as dispatch; disabled routed commands retain their keys without invoking a shared handler or exposing an outer action. An explicit route corner request overrides a row seat.

Cover native editing, scope changes, replacement, alias merging, disabled rows and routes in real-browser tests, and add a standalone gallery and screenshot state.
Declare concise titles, optional descriptions, and boolean Decision roles
throughout the runtime and bundled packages. Compile explicit contextKeys
as references to their original commands at local and Ask-associated scopes.

Remove Ask digit allocation and the mandatory answering-widget wrapper.
Keep native editing ahead of contextual aliases, reserve unavailable digits,
and preserve stable option identities through generated choices and undo.

Replace synthetic Ask-action assertions with real command availability and
execution regressions across hints, ARIA, the bar, reference, and source lifetime.
Regenerate the gallery corpus and registry reference for the new contract.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command-title migration leaves test_a_reference_command_finishes_its_gesture_before_a_newer_control unable to reach the behavior it tests. commenting() now exposes comment on the control, while the test locates the exact accessible name Comment on the control; both parameterizations fail at to_be_visible() before dispatch. I reproduced the arrival failure in isolation. Align the title or the locator, then run both cases so this gesture regression remains covered.

leaf-agent
leaf-agent previously approved these changes Oct 3, 2026
@max-sixty
max-sixty merged commit a8cf383 into main Oct 3, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/widget-context-keys branch October 3, 2026 08:37
max-sixty added a commit that referenced this pull request Oct 14, 2026
Strict `tsc` covered only `build/browser/*.ts` and the seven runtime
modules marked `// @ts-check`; the other ~240 files under
`skills/leaf/assets/runtime/` were unchecked. `pnpm run check:browser`
(and so `pnpm run check`, the PR `test` job and `wt merge`'s pre-merge
`node-checks`) now runs a second, non-strict `checkJs` program over
every runtime module and the render checks pages import from `/checks/`.
It found about 400 errors on main, and this PR clears them, mostly with
JSDoc types, casts and narrowing.

## How the gate is wired

- `build/browser/tsconfig.runtime.json` is the non-strict program.
`paths` resolves the runtime's rooted imports (`/vendor/…`,
`/runtime/…`, `/checks/…`). Its `include` also pulls in Web Awesome's
`copy-button` and `input` declarations, which add those tags to the tag
map.
- `build/browser/tsconfig.json` now includes every runtime module
(unchecked unless it carries `// @ts-check`), so any module that opts
into strict mode is checked strictly, whether or not the framework
imports it.
- `build/browser/build.mjs` (`typecheck`) runs both programs. tsc checks
a JS file wherever an import reaches it, under the options of the
program it's in, and has no per-file opt-out. So from the runtime
program the build drops diagnostics in vendored third-party bundles and
in files the strict program owns (`.ts` and `// @ts-check`). Every other
diagnostic fails the build. The runtime program takes about 1.2 s.
- The framework's types reach the runtime through a generated
`skills/leaf/assets/vendor/browser-runtime.d.ts` (`export * from
"…/build/browser/index.ts"`). Before, tsc inferred them from the
compiled facade (types blanked) and the minified Lit bundle, which
produced bogus errors such as `render(): symbol` on `LitElement`
subclasses. This file ships in the layer like the `.LICENSES.txt` files
beside it; nothing loads it at runtime.
- `build/browser/runtime-globals.d.ts` declares, in one place:
- what `prepaint.js` and `bootstrap.js` hang on `<html>` (`lfInitial`,
`lfStorage`, `lfKeyboard`, `lfChrome`, `lfViews`, `lfInputs`,
`lfDocumentLifetime`, `lfStartupException`, `lfSample`) and on `window`
(`lfSampleBridge`);
  - the entry script's `lfDocumentPort` and `lfRenderingState`;
- the events dispatched with a detail (`lf-startup-failed`,
`lf-command-invoked`, `lf-held-keys`, `lf-reveal`, …);
- the runtime's custom elements by tag, through a `@typedef` beside each
class.

  The scripts' assignments are checked against these declarations.

## Declarations corrected at their owner

`application.ts` didn't declare served-state fields the runtime already
reads: `files` (each binding's stamp), `browser.version_notes`,
`browser.history`, the undo entries' `newest`, the report feed's fields,
and a to-do subject of kind `element`. `thread/model.js` now accepts the
readonly thread snapshots its callers pass. `askValue` takes an
`Immutable` widget. `retainUserIntent`, `watchArrivals`, `rowWalk`,
`closeLayer` and similar functions get parameter types where defaults
had inferred narrower ones.

## Behavior the types exposed

- **Bug, fixed:** `queue-walk.js` subscribed to
`effective.queues.questions`, a field #2783 renamed to `on_user`. The
selection was always `undefined`, so the walk never asked for a key
repaint when On me emptied or filled. It now selects `on_user`.
`tests/runtime/queue-walk.test.mjs` covers it: it fails on the old line
and passes on the new one.
- **Dead code, removed:** `comment.create` declared `description: () =>
commentDestination().description`. `commentDestination` stopped
returning `description` in #1654, so the field always answered
`undefined`; every consumer resolves it through
`word()`/`descriptionOf`, so removing it changes nothing.
- Two edits change code shape without changing behavior: a boolean
subtraction in a sort comparator now goes through `Number()`, and two
Lit directives' `render()` now declare the values `update()` already
received.

## Checks

`pnpm run check`, including `test:runtime` (423 tests), passes. Focused
pytest `tests/model/test_unused_exports.py`, `test_interact_layer.py`,
`test_distribution.py` and `test_module_url_delivery.py` (238 tests)
pass. Pre-commit passes on every changed file. An injected property
error in a runtime module fails `check:browser` with the diagnostic.

Not covered yet: `skills/leaf/assets/leaf.js` and the packages' widget
modules sit outside `runtime/` and aren't in the runtime program.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.

2 participants