Skip to content

Keep each draft with what it is about, list drafts in Threads, and keep each local page's drafts apart - #6060

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

max-sixty merged 7 commits into
mainfrom
canonical-drafts

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A message draft now stays with what it is about, and Threads lists drafts under a new Drafts band above Open. Before, an explicit Comment on another target, opening a drawing there, or c into a thread moved the unsent words into that new box, and a put-away draft was reachable only by g i. Now each of those opens the target's own draft, the panel says "Draft kept — g i resumes writing" when words leave view, and a Drafts row (its words, then dim what it is about, then Comment/Suggestion/Reply/Edit) resumes the draft in its own box.

What the diff doesn't show:

  • drafts.js now names every message draft context in one table (page, passage comment, widget seat, reply, rewrite). Widget value edits (lf-draft, an option being added) aren't messages and aren't listed. The page's own draft isn't listed either, because the field under the list shows it.
  • Calls I made, each easy to reverse: Drafts above Open; g T still lands on the first thread (at); a thread's Open row no longer says "Draft"; Threads doesn't repaint on draft news, so another tab's typing costs nothing and a cross-tab draft shows at the list's next paint.
  • Codex's review found a rewrite of a message taken back unreachable from both g i and the new row; threadHolding now counts that box as gone, so the words move to the page comment like any other draft whose box is gone.
  • Where no thread has news, the On Me mark and the folded leaf wear the unread dot grey while a listed draft waits, and a press on the mark opens Threads. Max asked for it on the design page.
  • A local server serves its one page at the root of a port, and web storage is per origin, so a page inherited the drafts and tab state of whatever page an earlier server ran on that port. Drafts listed one: a month-old comment draft from another page, shown as JSON, whose press said "That writing place is unavailable". The local server now declares the page's storage scope from its directory (state.page_key); a release keeps its path. Drafts kept under the old unprefixed keys are left behind.
  • A separate commit fixes leaf-dev probe's settle, which failed after any pointer press that closed the panel's view (pre-existing on main).

Max asked for this. Tests: the new test_a_draft_stays_with_its_subject_where_threads_lists_it, test_a_put_away_draft_dots_the_on_me_mark_grey and test_a_served_page_keeps_browser_state_under_its_directory, the updated carry tests, test_rewrites.py -k "resume or restore or refused or discard or kept", pnpm run check:browser and test:runtime pass; stills state threads-drafts shows the before/after.

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

…tch up

Chromium keeps the hover flag on a subtree hidden under the pointer after the
hover moves on, so `settle` failed after any pointer press that closed the
floating panel's view (its ✕, or a row that travels to the page): `:hover`
still ended at `.lf-fp-opened` through every later mouse move, on main and
on this branch alike.
A message draft is now kept under its subject and stays there: the page's
comment, a comment on a passage or element, a comment in a widget's thread
seat, a thread's reply, or a rewrite of a sent message. drafts.js names
those contexts in one table and lists them (`messageDrafts`).

Behaviour that changed:

- Comment on another target opens that target's own draft. Before, an
  explicit Comment on an empty target, or opening a drawing there, moved the
  unsent words to it. The earlier words now stay with their passage, and the
  panel says "Draft kept — g i resumes writing".
- `c` into a thread opens the thread's own reply draft. Before, the
  composer's words moved into an empty reply.
- Threads has a Drafts band above Open. A row reads the draft's words, then
  dim what it is about, and at its end what Send makes of it (Comment,
  Suggestion, Reply, Edit). A press puts the view away and resumes that draft
  in its box (`resumeDraft`, beside the Resume writing command). The page's
  own draft is not listed, since the field under the list holds it.
- A thread's Open row no longer says "Draft"; its reply is listed under
  Drafts.
- Threads still lands on its first thread (`at`), so Enter opens a
  conversation whether or not Drafts stands over it.

- A rewrite of a message the user may no longer rewrite, such as one taken
  back while an answer stands on it, counts as having no box
  (`threadHolding`), so Resume writing or its Drafts row moves its words into
  the page's comment. Before, both stopped at "That writing place is
  unavailable" and the words stayed out of reach.

Unchanged: Resume writing (g i) returns to the last place written in, and
words whose box is gone still move into the page's comment (`moveToPage`,
now the only caller of `transferDraft`). Each paint of Threads reads the
drafts afresh; nothing repaints it on draft news, so another tab's typing
costs this tab nothing.

Tests: the carry expectations become the subject's own draft
(test_comment_follows_*, the refused anchored comment's held reply now
resent from its own passage), the transfer write-failure test goes with the
transfer it tested, and test_a_draft_stays_with_its_subject_where_threads_lists_it
covers the Drafts band and a press on a row.
leaf-agent
leaf-agent previously approved these changes Nov 15, 2026
…ark for drafts

