Skip to content

Make reactions direct agent feedback controls - #365

Merged
max-sixty merged 14 commits into
mainfrom
codex/agent-feedback-reactions
Sep 7, 2026
Merged

max-sixty merged 14 commits into
mainfrom
codex/agent-feedback-reactions

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Reactions are now direct feedback controls for work with an agent rather than a generic social-emoji picker. When a selected target enters reaction mode, all six emoji become individual margin buttons, with arrow and digit routes that preserve the selected anchor.

The default vocabulary is action-oriented (keep, change, clarify, shorten, support, and prioritize), while Leaf's core remains generic: packages own token names and may optionally supply explanatory prose. Agent delivery guidance reports the reaction and its target without interpreting application-specific tokens. A dated TODO records the remaining question of whether optional means prose belongs in the core contract at all.

The examples, seed logs, protocol documentation, projections, transcripts, and browser coverage are updated together. The integrated branch passes uv run pytest tests (904 tests), the touched-module nightly gate (423 tests), and pre-commit run --all-files.

This was written by Codex on behalf of max-sixty

@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 token rename reached examples/developer/feature-gallery.html but not the assertion in tests/test_render_margin.py that reads those same strings back, so test_the_feature_gallery_balances_one_button_sample_with_feature_sections is red on this branch and green on a6fcf15. Four of the six expected lines still name the old vocabulary. Inline suggestion covers the two that fall inside a diff hunk; lines 1396–1397 need "1 · 👍 · keep this." → "1 · 👍 · keep." and "2 · ❌ · wrong." → "2 · ❌ · change." as well, and I'm happy to push the whole correction as a commit if that's easier.

Worth noting where this hides: test_render_* is nightly, so the 904-test uv run pytest tests run the description cites — and the green test job on this PR — never reaches it. ci picks it up only after main moves, which is the "a red ci on main is live" case rather than a red PR.

Reproduction on the merged tree
$ uv run pytest tests/test_render_margin.py -q -n0 -k feature_gallery_balances
E           AssertionError: assert ['1 · 👍 · kee... prioritize.'] == ['1 · 👍 · kee... prioritize.']
E             Full diff:
E               [
E             -     '1 · 👍 · keep this.',
E             +     '1 · 👍 · keep.',
E             -     '2 · ❌ · wrong.',
E             +     '2 · ❌ · change.',
E             -     '3 · 🤔 · unclear.',
E             +     '3 · 🤔 · clarify.',
E                   '4 · ✂️ · shorten.',
E             -     '5 · 🔎 · substantiate.',
E             +     '5 · 🔎 · support.',
E                   '6 · 🎯 · prioritize.',
E               ]
1 failed, 80 deselected in 7.42s

The same case passes on the merge base, so this is the branch's own regression rather than one of main's standing nightly failures. The rest of the browser modules this PR touches are clean against it: test_render_reactions.py and test_render_semantic_selection.py pass (71), test_render_conversations.py passes, and the failures I hit in test_render_anchors.py (test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline) and test_render_drafts.py (test_a_comment_hidden_by_narrowing_is_revealed_in_the_open_panel[True], test_an_unsent_comment_stays_with_its_passage_when_another_is_selected) reproduce identically on a6fcf15. scripts/corpus.py regenerates examples/corpus.html with no diff, and nothing outside the frozen versions/feature-gallery.v2.html still names an old token.

One smaller thing, take it or leave it: lowerMarginSurface's new if (!marginUnfolded && marginTarget) openButtonOptions(marginTarget) restores the ordinary inventory for a cluster the reader had already unfolded before pressing r — and the block in test_putting_a_reaction_down_folds_back_only_the_cluster_it_unfolded that stood the reader in exactly that state ("Nor does the raise that finds the fold already open") came out in the same change, so that branch now has no test standing on it.

Comment thread tests/test_render_margin.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.

1ba86292 clears what the earlier review raised: test_the_feature_gallery_balances_one_button_sample_with_feature_sections passes on the merged tree, and the already-unfolded cluster has a case standing on it again.

On the runtime half, though, it is the reorder that carries the fix, not the call it moved. Three variants of lowerMarginSurface, each run against the block this commit adds:

