Skip to content

Keep thread cards attached to their page source - #471

Merged
max-sixty merged 4 commits into
mainfrom
codex/thread-card-lifecycle
Sep 9, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/thread-card-lifecycle

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Thread cards could outlive their page source and change sides as unrelated margin controls scrolled through the viewport. Keep an open card in a stable readable page margin, protect its own control cluster, and close it when scrolling carries that source outside its visible reading region.

Thread walks now transfer the open card directly between targets, retain a reachable Thread control in crowded clusters, and preserve the surrounding interaction state. Conversation spacing and the card's narrow-screen sizing use the same shared geometry. Browser tests cover the forward and reverse thread walk, side stability, source detachment, crowded controls, constrained regions, and focus reflow.

This was written by Codex on behalf of max-sixty

…ecycle

# Conflicts:
#	skills/leaf/assets/runtime/chrome.css
#	skills/leaf/assets/runtime/living-margin.js

@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 defects in the new placement path, both reproduced on this head and checked against the merge base. Inline suggestions carry the fixes; with both applied the 29 thread cases in test_render_margin.py and test_render_navigation.py pass.

The card dismisses itself on its own scroll events. The capture-phase scroll listener arms the detach check for a scroll anywhere in the document, and the card is in the document. Shrinking the viewport shrinks the card's max-height, its overflow scrolls, and the scroll events it dispatches arrive while the source cluster now sits below the fold — so the conversation closes although the reader scrolled nothing. This PR's own test_the_shipped_long_thread_uses_the_margin_clear_of_its_controls fails on it here: after resized_shell(page, 1536, 480) the card is closed and the height-cap assertions read a zero rect. test is green on this commit, which makes the surviving case a race rather than a guarantee — a scheduleThreadPreviewPosition(true) landing after the scroll clears the pending flag, so whichever event lands last decides whether a window resize keeps the reader's open conversation. Ignoring scrolls that originate inside the card leaves the reader-scroll dismissal (and its new test) intact.

The right margin is measured with the scrollbar included. innerWidth counts the standing scrollbar the theme reserves (html[data-lf-live]:not(.lf-copy) { overflow-y: scroll }), but the card is position: fixed, so its coordinate space ends at documentElement.clientWidth. Pinning it to innerWidth - 8 puts its right border and padding under the scrollbar, and the same overcount admits a strip a scrollbar's width narrower than --thread-card-min as if it were readable. Measured on ASK_PAGE at 1440: card right edge 1432 against a client width of 1425. At the merge base the same page placed the card at 898.5–1358.5, inside the visible width, so the clipping is new. The suite cannot see it — Playwright's headless launch passes --hide-scrollbars, so innerWidth === clientWidth in every browser test — and geometry.js's shownBand already states the root scrollport's reading as "the padding box less whatever a scrollbar takes".

How each was reproduced

Both runs are on refs/pull/471/merge (head 49b8bf27, base 18b1edec) with the suite's own pinned headless shell.

  • uv run pytest tests/test_render_margin.py::test_the_shipped_long_thread_uses_the_margin_clear_of_its_controls -n0 fails at the capped["top"] >= capped["bannerBottom"] + 7 assertion with a zero rect (:popover-open false). The predecessor case, test_the_shipped_long_thread_opens_beside_its_source_in_the_right_margin, passes in a merge-base worktree in the same environment. Logging the capture listener across resized_shell(page, 1536, 480) prints two scroll events, both with target ASIDE.lf-ui lf-margin-preview, while the owning cluster measures 595–985 against the new 480px viewport.
  • The scrollbar reading comes from the same fixture launched with ignore_default_args=["--hide-scrollbars"]: {innerWidth: 1440, clientWidth: 1425, cardLeft: 972, cardRight: 1432} on this head, {cardLeft: 898.5, cardRight: 1358.5} at the merge base.

@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 findings are fixed in 728143c and verified on that head; no remaining findings.

