Skip to content

Land every Send on its thread, never in the box it sent from - #6472

Merged
max-sixty merged 3 commits into
mainfrom
first-comment-focus-research
Nov 19, 2026
Merged

max-sixty merged 3 commits into
mainfrom
first-comment-focus-research

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

After a Send, keyboard focus now leaves the text box for the thread the message went into: a reply from a margin card, a seat or the panel's field, a page comment from the panel's field, and a rewrite's Save. From the thread, Escape closes a card, t and m walk, r resolves, and c or Enter opens the box for a follow-up. This reverts #5039's experiment of keeping the caret in a reply's box.

Before After
Reply from a margin card
Page comment from the panel's field

Why: max-sixty proposed it, and his observation logs back it. Of 1,297 Sends from his keyboard (14 October to 18 November), taking the first key within 4 s: with the caret kept in the box, 58 of 309 (19%) were a walk key typed into the box as a letter, 24% for replies alone; with focus on the thread, words typed on ran as keys once in 439.

Where to look: landSent (thread/landing.js) is now the one owner of where a send leaves the user, by the same way out as Escape. A refused send returns an untouched user to its box from one place, sendMessage in drafts.js, replacing the passage composer's and the panel's own copies. user-intent.js now reads containment across shadow trees, so that return also works in a seat a widget draws in its shadow root, such as lf-diff's. A package reader's message parts declare their thread's reply box, so c from one reaches it. A Send pressed on its control now puts the user in the box only where the send left them where they were (composing/input.js), as in a widget's box that stays to take more.

Calls to confirm:

  • A rewrite's Save also lands on the thread. Max asked only about sends, so this one is Claude's call. Over 20 rewrite Saves in the logs, the first key was Escape 5 times, ↑ 3 times, and t typed into the box twice. Escape and Discard still return to the reply box.
  • A card above its passage now shows news at once with the user on its thread.

Left as on main:

  • A refused rewrite keeps its words as an "unsaved edit" on the message.
  • In the gallery's Feed reader, c on a thread with no drawn reply box starts a new comment.

Reviewed by a subagent, Codex and leaf-agent; their findings are fixed here. Tests: the changed assertions are listed in the commit message. Also ran 190 affected browser and journey cases, the hold matrix in Chromium and Firefox, pnpm run test:runtime, and pnpm run check. test_an_open_card_takes_news_without_moving_its_controls fails the same way on main, and test_a_reply_sent_after_progress_stands_below_it is intermittent on main too.

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

After a Send, keyboard focus now leaves the box for the thread the message
went into, whichever surface and whichever control sent it: a reply in a
margin card, in a seat, or in the floating panel's field, and a page comment
sent from the panel's field, and a rewrite's Save. A passage's first comment
and a seat's first comment already did. The user stands on the card or seat,
ringed, or on the panel's thread view, which wears no ring by the panel's
earlier choice. From there Escape closes a card, `t`, `m`, `j` and `d` walk,
`r` resolves, and `c` or Enter opens the box again for a follow-up.

## Why

#5039 (d000889, 1 November) kept the caret in a reply's box after Send as
an experiment for consistency with the panel's field, which had always kept
it. Max's observation logs, 14 October to 18 November, 1,297 Sends from his
keyboard, taking the first key within 4 s of each:

- Focus left in the box (309 Sends): 239 Escape, 58 (19%) a walk key such as
  `t` or `m` typed into the box as a letter, 11 follow-up words.
- Focus on the thread or page (439): 270 keys ran as meant, 129 Escape, and
  words typed on ran as keys once.
- Replies alone: 52 of 218 (24%) were the stray letter, with no week-to-week
  fading.

Over 20 rewrite Saves (`event_post` kind `edit`), each of which left the
caret in the reply box, the first key within 4 s was Escape out of the box
(`text.leave`) 5 times, ↑ to edit again 3 times, and a `t` typed into the box
as a letter twice (16 and 17 November); 5 began with a click.

