Skip to content

Give the keyboard an explicit layer stack - #780

Merged
max-sixty merged 4 commits into
mainfrom
keyboard-bindings
Sep 18, 2026
Merged

max-sixty merged 4 commits into
mainfrom
keyboard-bindings

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

keyboard/layer-stack.js replaces keyboard/return-stack.js and runtime/native-layers.js with one ordered stack of what stands over the page: auto popovers, modal dialogs, and the return frames commands push when they enter a temporary surface. An opener pushes its entry as the surface opens, and a command whose own run opened a native layer adopts that entry, so one gesture leaves one entry. This is TODO.md's architecture item 24, which the branch removes from the list.

stack() in keyboard/dispatch.js now reads that stack rather than inferring the layer situation from :popover-open and dialog:modal ancestry on every press. It tiers the scopes over the stack in one loop from the top down: each layer takes the scopes rooted inside it, the topmost layer also takes the focused control, explicitly inner modes and the return frame, and a boundary follows each layer. The newest modal is the floor. A covering auxiliary surface stays out of the stack and becomes the floor when no modal stands, so a frame entered while its panel stood beside the page survives a resize into the covering posture and back.

Two tiering changes are observable, and both close holes. A popover standing above a modal but not nested inside it keeps its own scopes. Widget scopes in a shadow root under the covering panel are reachable.

A review of the first commit found that a popover closed by light dismissal and reopened by script could take back its old entry, frame and origin included, so Escape would have restored a place the reader never asked to return to. A modal now marks the entries beneath it as suspended when it is pushed, and the popover patch declares the layer before the native call rather than after, so the stack sees the surface closed and starts a fresh entry. A new case in test_native_top_layers_bound_the_keyboard_stack pins that, using a popover in an undeclared shadow root where only the patched method can declare the opening.

Run green on the branch locally: the four keyboard-facing nightly files (test_render_navigation, test_render_controls, test_render_startup, test_render_widgets), pre-commit, and the everyday gate.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 4 commits September 17, 2026 21:15
`keyboard/layer-stack.js` replaces `keyboard/return-stack.js` and
`runtime/native-layers.js` with one ordered list of what stands over the page. A
popover or modal dialog pushes an entry as it opens, and a command that enters a
temporary surface pushes a return frame or adopts the layer its own run opened,
so one gesture leaves one entry. Every read prunes the stack, keeping an entry
under an active modal suspended with the frame it carries, and `current()` is the
top entry when that entry carries a live frame. The monotonic order counter and
the ancestor walks it was compared against are gone with it.

`stack()` in the dispatcher drops the popover, modal and covering branches that
inferred the layer situation from focus ancestry on every press. It tiers the
scopes over the stack instead: each layer takes the scopes rooted inside it, the
topmost layer also takes the focused control, explicitly inner modes and the
return frame, and a boundary follows each layer. The newest modal, or a covering
auxiliary surface, is the floor, and what that floor makes inert stays out of
reach however near the reader it stands.

The covering auxiliary surface stays off the stack on purpose, so a frame entered
while its panel stood beside the page survives a resize into the covering posture
and back. `openAuxiliarySurfaceFor` and the modality's `openSurfaceFor` go with
the order comparison that was their only reader.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A reopened popover took back its old entry, frame and origin included, whenever
the stack had not been read since the surface closed. That let a pointer-reopened
popover restore an origin the reader never asked to return to. Now a modal marks
the entries beneath it as suspended when it is pushed, before the native call
hides the popovers under it, and an opening lifts an existing entry only when it
is standing or carries that mark. A closed entry is pruned and its reopening
starts fresh; the command reference's re-show still finds its suspended entry.

The header names the one layer this module cannot hear: a popover opened
declaratively inside an undeclared shadow root. The keyboard guidance calls the
entries return frames in every file, the `closedby` rule lives only in the module
that owns it, and the glossary names the layer stack. TODO #24 leaves, since the
stack landed; the invoker-commands row now states what a pointer-opened surface
still lacks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The showPopover patch declared the layer after the native call, when the surface
was already standing, so a popover a light dismissal had closed and a script then
reopened lifted its old entry, frame and origin included, and Escape would have
restored a place the reader never asked to return to. It now declares before the
call, as the showModal patch does, so the stack sees the surface closed and starts
a fresh entry. One opening is then declared twice, by the patch and by
beforetoggle, and the second finds the lifted entry not yet open, so the
suspension mark now lasts until the entry is next seen standing rather than
clearing on the lift. The layer test pins the reopening with a popover in an
undeclared shadow root, where only the patched method can declare it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@max-sixty
max-sixty merged commit b7e1efd into main Sep 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the keyboard-bindings branch September 18, 2026 05:32
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