Skip to content

Add swipe decisions and canonical package commands - #274

Merged
max-sixty merged 22 commits into
mainfrom
codex/swipe-package-interface
Sep 5, 2026
Merged

max-sixty merged 22 commits into
mainfrom
codex/swipe-package-interface

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Summary

  • Add an optional swipe package for rapid pass/keep design triage, with buttons, arrow keys, pointer swipes, durable replay, completion, answered review, and revision.
  • Make commands() the canonical package capability declaration for dispatch, help, accessibility shortcuts, exact Ask action routes, inline binding hints, and concise answered summaries; expose semantic Decision watchers and remove the parallel action registry.
  • Generalize package scaffolding and state validation around declared completion and position contracts, safe concurrent writes, package-local assets, and current authoring guidance and examples.

Verification

  • uv run pytest tests — 855 passed
  • uv run pytest --run-nightly tests/test_render_options.py tests/test_render_widgets.py -q — 149 passed
  • uv run pre-commit run --all-files
  • UI sweep at 1200×900 and 420×900, light and dark, covering keyboard, buttons, pointer swipes, answered review, Undo, and the live responsive tray transition

This was written by Codex on behalf of max-sixty

Make command declarations the shared source for keyboard dispatch, Ask controls, and inline bindings. Add semantic decision subscriptions, generic completion and position validation, package scaffolding, and the bundled swipe deck with browser coverage.
…nterface

# Conflicts:
#	skills/leaf/CLAUDE.md
#	skills/leaf/assets/leaf.js
#	skills/leaf/assets/runtime/decisions/actions.js
#	skills/leaf/assets/runtime/decisions/view.js
#	skills/leaf/assets/widgets/lf-suggestion.js
#	skills/leaf/packages/command-hub/widgets/lf-operations.js
#	skills/leaf/packages/default/widgets/lf-draft.js
#	skills/leaf/packages/default/widgets/lf-options.js
#	skills/leaf/references/packages.md

@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.

Two findings, both on gates that this PR widens. Neither blocks the claimed path — the suite is green and the swipe flow works as described — but each one is a contract the layer used to hold and no longer does.

The first is the Ask projection now mixing declared bindings with contextual digits: with the reader's character-shortcut preference off, the row's arrow bindings keep it alive while its digits are filtered out of dispatch, so the key line and the chips advertise a press the dispatcher refuses. That is exactly what the comment on live in keyboard/bindings.js says the register must never do ("no surface can promise a press the dispatcher refuses"), and before this change it could not happen because every Ask binding was a digit and the whole row went dark together. lf-swipe-deck is the first contribution that mixes the two.

The second is _validate_awaiting_units: the removed "answer verbs must fold on the widget" rule is replaced by a rule about verbs that declare completion, not by one about verbs whose unit is a part. Checked against the tree — dropping completion from lf-swipe-deck's finish while leaving unit: "card" still validates:

$ # composed swipe registry, finish.completion deleted
ACCEPTED: answer verb with unit != widget and no completion condition

answered_verb then short-circuits completion_met to True, so the Decision reads answered off the first part-scoped action with several items still queued, and action_contract_error has no completion to test either. The suggested rule keeps the new capability and re-closes the old one; I ran it over command-hub, diagram, diff, pr-review, swipe, and kernel+default — all still validate, and the stripped-completion case is rejected.

Notes

Finding 1 trace, with characterShortcutsOn false and focus on a swipe deck's Ask:

  • availableActions() resolves ["ArrowLeft", "ArrowRight", "1"] — contextual is built from MAX_NUMBERED_ADDRESSES without consulting the preference.
  • bindings(actionRow) applies characterBinding and yields ["ArrowLeft", "ArrowRight"], so paintActionAddresses passes its !bindings(actionRow).length guard.
  • The chip loop paints spell("1") over the Undo button, and label/does render ← / → / 1.
  • dispatch.js reads bindings(row) (three call sites), so 1 never reaches actionRow.run.

The suggested form routes the contextual candidates through the same bindings() filter the dispatcher uses, so the two cannot disagree. With the preference on it is a no-op; with it off, keyless decision commands drop out of the Ask projection and stay reachable by Tab.

…nterface

# Conflicts:
#	skills/leaf/CLAUDE.md
#	skills/leaf/assets/runtime/decisions/actions.js
#	skills/leaf/assets/runtime/decisions/view.js
#	skills/leaf/packages/default/widgets/lf-options.js
#	skills/leaf/references/packages.md
#	tests/test_render_widgets.py