The capture-phase listener now ignores scrolls originating inside the card, so the card's own overflow no longer arms source-detachment dismissal, and placeThreadPreview measures the page viewport with document.documentElement.clientWidth. uv run pytest tests/test_render_margin.py tests/test_render_navigation.py -k thread -n0 passes all 29 thread cases here, including test_the_shipped_long_thread_uses_the_margin_clear_of_its_controls, which failed at the previous head. Re-running the scrollbar probe — the same ASK_PAGE fixture at 1440 launched with ignore_default_args=["--hide-scrollbars"], which is the only way the suite can see a standing scrollbar — reads {innerWidth: 1440, clientWidth: 1425, cardLeft: 957, cardRight: 1417}: the card's right border and padding now sit clear of the reserved scrollbar, where the previous head placed that edge at 1432.

@leaf-agent

Copy link
Copy Markdown
Collaborator

The approval above holds on the current head: 272e53dc is the trivial merge of the reviewed 728143ce with 3b95e8ea — its tree matches git merge-tree --write-tree 728143ce 3b95e8ea exactly, and it leaves living-margin.js and the thread tests untouched — and every gating check is green on both commits.

test was red on 728143ce before that, on test_a_queued_codex_delivery_leaves_the_turn_ended_stamp_standing: the carrier had not reported live within the case's 10-second deadline. That case runs bin/leaf codex start as a subprocess and never loads the browser runtime, so nothing in this branch reaches it. It did not reproduce at the merge base on a Linux runner — the whole everyday suite once under the job's own -n 2, plus three runs of tests/test_interact_session.py -k codex — and the rerun of the failed job passed on the same commit. It belongs to the deadline-versus-runner-load class rather than to this PR; recording it here in case the same case shows up again.