Max proposed landing on the thread on 18 November; these logs support it.
The first comments whose focus went into `leaf-text[name="reply"]` right
after Send were the panel field's page comments, which opened their thread
with the caret in its reply in the field, not a narrow window opening a
passage's thread in the panel. Surveyed over the Firefox sessions in the
state home's and ~/.tmp's page logs, 289 such first comments, all at a
window wide enough for the rail, every one landing in the panel's reply
(accessible name "Reply to …"), 263 sent from the panel's page field and 26
from a box whose label wasn't logged. A narrow window's passage comment
already landed on the panel's view (probed, main and this change).

## One owner

`landSent` (thread/landing.js) hands the user back from a box, or from the
thread a send started, exactly as Escape's `text.leave` does: to the thread
the box belongs to, whole where it is drawn in pieces, or to the route a
widget control supplied. `returnToThread` is now internal to it. Every send
calls it: a reply view's send (thread/replies.js), for a card, a seat, a
package's reply part and the panel's field alike; the panel field's page
comment, which opens its thread with `part: "thread"` (floating-panel.js,
`open` → `focusView`); a rewrite's Save (message-edit.js, `saved`), whether
it saves words or finds none changed; and the passage and seat first
comments, which already did.

A rewrite's Save used to hand the user to the thread's reply box while that
box was in view, the rung its ↑ came from, and in a resolved thread the save
reopens, waited for the box to draw and landed there. Now it lands on the
thread. Escape and Discard still return to the reply box: they take back the
↑ that opened the rewrite, which Max chose ("one Escape undoes the ↑"). ↑ on
the thread does nothing; `c` then ↑ opens the next rewrite (probed).

A package reader's parts drawn on their own, as the gallery workspace's Feed
draws every thread's messages and the selected thread's reply box, have no
element around them, and a package has no way to declare one. So Send and
Escape land on a ring around the reply part, and Save on the message's own
part. A message part now declares its thread's reply box as its reply
(primary-reader.js), so `c` or Enter from it writes in that box, as from a
card. Before, a message part named no reply, so `c` after Save there opened a
new comment (found by Codex in review).

## What else changed