lowerMarginSurface test_putting_a_reaction_down_folds_back_only_the_cluster_it_unfolded
openButtonOptions before marginOffer?.unregister() (previous commit) fails at the last expect(item).to_have_attribute("data-lf-options-open", "")
openButtonOptions after unregister() (this commit) passes
no openButtonOptions at all passes

So the restore branch has no reachable effect of its own — unregistering the responses offer already leaves the reader's fold open, and standing the call in front of that unregister is what used to close it. Deleting const restoreOpen and its if, uv run pytest -n0 tests/test_render_reactions.py (46) and tests/test_render_margin.py (81) are both green, and the fold half of lowerMarginSurface is back to the shape it has on 4cbef417.

That also settles the comment: the margin does not see "no visible options" and close the group while the hidden owner exists, because if it did, removing the reopen would leave the fold shut and that same assertion would go red. The test's own block still earns its keep either way — it is what pins that a put-down leaves a reader-open fold alone.

CLAUDE.md's Stage section is why I would rather see the branch go than be kept and tested around: "Add a guard only for a reachable condition with a useful response."

How the three variants were run

Each on the merged tree at 1ba86292, with tests/test_render_reactions.py -q -n0 -k folds_back_only_the_cluster, restoring reactions.js between runs.

Previous ordering (the only variant that reddens):

E       AssertionError: Locator expected to have attribute ''
E       Actual value: None
/home/runner/work/leaf/leaf/tests/test_render_reactions.py:625: AssertionError

Restore branch deleted outright: 1 passed, then 46 passed for the whole reaction file and 81 passed for tests/test_render_margin.py. As a control that the harness does see edits to skills/leaf/assets/runtime/reactions.js at all, making the fold unconditional (foldButtonOptions() in place of if (marginUnfolded) foldButtonOptions()) reddens the reply-strip assertion earlier in the same test.

openButtonOptions keeps its other call site in raiseMarginSurface, so the import stays used.

