Repository navigation
fix(web): clear form drafts even when you sign out before the page loads - #346
Merged
Merged
Conversation
The root layout dropped an account's drafts from a submit handler on the sign-out form, which only exists once the page hydrates. Pressing Sign out before that posted the form natively, the handler never ran, and the drafts stayed in localStorage for whoever used the browser next. /logout now sets an ln_signed_out cookie naming the account, and the root layout drops that account's drafts and the cookie on the next page load, which every sign-out ends in. The submit handler is gone, since this covers it. Drafts of accounts that didn't sign out stay, so a session that lapses mid-form still gets its draft back after signing in again. The inquiry e2e now signs out with the dashboard's scripts held back and checks the draft is gone on the page it lands on.
bnb
previously approved these changes
Oct 31, 2026
Coverage Report for apps/web
File Coverage
SizeCompared with main. KiB are 1,024 bytes.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Conflicts: # apps/web/README.md
botandbang
enabled auto-merge
October 31, 2026 22:58
bnb
approved these changes
Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Form drafts kept in localStorage were dropped by a submit handler in the root layout, which only exists once the page has hydrated. Pressing Sign out before the dashboard hydrated posted the form natively, the handler never ran, and the account's drafts stayed in the browser for whoever used it next. This also made the e2e test "an inquiry from a planner show ... keeps an unsent message" fail about 1 run in 6.
Added:
POST /logoutsets anln_signed_outcookie naming the account that signed out, adding to any DIDs already in it. Every sign-out ends in a full page load, so on that load the root layout drops those accounts' drafts and then deletes the cookie. This works whether or not the page signed out from had hydrated, and the cookie also survives a tab closed before the next page loads. It isn't HttpOnly because the page's scripts read and delete it; it holds only DIDs, isSameSite=LaxandSecureon HTTPS, and lives until the next page load (a year at most).Changed:
clearDrafts(did)inform-draft.svelte.tsbecameclearSignedOutDrafts(), which reads the cookie. The README describes the new behaviour and lists the cookie in the security notes.Removed: the root layout's submit handler for the sign-out form, which the cookie makes redundant (it also cleared drafts when the logout request failed).
Drafts of accounts that didn't sign out are kept, so a session that lapses mid-form and is sent back through sign-in still finds its draft.
Clear-Site-Data: "storage"wasn't used because it clears all of the origin's storage, including the keyboard-shortcuts preference and other accounts' drafts.How it was tested
/hydrates. It failed on main before this change.layout.svelte.test.tscover the startup clearing: only the named accounts' drafts and the cookie go, and nothing is dropped without the cookie.format:check,lint,check,knip,test,test:storybook,test:build,test:coverage(lines 95.46%) andtest:e2e --project chromiumpass locally.Checklist
docs/and--helpstill say what the code does