Skip to content

Stand each draft in the margin where it is about, from one list every view reads - #6091

Merged
max-sixty merged 3 commits into
mainfrom
canonical-drafts
Nov 16, 2026
Merged

max-sixty merged 3 commits into
mainfrom
canonical-drafts

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Each unsent message now stands in the margin as a dashed entry where it is about, and every view of drafts reads one list. Follows #6060, which kept drafts with their subject and listed them in Threads.

  • drafts.js publishes the list (draftsReading), a signal fed by the draft cache and the sending mask (each a ListingMap whose writes re-list that draft). It changes only when a draft starts or stops holding words or what it is about changes, never per keystroke.
  • The margin's inventory gives each draft an entry of a new draft kind, through the same standing list and passage rows threads use: a reply or rewrite after its thread's entry in the same row, or alone there once the thread is resolved; a comment or seat draft at its anchor (resolved once per reading of the page), so drafts about two passages of one paragraph stand apart. A press resumes the draft. The item says what the draft is, not its words: its preview (through draftPreview, which the Threads row shares) and its Page Map row read the words where they draw, since the list publishes no keystroke.
  • Threads' Drafts band now holds its rows while the list stands: a draft that joins waits behind the notice that holds new threads ("1 new draft").
  • Calls to weigh: t still walks threads only (drafts are reached by the margin's walk, g m, Page Map and Drafts), and a draft's entry stays while its box is open, the box hanging under it.

Max asked for this; Codex reviewed it, and its three findings (a per-keystroke walk of the event log, quoted drafts losing their passage row, a resolved thread hiding its reply draft) are fixed. Tests: new test_a_draft_stands_in_the_margin_where_it_is_about, test_drafts_stand_by_their_own_passage_and_outlast_a_resolved_thread and test_a_draft_another_tab_writes_waits_behind_threads_notice (fails with the hold removed); test_page_map_reads_a_listed_draft_as_it_now_stands (fails with the copied words, as the leaf-agent review found); test_a_resolved_reply_composition_stays_open_until_deliberately_dismissed now expects the resolved thread's unsent reply to stand as a draft entry, and three revision tests in test_revision_patches.py the draft #6060 named on the On Me door; the Drafts, panel, thread and margin selections (219 + 43 passed), check:browser and test:runtime.

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

… view reads

drafts.js now publishes one list of the message drafts holding words or a drawing
(`draftsReading`), a signal its two state maps feed: the document's draft cache and the
sending mask are each a `ListingMap`, whose writes re-list that one draft. It publishes
only when a draft starts or stops holding something or what it is about changes, so a
keystroke in a listed draft costs one comparison. `draftAnchor` and `draftSends` say
where a listed draft is and what Send makes of it; `messageDrafts` is gone.

Every view of drafts reads that list:
- the margin's inventory stands each draft as an entry of a new `draft` kind, dashed,
  through the same standing list and passage rows threads use: a reply or rewrite in
  its thread's row after the thread, which keeps the face, or alone there once the
  thread is resolved; a comment or seat draft at its anchor, resolved once per reading
  of the page, so two drafts about passages of one paragraph stand apart. A press
  resumes the draft in its box; its preview reads the words as they stand
  (`draftPreview`, shared with the Threads row). A resolved thread's unsent reply now
  leaves that entry where the thread's was, which
  `test_a_resolved_reply_composition_stays_open_until_deliberately_dismissed` now
  expects;
- Threads' Drafts band, which now holds its rows while the list stands: a draft that
  joins, as another tab's, waits behind the notice that holds new threads, and the
  notice's press draws it;
- the On Me mark's grey dot.

The user asked for both on 15 November 2026 (the margin entries, and one list with held
rows). `t` still walks threads only: drafts are reached by the margin's walk, Go-to's
`g m`, Page Map and Drafts.

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

If you edit a draft that is already listed, its Page Map row keeps showing the old words. The cause is that draftItem copies the draft's words into text at collection time. draftsReading deliberately doesn't republish per keystroke, so nothing collects again when the words change. Page Map's row label (visibleLabel = item.text || entry.title in margin-map-model.js) and its search both read that copy.

I reproduced this on the head: write "About the ninth paragraph." at #p9 and press Escape. Then press the draft's margin entry, add " More words added later." and press Escape again. g P lists the row as "About the ninth paragraph.", while Threads' Drafts row shows both sentences.

The margin preview and Threads rows avoid this because they read loadDraft when they draw. That points at the fix: the item shouldn't carry words the list doesn't track. One option is for its text to name the entry the way Threads' row does (what it is about, or what Send makes), with the Page Map row reading the words when it draws. The other is to republish when a box closes with changed words. Which one fits is a call about what Page Map should show.

No open backlog issue matches this change's subject, so the description needs no Closes.

Comment thread browser/runtime/annotation-inventory.js Resolved
…raft in the revision tests

A draft's margin item copied its words when the inventory collected, and since the
drafts list publishes no keystroke, Page Map's row and its search kept the words the
draft had when it was listed: words added after resuming it never reached the map.
The item now says what the draft is ("Comment draft"), and Page Map reads the words
as it opens, as every other view of drafts reads them where it draws. The leaf-agent
review found it on #6091.

#6060 named a draft being written on the On Me door ("On Me, 1 draft unsent"); three
revision tests still expected the bare name, so they now expect the draft too.
@max-sixty
max-sixty merged commit d11674f into main Nov 16, 2026
6 checks passed
@max-sixty
max-sixty deleted the canonical-drafts branch November 16, 2026 04:40
max-sixty pushed a commit that referenced this pull request Nov 16, 2026
…aft with its own target (#6115)

#6060 ("Keep each draft with what it is about…") changed three draft
behaviours on purpose and updated the tests under
`tests/browser/drafts/`, but five browser tests elsewhere still asserted
the old behaviour. Pull requests don't run that tier, so they first
failed in main's push `ci` ([run
43801680826](https://github.com/max-sixty/leaf/actions/runs/43801680826),
`71044e73f`). This PR updates them to what #6060 intended. No product
code changes.

| Test | Old assertion | Now |
|---|---|---|
|
`test_render_aim.py::test_the_aim_still_promises_while_a_composer_is_open`
| a second ⌥-press carries the typed words to the card | the card's own
box opens empty |
|
`test_render_reactions.py::test_plain_clicks_stay_native_and_explicit_gestures_comment_on_visuals`
| Respond on a diagram part carries the figure's words | the part's own
box opens empty, named for the part |
|
`test_render_semantic_selection.py::test_a_keyboard_comment_gesture_carries_the_current_unsent_draft`
→ `…_opens_its_targets_own_draft` | the target picker carries the
heading's words to the paragraph | the paragraph's box opens empty, and
⌥-clicking the heading again brings back its words |
|
`navigation/test_reading_place.py::test_restore_selection_has_touch_route_and_does_not_carry_draft`
| tapping the On Me mark opens On Me | with nothing on the user and a
draft put away, the mark opens Threads (`pressMark`) |
|
`startup/test_readiness.py::test_refusing_the_storage_objects_does_not_block_startup`
| `tabStore.where` names the bare key | the key carries the page's
`data-lf-page-scope` prefix |

Before this change, all five failed locally on `origin/main`
(`81904bdec`) with the same diagnostics as CI. With it, all five pass.
#6091 already updated `test_revision_patches.py` for the "1 draft
unsent" mark label from the same run.

Refs #3985 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 16, 2026
Max asked for drafts to read in a dim colour rather than a dotted line,
which he didn't expect in Leaf's interface. A draft's margin entry (rail
and pin) now keeps the solid contour every entry wears and draws its
glyph in the muted grey the On Me mark's dot already uses for a draft,
so it reads apart from a thread's entry in the thread's colour. It had
worn a dashed contour since #6091.

