Skip to content

fix: keep a draft write out in the words watch until its answer is heard - #6164

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-6163
Nov 16, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-6163

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The words watch (tests/words_watch.js) stopped counting a draft write as still out as soon as the /api/draft response's headers arrived, but recorded what the server holds only after it had read the response body. A close checked between those two moments found the words in neither draftsOut nor draftsHeld, so stored(words) was false and the watch reported back-saved draft words as lost. Back's close lands in exactly that gap, because closing the editor is what sends the write. This change makes the write settle after its answer is heard, so the words are always in one set or the other. Neither the runtime nor the server changes.

Logging the watch during a run of [draft] showed this order: the write's response arrives, then the close is checked with held: [] and out: {edit:d: {}}, and only then is the answer heard with record.text: "Unsent words.". #6124 introduced the gap when it replaced the watch's localStorage scan with tracking of /api/draft traffic.

Verification: tests/browser/navigation/test_key_scopes.py::test_a_back_gesture_never_throws_away_unsent_words errored at teardown in both [draft] and [rewrite] with -n0 on main (1740bb536), and both cases pass after the change. tests/runtime/words-watch.test.mjs, the draft-related cases of tests/browser/test_render_words_watch.py, and the tab/close cases in tests/browser/drafts/ also pass.

Closes #6163 — automated triage

The words watch removed a draft write from the writes it counts as still out
when the response's headers arrived, but recorded what the server holds only
after reading the body. A close judged between the two found the words in
neither and reported back-saved draft words as lost, which since #6124 failed
both cases of test_a_back_gesture_never_throws_away_unsent_words at teardown.
The write now settles after its answer is heard. No product behavior changes.

Closes #6163
@leaf-agent
leaf-agent merged commit eeb5c1b into main Nov 16, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-6163 branch November 16, 2026 11:13
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.

test_a_back_gesture_never_throws_away_unsent_words: words watch reports back-saved draft words as lost since #6124

1 participant