Skip to content

Settle the comments panel before measuring the label to press - #88

Closed
leaf-agent wants to merge 1 commit into
mainfrom
fix/ci-33153186163
Closed

leaf-agent wants to merge 1 commit into
mainfrom
fix/ci-33153186163

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Problem

tests/test_render_navigation.py::test_a_label_press_keeps_the_controls_keyboard_standing fails deterministically on main, and has failed on every ci run since the commit that added it (db1100e) — run 33153186163 and run 33153722537 both name it. It reproduces at -n0 on this runner every time, so it is not contention and not a load-dependent race.

The test's last stanza opens the comments panel, focuses a thread, and then measures #frame-label span to press it. The panel's class flips at once but the document slides into its new width over about a fifth of a second (syncLayout), so the bounding_box() read lands mid-flight: it reported x=200.6 width=66.5, and by the time mouse.down() dispatched, the span's own rect was 164.8 → 231.4 while the pointer sat at 233.9 — just past its right edge. The press therefore landed on the enclosing lf-option rather than the label, no label.control appeared in the composedPath(), the runtime never opened a label transaction, and the thread lost its standing. That is the assertion's exact diff: ⏎ / reply where c / comments was painted.

Solution

Call the existing panel_settled(page) after opening the panel, which the same file already does at four other sites and which render_harness.py documents for precisely this read. It waits for the class to reach open and for document.body.getAnimations() to drain, so the geometry read is of the layout the press will meet. The behaviour under test is untouched — with the press landing on the label, the label transaction holds the thread's standing and the assertion passes on its own terms.

Testing

  • The named test at -n0, three consecutive runs: passed each time (failed before the change on the same commit).
  • uv run pytest tests/test_render_navigation.py --run-nightly: 51 passed.
  • uv run pytest tests: 648 passed, 6 skipped.

Automated fix for failed run

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Another occurrence: run 33154672429 (commit c4b7444) fails at the same assertion — tests/test_render_navigation.py:2885, assert key_line(page) == thread_standing with 'c\ncomments\n...' against '⏎\nreply\n...' — consistent with this PR's diagnosis. It was the only test failure in that run (1 failed, 1363 passed), so this PR covers it and I have not opened a duplicate. That run's lint job is red separately on the validation.py import ordering, which #89 fixes.

max-sixty pushed a commit that referenced this pull request Aug 28, 2026
Carry the one-line stabilization from #88 so the inherited navigation test observes the open panel after its transition completes.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (43ada1a) and force-pushed as 979bee8. The change is unchanged — still the one panel_settled(page) line.

The rebase is what this PR needed: its red lint was never about this diff. The branch was cut at c4b7444, where ruff's isort rule was failing on validation.py; main has since dropped that file entirely (5689178) and cleared the follow-on ruff format failure (43ada1a). I closed #90, which proposed those same seven blank lines, as already-applied.

So this is now the only thing keeping ci red on main, and both halves of the pairing recorded on #89 have resolved to this one PR.

Evidence

Two further occurrences since the last comment here, both naming the same assertion with the same diff (assert 'c\ncomments\...' == '⏎\nreply\nes...'):

On that last run lint is green and test is 1 failed, 1363 passed, 6 skipped, the one failure being this test.

Re-verified locally on the rebased tree, both directions from the same base (43ada1a):

pytest tests/test_render_navigation.py::test_a_label_press_keeps_the_controls_keyboard_standing
  with this branch's test file  → 1 passed
  with main's test file          → 1 failed

Main's lint state at 43ada1a, with the pinned [email protected] from .pre-commit-config.yaml:

ruff format --check .  → 123 files already formatted
ruff check --no-fix .  → All checks passed!

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Superseded — closing.