- A refused send returns the user who has done nothing since to its box from
  one home, drafts.js `sendMessage` (browser/AGENTS.md, "A refused or undone
  gesture gives back what it took"). Each sender passes only its way back in
  (`back`): the reply's row, in whichever view holds it; a passage's composer
  reopened on its words; the panel's field standing for the page again. The
  passage composer's and the panel's own copies of "untouched since Send, so
  come back" go. Replies gain it: before, the caret never left the box, so
  nothing had to bring it back. Only whether the user acted since counts, as
  the passage composer's copy had it; the panel's copy also asked that focus
  stay in the panel.
- `sendLanding` (thread/reply-landing.js) keeps the box's foot through the
  send as before; its step now reads where the send left the user from focus
  rather than a passed `currentLocation`. It predates #5039 and served the
  thread landing then too.
- In a card held by its foot (above its passage), the answer to a send would
  have waited behind "1 new": the rule showed news at once only with the user
  in the reply row. A user on the thread now stands at its reply box, unless a
  click left the caret in its words, by the rule `holdUserPlace` already
  keeps (user-place.js, `standingAt`, which shares `caretWords` with
  `caretPlace`). So a keyboard user who reached such a card's thread by `t`,
  Escape or Page Map now sees news draw at once, the card rising from its
  reply box, where it used to wait; one who clicked into a message's words
  still waits. Cards held by their top are unchanged.
- The text naming the send's caret goes: the session rule in replies.js
  ("a caret a send leaves begins nothing"), `mayReplyTo` (thread/focus.js),
  `endNewsMoves` and the card header (thread-preview.js), the `save` hook
  comment, keyboard/AGENTS.md's Escape list, and module-annotations.md's
  `sent()` (a send now leaves the user on the thread, and `sent()` runs in
  place of Leaf's landing of the turn). The mechanisms those named still
  serve the empty box a click's opening leaves, so they stay.
- Whether the user has done anything since a gesture (user-intent.js) reads
  containment across shadow trees, as focus.js's `currentLocationIn` does. A
  refused reply in a seat a widget draws in its own shadow root, such as
  `lf-diff`'s, moved the user onto the thread inside that root, which
  `documentElement.contains` doesn't reach, so the refusal left them there.
- The feature gallery's page comment scenario says where Send leaves the user.

## Tests (behavior changed)

Assertions that expected the kept caret now expect the thread:
`test_a_pressed_send_leaves_the_user_where_enter_does` (every surface lands
on its thread, and `c` writes the follow-up),
`test_a_pointer_send_finishes_the_words_an_input_method_holds`,
`test_a_seat_send_in_a_bounded_block_moves_the_block_and_not_the_page`,
`test_a_send_keeps_the_edge_its_card_holds`,
`test_a_held_reply_send_preserves_a_later_scroll`,
`test_one_field_starts_a_thread_takes_its_reply_and_settles_it`,
`test_a_walk_says_its_position_in_the_panel`,
`test_submitting_a_reply_reveals_its_new_message`,
`test_the_field_s_end_offers_next_on_me_while_on_me_lists_anything` (the
key-less press is now checked after `c` takes the user back into the box),
and `test_margin_card_holds_its_top_while_read_and_its_reply_while_written`.

Rewritten onto the route that still leaves an empty box with the caret, a
click's opening: `test_news_under_a_card_s_words_waits_once_the_user_begins_in_its_reply_box`
and `test_typing_in_the_box_an_opening_left_keeps_its_reply_through_settlement`
(fails with the `save` hook's adopt removed).
`test_a_card_above_its_target_holds_news_it_would_grow_up_for` now shows the
step at once with the user on the thread and holds it with the user on a
message's words (fails without the caret rule).
The runtime test `delayed work taken for the page counts a move inside a
widget's shadow tree as its own` fails without the shadow-tree reading.
`test_reply_admission_finishes_or_restores_its_native_session` asserts the
thread after Send and the box after a refusal. With `sendMessage`'s return
disabled, it fails, and so do
`test_a_refused_selection_comment_reopens_its_words_while_the_send_owns_intent`
and `test_a_refused_page_comment_hands_its_words_back_to_the_field`.
`test_a_rewrite_is_the_reply_box_where_the_words_stood` (each surface's
thread after Save, and `c` from there into the reply box, which failed in
Feed before message parts declared it; Escape still returns to the box),
`test_a_rewrite_saved_in_a_resolved_thread_goes_with_its_thread` (the panel's
view, where the box used to be its "user's decision") and
`test_the_field_is_the_thread_s_reply_box` expect the thread after a
rewrite's Save.
`test_a_send_into_a_full_thread_view_starts_where_the_view_stood` finishes
only the motions still running: the landing's reading cancels the first, and
finishing a cancelled one moved the panel 21px under the shift watch, though
the motion sampled per frame matches main's. The hold matrix gains the place
a send leaves the user, `{card,panel}-thread-{told,asked}`: the panel's holds,
and the card's grows down past the box by the choice `card-caret` already
records. `send_reply` clicks back into the box for each reply.

Ran: 133 browser and journey cases by node id, among them every affected
test, tests/browser/drafts/test_sending.py, tests/browser/threads/test_rewrites.py
and tests/journeys/threads/test_rewrites.py whole; the hold matrix's caret and
thread places in Chromium and Firefox; `pnpm run check`; and pre-commit.
`test_an_open_card_takes_news_without_moving_its_controls` fails the same way
on main. `test_a_reply_sent_after_progress_stands_below_it` fails its shift
watch intermittently with the same finding on main ("the panel's outlet moved
without input by (0, -108)px"): 3 of 10 runs on main, 7 of 13 here, on a
loaded machine; it passed in the final run. After review: `pnpm run
test:runtime` (1,053), and 57 refusal, send, rewrite and primary-reader cases.

@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_send_follows_a_reply_composition_whose_diff_outlet_disappears fails on this head and passes on main (5d9c213), reproduced twice each way: unchanged write: data-lf-floating-editor on html. A keyboard press on Send still puts the user in the box before submitting (pressed in composing/input.js), and landSent now takes them straight out again. In a margin card, a [data-lf-plane] leaf-text, readFloatingEditor sets the root's attribute on the first move and removes it on the second, in the same task. That write restyles the root, whose :has() matches against the whole document. This is the only failure among the 125 cases in tests/browser/drafts/test_reply_sessions.py, tests/browser/margin/test_card_reply.py and tests/browser/threads/test_composing.py.

Comment thread browser/runtime/composing/input.js Resolved
A keyboard press on a box's Send control, or a pointer press while the user
was elsewhere, used to put the user in the box before the send. Now that
every message's send lands on its thread, that hop went into the box and
straight out again in one task. In a margin card it wrote and removed the
root's `data-lf-floating-editor` mark, which restyles the root, and
`test_send_follows_a_reply_composition_whose_diff_outlet_disappears`
failed its write watch ("unchanged write: data-lf-floating-editor on html").
The automated review on #6472 found it.

The press now sends first and puts the user in the box only where the send
left them where they were: a widget's box that stays to take more, such as
an options group's add field, or a press that sent nothing.
`test_a_keyboard_press_on_add_leaves_the_user_in_the_field` covers the
first and fails without the hop.

Ran: the two tests above; the pressed-send and input-method cases; 38
send, press, refusal and submit cases in test_reply_sessions.py,
test_card_reply.py and test_composing.py; `pnpm run test:runtime`;
`check:browser`; pre-commit.
@max-sixty
max-sixty merged commit d8e0f44 into main Nov 19, 2026
7 checks passed
@max-sixty
max-sixty deleted the first-comment-focus-research branch November 19, 2026 05:23
leaf-agent added a commit that referenced this pull request Nov 19, 2026
…ening as a step (#6526)

Both cases of
`test_a_website_turn_posts_its_answer_when_the_move_is_settled_first`
(`tests/journeys/test_website_server.py`) failed on main because two
merged changes moved, on purpose, the behavior the test asserted. The
test now expects what each change meant to do. No product code changes.

- **Focus after Send (#6472).** A Send now leaves the user on the thread
it went into, not in the box it came from (`landSent`,
`thread/landing.js`). The test expected the panel's reply box to be
focused. It now expects the thread's view to be focused, the same change
#6472 made to its sibling tests in `test_sending.py` and
`test_card_reply.py`. The user then writes on in the reply through
`write`, which focuses the box, so the rest of the journey is unchanged.
- **The opening as a step (#6508).** The hosted turn posts its opening
as a progress message (`AppServerReplyStream.open`,
`src/leaf/codex.py`). Since #6508, the transcript draws a progress step
only as the thread's working face (`.lf-thread-working`) and never as an
`.lf-msg`. Once the focus assertion was fixed, this test stopped at its
next check, which looked for the opening in
`.lf-msg[data-lf-author=agent]`. The served state still carries the step
with no `completed_by` while the turn runs, so the step stands as
intended. The test now reads it from the face, as #6508's own updates to
`tests/journeys/threads/test_agent_replies.py` do.

The issue's bisect named only #6472, because the focus assertion failed
first. With that assertion fixed, `git bisect run` over `[here]` from
`d8e0f446f` (#6472) to `dd38dcb16` names `f7f9e2170` (#6508) for the
second failure.

Verification: both cases fail on `origin/main` (`78d3c5758`) without
this change and pass with it. `ruff` passes. No other assertion in the
test changed.

Closes #6518 — 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.

2 participants