Skip to content

Let back save an open draft, as a press away does - #4487

Merged
max-sixty merged 5 commits into
mainfrom
draft-back-saves
Oct 27, 2026
Merged

max-sixty merged 5 commits into
mainfrom
draft-back-saves

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

In an open `lf-draft` editor, Android's back gesture (a close request,
which runs the Escape row's `keep`) now saves the changed words as Save
and a press away do. Before, back closed the editor keeping the words
unsaved, with an "Edit kept" notice and an "unsaved edit" sign beside
Edit. The draft now has two rules: Escape and Discard throw the edit
away, and every other way out saves it. A stray edge swipe sends the
agent a turn, as a stray tap does (the user's decision, 2026-10-27).

Removed with the kept state: `#keep`, the 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 repaint a store change in
another tab made for the sign. An unchanged editor still just closes,
since `#commit` closes one without sending.

The message rewrite has no press-away save, so its `keep` still closes
the editor keeping the words, and the row field stays. The field's
description (`bindings.js`), the close path's header
(`close-requests.js`) and the package-author reference
(`module-input.md`) now say `keep` closes without losing the words,
saving them where a press away would or keeping them otherwise.

Tests, in `tests/browser/navigation/test_key_scopes.py`:
- `test_a_back_gesture_never_throws_away_unsent_words[draft]` asserts
  that back on an unchanged editor closes it and sends nothing, and that
  back on a changed one closes it, logs "keep", leaves history alone,
  draws the words in the draft and appends exactly one edit event with
  them. With `keep` discarding instead, it fails and the words watch
  reports "typed words left the screen". The `[rewrite]` case is
  unchanged.
- `back_gesture` 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 sent back before the
  watcher stood and failed 1 of 3; with the wait it passed 3 of 3. The
  modal test's own frame waits go.

`tests/words_watch.js` still credits a close only where storage holds
the words; a saving draft keeps its record there until the log accepts
the edit, so back's save counts as putting the words away (6 of 6 runs,
3 under `taskpolicy -b`). Only its header changes.
@max-sixty
max-sixty marked this pull request as ready for review October 27, 2026 19:54
@max-sixty
max-sixty merged commit c5e807d into main Oct 27, 2026
5 checks passed
@max-sixty
max-sixty deleted the draft-back-saves branch October 27, 2026 20:08
max-sixty added a commit that referenced this pull request Nov 10, 2026
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]>
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