@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.

Both fixes from the last pass are in and the registry one is properly pinned — I reverted its clause on this head and test_a_part_scoped_completion_verb_requires_a_completion_condition fails, so that test names the behavior it guards.

The browser test that accompanies the view.js fix does not. It passes on this head with the view.js hunk reverted, and the state its docstring describes is not the state the fixture is in. Detail inline. The view.js reading itself is right — the finding is about what the test can prove, not about the change.

Comment thread tests/test_render_widgets.py Resolved

@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.

One finding, and it is not in the two commits since the last pass — those check out. Each hunk of 78ab30b is pinned (reverting the ariaShortcuts projection fails test_numbered_ask_routes_follow_replaced_controls; reverting the reference dedup fails test_a_swipe_deck_is_one_ask_with_directional_action_hints on a strict-mode violation), and 7f7caa69's reworked test_character_shortcuts_off_removes_a_contextual_ask_digit reaches the mixed state the last pass could not find a page for — reverting the contextual filter there leaves the key line reading 1 / 2 / ← over Accept / Reject / Inspect, so it now names the behaviour it guards. The finding is on the field these routes read, which 78ab30b's dedup now decides between.

decisionControls reads label as the action's name — the word inside "Activate the “Pass” action", and the chip's — while the register reads that same label through labelOf as the row's compact keycap. Every Decision contribution before this PR was keyless, so labelOf fell through to bindings(row).map(spell) and the two readings never met. lf-swipe-deck is the first row that declares keys and label together, and there the keycap becomes the action's name.

On the shipped swipe example, a and then Tab, reading the key line at each stop:

TAB1  (the active card)   'Pass\npass the active card\nesc\nlet go\n?\nmore'
TAB2  .lf-swipe-pass      'Pass\npass the active card\nesc\nlet go\n?\nmore'
TAB3  .lf-swipe-keep      'Pass\npass the active card\nesc\nlet go\n?\nmore'

The always-visible line spells the press as Pass for the reader's first three Tab stops inside the deck, and ←/→ are on it nowhere. The reference says the same wherever the Ask row does not supersede the deck's own section — which is every open from outside a live deck, and after this commit that is the only place the deck's section is read at all:

--- 'In a swipe deck'
      swipe.pass       kbd="Pass"             aria="Pass"
      swipe.keep       kbd="Keep"             aria="Keep"
      swipe.undo-last  kbd="Undo last swipe"  aria="Undo last swipe"

aria-label carries the same word, so a listener is told the key is "Pass" too. That is the rule labelOf states for itself — "A row's rendering is made of its own bindings, so it cannot advertise a key it does not answer" — and it is skills/leaf/CLAUDE.md's "Tab walks the real controls without replacing that action map" read the other way round: one Tab replaces the map with a keycap nobody can press. Since references/packages.md tells a package to give a Decision row control and label, any later contribution that also binds a key lands here; swipe is the first, the way it was the first to mix declared bindings with contextual digits.

The two consumers want separate fields — a Decision-role name distinct from the register's keycap — or labelOf has to stop reading a row's Decision label. Which one is the layer's call rather than mine.

How the readings were taken

Both from tests/test_render_widgets.py's SWIPE_PAGE, on this head, with temporary probes deleted afterwards.

Key line: open_page(browser, serve(SWIPE_PAGE)), press("a"), then press("Tab") in a loop, printing key_line(page) and document.activeElement.className at each stop. TAB4 leaves the deck and the line returns to c / comment on the page.

Reference: same page, ? ?, then over .lf-help-section collecting each section's h3, its hidden, and per tr the dataset.lfCommand, its kbd text, and the .lf-key-sequence aria-label. Taken with focus at rest — pressing a first hides those three rows behind the Ask row's, which is this commit's dedup working as intended.

Reverting the dedup shows the pair the dedup chooses between: On this page carries swipe.pass :: ←Activate the “Pass” action and In a swipe deck carries swipe.pass :: PassPass the active card. The kept one is the one with the real key, so the dedup picks correctly; what is left is the entry it did not have to choose against.

@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 keyed half of the last finding is fixed and pinned: reverting the split on this head fails the new reference and Tab assertions in test_a_swipe_deck_is_one_ask_with_directional_action_hints, so the deck's own scope now spells ← where it used to spell Pass. The residue is the keyless half of the same field.

