Skip to content

Give a last-resort panel thread back to the page when its target returns - #3855

Merged
max-sixty merged 1 commit into
mainfrom
fix/3558-last-resort-returns-to-page
Oct 25, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/3558-last-resort-returns-to-page

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

When a responsive layout hides a reply's target, the destination's last resort opens the thread in the floating panel, the card closes, and the reply row moves to the panel. When the target came back, nothing moved it back: the card stayed closed and the reply stayed in the panel. That kept one view, but in the place the user never chose. This change gives the thread back to the page.

What changed

  • The destinations own the last-resort record. thread/destination.js keeps the keys of threads handed to the primary with request.last. This replaces the panel's own unplaced set, which recorded the same fact; the panel now reads atLastResort(key) to decide whether Show on page has anywhere to go.
  • returnToPage runs after each thread pass, chained after reply continuity in thread/presentation.js. For each last-resort thread the primary still shows, it draws the thread on the page first (openPageThread(..., { returning: true }), which skips the primary's first ask). Only once the page shows it is the primary asked again, so the panel puts its view away as it declines. A page that still can't draw the thread leaves the panel's view standing, with no flicker.
  • The panel hands the reply on rather than ending it. In the panel's reveal, when the page takes the thread the panel shows, it calls releaseReplies on its reply outlet and closes without dismissReply. Because the card is already open, the row moves straight into it, keeping focus, caret and undo history.
  • Where the user was on the panel's thread, not in its reply, they land on the card's thread. A user elsewhere stays where they are, and no scroller moves.

Differences from the triage design

  • The verdict assumed the card drew again at 1200 px beside the panel. A trace on current main showed something else: at 480 px the destination's primary handoff closed the card, and at 1200 px nothing reopened it. So the panel can't yield to a card that's already showing. The page has to draw the thread first.
  • I kept the card's withheldFocus hold. A probe showed it still serves targets hidden by a closed disclosure or visibility: hidden. There the card stays open, unseen, and the panel never takes the thread, and both cases still bring the reply back.
  • The page-first order means no thread passes through the hidden park. Asking the panel first did pass through it, and that hit Chromium's :focus-within gap (notes/browser-support.md, "State-preserving content reordering").

Behavior change beyond the issue

When any route asks the panel for the thread it already shows (Show on page, for example), the panel used to end the reply's editing session. Now the session moves to the card with its draft. The draft was kept either way; the difference is the native session.

Tests

  • tests/journeys/test_render_aim.py::test_open_draft_retains_words_when_responsive_layout_hides_its_target[True] fails on main and passes here. It now also asserts that the panel shows no thread view at 1200 px and that the card's editor is the node the user typed in. [False] and test_resume_reveals_an_open_draft_when_its_existing_subject_hides pass.
  • Related node ids pass: the panel's last-resort and route tests, the reply-session and seated-thread carry tests, Show on page, and the withheld-draft tests in tests/browser/test_render_aim.py.
  • pnpm run test:runtime passes, and the kernel is rebuilt.

Closes #3558

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

When a responsive layout hid a reply's target, the destination's last resort opened the thread in the floating panel and the reply row moved there, closing the card. When the target came back, nothing moved it back, so the reply stayed in the panel.

The destinations now own the record of threads handed to the primary as the last resort (replacing the panel's own `unplaced` set). After each thread pass, `returnToPage` draws each such thread on the page first; only once the page shows it is the primary asked again, so it puts its view away as it declines. The panel then hands the reply row it holds to the card instead of ending the session, so the user goes on in the same editor with its caret and undo history.

The journey test now also asserts the panel shows no thread view at 1200 px and that the card's editor is the one the user typed in.

Closes #3558

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 2302367 into main Oct 25, 2026
3 checks passed
@max-sixty
max-sixty deleted the fix/3558-last-resort-returns-to-page branch October 25, 2026 03:49
max-sixty added a commit that referenced this pull request Oct 25, 2026
A reply box's ↑ row ("edit last message") is live only once the user's
last words can be rewritten, which it reads from the messages the
thread view drew (`threadRewrites`, `view.model.editable`). That is
document state, so its renderer has to mark the row for reflection
(keyboard/scopes.js), and `ThreadView` never did: a thread opened by a
feed's "Talk about this" sent the user's first message, the message
became editable when the server's reading arrived, and the reply's
`aria-keyshortcuts` kept naming no ArrowUp until something else
repainted every key.

Before #3855 something else did repaint them after that reading, so
the gap was hidden; #3855 changed how the thread reaches its margin
card, and `test_presses_and_fills_leave_no_element_naming_stale_keys
[github-discoveries]` began failing on main, deterministically, at
steps 0, 2 and 5.

`ThreadView.#paint` now calls `paintKeysWithin(this.node)` after it
draws, so the keys a reply announces are current with the messages
above it.

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

Adds a nightly macOS run of every test tier, and fixes every test that
failed in its first run or in the Linux nightly beside it: 89 tests in
[run
40156291557](https://github.com/max-sixty/leaf/actions/runs/40156291557),
60 of them only on macOS.

## The macOS nightly

`ci.yaml` gains a `test-macos` job: every tier on `macos-15`, `-n 2` on
its three cores, in the daily schedule and a dispatch. It belongs to
`ci`, so a failure turns that run red and reaches tend through the
existing `workflow_run` trigger, with no tend configuration change.
GitHub doesn't bill hosted runners for public repositories; the job
holds one of the account's macOS slots for about three hours. The test
step names `shell: bash`, without which a step runs without `pipefail`
and piping pytest through `tee` reported the first run's failures as a
green job. The setup action's Ubuntu mirror step now runs only on Linux.

`tests/AGENTS.md` counts `test-macos` among what tend repairs and leaves
only failures no CI run shows to local sessions. It drops the
instruction to confirm a macOS-only failure at normal priority because
`taskpolicy -b` slows headless Chrome: a test that fails on a slower
host depends on timing, and the fix is to the test. `running-tend` tells
the session fixing a red run, which has only a Linux runner, to verify a
macOS-only fix by dispatching `ci` on its branch.

## The fixes, by cause

Product fixes:

- A drafted margin card rose against the window's foot and never came
back as the draft shrank (#3524). It now holds the top it opened at and
drops back.
- A tapped pin reseated 11px lower as it unfolded, because the
hold-to-read toggle was pressed before the browser focused it (#3341).
- A page's first thread card could cover its passage, because the
placement that makes room was dropped while Floating UI loaded (since
#1526).
- A heading's "Copy link to section" stayed at the heading's far end
after the window narrowed and widened, since every engine keeps its last
`position-try` fallback (#3836). It now picks its place from the current
width.
- Putting the response bar away moved focus off the button the press had
just focused, so the next `e` found nothing (#3756).
- A trace's image-tools status shared a class with the image's loading
notice, whose rules hid it (#3707).
- WebKit scrolled the outer page 1,386px when a sample editor took focus
(#3634).
- In draw mode a press left the previous press's release timer pending,
so a fast second click reached the page.
- Hint refreshes read the geometry of every target inside a closed
disclosure, forcing layout of skipped content.
- A sidebar page's sticky track clipped focus rings (#3918). A stuck
track body now keeps the ring's room inside its edges, so its blocks
stand 5px in from each side.
- Tab revealed a block's Copy flush with its scroller, cutting its ring
(#3916).
- The hidden "my change" word inside a choose group took a cell's
padding and read as clipped content (exposed by #3837's check).
- Visual review case buttons kept their wide padding after the first
breakpoint crossing, a Chromium restyle bug avoided by making the case
list a plain container.
- A held shot's scrolling stage didn't declare that it holds its height
(#3703/#3704).
- When the log refused a reply, the floating panel's head moved down
69px and the restored draft pushed its controls up 21px (#3400). Through
a refusal the panel now holds its head and the field its height, on the
holds a press already takes; the refused turn's room goes at the user's
next turn.
- A reply box's ↑ (edit your last message) appeared only after an
unrelated repaint once its last message became editable (#3855). Every
message draw, by any thread reader, now recomputes that row's keys.
- A trace's images took the page's scroll anchor, so a lane change in
the timeline scrolled the page 62px under an arrow key; they no longer
anchor scroll. The trace overview wrote its window's new start before
reading its size, so for one layout the window ran past its strip and
Chromium scrolled the page up to 838px; it now reads before it writes.
The image tools' status keeps its line when its text clears.
- Web Awesome's radio group moves focus on an arrow with a bare
`focus()`, which Leaf's ring scroll margin turned into a page scroll.
The vendored bundle is patched (`build/vendor.mjs`) so both calls pass
`preventScroll`.
- A Leaf page inside an iframe took focus from the page around it when
it finished arriving. Its arrival recovery now runs only at top level or
in a frame that holds focus.
- The margin rail's one Tab stop stayed on whichever row last held it,
so a resize could leave it below a row the user sees first. It is now
the highest row in view; a focused row keeps it.
- A resize that moved a sidebar page's track into the page, with neither
place made by the reader, took the track's place over the page's:
live-progress jumped 1861px (#3918). On a tie the page's own place wins.
- The whole-page rule read a shut disclosure whose children are all
generated as showing what it holds (#3908); it now skips only `.lf-ui`
apparatus.
- The gallery revealed its stamped frame at the centre, carrying the
pressed button 45px; it now scrolls only as far as needed.

Test fixes:

- The Codex fixture copies the running interpreter as `codex`; on a
framework Python, as on the runner, the copy fails its code signature
and macOS kills it at launch. That broke 39 tests. The copy is now
re-signed ad hoc, and the fixture no longer leaks `PYTHONHOME` into the
command it runs.
- The plain-HTTP copy test missed Chromium's lower-cased host; the
event-door refusal test read its answer after the server's reset; the
stale-keys sweep raced the browser entering fullscreen; the words watch
didn't credit a blur from a press elsewhere.
- Several tests read state before it settled (a shown gesture's arm, a
side list's smooth scroll, a sample's focus returning, a held reply's
menu), and now wait for it. Assertions predating #3830, #3916, #3670,
#3673 and #3217 now read the current behavior.
- Three waits fixed their own deadline instead of the suite's, among
them the async-probe test's 500ms.
- The command hub's record now sticks in view, so the Atlas journey
opens its news before reading each row; the region-capture journey drags
over the unreadable image it means to fail on (#3861 draws only the
element that alone paints the crop).
- The touch-capture removal test, which fails intermittently on main,
now reads the shelf right after the tap and names the elements the tap
reached, so its next failure says whether the tap missed or the image
came back.
- The feature-gallery scroll pass allows a third of its steps to write
the contents' `aria-current`, as gestures already do, since the count
depends on where sections fall under the platform's fonts.

The branch also merges the four open `grind/f-main-tests-*` pull
requests, whose fixes cover five more of the run's tests: #3871, #3882,
#3887 and #3906. This pull request lands them.

Each fix was reproduced failing and then passing by node id, on this Mac
or, for a Linux- or runner-only failure, against a run's log, except
where its commit says otherwise. Dispatched full runs on this branch
([40156291557](https://github.com/max-sixty/leaf/actions/runs/40156291557),
[40186545420](https://github.com/max-sixty/leaf/actions/runs/40186545420),
[40196342887](https://github.com/max-sixty/leaf/actions/runs/40196342887))
check both platforms; the second took the macOS job from 86 failures to
38, most of the rest fixed since. A few macOS-only failures pass on
every local attempt (two reading-place tests, a scroll repaint, Back
from a thread, opening a line under the last, the Android composer's
Return, margin-entry order, a card paging on, a turn arriving out of
view) and have no fix here; once this lands, the macOS nightly reports
them to tend.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 27, 2026
A reply handoff treated a margin card hidden with `visibility: hidden`
as still showing its editor: bare `checkVisibility()` ignores that
property. The floating panel therefore took focus in a fresh mirror
instead of carrying the native row, and returning to the card discarded
the original editor. Reply handoffs now use the shared `drawn` predicate
for both the current owner and destination views, preserving the editor,
caret and undo history through the responsive transition intended by
#3855.

The existing responsive-draft journey fails on current main at the
original-editor identity assertion and passes with this change, for both
comment and reply variants. Seven related cases covering hidden subjects
and transfers between diff seats and margin cards passed. All 673
runtime tests pass, and the kernel build/type check passes.

The on-screen card, reply words and focus keep their existing
presentation; the corrected behavior retains the native editing session
during the hidden-card/panel/card transition. A served `review-a-plan`
startup comparison keeps 31 code requests through widget upgrade and
first server-state presentation; JavaScript decreases by 27 bytes, while
total code bytes increase by 58 bytes. Both arms report no console
errors or layout shifts. The fix adds no startup task or dependency.

Closes #4239 — automated triage

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.

Restore reply focus when a responsive target reappears

2 participants