Repository navigation
Let Android's back gesture take the step Escape would, keeping unsent words - #3856
Conversation
On a phone, the back gesture closed nothing Leaf opened: a finger that opened the page menu, the Threads view, Draw mode or a selection had only the panel's ✕ or a tap elsewhere to leave it, and back left the page instead. The platform turns the back gesture into a close request (HTML, "Close requests and close watchers"; CloseWatcher ships in Chrome 126 and Firefox 149, desktop and Android). `keyboard/close-requests.js` holds one CloseWatcher while Escape has a step to take, read in the repaint frame beside the touch controls, and its close runs that step through the dispatcher (`pressEscape`). With nothing to take the page holds none, so back goes back in history as before. A real Escape keydown the dispatcher answers is canceled, which the spec says ends the close request before any watcher hears it, so a key still takes one step. Native modals and popovers keep their own watchers and the browser's order. Safari lacks CloseWatcher and keeps today's behaviour. Evidence, `uv run leaf-dev probe release-notes --touch --viewport 390x844 --journey .tmp/back-journey.py`, which taps the menu, sends a back close request, taps Threads and sends two more: - before: menu stayed open after back; the Threads view stayed open after two backs. - after: the first back closed the menu, the second the Threads view. Tests: `test_a_back_gesture_takes_the_step_escape_would` (390x844, touch) and `test_escape_takes_one_step_where_a_back_gesture_would_take_it` (a real Escape closes the view and leaves the selection beside it for the next back) in tests/browser/navigation/test_key_scopes.py. Both fail with the painter unwired. A test-held CloseWatcher stands in for the browser's own back and fires only once the page holds none. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # dist/kernel/kernel.json # dist/kernel/leaf.js # dist/kernel/runtime/bundle-layer-client.js
Back takes the step Escape would, and in an open lf-draft editor or a message rewrite that step is Discard, which nothing undoes. On Android the first back hides the keyboard and the next discards, so a stray edge swipe lost the edit. A command row now declares `discards`: whether its run would throw away words the user wrote and hasn't sent (keyboard/bindings.js). lf-draft's Discard says so while the editor's words differ from the saved ones, and a rewrite's Escape while its words differ from the message's. The close request path (close-requests.js) takes every other step as before, but declines one that discards: the editor stays open with its words, a notice says "The unsent words are kept", and the watcher still stands, so the gesture doesn't leave the page either. Escape and the Discard control still discard. An unchanged editor closes on back as on Escape. Back taking no step is a call Max may reverse. Rejected: back saving the words (it sends a turn the user didn't ask for), and back closing the editor while the store keeps the words (a closed box holding words it gives no sign of, which lf-draft and message-edit.js rejected for Escape). The rule is stated where it is owned: the row field in bindings.js, the close path's decision in close-requests.js's header, the Escape section of keyboard/AGENTS.md, and package authors' row reference in skills/leaf/references/module-input.md. Test: test_a_back_gesture_never_throws_away_unsent_words[draft|rewrite] in tests/browser/navigation/test_key_scopes.py. On the branch before this commit both fail at the changed editor: the rewrite announces "Edit discarded; the message is as it was" and the harness reports "typed words left the screen without a key or press". Both pass now, with the unchanged-editor back closing it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
Back can skip a Leaf step inside a native modal when the page already holds a watcher. The Boolean-only reuse check keeps the older watcher when a dialog opens with an inner Escape command, so the dialog's newer native watcher receives the close request first. This bypasses both the dispatcher and the discards check. The result depends on what was open before the dialog, rather than the current Escape step.
Reproduced in Chrome with leaf-dev probe release-notes: open Threads, append and show a modal whose focused button declares an Escape command through commands, then compare ordinary Escape with the uncanceled-Escape close request used by the new tests. Ordinary Escape ran the inner command and left the modal open; the close request closed the modal without running that command. The watcher lifetime needs to account for native-layer ordering so an inner Leaf step is handled before its containing layer, while an unhandled step still reaches the native layer.
# Conflicts: # dist/kernel/kernel.json
…the user there
The previous commit made Android's back gesture take no step in a
changed lf-draft editor or message rewrite. Review measured that this
traps the user: Chrome and Firefox let a watcher rebuilt after each close
catch every back (10 of 10 in a changed draft and in a changed rewrite;
12 of 12 in plain HTML on Chromium 153, Chrome 155 and Firefox 155), so
the only ways out were Save, Discard or a tap elsewhere, and nothing on
screen said so. The notice was also cut off at 390px ("The unsent
words…").
Back now closes the editor as Escape would but keeps the words, as a
composer closed over its words does. A row whose `run` throws away
unsent words declares `keep` (keyboard/bindings.js), which the close
request runs in place of `run` (dispatch.js, `answerCloseRequest`);
`discards` is gone, since `keep` carries the whole decision.
- lf-draft: an unchanged editor closes as on Discard; a changed one
closes leaving its words in the store. The notice says "Edit kept", and
the closed box's toolbar stays in view saying "unsaved edit" beside
Edit, which reopens the words, as Resume writing and a reload do.
- A message rewrite: the editor closes keeping its draft. The notice
says "Edit kept", and the message's head already says "unsaved edit"
for kept words, which opening the rewrite or Resume writing finds.
The close-requests.js, lf-draft.js and message-edit.js headers record
the decision and the rejected reading (back taking no step). The test
watches count a close watcher's trusted `close` as the user's gesture
(input_work_watch.js, words_watch.js), since Android's back reaches the
page only that way and the words watch otherwise reported the kept
editor's words as leaving without a key or press.
test_a_back_gesture_never_throws_away_unsent_words[draft|rewrite] now
asserts that back closes the changed editor, shows the notice and the
kept sign, doesn't go back in history, and that reopening finds the
words. With the previous commit's runtime both cases fail where the
editor should close.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… Edit The previous commit taught the words watch that a close watcher's close is the user's gesture, and counted every close as putting the words away, as Escape does. Escape may discard; back may not. Review drove the runtime from before `keep` (18b1a78, where back discards) through open, type, back and reopen: both editors lost the words, and the watches passed. A widget whose Escape discards and that declares no `keep` would lose words on back with the suite green. A close now puts words away only where the page's storage still holds them, bare or as a JSON string, as Leaf's draft store keeps them (tests/words_watch.js, `stored`). Every browser test that closes a field by a close request therefore checks that back never discards. The rule reads storage, not the event's trust: a script's close() or requestClose() also fires a trusted close. test_words_a_close_request_puts_away_only_words_it_keeps[close-keeps| close-discards] in tests/browser/test_render_words_watch.py: a plain page stores the words on input and a CloseWatcher closes the box, keeping or removing them. With the previous watch the close-discards case fails (no finding); with this one both pass. Against 18b1a78's runtime, test_a_back_gesture_never_throws_away_unsent_words now reports "typed words left the screen without a key or press" in both editors. Also: - dispatch.js `answerCloseRequest` logs "keep" as the command's title when it runs a row's `keep`, rather than the row's own "Discard"; the test asserts it. - The rewrite's kept sign says "The edit is kept; open it to save or discard", the same words as lf-draft's, naming the Discard control. - Back on a changed rewrite lands on the message's Edit control, beside the "unsaved edit" sign, rather than in the reply box, whose caret would raise a phone's keyboard and covered the "Edit kept" notice in the panel seat. lf-draft already lands on its Edit control. The test asserts both. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The backlog is now GitHub issues labelled `backlog`. Every item under Now, Next and Etc in `TODO.md` became one issue, so a pull request that says `Closes #N` links itself to its item, and a session finds untaken work with a query instead of reading a file that has no claim signal. #4000 landed first, so none of the new issues started a triage run (all 82 `tend-triage` runs were skipped). **Query.** ```bash gh issue list --search "label:backlog label:now -label:waits-on-user -linked:pr" ``` then `label:next` and `label:etc`. `-linked:pr` leaves out issues a pull request already links with a closing keyword. **What moved where.** - 82 issues from #4007 to #4089 (#4067 is another session's), one per bullet. Each is labelled `backlog` and its priority: 13 `now`, 29 `next`, 40 `etc`. Now and Next items also carry a theme mapped from their `###` heading: `ux` (User experience; User continuity and mobile access), `agent-experience` (Agent and author experience; The agent's text interface), `layout` (Layout; Layout stability; Queues), `review-tools` (Before/after comparison; Recorded interaction review) and `dev-velocity`. Etc's two headings, Product and harness ideas and Implementation candidates, sort kinds rather than subjects, so those items carry no theme. - 14 items also carry `waits-on-user`, the "Waits on the user" marking from #3891 (`todo-review`), and their bodies take that branch's wording, including its rewrite of the held-news item as "Keep a held-news count whole as it grows" (#3459 landed the "+N" route). `TODO.md` says what the label means, and the query above leaves those items out. - After the migration, #3891's author asked for three more edits from the grind PRs that touch these items: #4039 is retitled "Decide whether Pixels should soften redrawn-shadow fringes" (#3838), #4039 and #4048 (#3840) also carry `waits-on-user`, and #4098, "Keep a window preference from cramping a dashboard into a workspace", is the item #3913 puts in place of #4033. - Each title is the bullet's bold outcome. For the bullets whose bold text is a label ("Multiplayer:", "MCP Apps:"), the title adds the bullet's first clause. - Each body is the bullet's text with its hard wraps joined (GitHub renders a single newline as a line break), relative links made absolute, and `notes/` paths linked. A footer gives the bullet's `TODO.md` permalink, its heading, its position within its priority, the old `TODO #N` id for the six that had one, and the theme section's introduction where there was one. #4014's mention of the reply-widgets item now links #4089. - `TODO.md` keeps "Biggest current challenges" unchanged. Its priority explanation now says the items live in issues, what the labels mean, and how to query them. - `/developing-leaf` gains "Take a backlog item": pick an unclaimed issue that isn't waiting on the user, and open the PR early with `Closes #N`. It points at `TODO.md` for the query, so the rule and the query each have one home. - Every reference to a current `TODO.md` item now names its issue: `AGENTS.md`'s repository map, `/developing-leaf`, the thread snapshot skips, `journey.py`, `thread_snapshots.py`, `llm.py`, `test_tabs.py`, the Worker, two eval comments and five notes. - #3891's two note edits come along (`notes/browser-support.md`'s recheck rule, `notes/user-feedback-responsiveness.md`'s retired tone lever), since #3891 will drop its `TODO.md` changes. **Order.** Each issue's footer records its old position ("item 6 of 13 in Now"). I didn't keep an ordered index in `TODO.md`: it would be a second list of the backlog that every new issue has to be added to by hand, and it would drift from the labels. The priority label is the ordering that stays current. **Duplicates.** None of the 15 open issues duplicated an item, so every item is a new issue. **Mapping.** The old-item-to-issue table, with open PRs whose titles match an item, is below; the same table is at `~/.tmp/leaf.agent-afd0a8c0d63089ed9/backlog-mapping.md`. <details><summary>82 items</summary> | Issue | Priority | Old position | Old id | Title | Possible PRs | |---|---|---|---|---|---| | [#4007](#4007) | now › User experience | 1 (TODO.md line 43) | | Make complete reading journeys feel coherent | #3860, #3865 | | [#4008](#4008) | now › User experience | 2 (TODO.md line 47) | | Keep the Thread hierarchy clear | | | [#4009](#4009) | now › User experience | 3 (TODO.md line 49) | | Keep a long Thread's current status visible | | | [#4010](#4010) | now › User experience | 4 (TODO.md line 53) | | Test annotation placement in context (waits-on-user) | | | [#4011](#4011) | now › User experience | 5 (TODO.md line 57) | | Make the next move and its result apparent | #3879 | | [#4012](#4012) | now › User experience | 6 (TODO.md line 62) | TODO #28 | Finish the floating panel (waits-on-user) | | | [#4013](#4013) | now › User experience | 7 (TODO.md line 69) | | Keep a held-news count whole as it grows (waits-on-user) | | | [#4014](#4014) | now › User experience | 8 (TODO.md line 80) | | Stop moving live content between parents | | | [#4015](#4015) | now › Agent and author experience | 9 (TODO.md line 94) | | Wake idle Codex desktop chats without user messages | | | [#4016](#4016) | now › Agent and author experience | 10 (TODO.md line 99) | | Consider a reminder when revising decided content (waits-on-user) | | | [#4017](#4017) | now › Agent and author experience | 11 (TODO.md line 104) | TODO #20 | Act on the plain HTML comparison | | | [#4018](#4018) | now › Agent and author experience | 12 (TODO.md line 118) | | Keep delegated work in the panel's status on Codex and Pi | #3854 | | [#4019](#4019) | now › Agent and author experience | 13 (TODO.md line 123) | TODO #24 | Measure time to an initial reviewable page and the value of review | | | [#4020](#4020) | next | 1 (TODO.md line 149) | | Add a host-owned widget LLM allowance (waits-on-user) | | | [#4021](#4021) | next › User continuity and mobile access | 2 (TODO.md line 159) | | Bring back a rewrite Escape discarded | #3862 | | [#4022](#4022) | next › User continuity and mobile access | 3 (TODO.md line 163) | | Decide when a page merits a separate phone composition (waits-on-user) | | | [#4023](#4023) | next › User continuity and mobile access | 4 (TODO.md line 169) | | Improve maintained examples through a phone-quality queue | #3869, #3899, #3902 | | [#4024](#4024) | next › User continuity and mobile access | 5 (TODO.md line 175) | | Decide whether Back may restore a leaf.page page whole (waits-on-user) | | | [#4025](#4025) | next › User continuity and mobile access | 6 (TODO.md line 182) | | Consider automatic Leaf recovery on resume | | | [#4026](#4026) | next › User continuity and mobile access | 7 (TODO.md line 185) | | Verify the native phone reading journey | | | [#4027](#4027) | next › User continuity and mobile access | 8 (TODO.md line 189) | | Finish what a phone user still cannot reach | #3856, #3868, #3874, #3875 | | [#4028](#4028) | next › User continuity and mobile access | 9 (TODO.md line 199) | | Reconsider thread navigation (waits-on-user) | | | [#4029](#4029) | next › Layout | 10 (TODO.md line 224) | | Show returning threads without moving the current reading | #3883 | | [#4030](#4030) | next › Layout | 11 (TODO.md line 229) | | Let a page restyle Leaf's chrome on purpose (waits-on-user) | | | [#4031](#4031) | next › Layout | 12 (TODO.md line 235) | | Let a block be a workspace | | | [#4032](#4032) | next › Layout | 13 (TODO.md line 245) | | Show each floating surface across the content it can hold | | | [#4033](#4033) | next › Layout | 14 (TODO.md line 275) | | Test the Layouts on agents | #3913 | | [#4098](#4098) | next › Layout | 14, added by #3913 in #4033's place | | Keep a window preference from cramping a dashboard into a workspace | | | [#4034](#4034) | next › Layout | 15 (TODO.md line 285) | | Layout values that wait for a task: list-detail on a phone, canvas regions, slides | | | [#4035](#4035) | next › Layout | 16 (TODO.md line 288) | | Decide whether a too-narrow table fails a page at the fixed widths (waits-on-user) | | | [#4036](#4036) | next › Layout stability | 17 (TODO.md line 298) | | Keep what a live revision adds above the reader from moving it | | | [#4037](#4037) | next › Layout stability | 18 (TODO.md line 304) | | Keep the merge film's controls still as it steps | | | [#4038](#4038) | next › Queues | 19 (TODO.md line 314) | | Keep the open item's group named on a phone | #3853 | | [#4039](#4039) | next › Before/after comparison | 20 (TODO.md line 323) | TODO #29 | Decide whether Pixels should soften redrawn-shadow fringes (waits-on-user; was "Explain the faint amber halo in Pixels") | #3838 | | [#4040](#4040) | next › Recorded interaction review | 21 (TODO.md line 333) | | Explore DOM selection in the imported timeline | | | [#4041](#4041) | next › The agent's text interface | 22 (TODO.md line 343) | | Decide the Leaf-owned defects the bad-pages eval left open (waits-on-user) | | | [#4042](#4042) | next › The agent's text interface | 23 (TODO.md line 350) | | Read the full render gate after handover | #3888 | | [#4043](#4043) | next › The agent's text interface | 24 (TODO.md line 366) | | Consider loading a page once per render check (waits-on-user) | | | [#4044](#4044) | next › The agent's text interface | 25 (TODO.md line 372) | | Derive the waiting status from the page's open obligation | | | [#4045](#4045) | next › Development velocity | 26 (TODO.md line 380) | | Require `test` on `main` again (waits-on-user) | | | [#4046](#4046) | next › Development velocity | 27 (TODO.md line 386) | | Resume the thread appearance gate (waits-on-user) | | | [#4047](#4047) | next › Development velocity | 28 (TODO.md line 394) | | Guard thread appearance on CI again | #3896 | | [#4048](#4048) | next › Development velocity | 29 (TODO.md line 404) | | Keep the agent journey's samples (waits-on-user) | #3840 | | [#4049](#4049) | etc › Product and harness ideas | 1 (TODO.md line 420) | | Consider Redo and a Changes panel | | | [#4050](#4050) | etc › Product and harness ideas | 2 (TODO.md line 433) | | Link filenames to their repository context | | | [#4051](#4051) | etc › Product and harness ideas | 3 (TODO.md line 438) | | Revisit the Claude desktop app opening a page's file over the live page | | | [#4052](#4052) | etc › Product and harness ideas | 4 (TODO.md line 448) | | Decide the site's structure before release | | | [#4053](#4053) | etc › Product and harness ideas | 5 (TODO.md line 451) | | Assess whether automatic measurement freshness is useful | | | [#4054](#4054) | etc › Product and harness ideas | 6 (TODO.md line 457) | | Revisit where an abandoned comment's words come back | | | [#4055](#4055) | etc › Product and harness ideas | 7 (TODO.md line 462) | | Revisit a pin's icons if they read unclearly | | | [#4056](#4056) | etc › Product and harness ideas | 8 (TODO.md line 466) | | Revisit the reaction tokens' meanings or glyphs if they confuse | | | [#4057](#4057) | etc › Product and harness ideas | 9 (TODO.md line 471) | TODO #30 | Try a feed of ready-to-approve actions | | | [#4058](#4058) | etc › Product and harness ideas | 10 (TODO.md line 477) | | Explore independent jobs | | | [#4059](#4059) | etc › Product and harness ideas | 11 (TODO.md line 480) | | Tell the agent when to ask before ending its own to-do | | | [#4060](#4060) | etc › Product and harness ideas | 12 (TODO.md line 485) | | Let the user edit items in the On view | | | [#4061](#4061) | etc › Product and harness ideas | 13 (TODO.md line 489) | | Multiplayer: let several users share a page, each recorded as themselves | | | [#4062](#4062) | etc › Product and harness ideas | 14 (TODO.md line 495) | | Show which pane has focus, and move between panes by key | | | [#4063](#4063) | etc › Product and harness ideas | 15 (TODO.md line 508) | | Expand everything waiting with a keypress | | | [#4064](#4064) | etc › Product and harness ideas | 16 (TODO.md line 514) | | Let a user add, remove and edit table rows | | | [#4065](#4065) | etc › Product and harness ideas | 17 (TODO.md line 519) | TODO #16 | Named widget interfaces: let a typed reference name the interface its target implements | | | [#4066](#4066) | etc › Product and harness ideas | 18 (TODO.md line 523) | | Visual review beside Leaf: coordinate a real browser target through the harness | | | [#4068](#4068) | etc › Product and harness ideas | 19 (TODO.md line 526) | | Other harnesses: add a blocking `leaf wait` route when another harness needs it | | | [#4069](#4069) | etc › Product and harness ideas | 20 (TODO.md line 528) | | Consider Leaf running the agent session | | | [#4070](#4070) | etc › Product and harness ideas | 21 (TODO.md line 533) | | Decide whether an exported page carries its threads | | | [#4071](#4071) | etc › Product and harness ideas | 22 (TODO.md line 540) | | Character bindings: let users disable them | | | [#4072](#4072) | etc › Product and harness ideas | 23 (TODO.md line 541) | | Replacement diffs and visual masks for repeated reviews | | | [#4073](#4073) | etc › Product and harness ideas | 24 (TODO.md line 543) | | Motion evidence: define video, caption and transcript handling | | | [#4074](#4074) | etc › Product and harness ideas | 25 (TODO.md line 545) | | Revisit long-thread folding after using summaries | | | [#4075](#4075) | etc › Implementation candidates | 26 (TODO.md line 551) | | Remove the early-key hold once startup is fast on slower machines too | | | [#4076](#4076) | etc › Implementation candidates | 27 (TODO.md line 578) | | Draw the margin's annotations once per thread pass | #3864 | | [#4077](#4077) | etc › Implementation candidates | 28 (TODO.md line 587) | | Read moves exactly where the before/after pair is a browser's capture | | | [#4078](#4078) | etc › Implementation candidates | 29 (TODO.md line 597) | | Reduce plugin-update downloads by cleaning Git history | | | [#4079](#4079) | etc › Implementation candidates | 30 (TODO.md line 605) | | Set interaction-trace privacy before sharing pages | | | [#4080](#4080) | etc › Implementation candidates | 31 (TODO.md line 610) | | Make a leaf.page dispatch survive its container | | | [#4081](#4081) | etc › Implementation candidates | 32 (TODO.md line 616) | | Start each release's containers on its own image | | | [#4082](#4082) | etc › Implementation candidates | 33 (TODO.md line 629) | | Push page updates instead of polling | | | [#4083](#4083) | etc › Implementation candidates | 34 (TODO.md line 670) | | Claude Code tool observation: a cheap hook for sessions holding pages | | | [#4084](#4084) | etc › Implementation candidates | 35 (TODO.md line 672) | | Measure Leaf's hook cost for sessions holding pages | #3876 | | [#4085](#4085) | etc › Implementation candidates | 36 (TODO.md line 677) | | Invoker commands: test `command` and `commandfor` once Leaf's Chromium floor allows | | | [#4086](#4086) | etc › Implementation candidates | 37 (TODO.md line 681) | | MCP Apps: rebuild inline hosting as a direct resource | | | [#4087](#4087) | etc › Implementation candidates | 38 (TODO.md line 692) | | Release labels: prefer an exact tag when Leaf adopts named releases | | | [#4088](#4088) | etc › Implementation candidates | 39 (TODO.md line 693) | | Diff controls: author-configurable wrapping and per-file review tracking | | | [#4089](#4089) | etc › Implementation candidates | 40 (TODO.md line 695) | | Show a reply's widgets in every view of it | | </details> **Not migrated cleanly.** - Each section introduction (Layout, Layout stability, Queues, Recorded interaction review) is copied into every issue of its section, since a label can't carry it. - Eval fixtures that quote a past session mentioning `TODO.md` (`assessment-surfaces-pending-decisions`, `record-asks-hold-their-premise`, `options-*`) are recorded inputs and stay as they were. Two eval provenance comments and one line of `notes/agent-usability-evals.md` name items that left `TODO.md` before this change, so they have no issue to point at. - The fold-button entry #3891 corrected is in neither `TODO.md`, and #3928 fixed it, so it has no issue. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Takes main's TODO.md, whose backlog moved to GitHub issues in #4090. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Leaf panel's row no longer has a Threads control (#4144); Threads opens from the On me mark's tab. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A modal dialog opened while the page held its watcher stood a newer watcher above it, so back closed the dialog where Escape took the step a command inside it declares. The watcher now remembers the native layers standing when it was made, and the repaint frame makes it again when a newer layer stands over it and Escape still has a step of Leaf's to take; a layer opening or closing asks for that frame. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
message-edit.js keeps both Escape's restorable discard (#3862) and back's keep. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In an open `lf-draft` editor, Android's back gesture now saves the changed words, as Save and a press away from the draft do. Before, back closed the editor keeping the words unsaved, with an "Edit kept" notice and an "unsaved edit" sign beside Edit (#3856). **The decision** (Leaf page question "Which exits from an open draft send it, keep it, or throw it away?"): "Back saves, as a press away does. Two rules: Escape and Discard throw away, every other exit saves. The kept state #3856 added to `lf-draft` goes: the "Edit kept" notice, the "unsaved edit" sign and its method. An accidental swipe sends a turn, as an accidental tap does today." ## What changed - `lf-draft`'s Escape row declares `keep: () => this.#commit()`, the same path a press away takes (`onPressAway` → `#commit`). An unchanged editor still just closes, since `#commit` closes one without sending. - Removed with the kept state: `#keep`, the "unsaved edit" sign in `#paintTools`, its `.lf-draft-kept` rule, the toolbar rule that kept a non-empty status in view (a failed save's status shows only in an open editor, which already keeps the toolbar in view), and the toolbar repaint a store change in another tab made for the sign. - The message rewrite has no press-away save, so its `keep` still closes the editor keeping the words, and the `keep` row field stays. Its description in `bindings.js`, `close-requests.js`'s header and `skills/leaf/references/module-input.md` now say `keep` closes without losing the words: it saves them where a press away would, and keeps them otherwise. `keyboard/AGENTS.md`'s Escape section already said only that back runs `keep`, so it is unchanged. ## Tests - `test_a_back_gesture_never_throws_away_unsent_words[draft]`: back on an unchanged editor closes it and sends nothing. Back on a changed one closes it, logs "keep", leaves history alone, draws the words in the draft and appends exactly one `edit` event holding them. With `keep` discarding instead, it fails, and the words watch reports "typed words left the screen". The `[rewrite]` case is unchanged. - `back_gesture` now waits two animation frames before the close request, since the page makes its watcher in the repaint frame after an editor opens. Under `taskpolicy -b` the draft case sometimes sent back before the watcher existed and failed (1 of 3 runs). With the wait it passed 3 of 3. The modal test's own frame waits are removed. - `tests/words_watch.js` still counts a close as putting words away only where storage holds them. A saving draft keeps its record there until the log accepts the edit, so a save by back passes (6 of 6 runs, 3 of them under `taskpolicy -b`). Only the header changes. Ran: the back-gesture and Escape tests in `test_key_scopes.py` (5 passed), `test_render_words_watch.py` (102 passed), the press-away/back/Escape/discard selection of `drafts/test_draft_editing.py` and `drafts/test_sending.py` (11 passed), `pnpm run test:runtime` (682 passed), `pnpm run build:browser` (kernel hashes for the two edited runtime comments), `pnpm run check` (passed). Not changed: back on a draft whose edit has become unavailable while its editor is open does nothing, as a press away already does there. Escape and Discard still close it. > _This was written by Claude Code on behalf of max-sixty_
Tend's PR review now checks each change against the open backlog and gets the description to close what the change settles. Where the change leaves nothing of a `backlog` issue to do, by finishing what remains, removing its premise or recording a decision against what it asks, the description says `Closes #N`. Where it does part, the description says `Part of #N` and what is left, so the review of the last part can tell that part finishes the issue. On Tend's own pull request the review edits the description. On someone else's it asks in the review, and the ask goes in an approval rather than holding one back. The rule is a new section of `running-tend`, **Issues a change finishes**, after **Review threshold**. ## Why Leaf's backlog triage of 2026-11-04 found seven merged pull requests that did an open backlog issue's work without closing it. Four said `Part of #N`: #3879, #3902, #3856 and #3868. Three named no issue: #4487, #4124 and #5039. Nothing asked those three to look, since `/developing-leaf` asks for `Closes #N` only of a session that starts from a backlog item. Tend's nightly sweep reads a seventh of the open issues each night, long after the diff has left the reader's context, and, by the triage's count, it commented on none of them in ten nights. The review is the step every change passes with its diff in hand. The replay below sorts the seven more finely than the triage did. #4011, #4036 and #4013 were settled by #3879, #4124 and #5039. #3902 did half of #4023, whose five composition defects stayed open. #3856, #3868 and #4487 each did one item of #4027, which is still open. For those four the right description is `Part of #N` with what is left. A `Closes #N` would have been wrong. ## Replay Each case gets the rule as this branch ships it, together with `running-tend`'s **Review threshold** section, which it competes with. It also gets the PR's title, author, description and diff, capped at 80k characters with vendored files left out, and every `backlog` issue open when the PR merged, as it read then. That list is rebuilt from the issues' creation and close times, label events and body edit history, plus their comments up to the merge. Each case runs once through a headless `claude -p` on `claude-opus-5-5` (the review's model), with no tools, in a scratch home. The JSON verdict is graded against an expected answer fixed before the run. | PR | What it did | Expected | Result | | --- | --- | --- | --- | | #3879 | the play-through #4011 asked for | close #4011, or part with its open decision left | pass: part, the decision and the home-page test left | | #3902 | #4023's touch-target half | part of #4023 | pass (also part of #4027) | | #3856 | #4027's Android back item | part of #4027 | pass | | #3868 | #4027's Draw mode item | part of #4027 | pass | | #4487 | #4027's lf-draft back item | part of #4027 | pass | | #4124 | recorded the call that settled #4036 | close #4036 | **miss**: read #4036 and judged the call unrelated | | #5039 | one held-news count, #4013 | close #4013 | pass (also part of #4012) | | #5331 | removed #4060's premise | close #4060 | pass | | #4643, #4718, #4847, #5020, #5252 | nothing in the backlog | nothing | 5 pass | | #5441, #5446, #5454 | rightly a part of an open issue | that part | 3 pass | | #4212 | rightly said `Closes #4037` | close #4037 | pass | That is 6 of the 7 triage cases, the premise case, and 9 of 9 controls. No run closed or named an issue it shouldn't have. #5020 is a hard negative: it changes held-news notices, which #4013 is about, and the run left #4013 alone. #4124's miss held in all three wordings tried. The triage itself only inferred that the 2026-10-25 call in `reading-place.js` covers #4036's case. The clause for a removed premise or a recorded decision goes beyond the two cases Max named. It is there because the triage closed several issues as obsolete after a landed change removed their premise. Without the clause, the #5331 run read #4060 and declined: "It only makes one sentence of the issue's background out of date". With it, the run closed #4060. Two grades were corrected after the first run, each on evidence from the record. #5252 says `Part of #5194`, but #5194 was labelled `backlog` only on 2026-11-05, after #5252 merged. #5039 left a count that gains a digit outgrowing its room, as its own `thread-card.js` comment says, and #5288 fixed that on 2026-11-04, so `Part of #4013` naming that is also right at merge time. The final wording closed #4013 anyway. ```sh uv run python .tmp/replay/replay.py --jobs 4 uv run python .tmp/replay/replay.py --only 5331,4124 --rule-file .tmp/replay/arm-finishes-only.md --runs runs-finishes-only --results results-finishes-only.json ``` The final wording's 17 runs cost $6.75. All runs together cost $19.64, across three wordings and the two-run ablation. The script, cases, prompts, answers and results are in `.tmp/replay/` of the worktree that wrote this PR, not committed. The last run used this text before one sentence was split in two. ## Decisions Max may reverse - **Where the rule lives.** It lives in `running-tend`, which only Tend loads. `/developing-leaf`'s `Closes #N` under **Take a backlog item** stays as it is. That rule claims an item early: the closing keyword is what makes `TODO.md`'s `-linked:pr` query skip it. The review then corrects a claim the change only partly fulfils to `Part of #N`. Repeating the search in the author's skill would make every Leaf session pay for a check the review already makes on every PR. - **How it acts on others' pull requests.** The review asks and doesn't edit, since the author owns the description and Leaf sessions rewrite it whole from a file. The ask doesn't withhold approval. `tend-review` runs on `opened`, `synchronize`, `ready_for_review` and `reopened`, not on `edited`, so a held approval would wait for the next push. The review approves with the ask as its body. - **Scope.** Only issues labelled `backlog`. CI failure reports and cause issues close by their own routes. ## Not verified - **Use inside a full review.** The replay gives the section on its own, with the backlog inline. It shows that the rule, once applied, picks the right issue. It doesn't show whether a whole Tend review, with the bundled review skill in context, remembers to apply it. Tend's next reviews will show that. - **What-is-left lists.** The replay leaves out the earlier PRs that name each issue, which the rule tells the review to read. So its lists repeat items that earlier parts had done. #5454's ask lists #4027 items that #3856 and #3868 had finished. - **Repeat runs.** Each case ran once. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 <[email protected]>
On a phone, the back gesture closed nothing Leaf opened: a finger that
opened the page menu, the Threads view, Draw mode or a selection had
only the panel's ✕ or a tap elsewhere to leave it, and back left the
page instead. Now back takes the step Escape would. In an editor whose
words the user changed, it closes the editor but keeps those words.
The platform turns the back gesture into a close request (HTML, "Close
requests and close watchers"; CloseWatcher ships in Chrome 126 and
Firefox 149, desktop and Android).
keyboard/close-requests.jsholdsone CloseWatcher while Escape has a step to take, read in the repaint
frame beside the touch controls, and its close takes that step through
the dispatcher (
answerCloseRequest). With nothing to take the pageholds none, so back goes back in history as before. A real Escape
keydown the dispatcher answers is canceled, which the spec says ends the
close request before any watcher hears it, so a key still takes one
step. Native modals and popovers keep their own watchers, and where one
opens over the page's watcher while Escape still has a step of Leaf's
to take inside it, the watcher is made again above it, so back takes
that step before the layer closes, as Escape does. Safari lacks CloseWatcher and keeps today's behaviour.
Back never throws away unsent words. In an open
lf-drafteditoror a message rewrite, Escape's step is Discard, which nothing undoes.
On Android the first back hides the keyboard and the next would
discard, so a stray edge swipe would lose the edit. A command row whose
runthrows away unsent words now declareskeep(
keyboard/bindings.js), which a close request runs in place ofrun:lf-draft: an unchanged editor closes as on Discard. A changed onecloses and leaves its words in the draft store. A notice says "Edit
kept", and the closed box's toolbar stays in view saying "unsaved
edit" beside Edit, where focus lands. Edit, Resume writing (a row in
the panel's menu under a finger) or a reload opens the words again.
"Edit kept", and the message's head says "unsaved edit", as it already
does for words a reload or a refusal kept. Focus lands on the
message's Edit control, not the reply box, whose caret would raise a
phone's keyboard and cover the notice. Opening the rewrite or Resume
writing finds the words.
Both signs' tooltips say "The edit is kept; open it to save or discard"
(the rewrite's said "save or cancel"). Escape and the Discard control
still discard. A press away from an open draft saves it, as main does since
#4270; back, which may be an accidental edge swipe, keeps the words
unsaved instead.
A call Max may reverse: back keeps a changed edit and closes the
editor. Rejected:
this PR shipped. Chrome and Firefox let a watcher rebuilt after each
close catch every back, so this held the user in the editor with only
Save, Discard or a tap elsewhere to leave, and nothing on screen said
so. An independent review measured 10 of 10 backs caught in a changed
draft and in a changed rewrite, and 12 of 12 in plain HTML on Chromium
153, Chrome 155 and Firefox 155.
turn the user didn't ask for.
lf-draft.jsandmessage-edit.jsrejected keeping words for Escapebecause a closed box gave no sign of holding them. Back now gives that
sign beside the control that reopens them. The notice is short enough
for the panel's seat at 390px; the sign beside the edit control says
where to reopen the words.
The rule is stated where it is owned: the row field in
bindings.js,the close path's decision in
close-requests.js's header, the owners'headers, the Escape section of
keyboard/AGENTS.md, and the rowreference package authors read in
skills/leaf/references/module-input.md.The command log names the step a close request ran: "keep" where a
row's
keepran, not the row's own "Discard" (answerCloseRequest).Every browser test now checks that back keeps words. Android's back
reaches the page only as a close watcher's
close, whichtests/input_work_watch.jsnow treats as an input.tests/words_watch.jscounts that close as putting typed words away only where the page's
storage still holds them, bare or as a JSON string, as Leaf's draft
store keeps them. Escape may discard; back may not. So a widget whose
Escape discards and which declares no
keepfails the suite on back.The rule reads storage, not the event's trust, since a script's
close()orrequestClose()also fires a trusted close.Evidence,
uv run leaf-dev probe release-notes --touch --viewport 390x844 --journey .tmp/back-journey.py, which taps the menu, sends aback close request, taps Threads and sends two more:
after two backs.
Tests, in tests/browser/navigation/test_key_scopes.py:
test_a_back_gesture_takes_the_step_escape_would(390x844, touch)and
test_escape_takes_one_step_where_a_back_gesture_would_take_it(a real Escape closes the view and leaves the selection beside it for
the next back). Both fail with the painter unwired.
test_a_back_gesture_never_throws_away_unsent_words[draft|rewrite]:back closes an unchanged editor. Back on a changed editor closes it,
shows "Edit kept" and the "unsaved edit" sign, logs "keep", lands on
the Edit control and doesn't go back in history. Reopening finds the
words, and Escape then discards. With the runtime that held the user
in the editor, both cases fail where the editor should close. With
the runtime where back discards (18b1a78), both fail and the words
watch reports "typed words left the screen without a key or press".
test_a_back_gesture_takes_a_step_inside_a_modal_before_the_modal:with Threads open, a modal whose button declares an Escape command
opens; back runs the command and leaves the modal open, the next back
closes the modal, the next the view. With the watcher kept from before
the modal, the first back closed the modal.
In tests/browser/test_render_words_watch.py,
test_words_a_close_request_puts_away_only_words_it_keeps[close-keeps|close-discards]:a plain page stores its words on input, and a CloseWatcher closes the
box, keeping or removing them. With the watch that counted every close,
the close-discards case fails (no finding); now both pass.
A test-held CloseWatcher, added as an init script so it stands before
the page's watchers, takes the close requests the page holds no watcher
for. It counts backs that reach history.
Ran: test_key_scopes.py, drafts/test_draft_editing.py,
drafts/test_sending.py, threads/test_rewrites.py and
test_render_words_watch.py (215 passed), the rewrite tests in
test_render_threads.py,
pnpm run test:runtime(559 passed),node --test tests/watch_owner.test.mjs,pnpm run check:browser.Screenshots at 390x844 touch and 1200x700 show the notice whole, the
kept sign beside Edit in a draft and on a rewrite's head, and focus on
the rewrite's Edit control after back.
After merging main: the two back-gesture walk tests open Threads by the
On me mark's tab (
open_threads), since the panel's row no longer has aThreads control (#4144).
pnpm run test:runtime,pnpm run check, andthe back, close-request and words-watch tests pass.
test_a_press_away_from_an_open_draft_saves_itfails the same way onmain (the panel field's placeholder reads "Away c"), so it is not this
change's.
Not verified: a real Android device (the close request was driven by
Chrome's uncanceled-Escape route, which the spec defines as the same
request); Firefox's CloseWatcher in a probe; Draw mode and page search
by back (both are Escape steps, so they follow, but no test drives
them).
How far back reaches: HTML lets a page hold one close watcher without
user activation, and this design holds at most one at a time, rebuilt
after each close. The review above measured Chrome and Firefox catching
every back such a rebuilt watcher stands for. A ladder of steps
therefore unwinds one back at a time, and back goes to history once
nothing Escape would take remains, with nothing holding the user on the
page.
Also a call Max may reverse: the watcher is held in exported pages too,
for widget Escape steps.
Part of #4027.
On landing, update #4027: drop "Android's back gesture closes nothing (the Escape ladder could answer it)" and "an
lf-drafthas no close that keeps the edit".