The identical one-line change is already on main: e4be680 ("Make Python the canonical browser projector", #87) added panel_settled(page) at the same site in test_a_label_press_keeps_the_controls_keyboard_standing, so this branch's only commit is now a no-op against main and merging it would change nothing.

Verification

This run was dispatched for run 33159578982 on 43ada1a, which failed at the same assertion this PR diagnosed — tests/test_render_navigation.py:2885, assert key_line(page) == thread_standing, 'c\ncomments\n…' against '⏎\nreply\n…'. That commit is this branch's merge base, and it is the last main commit without the fix.

$ git diff origin/main origin/fix/ci-33153186163 --stat -- tests/test_render_navigation.py
(no output)

$ git show origin/main:tests/test_render_navigation.py | sed -n 2873,2876p
    page.evaluate("() => getSelection().removeAllRanges()")
    page.locator(".lf-comments").click()
    panel_settled(page)
    thread = page.locator(".lf-threads > .lf-thread")

ci on 8eb3a8f was still in flight when this was written; it predates e4be680, so it is expected to name the same test. 8eb3a8f..e4be680 is where the line arrives, and its ci run is the one that shows the assertion settled.

@leaf-agent leaf-agent closed this Aug 28, 2026
max-sixty added a commit that referenced this pull request Oct 12, 2026
…ts seat

Item #88 of the Lit follow-up review (the review numbers its own items; #88 is not a GitHub issue). #2614 took a reply being written in the margin card back to the diff line with its thread. It left four cases where the card closes before the thread's new place exists or is chosen. This PR settles all four.

## The rule

A thread moving between surfaces takes the user standing on it along:

- **The reply editor belongs to the editing session, not to the view showing it.** A view that can no longer draw the thread releases the editor row (`releaseReplies`, `thread/replies.js`). That covers a seat the thread left, and the margin card, open or closed, once its thread has left the margin (`releaseLeft`, `thread-preview.js`).
  - The row goes to a view that draws the thread now. Where none does yet, it waits in a hidden park in the chrome.
  - The next view to draw the thread claims the row in the same task, in place of its own (`claim`): a seat once it stands in the document, the margin card once it places its thread, or a visible Threads card.
  - The editor moves with `moveBefore`, so focus, caret, IME state and undo history stay, and no blur fires. Leaf's dictation stays with the row too: a view handing its row on (`give`) no longer stops it, and a seat releases a leaving thread's row before retiring the rest of its card.
  - A closed card whose thread is still in the margin keeps its row, as a hidden Threads panel does, since the user goes on there when it opens again.
- **A user standing anywhere else on the thread goes with it** (`holdThreadPlace`, `thread/focus.js`, generalizing #2614's `holdReply`). "Anywhere else" means a margin card's controls, a seat's controls, or the thread's margin marker (`entryThread`, `margin-projection.js`).
  - When the pass takes away the node they stood on, they land on the thread itself where the pass seated it.
  - They hold no words that need showing, so the pass opens no card or panel for them.
  - It does nothing for a resolved thread, nor once another owner has placed them or they have acted.
  - A reply control names its thread from its own session (`replyThreadKey`), so a parked row still names its thread.

## #88 A: the editor no longer blurs on a move

**What changed.** The editor keeps focus as it moves from the diff line to the margin card or Threads, and back. Before, it blurred once on each move, which cancelled an IME composition in progress and announced a focus change, and the move stopped Leaf's dictation, so the next words heard went nowhere.
- Card → diff: the margin releases the row into the diff line's new seat as its thread leaves the margin, before the card hides.
- Diff → card: the seat releases the row to the park, and the card claims it as it opens, in the same task.
- `holdBox` (`reply-landing.js`) no longer scrolls the page to hold a control that left its thread view.

## #88 B: leaving the card first keeps the editor

**What changed.** A user who left the card's reply before the patch returned gets the same editor on the diff line, undo history included. That holds whether they Tabbed onto the margin or closed the card. Before, the diff line drew a fresh editor with only the words, and the hidden card kept the original.

## #88 C: the card's Close

**What changed.** A user on the card's Close when the thread returns to the diff lands on the thread on the diff line. Before, they landed on the banner's More button.

## #88 D: the margin marker

**What changed.** A user on the thread's margin marker when the thread returns lands on the thread on the diff line. Before, they dropped to the page body.

## Tests

These failed on `main` and pass now:
- `test_a_reply_dictated_on_the_diff_keeps_listening_as_its_thread_moves` replaces the browser's speech recognizer at its boundary, as `tests/runtime/dictation.test.mjs` does. It dictates on the diff line, moves the thread to the card and back, and expects the heard words in the same box each time with the recognizer never aborted.
- `test_a_reply_box_whose_thread_leaves_the_diff_takes_the_user_to_its_card` (overlay, resolved, page margins) and `test_a_reply_box_whose_thread_returns_to_the_diff_takes_the_user_back` now count blur events on the editor and expect none. On `main` each counted one.
- `test_a_reply_box_left_by_tab_returns_to_the_diff_with_its_history[open|closed]` (B) failed at the undo.
- `test_a_user_on_a_thread_returning_to_the_diff_goes_with_it[close|marker]` (C, D) failed with focus on the banner, and on the body.

`test_a_diff_refresh_leaves_an_inline_reply_to_its_thread_owner` now finds the focused editor with `:focus` instead of `:focus-within`. Chromium leaves an element moved through a `display: none` parent unmatched by its own native `:focus-within`, while its new ancestors still match. No Leaf style reads that pseudo-class; focus paints through `data-lf-focus-within`. The gap is recorded in `notes/browser-support.md`.

## Lines

Hand-written source: +250 / −67.
- `replies.js` +95/−21
- `focus.js` +74/−33
- `inline.js` +21/−1
- `margin-projection.js` +16/−4
- `thread-preview.js` +16/−1
- `presentation.js` +10/−5
- `thread-card.js` +6
- `reply-landing.js` +5/−2
- `thread-list-view.js` +4
- `application.js` +3

Tests: +155 / −1.

## Checks

- The related browser selection passes: 881 tests across the thread, draft, widget, anchor, read-state, file, diff-control, margin, words-watch, response-continuity and response-pointer files. Three failed, and they fail on the base commit too: `test_observed_scroll_retains_the_seat_of_a_constrained_target` ×2, and `test_a_reaction_list_opens_from_a_trigger_under_the_thread_panel`, which #2625 has since fixed on `main`.
- `pnpm run test:runtime` and pre-commit pass on the changed files.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 14, 2026
…ts seat (#2638)

Item #88 of the Lit follow-up review (the review numbers its own items;
#88 is not a GitHub issue). #2614 took a reply being written in the
margin card back to the diff line with its thread. It left four cases
where the card closes before the thread's new place exists or is chosen.
This PR settles all four.

## The rule

A thread moving between surfaces takes the user standing on it along:

- **The reply editor belongs to the editing session, not to the view
showing it.** A view that can no longer draw the thread releases the
editor row (`releaseReplies`, `thread/replies.js`). That covers a seat
the thread left, and the margin card, open or closed, once its thread
has left the margin (`releaseLeft`, `thread-preview.js`).
- The row goes to a view that draws the thread now. Where none does yet,
it waits in a hidden park in the chrome.
- The next view to draw the thread claims the row in the same task, in
place of its own (`claim`): a seat once it stands in the document, the
margin card once it places its thread, or a visible Threads card.
- The editor moves with `moveBefore`, so focus, caret, IME state and
undo history stay, and no blur fires. Leaf's dictation stays with the
row too: a view handing its row on (`give`) no longer stops it, and a
seat releases a leaving thread's row before retiring the rest of its
card.
- A closed card whose thread is still in the margin keeps its row, as a
hidden Threads panel does, since the user goes on there when it opens
again.
- **A user standing anywhere else on the thread goes with it**
(`holdThreadPlace`, `thread/focus.js`, generalizing #2614's
`holdReply`). "Anywhere else" means a margin card's controls, a seat's
controls, or the thread's margin marker (`entryThread`,
`margin-projection.js`).
- When the pass takes away the node they stood on, they land on the
thread itself where the pass seated it.
- They hold no words that need showing, so the pass opens no card or
panel for them.
- It does nothing for a resolved thread, nor once another owner has
placed them or they have acted.
- A reply control names its thread from its own session
(`replyThreadKey`), so a parked row still names its thread.

## #88 A: the editor no longer blurs on a move

**What changed.** The editor keeps focus as it moves from the diff line
to the margin card or Threads, and back. Before, it blurred once on each
move, which cancelled an IME composition in progress and announced a
focus change, and the move stopped Leaf's dictation, so the next words
heard went nowhere.
- Card → diff: the margin releases the row into the diff line's new seat
as its thread leaves the margin, before the card hides.
- Diff → card: the seat releases the row to the park, and the card
claims it as it opens, in the same task.
- `holdBox` (`reply-landing.js`) no longer scrolls the page to hold a
control that left its thread view.

## #88 B: leaving the card first keeps the editor

**What changed.** A user who left the card's reply before the patch
returned gets the same editor on the diff line, undo history included.
That holds whether they Tabbed onto the margin or closed the card.
Before, the diff line drew a fresh editor with only the words, and the
hidden card kept the original.

## #88 C: the card's Close

**What changed.** A user on the card's Close when the thread returns to
the diff lands on the thread on the diff line. Before, they landed on
the banner's More button.

## #88 D: the margin marker

**What changed.** A user on the thread's margin marker when the thread
returns lands on the thread on the diff line. Before, they dropped to
the page body.

## Tests

These failed on `main` and pass now:
-
`test_a_reply_dictated_on_the_diff_keeps_listening_as_its_thread_moves`
replaces the browser's speech recognizer at its boundary, as
`tests/runtime/dictation.test.mjs` does. It dictates on the diff line,
moves the thread to the card and back, and expects the heard words in
the same box each time with the recognizer never aborted.
-
`test_a_reply_box_whose_thread_leaves_the_diff_takes_the_user_to_its_card`
(overlay, resolved, page margins) and
`test_a_reply_box_whose_thread_returns_to_the_diff_takes_the_user_back`
now count blur events on the editor and expect none. On `main` each
counted one.
-
`test_a_reply_box_left_by_tab_returns_to_the_diff_with_its_history[open|closed]`
(B) failed at the undo.
-
`test_a_user_on_a_thread_returning_to_the_diff_goes_with_it[close|marker]`
(C, D) failed with focus on the banner, and on the body.

`test_a_diff_refresh_leaves_an_inline_reply_to_its_thread_owner` now
finds the focused editor with `:focus` instead of `:focus-within`.
Chromium leaves an element moved through a `display: none` parent
unmatched by its own native `:focus-within`, while its new ancestors
still match. No Leaf style reads that pseudo-class; focus paints through
`data-lf-focus-within`. The gap is recorded in
`notes/browser-support.md`.

## Lines

Hand-written source: +250 / −67.
- `replies.js` +95/−21
- `focus.js` +74/−33
- `inline.js` +21/−1
- `margin-projection.js` +16/−4
- `thread-preview.js` +16/−1
- `presentation.js` +10/−5
- `thread-card.js` +6
- `reply-landing.js` +5/−2
- `thread-list-view.js` +4
- `application.js` +3

Tests: +155 / −1.

## Checks

- The related browser selection passes: 881 tests across the thread,
draft, widget, anchor, read-state, file, diff-control, margin,
words-watch, response-continuity and response-pointer files. Three
failed, and they fail on the base commit too:
`test_observed_scroll_retains_the_seat_of_a_constrained_target` ×2, and
`test_a_reaction_list_opens_from_a_trigger_under_the_thread_panel`,
which #2625 has since fixed on `main`.
- `pnpm run test:runtime` and pre-commit pass on the changed files.

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

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

1 participant