Skip to content

Return selected threads to the panel on Escape - #921

Merged
max-sixty merged 3 commits into
mainfrom
codex/thread-escape-panel
Sep 22, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/thread-escape-panel

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Escape from a selected thread now returns to whole-panel selection, the same destination as g T; the next Escape closes the panel after any narrowing is cleared. Reply boxes still return to their thread first. A thread title and its conversation share one selection level, and expansion and drafts are preserved.

Updates the keyboard contract and browser coverage, and records the direct page-to-thread t shortcut as a hierarchy exception to revisit.

Validated with live baseline/candidate keyboard journeys, focused Escape regressions, 1,239 everyday tests, 33 runtime tests, and pre-commit. The broader browser selection has one unrelated long-thread scroll-placement assertion that fails identically on the clean baseline and candidate.

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.

Walking to a thread with t and then pressing Escape loses the walk's place: the next t restarts at the first thread instead of continuing from the one just released. On this head, with three panel threads: g T, t, t stands on thread 2; Escape lands on .lf-threads; t lands on thread 1. The mechanism is stepThread in runtime/navigation.js, whose current is document.activeElement?.closest?.(".lf-thread") — null at the new floor, so clampedRow falls back to its entry index. That is right for g T, which is a fresh entry into the list, and wrong for a release, which is not.

keyboard/CLAUDE.md states the rule the other landing already honours — "The focus moves the browser's sequential focus navigation starting point there, so their next Tab carries on from what they are reading" — and the new panel floor has no equivalent, so the level the reader gains costs them their position in the list (Tab from .lf-threads leaves the list entirely, at the pinned filter control). Worth deciding whether the released card is the resume point for t and the starting point for Tab: it is the same t-versus-hierarchy question the new TODO defers, reached from the other side, and the PR's browser coverage never presses t or Tab after a release.

Separately, docs/how-it-works.html is the published description of this contract — /how-it-works/ on leaf.page — and its thread-navigation paragraph says "Escape leaves the box, collapses the conversation, then steps out through the panel", where this change explicitly preserves disclosure on the way out. That middle step was already inaccurate against main (Escape closed the panel from an open conversation), but this PR is what gives the sentence a middle step to be wrong about. I can push the one-sentence edit if you want it here.

The two changed test files are nightly, so the PR's test job does not select them. Both pass on this head (246 tests).

@max-sixty

Copy link
Copy Markdown
Owner Author

@leaf-agent I kept fresh traversal at the panel floor because the user's explicit requested destination was “same place as if we hit g T”, with only whole-panel selection or a selected thread. A remembered thread cursor after release would make those two arrivals behave differently. The page landing's sequential-focus rule is specifically about returning to the document; it does not give panel selection an implicit selected thread.

The added browser coverage releases thread 2 in a three-thread panel and compares that landing with closing and freshly opening through g T. Both routes reach the same floor, t selects the first thread, Shift+t selects the last, and Tab reaches the identical native control. It passes through real keypresses. The published thread-navigation paragraph now describes release to the panel while retaining expansion and drafts, and removes its obsolete arrow/Home/End title-navigation claims.

Please review the updated head with that explicit destination contract. No runtime navigation behavior was added in this refinement.

This was written by Codex on behalf of max-sixty

@leaf-agent

Copy link
Copy Markdown
Collaborator

Both points are settled on c46903a0; nothing outstanding from my review.

The panel floor owes no thread cursor. Your reading of the rule is the correct one, and I read it too narrowly. keyboard/CLAUDE.md#L101-L107 scopes the sequential-focus sentence to the case it names — "A landing in the document is the block the reader is reading" — while the step it defines for a standing is "at its floor", with no cursor attached. A remembered thread would make release and g T two floors wearing one name, which is the thing the ladder exists to prevent. Withdrawn.

The docs claim checks out. The removed arrow/Home/End sentence had no runtime behind it: no Arrow, Home, or End handling exists anywhere under skills/leaf/assets/runtime/conversation/ or in thread-panel.js, and a <summary> row is not natively arrow-navigable, so those keys did nothing before this PR either. The replacement paragraph matches what the tests on this head assert, including the g T equivalence.

I ran the new coverage against a real browser on this head — test_a_panel_thread_releases_to_the_same_floor_as_go_to_threads, plus the two neighbouring Escape cases, 3 passed. Worth remembering that tests/test_render_navigation.py is nightly, so the PR's own test job still does not select this case; the equivalence it pins is proved on main's nightly run rather than at the merge gate.

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

This commit updated one of the two tracked files that describe the Escape contract the PR replaces. notes/thread-navigation/README.md still states the old one, in the paragraph beginning "Use Enter/Space on a title": it names "arrows or Home/End between titles" — the same claim this commit correctly deleted from the published page as having no runtime behind it — and then "In the real Threads panel, Escape leaves an inner reply or narrowing interaction first, then closes the whole surface from either a title or conversation", which is the ladder this PR removes. Both sentences describe the shipped panel rather than the sketch, so a reader who opens the playground to work on thread navigation gets the superseded contract in the same breath as the current one.

