Skip to content

Reveal newly submitted thread replies - #997

Merged
max-sixty merged 8 commits into
mainfrom
codex/reveal-sent-reply
Sep 23, 2026
Merged

max-sixty merged 8 commits into
mainfrom
codex/reveal-sent-reply

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Submitting a reply in a long thread could leave the new message outside the thread's visible area. The send path revealed the editor before the conversation had painted the new message. This change waits for that presentation and uses the conversation's existing landing path to place the composer at the foot of the visible area while preserving later reader input and native focus. A short new message is fully visible; an oversized one shows its tail beside the focused Send control.

The browser regression covers both message sizes, keyboard and button submission, and visibility of the focused control. The growth test now uses Shift+Enter to insert lines under Leaf's Return-to-send behavior. A long-thread landing assertion also accounts for the scroller reaching its limit on macOS while retaining its target and line-crossing checks.

Checked: 29 conversation and reply browser tests, the composer-growth browser test, 77 runtime tests, pre-commit, and the prior head's full 1,348-test suite. CI lint and test passed on the current head.

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.

Sending an oversized reply leaves the focused control outside the scrollport. Reading document.activeElement at the end of the PR's own second case, the focused Send button sits at y 619–647 while .lf-threads ends at 455 — 164px below the foot of the list, with nothing on screen saying where focus is. revealReplyEditor kept it in the band before; block: "start" on a message taller than the room cannot, because the composer is laid out after that message. Typing recovers it through the input listener, but Enter, Tab or Escape pressed first each act on a control the reader cannot see.

What makes that worth more than a tweak is that the rule it breaks is already broken by another route. test_a_growing_reply_keeps_its_send_in_the_list fails on this branch — and it fails identically with leaf.js, application.js, landing.js and replies.js restored to the base commit, so it is not yours. Its docstring states the rule ("Growing the box past the list's foot then left the blue Send a sliver at the scrollport's edge… Growth is the landing's claim made again"), and replies.js carries the same sentence as a comment on the growth reveal. So the panel has a stated rule about a card that overruns the list, one site already violating it, and this PR adding a second — each reveal site choosing its own block and its own target, with nothing holding the rule for all of them.

That is the level I would rather see the change made at: the landing decides what a card overrunning the list may scroll to, and growth, send and direct arrival all ask it, instead of revealConversation, threadLandingStart and now revealReplyMessage each answering separately. Short of that, the narrow version needs a call about what the reader should be looking at after a long send — block: "end", which brings the message's tail and the composer into the band together, or moving focus onto the revealed message so focus and view agree. Either is defensible; choosing is what holds the approval, and it is a judgement about the reader rather than a rule in the repo's instructions.

The widened landing assertion. I could not reproduce the failure it answers. With the pre-change assertion restored, all four parametrizations of test_pressing_a_page_mark_stands_in_the_thread_it_opens pass on this Linux runner, and scrollTop sits 28px below maximumScroll in every one (44/60, 421/449, 961/989), so the new branch is never taken here. That line was already widened once — #956 made the block-alignment assertion conditional on scroll at all — and this widens it again, dropping both assertions in the exempted case rather than replacing one with the other. Nothing in this PR reaches that test's path: it sends no reply, and the landingRoom extraction is behaviour-preserving. So either the arrangement that produces the limit case belongs with the change, or the change belongs in its own commit.

Smaller. startPost already returns {answer, presentation}, where presentation is the pass that gesture's own enqueue opened, and setResolved consumes exactly that shape; post drops it, so createReply never sees it and the reveal reaches for the document-wide whenDocumentPresented() instead. And showThreadNow's preamble in landing.js still says "A reply send keeps the native focus of its button or editor and only reveals the editor if needed", a few hundred lines above the new function in the same file — outside the diff, so say the word and I will push that correction.

Readings and test selection

The focus reading, taken immediately before the existing expect(...to_be_focused()) at the end of test_submitting_a_reply_reveals_its_new_message:

page.evaluate(
    """() => {
      const list = document.querySelector('.lf-threads').getBoundingClientRect();
      const at = document.activeElement.getBoundingClientRect();
      return {listTop: list.top, listBottom: list.bottom, top: at.top,
              bottom: at.bottom, what: document.activeElement.className};
    }"""
)
{'listTop': 197, 'listBottom': 455, 'top': 619.55, 'bottom': 647.55,
 'what': 'lf-btn lf-thread-send lf-ui lf-icon-action lf-compose-submit'}

Run against this branch: test_render_navigation.py -k "submitting_a_reply_reveals or pressing_a_page_mark_stands or submit_shortcuts_activate" (6 passed); test_render_conversations.py and test_render_application_boundary.py (113 passed, 2 failed). Both failures — test_a_growing_reply_keeps_its_send_in_the_list and test_a_coined_class_cannot_reach_the_chromes_rules — reproduce with the four runtime files restored to 878780e, which is byte-identical to the base tip for all four, so neither is this branch's. Neither file is in the pull-request gate. npm run test:runtime could not run in this session (@happy-dom/global-registrator is not installed here), so CI's test job owns that half.

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

test_submitting_a_reply_reveals_its_new_message's oversized half does not separate this change from what it replaces. Restoring leaf.js, application.js, landing.js and replies.js to the merge base (131443d2) and running it, the long message reads top: 401.6, bottom: 772.5 against a band of 227–455 — its head clipped at the list's foot and its tail 317px below the scrollport — and both new assertions pass anyway, because top < bandBottom together with bottom > bandTop says no more than "overlaps the band somewhere". The short half does fail at base, so that one pins the behaviour; the long half is carried entirely by the in_threads_scrollport call on Send, which is about the focused control rather than about the reply. The reading that separates the two is the message's foot: 393.5 on this branch against 772.5 at base. Suggestion inline.

revealReplyMessage no longer reveals the message. It looks the message up by attempt and then drops it on the floor — the scroll target is landingTarget(held, control), so the landing is positioned from the composer and the reply is visible only because it sits directly above one. What attempt is left doing is an existence probe, and the true/false it returns has no reader. That is more than a stale name: with the message no longer the target, the probe is the only thing tying this landing to this gesture's reply, and when it misses the reveal is dropped with no retry and no fallback, where the base path called revealReplyEditor(input) unconditionally. Given the wait is still the document-wide whenDocumentPresented() rather than the presentation this gesture's own startPost returns, that is the case the probe now stands alone against, and it fails silently.

Dropping the probe and the attempt parameter leaves revealConversation(held, control, scrollBehavior(), "end"), which is revealReplyEditor with a block. Giving that existing dependency the block — revealReplyEditor: (control, behavior, block) => revealConversation(control.closest(…), control, behavior, block) in leaf.js, called as revealReplyEditor(control, scrollBehavior(), "end") — keeps one reveal route through the stack instead of threading a second capability through leaf.js and application.js, and drops the third copy of the ".lf-thread, .lf-conversation-thread, .lf-conversation" selector that the send handler now carries. landingRoom, extracted last round for the block decision this commit removed, goes back inline with it. Say the word and I will push that.

Readings

Both cases measured by replacing the assertions with a print, at the PR head and with the four runtime files restored to 131443d2, on this Linux runner at resized(page, 800, 520):

short case oversized case
base 131443d2 top 338.2, bottom 479.6 top 401.6, bottom 772.5, height 370.9
head 301b1c41 top 252.2, bottom 393.6 top 22.6, bottom 393.5, height 370.9

Band 227–455, room 228 throughout. At base the oversized case also passes expect(...send).to_be_focused() and fails only at in_threads_scrollport.

Test selection run at the head: test_render_navigation.py -k "submitting_a_reply_reveals or pressing_a_page_mark_stands" plus test_render_conversations.py::test_a_growing_reply_keeps_its_send_in_the_list — 6 passed, including the growth test that the Shift+Enter change repairs and all four landing parametrizations.

Comment thread tests/test_render_navigation.py Resolved
@max-sixty
max-sixty merged commit 869c225 into main Sep 23, 2026
7 checks passed
@max-sixty
max-sixty deleted the codex/reveal-sent-reply branch September 23, 2026 15:43
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