Seven Decision rows declare keys: [] — suggestion.accept/reject, operation.*, draft.edit, draft.cancel, option.choose-N, option.done, swipe.undo-last — and this commit takes label off all of them. labelOf then falls through to bindings(row).map(spell).join(" / "), which is "" when the row has no bindings, and rowSteps hands that single empty step to keySequence. The ? reference keeps those rows deliberately: its row filter is bindings(row).length > 0 || declaredBindings(row).length === 0, under the comment "Pointer-native actions can deliberately carry a label but no key. Keep those in the complete reference." So each one now renders an empty <kbd> with an empty aria-label, where before this commit it rendered its name.

Readings on this head, walking .lf-help-section after ? ? at rest:

SWIPE_PAGE            'In a swipe deck'          swipe.undo-last   kbd=''  aria=''
STACKED_OPTIONS_PAGE  "In a question's options"  option.choose-1   kbd=''  aria=''
                                                 option.choose-2   kbd=''  aria=''
SHORT_SUGGESTION      'On a suggested change'    suggestion.accept kbd=''  aria=''
                                                 suggestion.reject kbd=''  aria=''

The same walk on 7f7caa69 reports no empty keycap on any of the three pages. The key line is unaffected — it does not carry keyless rows — so this is the ? reference and its listener projection only.

Two shapes close it, and which one is the layer's call rather than mine. The packages can carry label again on the keyless rows only, since with no press to spell the name is that row's compact cell and it cannot advertise a key it does not answer. Or labelOf can fall back for a row that resolves to nothing — word(row.label) ?? bindings(row).map(spell).join(" / ") || word(row.decision) — which cannot reach the case this commit fixed, because a row with a live binding never gets there.

How the readings were taken

A temporary test beside tests/test_render_widgets.py, deleted afterwards, on this head and again with skills/leaf/assets and skills/leaf/packages checked out at 7f7caa69:

page.keyboard.press("?")
page.keyboard.press("?")
page.evaluate(
    """() => Array.from(document.querySelectorAll('.lf-help-section')).map((s) => ({
         title: s.querySelector('h3')?.textContent,
         rows: Array.from(s.querySelectorAll('tr')).map((tr) => ({
           id: tr.dataset.lfCommand,
           kbd: Array.from(tr.querySelectorAll('kbd')).map((k) => k.textContent),
           aria: tr.querySelector('.lf-key-sequence')?.getAttribute('aria-label'),
         })),
       }))"""
)

swipe.undo-last is listed at rest even though when is false, because the reference's liveness clause is !inIt || live(row) and the reader is not in the deck's scope. The suite stays green because this commit's new reference assertion is on swipe.pass, which has a binding.

@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.

One finding, and it is on the test the commit adds rather than on the change itself. The surface.js reading is right — I reproduced the defect it closes, and with the hunk reverted a claimed drag the deck lets go of restores 'Refresh once a minute.' under the reader and leaves the bar standing over it.

What the new assertions cannot do is fail. test_swipe_deck_pointer_threshold_cancel_and_commit passes with the surface.js hunk reverted on this head, for two independent reasons, both measured:

The read happens before the restore could land. The restore runs inside the update mouseup defers, so getSelection() immediately behind page.mouse.up() is empty either way; .lf-fab-bar is genuinely hidden at that instant too, because the deck's own removeAllRanges() repainted it mid-press, so to_be_hidden() is satisfied on its first poll and never sees the bar come back. That is tests/CLAUDE.md's "a state the page passes through is not a state to poll for", read from the other side.

And the gesture chosen never reaches the restore. Draining the deferred update on the committing swipe still leaves the selection empty with the hunk reverted — the card is carried into #session-pass under the stationary pointer and nothing is restored there in either state. The restore fires on a claim the deck lets go of: the card snaps back under the pointer and the release lands on the page's own words with the captured range still in hand.

The suggestion adds that gesture and states the ordering before reading. On this head it passes; with the surface.js hunk reverted it fails on assert 'Refresh once a minute.' == ''.

Separately, and in this PR's favour rather than against it: the test_render_reactions.py line is red on main, not only on this branch. main carries SEND = "Mod+Enter" and this PR does not touch input.js, so the bare Enter there fails deterministically in the nightly suite — reverting just that line on this head times out on sent the comment on the projected document. Worth landing wherever it lands soonest.

