Skip to content

Keep message submission out of the next text box - #961

Merged
max-sixty merged 2 commits into
mainfrom
codex/keep-focus-after-message-send
Sep 23, 2026
Merged

max-sixty merged 2 commits into
mainfrom
codex/keep-focus-after-message-send

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Sending a message now leaves focus where the submission gesture placed it: on Send after a button press, or in the same editor after the keyboard shortcut. When an anchored comment creates a thread, Leaf focuses the sent thread itself without moving into its reply field. This also removes the obsolete shared typing handoff.

Verified with the two live preview versions, focused mouse and keyboard browser cases, the runtime tests, pre-commit, and the everyday suite (1,302 passed). The complete conversation and anchor browser files passed 192 cases; two existing diff receipt selector cases failed identically on the clean base commit. The anchored-comment focus case passed again after the review fix.

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 anchored comment now leaves document.activeElement on <body> for two of its three destinations. settleComposer tears the composer down and letGo() releases focus to the page, so the send's landing is whatever the reveal takes: the widget-local route lands the reader through focusSurface(id, { focus: "thread" }), but the margin card is opened with no onPositioned and the panel route is passed focus: false, so neither picks up the focus the destroyed composer gave up.

Measured by reading document.activeElement immediately after the send in test_an_ambiguous_revised_passage_detaches_until_the_agent_moves_it: TEXTAREA.lf-ui on the merge base (eb409e7), BODY at this head, and BODY again with Threads open. A keyboard or screen-reader reader who sends a comment is put back at the top of the document, with the new card on screen but outside the tab order they were in and unannounced.

"Don't move into the next text box" and "land nowhere" are separable, and this diff already carries the primitive for the first without the second — focus: "thread" on the widget route, pinned by the new .lf-conversation-thread assertion in test_a_manifest_diff_can_comment_on_one_unloaded_file. The deleted mayLandTyping said its rule once "for the three boxes a send can land in, because it is one fact about a send landing"; giving the other two routes that same thread landing keeps one answer instead of three.

The inline suggestion does that. With it applied, test_render_conversations.py and test_render_anchors.py give 192 passed — the only failures are the two test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline receipt cases, which fail identically on eb409e7, matching what the PR description reports. The margin route's .lf-margin-preview textarea assertion stays green, since focusing the thread element is still not the reply box.

@max-sixty
max-sixty merged commit a302534 into main Sep 23, 2026
5 checks passed
@max-sixty
max-sixty deleted the codex/keep-focus-after-message-send branch September 23, 2026 00:04
max-sixty added a commit that referenced this pull request Sep 27, 2026
…1303)

An audit of focus and scroll across every thread surface — the Threads
panel, the margin card, page seats and threads drawn in widgets — from
sending a message down to typing a newline. Three browser audits drove
each interaction at 1200×900 and 800×520 and measured positions against
each scroller's landing band; this fixes what they found and adds a
failing-first regression test for each.

**Sending and typing**
- The margin card pins its reply row to the transcript's foot, so every
landing aimed at that row (Reply, a send, each keystroke) moved the
transcript by 5px: a sent turn stayed under the row, and typing crept a
reader partway up toward the end. A pinned row now lands the thread's
end, and growing it moves the transcript by what the row newly covers.
- A seat that gives its box up to the thread its first message starts
dropped focus to the body, so the next keys ran page commands; the user
now goes on in that thread's reply. A seat send or a paste near the
window's foot left the new turn or Send below the fold.
- The send landing and the growth follow are one step each in the new
`thread/reply-landing.js`, and `wireInput` runs the growth follow for
every box a thread or seat holds, rather than for reply boxes alone.
- The landing's climb now crosses shadow roots, so a diff thread taller
than the window no longer reads as one that fits.

**Turns arriving**
- Following an agent turn in the panel now lands the thread's end, reply
box included, so the box the user is typing in stays at the list's foot
with the turn's newest words just above it, however tall the turn grows.
- A turn arriving above a page box the user is typing in holds that box
still, unless the user has scrolled away from it.
- While a reply is being drafted, the margin card keeps the side it
opened on and its reply box's foot: a newline, an arriving turn, a send
or a pressed Send no longer flips the card or moves the editor
(`thread-card-geometry.js` states the held-foot contract).

**Arriving, leaving and settling**
- A thread sent from the panel's general box landed under a smooth
scroll that the list's place hold then cancelled; landings now wait for
the render in flight.
- Resolving a long panel thread focused the next title while the fold
still held its room, leaving the title above the list; the landing now
waits for the fold, and yields to a gesture made during it.
- Enter on an open panel title now writes a reply, so Escape then Enter
round-trips. Escape out of a reply in a thread taller than the list
keeps the list where it was.
- `t` onto a thread taller than the list shows it from its title instead
of leaving the title at the list's foot.
- A pressed Resolve on a long page thread jumped the page ~700px to the
thread's head, and resolving or reopening a diff thread by key left it
above the window; page threads now land around the user's focus as they
settle, and a thread too tall to show that is already on screen stays
put.

**Tests that moved**: the chrome-contract follow tests assert the
thread's end at the list's foot; margin tests that assumed entering the
reply left the transcript partway up now scroll back up first; the
drafting-by-foot test holds Send still after its press.