Unsent drawing ink with its comment box put away (or its element gone
after a revision) was the other dashed draft; it now keeps the accent at
60% stroke opacity. Grey ink was tried first and read as a strikethrough
in the page's text, so this one stays blue. `browser/AGENTS.md`'s
"Contours are solid" no longer lists a draft among the states a dashed
line marks.

Before/after stills (light and dark rail, pin, ink) were checked, and a
fresh-context reviewer read them; its finding on grey ink is what moved
the ink to dimmed accent. Tests:
`test_a_draft_stands_in_the_margin_where_it_is_about` now asserts a
draft's glyph colour differs from its thread's (it fails when the draft
takes the thread's colour), plus the drafts and parked-drawing
selections and pre-commit.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 16, 2026
…s and devices (#6124)

Unsent drafts move from browser localStorage to the page's server, so a
draft follows the user to another tab, browser or device. Follows #6060
and #6091.

- `src/leaf/drafts.py` keeps `drafts.json` in the page directory,
outside the log: one generation per draft context. A write names the
generation it replaces (compare-and-set), so another tab's or device's
later words come back instead of being overwritten. Admitting an event
settles the draft its attempt came from, and the store remembers recent
admitted attempts so a write landing after its send settles too. No page
reading, activation or watcher counts the file, and the agent never
reads it.
- Tabs hear changes through the existing news look (`/api/news` carries
a drafts version, then `/api/drafts`), and a served document arrives
with its drafts, so a box opens on its words at once. `drafts.js` keeps
one write in flight per draft, and drops the cross-tab storage machinery
(storage listener, nondurable branches, tombstones, refresh-before-send,
`settleAcceptedDrafts`).

What changes for the user, to weigh:
- Words typed while the server is out of reach, or still on their way,
stay in their tab and go if it closes first; a closing page resends
what's waiting with `keepalive`.
- On leaf.page, drafts are saved with the page at each send and answered
from there while its container sleeps, so a tab opened then shows them
without waking it; a container replaced with no tab open loses words
typed since the last send.
- A tab that missed newer words sends what it shows, and the newer words
stay the draft. Two places writing one draft at once keep the first
write; the other's words since give way.
- Rarer losses Codex reproduced in schedules: a store restored and
advanced past by another tab before this tab looks; and a ghost of sent
words, from a write held past 64 later sends or a crash between a send's
append and its settlement, winning over fresh words.
- Each write rewrites the page's drafts file, which holds only unsent
drafts. AGENTS.md's rule that a draft being typed stays with the browser
now says the server keeps it.

Max asked for this. Codex reviewed it three times; its findings on stale
reads, a restore race, moves, leaf.page's first draft, closing tabs,
late writes of sent words and the words watch are fixed. Tests:
`tests/process/test_drafts.py`; browser tests for another device, a
server that lost drafts, a stale read and a refused move, each failing
without its fix; the cross-tab tests rewritten from storage faults to
refused writes and reads.
`test_refused_reply_retains_its_live_foot[margin]` fails on main since
#6091 and here alike.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 16, 2026
…it (#6188)

#6091 made an unsent reply stand in its thread's margin row, so while
the user writes, the row's marker carries `data-lf-kinds="comment
draft"`.
`test_margin_card_holds_its_top_while_read_and_its_reply_while_written`
looked the marker up with `[data-lf-kinds="comment"]`. That locator
stopped matching after the test typed its reply, and
`marker.bounding_box()` timed out at line 461. The locator now matches
`comment` as one of the marker's kinds (`~=`). The test's assertions
about the card are unchanged, and the marker is the same element the
user pressed. Run by node id with `--run-nightly`, the test fails on
`f1b367375` and passes with this change.

The issue's other failure,
`test_refused_reply_retains_its_live_foot[margin]`, is a runtime
placement defect and isn't fixed here. The diagnosis is on #6178.

Refs #6178 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 16, 2026
… it answers (#6199)

A refused reply no longer drops its margin card: the card holds its top,
as it does through the send, and its reply box rises into the refused
turn's room. Since #6091 the card's top dropped 56px and its box rose
24px, sliding the card out from under the pointer, and
`test_refused_reply_retains_its_live_foot[margin]` failed on main.

The card's one edge rule (`heldEdge`, `thread-preview.js`) holds the
foot while the user writes words in its reply box. After a refusal the
words return to the focused box under the refusal's cover, which shows
no line being typed, so the rule now counts covered words as it counts
an empty box. No hold, timer or memory of the send is added. `errorOver`
moves from `composing/input.js` to `errors.js`, which owns the cover, so
the box and the card read one definition.

Closes #6178: #6188 fixed its other journey, and this fixes the refused
reply.

Max chose keeping the top still over letting the card drop, from
captures of both on his Leaf page. Tests: the refused-reply journey
passes at all four places; `pnpm run test:runtime` passes.

> _This was written by Claude Code on behalf of max-sixty_
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