How the readings were taken

All on 7911158, with uv run pytest tests/test_render_widgets.py -k test_swipe_deck_pointer_threshold_cancel_and_commit --run-nightly -n0, reverting the hunk with git show 7911158 -- skills/leaf/assets/runtime/composing/surface.js | git apply -R - and restoring afterwards. The tree is clean.

  • Unmodified test, hunk reverted: passes.
  • The whole of tests/test_render_widgets.py --run-nightly -n0, hunk reverted: 103 passed, 1 failed — test_a_newer_swipe_survives_an_older_swipe_refusal at line 1523. It passes in isolation with the hunk still reverted, so I am not attributing it to the hunk; it reads like the ordering class running-tend describes, and the same file is 104 passed with the hunk in place.
  • A temporary test beside the suite, deleted afterwards: select #swipe-a's first p, raise the bar, then mouse.down() / move(x - 30, y) / up(). Hunk reverted, after the deferred update: selection 'Refresh once a minute.', bar visible. Hunk in place: selection '', bar hidden.
  • Same page, committing swipe, mouseup target recorded at capture: lf-swipe-card#swipe-a inside lf-swipe-pile#session-pass, selection '' with the hunk reverted and the deferred update drained.
  • The ControlOrMeta+Enter reading: git show origin/main:skills/leaf/assets/runtime/composing/input.js has SEND = "Mod+Enter" at 9a655c2, input.js is absent from this PR's diff, and test_render_reactions.py carries pytestmark = pytest.mark.nightly, so the everyday suite never ran it.

Comment thread tests/test_render_widgets.py Resolved
…nterface

# Conflicts:
#	skills/leaf/assets/widgets/lf-suggestion.js
#	skills/leaf/packages/default/widgets/lf-draft.js
#	skills/leaf/packages/default/widgets/lf-shot.js
…nterface

# Conflicts:
#	skills/leaf/assets/registry.json
#	tests/test_interact_document.py
leaf-agent
leaf-agent previously approved these changes Sep 5, 2026
max-sixty and others added 3 commits September 4, 2026 17:39
…nterface

# Conflicts:
#	skills/leaf/assets/runtime/widget-api.js
#	skills/leaf/references/packages.md
Ordinary action controls used separate pill and border styles, including
the diff toolbar and file headers. Route diff controls, call-diff
toggles, host operations, preview diagnostics, and inline Add controls
through the shared ordinary-button style, with 6px corners and common
ink, hover, and disabled treatment. Carry that style into declared
shadow trees while retaining compact placement where needed.

The inline Add control grows to fit its label, with input space reserved
alongside it.

Right-margin Buttons and reaction/status chips keep their distinct
forms. Update the control guidance and the existing keyboard-focus
expectation for host operations.

Validation: widget and projection browser suites, focused light/dark
checks at 1200px and 1440px, keyboard/pointer review activation, a
regression check for button ink across tinted document/shadow surfaces,
and pre-commit checks.

> _This was written by Codex on behalf of max-sixty_
Record output size, the browser visibility gap, and shared-source record
selection. Define a paired comparison of HTML, construction, and browser
readings that measures comprehension, correct edit targets, reader-state
preservation, and context cost before changing the default interface.

@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.

Three findings, all on the swipe package's control row, all in tests/test_render_controls.py, which is nightly-marked — so none of them ran in this PR's test check and all three would first show on main's nightly after the merge. Measured on this head with --run-nightly -n0; each reproduces at the same assertion, so this is the regression class rather than the ordering one.

FAILED test_the_composed_corpus_declares_every_control_row_archetype
FAILED test_every_control_the_layer_offers_is_a_box_the_reader_can_hit[True]
FAILED test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus

The two theme ones are inline, and I confirmed both: with only those two lines changed, test_every_control_the_layer_offers_is_a_box_the_reader_can_hit and test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus are green (3 passed). The ring name does not move the failure to the walk's other half — the corpus paints the deck's controls, so the name it declares is credited.

The third is the interesting one, and it is not paperwork. The deck's ← Pass / Keep → are a new control-row mechanism, and CONTROL_ARCHETYPES has no entry covering them, so the corpus sweep reports Decision: button "← Pass": no archetype. Adding an entry then puts the row through test_each_control_archetype_holds_its_neighbours_still, and it fails there: pressing ← Pass moves Keep → up two pixels under the reader's pointer. The cause is the unseen pile, not the row — with one card gone the queue measures 206px where it measured 208, and the controls row sits below it:

queue     h=208  ->  h=206
row       top=1167  ->  top=1165
keep      top=1167  ->  top=1165

So the deck's own stacking offset is what the reader's next aim moves by, on every swipe. That is the thing the archetype contract exists to catch, and it is why declaring the archetype is the fix rather than an exemption.

I can push the archetype entry plus the swipe deck the stability fixture needs, and a pile-height fix if you want me to take one — say the word and I will. Holding the approval until the row is settled, since these three are green-on-merge-then-red-on-main.

How the readings were taken

All on 1903aea3, uv run pytest tests/test_render_controls.py --run-nightly -n0. The tree is clean; every edit below was reverted.

  • Baseline, unmodified: 3 failed, 1 passed on the three named above, and the same three again in the full-file run (3 failed, 91 passed).
  • Both inline suggestions applied, nothing else: 3 passed for the aim and ring cases (the aim case is parametrized over both pointers).
  • The archetype entry I tried, to see what declaring it costs: {"name": "swipe-control", "coverage": ":is(.lf-swipe-pass, .lf-swipe-keep, .lf-swipe-undo)", "target": "#stable-swipe .lf-swipe-pass"}, with a two-card deck added to CONTROL_STABILITY_PAGE. The corpus sweep goes green; test_each_control_archetype_holds_its_neighbours_still[swipe-control] fails with button.lf-swipe-keep.lf-ui "Keep →" moved by [0, -2, 0, 0]. The fixture markup is mine, so treat the entry as a candidate rather than the shape to land — the displacement is not, since the target is the deck's own press.
  • The pile reading is offsetTop / getBoundingClientRect().height on the deck's piles and controls row, before the press and after round_trip + page_at_rest. pass and keep piles grow 114 -> 124 in the same transition; the queue is the one the row sits under.

Also ran, all green on this head, since the increment since the last pass was #287's control restyle landing here: tests/test_render_widgets.py --run-nightly (104 passed), tests/test_render_commands.py (green), and test_call_diff_projects_stable_commentable_rows, test_a_spent_request_and_a_static_badge_say_so_before_the_press, test_command_hub_request_waits_for_one_linked_host_receipt in tests/test_render_projection.py. The deck's buttons do not take .lf-btn, which #287's new skills/leaf/CLAUDE.md paragraph asks ordinary action controls to use; measured, they match it on radius, border and background and differ only in ink (--ink-2 against --ink) and in a hover that carries pass/keep meaning, so I read that as the deck's own affordance rather than drift and am not raising it.

.lf-swipe-pass.lf-ui,
.lf-swipe-keep.lf-ui,
.lf-swipe-undo.lf-ui {
min-height: 2.5rem;

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.

40px, so test_every_control_the_layer_offers_is_a_box_the_reader_can_hit[True] reports lf-swipe-pass at 86.6x40.0 and lf-swipe-keep at 90.2x40.0 under the 44px coarse-pointer floor. --aim-floor is the token that states both floors, and chrome-style.js already carries this shape for the banner's buttons (min-height: max(40px, var(--aim-floor))), so the deck's own 2.5rem stays the fine-pointer height and a finger gets 44.

Suggested change
min-height: 2.5rem;
min-height: max(2.5rem, var(--aim-floor));

.lf-swipe-pass:focus-visible,
.lf-swipe-keep:focus-visible,
.lf-swipe-undo:focus-visible {
outline: var(--here-ring);

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.

This rule draws the here ring without naming it, so test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus fails: 1 rules draw the here ring and name none of them, so the floor below divides by a population short of them. The deck's card rule above already declares --lf-here-ring: swipe-card; its controls need their own name for the same reason.

Suggested change
outline: var(--here-ring);
outline: var(--here-ring);
--lf-here-ring: swipe-control;

@leaf-agent
leaf-agent dismissed their stale review September 5, 2026 01:31

Superseded: three nightly-only regressions on the swipe control row, found on 1903aea after this approval was written at bac67f0. See the review at 1903aea.

@max-sixty
max-sixty merged commit 4b68d2d into main Sep 5, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex/swipe-package-interface branch September 5, 2026 05:13
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