A local server serves its one page at the root of a port, and the browser keeps web
storage per origin, so a page inherited every draft, reading position and tab state
left by whatever page an earlier server ran on the same port. Threads' new Drafts band
listed those: on a page served at 127.0.0.1:55930, a month-old comment draft from
another page showed its record as JSON, and a press on it said "That writing place is
unavailable". The local server now declares the page's storage scope on the root from
the page directory's identity (`state.page_key`), and prepaint reads it before the
canonical root it derives elsewhere. A release keeps its path, which names its page
under its host. Drafts kept under the old unprefixed keys are left behind.

Where no thread has news, the On Me mark and the folded leaf wear the unread dot grey
while a draft Threads lists waits, and a press on the mark opens Threads. The user
asked for this on the design page. With news, the dot keeps meaning news only.
@max-sixty max-sixty changed the title Keep each draft with what it is about, and list drafts in Threads Keep each draft with what it is about, list drafts in Threads, and keep each local page's drafts apart Nov 16, 2026

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

On a local server, returning from a version address to the live page now goes to a 404. goActive in browser/runtime/version.js navigates with location.href = PAGE_SCOPE || "/";, treating the storage scope as the live root's path. The new _delivery scope is f"{page_key(self.page_dir)[:16]}{self.page_root}/", a relative string like 0123456789abcdef/, so from /versions/v2.html the latest chip (latest: goActive) resolves to /versions/0123456789abcdef/ instead of /. Before this commit the local scope was "", so the fallback "/" applied.

The scope is no longer a path, so navigation should read the declared root instead: PAGE_ROOT from context.js (the canonical link's href), e.g. location.href = PAGE_ROOT ?? "/";. After that, version.js would be the only reader of PAGE_SCOPE outside storage, so the import can go.

goActive navigated to PAGE_SCOPE, which named the page's root only while the scope was
its path. A local page's scope is now its directory's identity, so from a version
address the chip opened /versions/<scope>/, a 404. It reads the canonical page root
(context.js, PAGE_ROOT). Found by the leaf-agent review; the older-version journey test
fails on the previous code and passes on this.
main prefixed every theme token (#6025), so --muted no longer exists and the grey dot's
rule read nothing; test_every_token_a_sheet_reads_is_set_somewhere caught it on the PR's
merge with main.
@max-sixty
max-sixty merged commit 35dc495 into main Nov 16, 2026
5 checks passed
@max-sixty
max-sixty deleted the canonical-drafts branch November 16, 2026 02:51
max-sixty added a commit that referenced this pull request Nov 16, 2026
…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 added a commit that referenced this pull request Nov 16, 2026
… view reads (#6091)

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_
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]>
leaf-agent added a commit that referenced this pull request Nov 16, 2026
…and a deleted theme section (#6125)

Brings seven comments and docstrings in line with code that changed in
the last day. No code changes.

- **Draft carrying (#6060).** #6060 removed `carry` from `openComposer`,
so a new target opens its own draft and earlier words stay with their
passage. It also dropped the word "Draft" from Threads' row status. Four
comments still described the old behavior:
- `composing/surface.js`'s header said `commentOnTarget` carries an
unsent draft to the new target.
- `composing/aim.js` said an ⌥ press moves the draft onto another
target.
- `composing/selection.js` said an explicit Comment gesture can carry
user text.
  - `floating-panel.js` said a drafted Threads row says "Draft".
- **Other pages (#6068).** The served `others` list became `/api/pages`,
but `server.py`'s docstring for the machine key still named the `others`
menu.
- **Theme tokens (#6025).** `tests/browser/test_render_anchors.py` cited
`package-themes.md`'s "Theme colors" section, which #6025 replaced with
"Theme tokens".
- **`renderQuiet` (#6070).** Its new comment said it runs as a message's
markup arrives. `paintDeclaredWords` also runs it on the page at upgrade
and on a revision's roots.

Found by the nightly review of the commits since the last run.

Co-authored-by: leaf-agent <[email protected]>
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
…view journey (#6186)

Since #6060, Threads lists a kept draft under **Drafts**, and a list
opened by a key lands on its first row; the view keeps focus itself only
where it lists nothing (`focusView` in
`browser/runtime/floating-panel.js`). The visual review journey leaves
"Restore Back to releases" in a comment field, presses Escape, then `g`
`Shift+T` twice, and both steps still expected focus on the empty
Threads view. With the draft now listed, the key lands on the draft's
row, as #6060's landing rule says it should when no thread is open. The
test now expects that row, and checks that it shows the journey's draft.

This changes only the test. #6060's description says `g T` "still lands
on the first thread"; with no open thread, the fallback to the first row
is the documented rule, so the code is not changed.


`test_an_authenticated_navigation_journey_becomes_credential_free_review_evidence`
fails on `main` at `f1b367375` with the reported `to_be_focused` error
and passes with this change, run locally by node id.

Closes #6177 — 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