@max-sixty
max-sixty merged commit 18b37e8 into main Sep 9, 2026
6 of 7 checks passed
@max-sixty
max-sixty deleted the codex/thread-card-lifecycle branch September 9, 2026 02:40
max-sixty pushed a commit that referenced this pull request Sep 9, 2026
…tly tests to the shipped behavior (#509)

The daily complete-suite run on `main` went red with eleven failures
([run
34342437953](https://github.com/max-sixty/leaf/actions/runs/34342437953)).
None of them is a flake: every one reproduces locally at `26754cc4`, and
each traces to a change that landed since the previous nightly and could
not be gated by it. The two scheduled runs are ~70 commits apart — the
one before this ran at `7e403108`, so this was the first complete suite
over that whole span, and eleven failures is what a span that wide
accumulated.

Ten of the eleven are the nightly-only tests still describing a behavior
a shipped change has replaced, or an arrangement a shipped change has
moved. One is a real defect on <https://leaf.page/>.

## The site defect

`docs/sitenote.js` looked for `main > :only-child > header` and, finding
none, dropped the site's context label beside the workspace under
`main`. That second element under `main` is exactly what
`syncRootWorkspace` reads to decide a workspace is *not* the page's
root, so the note cost the example the bounded allocation it is
published to demonstrate: `notification-playground` arrived on the site
in ordinary document flow with no bounded regions at all. It became
reachable when #481 compacted the example and removed the `<header>` the
note had been landing in — the site's placement rule had been resting on
markup the example was free to drop.

The note now gives a headerless framed task a header of its own rather
than standing beside it. The generated header is marked `lf-ui`, like
the note it carries, so the example's anchorable reading is unchanged.
The framed root is still read as `main`'s only element child: narrowing
that to the `lf-workspace` tag would have moved the same defect onto
`live-progress`, whose root is `lf-monitor`.

`test_published_workspaces_keep_their_allocation_under_site_context` is
what let the original defect through — it named two examples, so neither
`live-progress` nor `current-proposed-comparison` was gated. It now
derives its parametrization from the corpus, covering every example
whose whole `main` is one framed task, and reads the root by the
`lf-workspace-arranged` class the runtime marks any arranged workspace
with rather than by tag. Under the tag-name selector that gate fails on
`live-progress` and passes on the other three.

## The stale readings

| Failure | What moved under it |
| --- | --- |
| `test_a_key_on_screen_is_a_key_that_works`,
`test_no_two_hints_on_the_key_line_say_the_same_word` | #494 renamed
`version.previous`/`version.next` to `version.later`/`version.earlier`,
added `1`–`9` numbered travel to the menu's `aria-keyshortcuts`, and set
`promoteEscape: false` on both of the menu's doors out, so the compact
line now prints the walk beside numbered travel rather than the Escape
return. The assertions name the new commands, keys, and words. |
| `test_the_layer_traps_no_margin_in_the_panel_it_draws` | The test
picked its page as the first corpus source shipping *any* `.jsonl`. #505
added `current-proposed-comparison.jsonl`, which sorts first and holds
one widget action and no conversation, so the panel opened on nothing
and the test's own positive control — a rule planted to trap a margin
against a thread's quoted address — found nothing to plant against. The
selection now asks for a log holding an anchored comment. |
| `test_page_round_trip`,
`test_browser_and_file_captures_stop_at_the_same_widget_fences[1,2]` |
#471 keeps an open thread card standing in a stable page margin. Both
tests send a comment and then reach for something underneath the card it
leaves open: the board column the drag is aimed at (the board is a wide
widget, so its columns run out into that same band) and the composer
field for the next passage. Both now dismiss the card first, which is
what a reader does. |
|
`test_an_exported_page_fixture_stands_on_its_own[notification-playground,
corpus]` | The copy's `unshown` reading reported
`section#notification-artifact` — the slot `notification-playground`
authors `hidden` so that `notification-artifact` is bound before the
agent captures it. `lf-source` renders a `no data` caption into it, and
the reading counted those words as content a copy had lost. A slot the
markup hides is hidden on the live page too, so the copy withholds
nothing; `[hidden]` joins the reading's exemptions. Across the whole
corpus this exempts that slot and nothing else — every other fixture's
reading is already empty. |
| `test_the_feature_gallery_keeps_its_real_actions_reachable[390]` | The
gallery is ~20,000px tall at 390px, and its arrival cascade after the
test's bare `page.reload` intermittently raises `ResizeObserver loop
completed with undelivered notifications` — the platform reporting a
deferred delivery. The repo already adjudicates that notice over two
attempts on the same document, in `render_harness.navigate` and again in
the render gate's own arrival readings; this reload was the one that
bypassed it. It goes through `navigate` now. |

## Verification

`uv run pytest tests --run-nightly` on this branch: **2327 passed, 6
skipped, 10 failed** in 45:23. All eleven of the run's failures pass.
Every one of the ten remaining failures is this sandbox's, not the
branch's — none appeared in the CI run, and all ten reproduce
identically with `tests/` and `docs/` checked out at the merge base.
They are three capabilities the container withholds: no IPv6 for the two
stated-host wildcard binds `tests/CLAUDE.md` already names, no `AF_UNIX`
socket for the two app-server tests, and a denied `process_singleton`
socket for the six that launch the installed Chrome from a subprocess
(`Check failed: socket() failed: Operation not permitted`) rather than
through the pinned headless shell the fixtures use.

`uv run pre-commit run --files` over every changed file: passed.

<details><summary>How the two non-obvious causes were
established</summary>

`test_page_round_trip` fails deterministically at `26754cc4` and passes
with `skills/` and `examples/` checked out at `7e403108`; swapping
either alone still fails, because `examples/layer.json` at head names a
package the older `skills/` has not got. Swapping the pair commit by
commit lands on #471, and a probe of `document.elementFromPoint` at the
drop coordinate returns `div.lf-margin-thread-body` — the card the
comment opened, over the column.

The gallery's notice was traced by wrapping `ResizeObserver` on the page
and recording each callback's construction site per frame. With the
reload followed by a settle, no notice arrives at all and no gesture in
the test produces one; the frames that raise it are the post-reload
arrival cascade, in which body height climbs from ~18,000 to ~20,500px
across a dozen frames while three observers deliver on each.

</details>

---------

Co-authored-by: leaf-agent <[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