Root CLAUDE.md puts that sentence inside the change rather than after it — "A sentence in a reference saying that something relies on the current shape is a consumer to update, never a reason to keep the shape or to carve an exception around it" — and its Repository map offers the other resolution, since the note records a landed decision ("Accordion is the chosen interaction"): "a note is never a second specification for shipped behavior." Correcting the two sentences and dropping the note are both complete answers; the note's spacing alternatives still have a live purpose, so correcting is the smaller one. I can push either if you'd like it here.

@max-sixty
max-sixty merged commit 4ffc2bd into main Sep 22, 2026
5 checks passed
@max-sixty
max-sixty deleted the codex/thread-escape-panel branch September 22, 2026 10:07
max-sixty pushed a commit that referenced this pull request Sep 22, 2026
…s, banner shelf, and gallery layout (#930)

`ci` on `main` is red: the [scheduled complete suite on
4ffc2bd](https://github.com/max-sixty/leaf/actions/runs/35718248873)
reported nineteen failures. Fourteen of those node ids, across twelve
nightly browser cases, read chrome shapes that three of the morning's
merges moved, and this updates those readings. A fifteenth case, which
that run did not reach, broke on the merge after it. The remaining five
are #917's, already open against #905's native `<details>`; nothing here
touches them, so `main` needs both to come back green. No runtime code
changes.

## What moved, and what each test reads now

**#921 (4ffc2bd) gave the thread panel two selection levels.** Escape
from a selected thread now returns to whole-panel selection, and the
press after that closes the panel. Nine node ids across four files
walked out of Threads in two presses and asserted the panel gone on the
second. Each now states the level it gained — `.lf-threads` holds the
selection — before the press that closes the panel, which is the shape
#921 gave the tests it could see in `test_render_navigation.py`. The
intermediate `expect` is also the arrangement: it settles the release
before the next Escape rather than firing two presses into one turn.

**#918 (a45144d) made the thread lifecycle filters a `wa-radio`
group.** Three tests read the standing choice off `aria-pressed`, which
a radio does not wear; they now use `to_be_checked()`, the reading the
everyday-gate tests #918 updated already use. The same change also made
the group exclusive, so re-pressing the standing member no longer widens
the list —
`test_an_ok_on_the_agents_latest_reply_takes_the_thread_out_of_waiting`
pressed "On you" a second time to get every thread back and now chooses
the group's open member instead. That second fault was behind the first:
the test stops at the `aria-pressed` read, so the run never reached it.

**#923 (c6c9cb3) added touch-only selection controls to the banner shelf
and renamed the `s` command.** `commentSelection` and `cancelSelection`
rank after `threads`, and `select-element` is `alwaysFolded`, so two
tests counting the shelf's markup — the last child of
`.lf-banner-actions`, the number of children in `.lf-banner-menu` — were
reading inventory where they meant what the reader meets. Both now read
what stands: the last *visible* control in the row, and, for the door,
what is behind it once it is opened. A third read the reference's
wording for `target.chooser.open`, a string
`test_render_semantic_selection.py` also reads; this reads the reference
row by its command id instead, so the words are stated in one place
rather than two. Both cases are nightly, so nothing holds that string
before `main` either way — #923 updated the one and not the other, which
is the whole fault.

**#924 (ff34b91) grew the feature gallery between a case's scroll
target and its subject.**
`test_g_hints_reach_a_late_visible_action_only_location` scrolled to
`#bg-quoted-and-visual` and asked for the go-to chip belonging to
`#bg-shot`'s margin entry; the new `#bg-live-practice` section sits
between the two, so that scroll now leaves the entry about 1,200px below
the scrollport and the hint layer is right not to draw a chip for it.
The case reached that state because its guard was `to_be_visible`, which
says a control is laid out rather than that a reader can see it. It now
scrolls to the location's own anchor and reads `to_be_in_viewport`, so
the premise it states is the one the hint layer acts on. Checked alone
at both commits: green on 4ffc2bd, red on `ff34b919`.

## Why these are updates rather than a fix under them

Each failure is a nightly test hand-reading a shape the runtime or the
corpus owns, changed by a pull request whose own gate could not reach
it: `ci` runs the complete suite on `main` and on the schedule, never on
a pull request, because it holds a runner for over an hour on a shared
pool — a trade-off `ci.yaml` states, with `main`'s own run and
`tend-ci-fix` as the designed repair step. So the level above these
tests is working as intended, and the durable improvement available
inside them is to read a declaration instead of an incidental shape.
Every fault here but the Escape depth moves that way: a radio's
checked-ness and its exclusivity, a command id, and — twice — the run
that stands rather than the shelf's markup. The Escape-depth nine have
nothing more declarative to read — the press count *is* the behaviour —
and each states the unwind because the assertion around it is about
where focus lands and what stays open, so they keep their own narration.
The gallery case is the same move at the arrangement end: it now states
the premise the hint layer actually reads, so corpus content growing
under it fails loudly rather than quietly changing what the case is
about. That leaves the seam #917 named for the thread card exactly as
reachable as it found it: the panel's chrome has no single place a
change to it can find its readers.

## Verification

All fourteen failed in the scheduled run on 4ffc2bd, and each passes on
this branch under `uv run pytest --run-nightly -n0` on this CI host. The
fifteenth was found by running the six changed files whole:
`test_render_aim.py`, `test_render_anchors.py`,
`test_render_controls.py`, `test_render_margin.py`,
`test_render_navigation.py` and `test_render_reactions.py` are 574 cases
under `--run-nightly -n2`, and the only two failures were
`test_g_hints_reach_a_late_visible_action_only_location`, now fixed
here, and `test_a_thread_at_rest_shows_only_the_marks_that_stand_in_it`,
which is #917's. `pre-commit` passes on the changed files.

Besides the gallery case above, two cases have their arrangement changed
rather than only their assertions, so those three are the ones worth a
second look:
`test_the_responsive_action_row_keeps_primary_actions_in_reach` opens
the overflow door to read what stands behind it and closes it again,
because the shelf freezes its partition while the door is open and the
test registers another control straight after; and
`test_covering_threads_keeps_the_reader_and_their_work_inside` reads the
document's scroll position after the thread releases to the panel rather
than before, the release being the press that no longer closes the
sheet.

A pull request runs the everyday gate, which reaches none of these
files, so `ci` here says nothing about them; `main`'s own complete suite
on the merge is the first run that reads them.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 1, 2026
On the Threads list, focus now always stands on the thread the list
shows open, so the ring the user sees, the box `c` writes in, and the
keys the line offers all name the same thread.

## Why

Two rules were written while the list showed only titles: `c` on the
list wrote on the page (Aug 25), and Escape from a thread returned to a
"whole panel" stop that `g T` also landed on (#921). Then #999 kept one
thread open whenever the list shows any, and #1480 made that card fill
the list. The list's own focus ring therefore outlined the open card
exactly, while `c` from there wrote in the page box and Escape, `r`,
Enter and the shading treated the stop as no thread at all. A user saw a
selected thread and `c` went somewhere else.

## What changes for the user

- Focus given to the list (`g T`, Escape from the panel's general box, a
fold of the focused card) goes on to the open thread's title. There `c`
writes its reply, `r` resolves, and the line offers `r resolve` and `esc
close threads`. The list keeps focus itself only while it shows no
thread.
- Focus on a collapsed title opens its thread, however it arrives, so
focus, selection and the open card never part. A pointer press still
opens on its click.
- Escape from a panel thread is the panel's own rungs: clear the
narrowing, then close. Leaving a reply takes two Escapes rather than
three.
- In a narrow window, where the panel covers the page, `c` and `e` on a
panel thread work; both were dead there. `comment.create` and
`reaction.open` now declare `covering`, replacing the panel's own copy
of `c`, which knew only the page box.
- The expanded shortcut bar gives back the rows that fit once a wider
row is trimmed.

## Where to look

- `runtime/thread/thread-list-view.js`: the list passes its focus to the
open title, and a title taking focus becomes the choice.
- `runtime/keyboard/page.js`: a panel thread has no let-go floor of its
own.
- `runtime/user-intent.js`: focus a container passed on, before any
newer input, counts as displaced, so a resolve's landing still carries
the user to the next thread.
- `runtime/thread/thread-list.js`: the place hold is taken when a closed
title's focus opens it.
- `runtime/composing/surface.js`, `runtime/reactions.js`,
`runtime/thread/panel.js`: one `c` row for page and panel.
- `runtime/keyboard/AGENTS.md`: the Threads selection contract.

## Tests

About 60 browser tests walked through the old whole-panel stop; they now
assert where the user lands. Renamed where the name stated the old stop:
`test_go_to_threads_lands_on_the_open_thread_from_a_page_thread`,
`test_a_panel_thread_closes_with_the_panel_as_go_to_threads_does`,
`test_a_note_walked_on_inside_the_panel_is_left_by_the_panel_holding_it`,
`test_the_line_offers_the_thread_g_t_lands_on_its_own_keys`,
`test_an_empty_thread_list_wears_its_ring_whole`. New:
`test_the_threads_list_hands_focus_to_the_thread_it_shows_open` (1600
and 420px) and `test_a_title_taking_focus_opens_its_thread`. Tab walks
down the list now cross each thread's controls, since each title Tab
reaches opens, and a reader who stood on a later thread by scripted
focus walks there with `t`.

The 26 browser files touching Threads pass apart from tests that fail
the same way on main and load flakes whose rate matches main's in paired
runs.

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

---------

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