**Left open**
- Focus stays on Send after a click (per #961), so further typing goes
nowhere until the user returns to the box.
- A "Send & pause" seat keeps its own box after a send, so a follow-up
there starts a second thread rather than a reply.
- A diff data refresh that moves the thread being replied to out of the
diff drops the user's focus; the draft survives.
- A margin card the user is only reading still re-chooses its side when
a turn arrives, and can flip at short windows.

> _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.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 27, 2026
…e page, and widen samples to their data-width (#1364)

Three follow-ups to #1303: two of the open focus/scroll gaps it left,
and one layout bug found while presenting them.

## A pressed Send leaves the user in the box

Clicking a box's Send left focus on the button, so the next letters the
user typed ran page keys (an "ok" hid every mark and closed the margin
card) instead of reaching the box. Pressing Send is now the send key
pressed from the box, on every surface `wireInput` wires (margin card,
thread panel, general box, seat Send and Send & pause, widget comment
boxes):

- A pointer press never takes focus (`mousedown` default prevented), so
the box keeps it throughout.
- A keyboard press on a focused Send returns the user to the box before
submitting, so what the send does next starts from where Enter starts
it. A seat that gives its box up still hands the user to the new
thread's reply, and a first anchored comment still lands on the thread
it starts (#961).
- While an input method holds unfinished words, the press takes focus as
before, since leaving the box is what finishes them; otherwise the
unfinished words went out and the input method's commit wrote them back
into the emptied box.

`sendLanding` (thread/reply-landing.js) no longer takes the button: its
"focus is on the box or its Send" guard is always true now, and box.js's
Send vs Send & pause branch is gone.

Tests: `test_a_pressed_send_leaves_the_user_in_the_box` (six surfaces ×
pointer/keyboard, the composer by pointer only since its Tab walks
response options), 8 of whose cases fail on main;
`test_a_pointer_send_finishes_the_words_an_input_method_holds`, which
drives a composition through CDP and fails without the composition
guard. Tests that expected Send focused after a click now expect the
box.

## Bounded blocks are reading regions

A block bounded with `data-bound`/`x-bound` scrolls on its own but
registered no reading region, so every "which box scrolls this node"
question answered with the page. A talk seat's first send in a bounded
`lf-command` scrolled the page 117px and the second carried the block
off screen; thread travel and the Ask walk into a bounded log moved the
page.

`bounds.js` now holds every `[data-lf-bound]` block as a region while it
stands in the page, whoever painted the bound (delivery for page content
since #1325, `markDeclared` for message markup). A named block in the
page's own document is `lf-region:<id>:bound`, so a revision finds its
place again; an anonymous one, or one in a message's frozen markup,
keeps one id for its life in this document.

- **One arrival watch.** `arrivals.js` (`watchArrivals(selector,
attributes, { arrive, leave })`, `watchArrivalsIn(root)`) is now the one
owner of "keep a paint on elements matching a declaration while they
stand in the document or an enrolled shadow root". External links, which
had their own document observer, and bounds both use it; shadow-stage.js
enrolls each root it fills. The watch starts at boot, before
presentation, so an `end` log opens at its end rather than jumping there
after.
- `scrollersOf(node)` (reading-regions.js) walks the boxes scrolling a
node, innermost first; `holdBox` gives the move to the block and hands
what it cannot take to the page. Anchor travel's `scrollingBoxFor` uses
the same walk. Whether the held control is on screen at all is
geometry.js's answer, so a box in a block the page has scrolled away
doesn't pull the page back when an agent turn arrives.
- **One "seen" reading.** geometry.js's new `seenRect` is what of an
item the user sees: `shownRect` cut at top and foot by the room the
banner and shortcut bar leave (`shownWindow`), its sides left to the
layout viewport so a pinch zoom doesn't count as a clip. Landing,
`bringForward`, read acknowledgement (`thread/read.js`) and the thread
card's "being read" check all ask it; `read.js` had counted lines under
the banner or bar as read, and no longer does.
- Travel and the Ask walk centre the destination in the block, then
scroll the page only as far as needed.
- Continuity records a following `end` block's place as its end
(`followingItsEnd`), so a revision keeps it following; readings of
regions no longer standing are dropped. carry.js restores a region
body's sideways offset and leaves the vertical one to continuity.
- Margin rows for a target in a bounded block in the column's flow keep
the rail (`railBeside`), their lane clipped to the block; rows in a
workspace's panes still pin, as #1333 has it.
- With focus inside a bounded block, `d`/`u` page the block; thread
context takes the nearest labelled region. The glossary now defines a
bounded block as a reading region.

Tests in test_render_threads.py, test_render_navigation.py,
test_render_margin.py and test_render_widgets.py cover the seat send
(`end` and `start`), an arriving agent turn over a full, an unfilled,
and a scrolled-away block, travel into named and anonymous logs, the Ask
walk, margin rows beside the column and in side-by-side panes, `d`/`u`
in a log, a bounded log in an agent reply, and a revision over a
following log. Each fails with the arrival watch disabled, and all but
the revision case fail on main.

## A sample fills the room its `data-width` asks for

`lf-sample` is `display: table; width: 100%`, and a table box does not
fill the negative margins the kernel's breakout gives it, so
`data-width="wide"`/`"available"` shifted a sample left without widening
it. The package theme now gives a sample its own breakout width,
`calc(100% + var(--lf-surplus))`, under the same painted selector as the
kernel's `table[data-lf-space]` rule. It is scoped to the sample's own
breakout because `--lf-surplus` inherits: unscoped, a plain sample
inside a wide section came out 1080px in a 720px item.
`test_a_sample_fills_the_room_its_authored_width_takes`
(test_render_pages.py) fails without the rule.

## Checks

`uv run pytest tests` (1426 passed) and `npm run test:runtime` (151
passed) locally. Independent reviews ran on each of the three changes
and on each repair; the browser files these touch have pre-existing
failures on main (the `?t=` URL assertions after #1337, the margin
`picked_up` cases,
`test_a_coined_class_cannot_reach_the_chromes_rules`), each reproduced
on the merge base.

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