Comment thread skills/leaf/assets/runtime/reactions.js Resolved
max-sixty pushed a commit that referenced this pull request Sep 7, 2026
…walk to the pill ring (#367)

## Problem

The nightly leg of [`ci` on
`59d0aa3`](https://github.com/max-sixty/leaf/actions/runs/34060060243)
went red on three readings. Two were the interaction gallery and landed
with #359; the third,
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`,
still reproduces on `ac3342a4` and is a different seam — #366 names it
as outstanding and does not reach it.

The census reports the resolve icon action's focus ring clipped in
`ship-review`, in the page and in the comments:

```
in the page of ship-review, the ring on button.lf-btn.lf-resolve.lf-icon-action.lf-ui ""
is not all there: its left edge is under button.lf-react-trigger.lf-ui ""
(ring 1143,466,1179,502 vs 1119,467,1145,493, sampled 1144,484)
```

The reaction trigger is painted above the message head and turns opaque
exactly while the message is focus-within — which is when the resolve
control beside it is wearing a ring. It stood off that control's own box
by 2px, and the ring is 4px wide of it, so two of those pixels were
behind the trigger. Two independent PRs put the rows there: the icon
action (#347) and the trigger's offset (#349), each correct about the
box it measured.

## Solution

Both copies of the rule — the chrome sheet's, and the
frozen-conversation mirror in `theme.css` — now stand the trigger off
the ring rather than off the box, naming the band as `--here-ring-w`
plus the offset each sheet's own focus rule states, and keeping the 2px
gap that was already there measured outwards from the ring.

Clearing that fault makes the census reach its last assertion for the
first time, and it reports the `pill` ring painted nowhere the corpus
can be walked to. That one is pre-existing and was masked behind the
clip: the strip's trigger wore `lf-pill lf-react-trigger` until #349
made it an icon, so the palette chips behind the press are now the only
focusable boxes left drawing that ring — and no walk opens a palette. A
`a reaction palette` walk scope presses a message's trigger and stands
on the chips.

## Testing

- `tests/test_render_controls.py` in full on this branch: 81 passed.
- The everyday suite (898 passed, 6 skipped) and `pre-commit run
--all-files` pass.
- Bug-back for each half, on this branch's own tree: reverting the two
CSS rules returns the 2 clipping faults over 714 stops; reverting the
walk scope alone returns `1 of the layer's 45 rings are painted nowhere
the corpus can be walked to: pill`.

<details><summary>Scope, and what this deliberately leaves to other
PRs</summary>

The same run's other two readings are #359's and merged.
`test_the_composed_corpus_declares_every_control_row_archetype` is red
on `main` for the playground package's Reset / Copy instruction / Apply
card row; #366 declares that archetype, so it is left out of this branch
— an earlier revision of this one carried a second implementation of it
and it was dropped once #366 appeared.

#365 touches `reactions.js` and `chrome.css` but neither the trigger's
offset rule nor the `lf-pill` class on a chip, so the walk scope added
here keeps its subject if that lands first.

</details>

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/34060060243)

Co-authored-by: leaf-agent <[email protected]>

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

451107f3's anchors half is right — x leaving a focused thread open is what test_render_navigation.py now pins after #345, and the Tab/Enter route passes on the merged tree.

The other half goes the wrong way, though. It restores "token": "ok" in tests/test_render_drafts.py, and ok is the name this PR retires — so it is the one place left in the tree still seeding the old vocabulary, and the net three-dot diff for that file is now empty, which is why it reads as untouched rather than as a leftover.

It stays green, so nothing catches it: the seat is painted from the event either way. What changes is which path paints it. seatReactions falls back with glyph: entry?.glyph ?? root.token, so the fixture now stands on the dropped-token branch and the margin mark wears the literal word:

"token": "ok"   ->  SEAT_GLYPH= ok ok
"token": "keep" ->  SEAT_GLYPH= 👍 keep

That is the state vocabulary_gaps exists to refuse — "a standing reaction on it would fall silent" — so a test named for a reaction keeping its authored seat is the last place to seat one on a token the layer no longer declares. "keep" passes identically, and the line is outside the diff so there is no suggestion to click; happy to push the one-word commit if you want it.

How this was run, on the merged tree at 451107f

Both edited cases pass as they stand:

$ uv run pytest tests/test_render_anchors.py -q -n0 -k diff_surface_keeps_the_complete_thread_lifecycle_inline
2 passed, 78 deselected in 6.31s
$ uv run pytest tests/test_render_drafts.py -q -n0 -k reaction_inside_a_widget_keeps_its_authored_seat
2 passed, 64 deselected in 3.02s

The glyph readings above come from printing .lf-reacts[data-lf-for="draft-ops"] .lf-react-mark's text inside that second case, once with each token; both tokens pass, so the assertion set is insensitive to the difference.

grep -rn '"token": "\(ok\|no\|lost\|cut\|more\|this\)"' tests/ examples/ skills/ returns exactly one hit on the merged tree, this line. Every other call site took the rename.

@max-sixty

Copy link
Copy Markdown
Owner Author

Addressed the review on 451107f3: the widget-anchor coverage now uses the declared keep token rather than exercising the retired-token fallback. The recovered-draft control fix has since landed on main via #369 and is merged here; the draft module therefore remains legitimately covered by this PR's touched-module nightly gate. The exact pushed head passes 423 touched nightly cases and the full 904-test suite.

This was written by Codex on behalf of max-sixty

@leaf-agent

Copy link
Copy Markdown
Collaborator

Confirmed on 44ced702. tests/test_render_drafts.py seats the widget-anchor reaction on keep, so the fixture stands on the declared entry rather than seatReactions' dropped-token fallback, and test_a_reaction_inside_a_widget_keeps_its_authored_seat passes (2 passed). The two earlier findings are clear on the same head too: the feature-gallery assertions read keep. / change. / clarify. / support., and lowerMarginSurface's restore branch is gone — openButtonOptions keeps only its raiseMarginSurface call site.

One thing worth recording about the merge, since it is not visible in the three-dot diff: 11b1f494 carried its own copy of the recovered-draft fix, and 44ced702 resolved it to main's. Against origin/main the branch's skills/leaf/packages/default/widgets/lf-draft.js is now byte-identical and tests/test_render_drafts.py is a one-line diff — the token. So the module is touched, and the nightly gate covers it, but nothing of 11b1f494's draft work survives the merge; #369 is doing that job alone. Nothing to change — just so a later reader does not go looking for a second fix.

@max-sixty
max-sixty merged commit 06daeef into main Sep 7, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/agent-feedback-reactions branch September 7, 2026 03:28
@leaf-agent

Copy link
Copy Markdown
Collaborator

This merged while I was running the untouched nightly modules against it, so this lands as a note rather than a review: two cases that pass on 43147601 fail on main at 06daeef3. Neither module is touched by this PR, so the touched-module nightly selection never reached them and ci/test was green here. The ci run on 06daeef3 is the one that meets them.

Tab from the compact field no longer reaches Suggest. test_other_responses_can_turn_the_compact_field_into_a_suggestion presses Tab out of the compact field and expects .lf-fab-bar still visible with .lf-fab-suggest a Tab further on. raiseMarginSurface now puts data-lf-margin-raised="1" on the bar, and .lf-fab-bar[data-lf-margin-raised] { display: none !important; } hides it, so the walk stops at the first expect(choices).to_be_visible().

The test is the smaller half. hasOtherResponses in composing/surface.js is true as soon as the layer declares a token, and setReact on an anchor target always goes through raiseMarginSurface, so .lf-fab-suggest is only ever drawn for a layer with an empty reaction vocabulary. Under the default six, a reader who selected words reaches Suggest only through the composer's Suggest replacement text checkbox. docs/how-it-works.html dropped the old claim in this same change, so the route looks deliberately retired — but that is the answer the rewritten test would be asserting, and CLAUDE.md's give every action a keyboard route is the thing it would be asserting against. Worth settling before the assertions move.

The ring walk never reaches a settled page. test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus times out in page_at_rest's pageSettled probe. Instrumenting that probe to print moving() at the timeout gives the same reading every run — three finite animations still playing on one node, the contributed reaction group:

Leaf wait probe pageSettled did not become true within 30000ms
MOVING=['<span id=lf-reactions-2>', '<span id=lf-reactions-2>', '<span id=lf-reactions-2>']

A finite animation still running after 30s is one being restarted, so that group is being re-placed every frame rather than reconciled in place. I did not isolate which writer moves it. The note added to prepareVisualActions names this exact hazard for a seat two reconcilers share, so that and syncOptionGroup's new owner-focused branch are where I would look first.

How this was run

Each case on a clean worktree, -n0, so neither reading is a scheduling artifact.

# main at 06daeef3 (this PR merged)
$ uv run pytest tests/test_render_navigation.py -q -n0 -k other_responses_can_turn_the_compact_field
1 failed, 88 deselected in 7.54s
E       AssertionError: Locator expected to be visible
E       Actual value: hidden
E         - waiting for locator(".lf-fab-bar")
E           14 x locator resolved to <div ... data-lf-margin-raised="1" class="lf-ui lf-fab-bar ...">

$ uv run pytest tests/test_render_controls.py -q -n0 -k every_ring_the_layer_draws
1 failed, 81 deselected in 205.04s

# main at 43147601 (immediately before)
1 passed, 88 deselected in 2.46s
1 passed, 81 deselected in 206.35s

The same two failed on the pre-merge merged tree at 44ced702 and passed on its merge base 934bfc4c, so the attribution holds across both bases.

The rest of the untouched nightly render corpus is clean against this change: test_render_navigation.py whole is 1 failed, 88 passed, test_render_controls.py has no second failure, and test_render_aim.py, test_render_commands.py, test_render_drawing.py, test_render_widgets.py, test_render_projection.py, test_render_options*.py, test_render_outbox.py, test_render_startup.py, test_render_export.py, test_render_gate.py, and test_render_mcp.py are green — 680 cases.

The means half reads consistent end to end: described, transcript.py, messages.js, and reactPill each guard the absent case, validate_layer_declarations matches the new optionality, and event-batches.md and $reactions say the same thing. No surviving ok/no/lost/cut/more/this token outside the frozen revisions; the gallery's bg-react-* section ids keep their old words, which is right — a source id holds one contract for the page's lifetime.

Happy to push the navigation test once the Suggest route is settled; the ring walk reads like a runtime fix rather than a test edit.

max-sixty pushed a commit that referenced this pull request Sep 7, 2026
…us and its exported copy (#383)

## Problem

The nightly leg of [`ci` on
`edd1c5a`](https://github.com/max-sixty/leaf/actions/runs/34083084673)
went red on 17 readings. All but two came from one cause, and every one
of them reproduces deterministically on that commit and on today's
`main`.

#354 gave the interaction gallery three contained frames, and each of
them runs a whole second Leaf page. A Leaf page arrives:
`restoreArrangements()` puts back the workspace this reader last had
open, and `letGo()` puts them on the page's own body. Both run inside
the frame, and a document has one focus — so `document.activeElement`
out on the gallery became the `<iframe>`, and whatever the reader was
holding was let go of. That is what closed the crowded margin cluster
mid-test, dropped every `.lf-target-hint` on the corpus, and took
`#bg-choice-ask` off its focus.

The export half is separate and had been masked by the reading in front
of it: the frame's `srcdoc` names the runtime, the theme, and the
gallery adapter on a server a standalone file has not got, so an
exported copy opened with four CORS failures. Its `<kbd>` chord caption
was authored hidden, so the copy also held words with no script left to
reveal them.

## Solution

`data-lf-contained` marks both sides of the boundary — the frame element
out in the gallery and the body of the page inside it. A contained page
arrives restoring no arrangement and placing no focus, and the bake
drops a contained frame with the scripts. The chord caption now lives
with its own visibility rather than in authored markup. On a page that
is not contained nothing changes: every guard reads a constant that is
false there.

Arrival is only half of it. The framed chrome still places focus once a
replay runs it — a shown `<dialog>` runs the browser's focusing steps
whatever the page around it wants. So the frame's body is written
`inert` beside the mark: an inert subject ends those steps before they
reach anything, so the focus never crosses the boundary and there is
nothing to hand back. The replays are unaffected, because they drive
that chrome through the adapter rather than by pointing at it. Measured
on the `Open and close Threads` tab: without the line the reader loses
the tab they just pressed the moment the framed panel opens, and `g T`
and `w` then reach a document they cannot see.

`inert` is the same one-line fix #393 carries, arrived at from the other
side. The two conflict textually — both write it into
`loadFrameDocument` on the line this branch marks the body on — and
resolving either way is taking one copy of the line.

`test_a_contained_replay_leaves_the_page_around_it_standing` pins both
halves: it fails on `main` with `assert 'IFRAME' != 'IFRAME'` at
arrival, and on the arrival fix alone at the replay, where the reader is
no longer standing on the tab they pressed.

Two readings are restated rather than repaired, because the gallery
really did change: its swipe specimen sits in an unselected tab, so one
margin row is withheld and the posture clear runs for it. (The Ask count
13 → 14 landed separately in #376.)

<details><summary>The 17 readings, and what each was</summary>

Focus taken by a frame — 14:
`test_the_feature_gallery_keeps_its_real_actions_reachable[1440/1200/700/390]`,
`test_ask_addresses_follow_the_feature_gallery_s_visible_margin_controls[1200/390]`,
`test_margin_target_hover_requires_pointer_movement`,
`test_a_workspace_lands_one_responsive_layout_and_carries_the_column_to_it[1440/1600]`,
`test_selection_hints_do_not_name_page_content_behind_a_covering_panel`,
`test_a_shipped_log_opens_its_example_on_a_live_thread`,
`test_other_responses_can_turn_the_compact_field_into_a_suggestion`, and
both `test_an_exported_page_fixture_stands_on_its_own` cases, which
failed on the caption before they could reach the CORS errors.

Restated:
`test_an_unchanged_heartbeat_restates_no_margin_name[gallery]`,
`test_the_feature_gallery_exercises_the_injected_core_surfaces`.

**Not this branch's**:
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
fails the same way on `06daeef3`, one commit before #354 — `pageSettled`
never becomes true in the response bar of `ship-review`. It took [run
34079766897](https://github.com/max-sixty/leaf/actions/runs/34079766897)
down too, so it is a red `main` of its own and I am carrying it
separately.

</details>

## Testing

`uv run pytest tests` (899 passed), and the complete nightly modules the
change reaches: `test_render_margin.py`, `test_render_navigation.py`,
`test_render_export.py`, `test_render_semantic_selection.py`,
`test_render_pages.py`, `test_render_widgets.py`, `test_site.py` — all
green. The new test was checked against a tree with the two runtime
guards reverted, where it fails.

For the focus half added since: `test_site.py` (31 passed), and every
gallery, contained-frame, export, standalone, accessibility and drawing
reading in the suite (130 passed), plus `test_render_margin.py` whole
and the two readings elsewhere this branch clears (83 passed). With the
`inert` line alone removed, the contained-replay reading fails on the
tab losing focus.

## One flake carried too

`test_unchanged_margin_refresh_cost_is_bounded_by_refresh_count` took
this branch's first CI run down at `LayoutCount: 29` against a bound of
20, and it does the same on `6b77b0a9` with none of this branch on it —
once in six runs there, once in seven here. The corpus carries the
gallery's contained frames, and a frame still arriving lays itself out
in the measured page's own process, which counted against five
dispatches that touch nothing reads as the heartbeat forcing layout.
Both corpus cost measurements — that one and
`test_margin_layout_batches_the_composed_page_without_refolding_controls`,
which measures the same page the same way — now wait for the frames to
be ready before opening the CDP session: fourteen runs green after,
where it failed twice in thirteen before.

## What this does not clear

One reading on `main` is still red and is not this branch's:
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`,
which I re-ran on this tree after #385 landed. It is tracked in #396,
where the two possible repairs are written out — both are a product
decision rather than a mechanical one.

<details><summary>What it looks like</summary>

The walk hangs on `pageSettled` in the response bar of `ship-review`:
three transitions on one reaction chip's `.lf-margin-button-label` —
opacity, transform, visibility, the label reveal — restart before they
finish, indefinitely. `startTime` moves forward and `currentTime` goes
back to 0 between two samples a second apart. Last green on
[`934bfc4c`](https://github.com/max-sixty/leaf/actions/runs/34077249270);
red from `06daeef3` (#365), which is what made a reaction a margin
button with a label.

The other readings that were red beside it have since been repaired on
`main` and pass here: the three `test_render_reactions.py` cases went
with #385, and
`test_render_gate.py::test_a_reload_mid_flight_never_wedges_round_trip`
passes on this tree.

</details>

## Rebuilt on #378

#378 landed while this was open and rebuilt the contained page without
`srcdoc`. The mark and the `inert` write both go on the document
`loadFrameDocument` writes, and the frame element carries the mark
beside it. `main` is merged in and the branch is green: `uv run pytest
tests` (901 passed), and `test_site.py` and `test_render_margin.py`
complete under `--run-nightly` (112 passed).

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/34083084673)

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Sep 7, 2026
…us and its exported copy (#383)

## Problem

The nightly leg of [`ci` on
`edd1c5a`](https://github.com/max-sixty/leaf/actions/runs/34083084673)
went red on 17 readings. All but two came from one cause, and every one
of them reproduces deterministically on that commit and on today's
`main`.

#354 gave the interaction gallery three contained frames, and each of
them runs a whole second Leaf page. A Leaf page arrives:
`restoreArrangements()` puts back the workspace this reader last had
open, and `letGo()` puts them on the page's own body. Both run inside
the frame, and a document has one focus — so `document.activeElement`
out on the gallery became the `<iframe>`, and whatever the reader was
holding was let go of. That is what closed the crowded margin cluster
mid-test, dropped every `.lf-target-hint` on the corpus, and took
`#bg-choice-ask` off its focus.

The export half is separate and had been masked by the reading in front
of it: the frame's `srcdoc` names the runtime, the theme, and the
gallery adapter on a server a standalone file has not got, so an
exported copy opened with four CORS failures. Its `<kbd>` chord caption
was authored hidden, so the copy also held words with no script left to
reveal them.

## Solution

`data-lf-contained` marks both sides of the boundary — the frame element
out in the gallery and the body of the page inside it. A contained page
arrives restoring no arrangement and placing no focus, and the bake
drops a contained frame with the scripts. The chord caption now lives
with its own visibility rather than in authored markup. On a page that
is not contained nothing changes: every guard reads a constant that is
false there.

Arrival is only half of it. The framed chrome still places focus once a
replay runs it — a shown `<dialog>` runs the browser's focusing steps
whatever the page around it wants. So the frame's body is written
`inert` beside the mark: an inert subject ends those steps before they
reach anything, so the focus never crosses the boundary and there is
nothing to hand back. The replays are unaffected, because they drive
that chrome through the adapter rather than by pointing at it. Measured
on the `Open and close Threads` tab: without the line the reader loses
the tab they just pressed the moment the framed panel opens, and `g T`
and `w` then reach a document they cannot see.

`inert` is the same one-line fix #393 carries, arrived at from the other
side. The two conflict textually — both write it into
`loadFrameDocument` on the line this branch marks the body on — and
resolving either way is taking one copy of the line.

`test_a_contained_replay_leaves_the_page_around_it_standing` pins both
halves: it fails on `main` with `assert 'IFRAME' != 'IFRAME'` at
arrival, and on the arrival fix alone at the replay, where the reader is
no longer standing on the tab they pressed.

Two readings are restated rather than repaired, because the gallery
really did change: its swipe specimen sits in an unselected tab, so one
margin row is withheld and the posture clear runs for it. (The Ask count
13 → 14 landed separately in #376.)

<details><summary>The 17 readings, and what each was</summary>

Focus taken by a frame — 14:
`test_the_feature_gallery_keeps_its_real_actions_reachable[1440/1200/700/390]`,
`test_ask_addresses_follow_the_feature_gallery_s_visible_margin_controls[1200/390]`,
`test_margin_target_hover_requires_pointer_movement`,
`test_a_workspace_lands_one_responsive_layout_and_carries_the_column_to_it[1440/1600]`,
`test_selection_hints_do_not_name_page_content_behind_a_covering_panel`,
`test_a_shipped_log_opens_its_example_on_a_live_thread`,
`test_other_responses_can_turn_the_compact_field_into_a_suggestion`, and
both `test_an_exported_page_fixture_stands_on_its_own` cases, which
failed on the caption before they could reach the CORS errors.

Restated:
`test_an_unchanged_heartbeat_restates_no_margin_name[gallery]`,
`test_the_feature_gallery_exercises_the_injected_core_surfaces`.

**Not this branch's**:
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
fails the same way on `06daeef3`, one commit before #354 — `pageSettled`
never becomes true in the response bar of `ship-review`. It took [run
34079766897](https://github.com/max-sixty/leaf/actions/runs/34079766897)
down too, so it is a red `main` of its own and I am carrying it
separately.

</details>

## Testing

`uv run pytest tests` (899 passed), and the complete nightly modules the
change reaches: `test_render_margin.py`, `test_render_navigation.py`,
`test_render_export.py`, `test_render_semantic_selection.py`,
`test_render_pages.py`, `test_render_widgets.py`, `test_site.py` — all
green. The new test was checked against a tree with the two runtime
guards reverted, where it fails.

For the focus half added since: `test_site.py` (31 passed), and every
gallery, contained-frame, export, standalone, accessibility and drawing
reading in the suite (130 passed), plus `test_render_margin.py` whole
and the two readings elsewhere this branch clears (83 passed). With the
`inert` line alone removed, the contained-replay reading fails on the
tab losing focus.

## One flake carried too

`test_unchanged_margin_refresh_cost_is_bounded_by_refresh_count` took
this branch's first CI run down at `LayoutCount: 29` against a bound of
20, and it does the same on `6b77b0a9` with none of this branch on it —
once in six runs there, once in seven here. The corpus carries the
gallery's contained frames, and a frame still arriving lays itself out
in the measured page's own process, which counted against five
dispatches that touch nothing reads as the heartbeat forcing layout.
Both corpus cost measurements — that one and
`test_margin_layout_batches_the_composed_page_without_refolding_controls`,
which measures the same page the same way — now wait for the frames to
be ready before opening the CDP session: fourteen runs green after,
where it failed twice in thirteen before.

## What this does not clear

One reading on `main` is still red and is not this branch's:
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`,
which I re-ran on this tree after #385 landed. It is tracked in #396,
where the two possible repairs are written out — both are a product
decision rather than a mechanical one.

<details><summary>What it looks like</summary>

The walk hangs on `pageSettled` in the response bar of `ship-review`:
three transitions on one reaction chip's `.lf-margin-button-label` —
opacity, transform, visibility, the label reveal — restart before they
finish, indefinitely. `startTime` moves forward and `currentTime` goes
back to 0 between two samples a second apart. Last green on
[`934bfc4c`](https://github.com/max-sixty/leaf/actions/runs/34077249270);
red from `06daeef3` (#365), which is what made a reaction a margin
button with a label.

The other readings that were red beside it have since been repaired on
`main` and pass here: the three `test_render_reactions.py` cases went
with #385, and
`test_render_gate.py::test_a_reload_mid_flight_never_wedges_round_trip`
passes on this tree.

</details>

## Rebuilt on #378

#378 landed while this was open and rebuilt the contained page without
`srcdoc`. The mark and the `inert` write both go on the document
`loadFrameDocument` writes, and the frame element carries the mark
beside it. `main` is merged in and the branch is green: `uv run pytest
tests` (901 passed), and `test_site.py` and `test_render_margin.py`
complete under `--run-nightly` (112 passed).

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/34083084673)

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Sep 7, 2026
#373)

`main` has been red on the nightly ring census since #365. The corpus
walk waits for the page to stop moving and it never does: three CSS
transitions on a reaction pill's tooltip label restart every frame, so
the label never outlives its own 90ms delay — it is invisible for the
page's whole life — and `pageSettled` can never go true.

## The loop

A docked margin row is floated back into the rail every pass to ask
whether it fits now, and docked again when it does not. That round trip
runs through `moveHost`, which relocates a cluster that may hold the
reader's focus: the move emits `focusout` and the restore emits
`focusin`, both of which reach `paintHere()`, and the resulting paint
runs `syncLayout` → `dockSeats` → another pass.

#365 made the cycle reachable from both ends. `dockSeats` schedules a
pass whenever a reaction seat stands anywhere on the page, and the six
emoji it moved into the margin mean one always does; and it put the
focused control inside the host being moved, which is what turns a
placement into focus traffic.

`anchors.js`'s `dockSeats` comment records the same shape being cut once
before — "a whole margin render every frame with nothing dispatched and
nothing moving… ~350ms of main thread a frame". This is that cycle
closing again through a consumer that did not exist then.

## The change

A dock is an answer about a width, so it holds while the width it
answered about holds. The pass remembers the room each row docked
against and keeps that answer until the room changes or the row restates
itself through `registerMarginRow`/`updateMarginRow`, whose own size is
the other half of the answer. The measurement that could not have
answered differently no longer moves the reader's focus to prove it.

The tooltip is user-facing, not only a probe: before this, focusing a
reaction pill showed no label at all, and the page never stopped
animating.

## Verification

-
`test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus`
passes; it failed five times running on `main`
- Paired control: the same test passes at `5d571319` (the four merges
before #365) and fails at `06daeef3`, isolated `-n0`, same machine
- `uv run pytest tests/test_render_margin.py
tests/test_render_controls.py tests/test_render_navigation.py
--run-nightly` on the merged tree: 250 passed, 5 failed
- Four of those five are `main`'s own, confirmed against a detached
checkout of `8fbf925c` carrying none of this branch: both
`test_an_unchanged_heartbeat_restates_no_margin_name` cases and both
`test_the_small_screen_map_is_a_complete_accessible_sheet` cases
- The fifth,
`test_unchanged_margin_refresh_cost_is_bounded_by_refresh_count` at `22
<= 20`, was contention from `-n 2`; isolated it passes
- `uv run pre-commit run --files
skills/leaf/assets/runtime/margin-layout.js` clean

Review found one fault in the first version of this change and
`41f940d0` folds it in: a row the posture read keeps docked reached the
classification loop with `hangs === true` and its docked rect, so
`rect.right > room` was false and it fell through to `inMargin` —
counted as hanging in the margin while standing in flow. Every
`staysDocked` member used to carry `hangs === false` and re-enter the
docked branch on its own, which is the invariant the new member broke.

## The other #365 red, and where it went

`test_other_responses_can_turn_the_compact_field_into_a_suggestion` was
red on `main` for a second, unrelated reason: one Tab from the compact
composer focuses the fab bar's Other responses trigger, which raises the
margin surface, and `.lf-fab-bar[data-lf-margin-raised] { display: none
!important }` then hides the bar the reader is standing in.

That was #365 moving where Other responses renders, not a fault, and
#372 has since settled it: the case is now
`test_reactionless_other_responses_can_turn_the_compact_field_into_a_suggestion`,
which serves a layer with the reaction tokens stripped and asserts
Suggest stays in the compact fallback there. Both readings pass on this
branch with `main` merged in, so `main` goes green on the nightly ring
census and on that case together.

## Why nothing caught it

#340's gate runs the nightly modules a pull request edits. #365 edited
twelve test modules, and neither of the two it broke was among them. The
full nightly behind that gate has not completed on `main` since
`934bfc4c`: four of the six runs after it were cancelled by the next
merge landing first.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 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