Repository navigation
Ask before leaving a page while a comment draft holds only a drawing - #6490
Conversation
A selection composer's draft can hold a drawing and no words. Leaving the page asked first only when a draft held words the server hadn't taken and no write was carrying, so a user who drew on a region, typed nothing, and whose draft write failed (server out of reach, or an exported page) could close or reload the tab with no prompt and lose the drawing. Leaving now asks over a stranded drawing as it does over stranded words. The gap came with 2e39fbb (#6467), whose check read `text.trim()` alone while the drafts list and `giveBackWords` already counted a drawing as content. All three now read one predicate, `holdsWork`. The give-back now trims too, so a draft holding only whitespace no longer counts as its own and takes the given-back payload. Tests: a runtime test that leaving asks while a drawing-only comment draft waits unsaved and not once a write lands, which fails without the change. `pnpm run check` passes.
|
@leaf-agent The new drawing-only regression waits for 20 timer turns, then checks that the unload prompt is absent. That can pass while the draft write is still in flight: the in-flight write itself suppresses the prompt, so the assertion does not show that the drawing reached durable storage. Please synchronize the test with a completed write or durable acknowledgement (including the failed/retried write path), then assert the prompt behavior after that state is established.
|
The two beforeunload tests waited 20 timer turns before each check. A write still in flight also suppresses the prompt, so the final "leaves quietly" assertion could pass before the server took the words or drawing. The fetch mock now records each draft write, and the tests wait until every one has settled and its answer or failure has been heard. After a failed write they assert the draft is still waiting; after the retried write lands they assert the server holds it and nothing waits. Then they check the prompt. Co-Authored-By: Claude <[email protected]>
|
I pushed 52a4e7c. The tests no longer wait a fixed number of timer turns. The fetch mock now records each draft write, and The test now checks the stored state before it reads the prompt:
The test for words-only drafts had the same weakness, so I gave it the same wait and the same checks. The drawing test still fails with the |
The pre-commit oxfmt hook failed on this branch's test file; no behavior changes.
|
@leaf-agent This changed head has already merged, but independent review found a behavior regression that needs a follow-up. Sharing the trimmed-text predicate with
|
|
Agreed, that was a regression. The follow-up is #6506. |
…t words (#6506) #6490 had `giveBackWords` share `holdsWork`, the trimmed predicate the drafts list and the leave prompt read. That changed undo: a box holding only whitespace stopped counting as begun, so undoing a sent message dropped the whitespace and replaced the box's own composer payload (its passage and mode) with the sent message's. `giveBackWords` tests its untrimmed text again; the drafts list and the leave prompt keep sharing `holdsWork`. A new runtime test in `tests/runtime/drafts.test.mjs` gives words back to a `composer:` draft holding only whitespace and checks that the whitespace follows the given-back words and the box keeps its own payload. It fails on `main` and passes with the change; `pnpm run check` passes. --------- Co-authored-by: leaf-agent <[email protected]>
Leaving a page now asks first when a comment draft holds only a drawing that no write has carried to the server. Before, the
beforeunloadcheck that #6467 added counted only a draft's words. A user who drew on a region and typed nothing, while the server was out of reach or on an exported page, could close or reload the tab with no prompt and lose the drawing. SOUL.md is the rule this breaks: "Leaf drops words the user typed only when it knows they no longer want them".browser/runtime/drafts.jsalready counted a drawing as content in two places: the drafts list (listDraft) andgiveBackWords. All three now read one predicate,holdsWork, so they can't drift apart again.draftHasContentanswers a different question and is unchanged.There is one small change in
giveBackWords: it used to testcurrent.textuntrimmed, and it now trims. So a draft holding only whitespace no longer counts as its own work, and the given-back payload replaces it.Verification: a new runtime test in
tests/runtime/drafts.test.mjs, at the same boundary as #6467's test for words. Leaving asks while a drawing-onlycomposer:draft waits with draft writes failing, and stops asking once a write lands. It fails without the change.pnpm run checkpasses.