Repository navigation
fix(app): keep an open request until the window is connected - #151
Merged
Merged
Conversation
A click on a notification of the old maild after a Flatpak update runs the new launcher, which replaces maild and then hands --open-message to the running window. The window had dropped its client when the old maild stopped, and with it MainWindow and the open-message listener, so the event was lost and the message never opened. The listener and the startup request now live as long as the webview. The latest request waits until a client is connected, and a request that fails because the connection broke is kept for the next client. Fixes #149
A late answer for an older request could select its message after a newer one opened. Each request is now an object, and a lookup applies only while its request is still the pending one. The tests remove a listener on unlisten and settle lookups by hand. Refs #149
bketelsen
approved these changes
Oct 30, 2026
1 task done
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.
Fixes #149.
Cause
After a
flatpak update, a click on a notification of the old maild runs the new launcher (frostmail-open, thenfrostmail --open-message <id>from the latest deployment). The launcher stops the old maild (mailctl shutdown), starts the new one, waits until it answers (about 0.2 s; maild.log in the gate:rpc.shutdown: stoppingat 15:13:16.036,maild startedat 16.235), and runsfrostmail-app --open-message <id>. The single-instance plugin hands it to the running window as theopen-messageevent.But when the old maild stopped, the window's connection closed:
Session(app/src/data/session.tsx) drops its client, unmountsMainWindow, and retries afterRETRY_MS(1 s). Theopen-messagelistener lived inMainWindow(watchOpenRequests), so the event arrived with no listener and was lost.startup_messageholds only the first launch's request, so the remount did not get it either. A later click, with no maild change, worked: the window stayed connected.A second race had the same result: an event that arrives before the window sees the close fails in
message.summariesand was dropped.Fix
app/src/app/openMessage.ts: the listener and thestartup_messagecall now start once per webview and stay. The latest request (a new object for each request) waits in the module until a client is watched, and is cleared after it opens or after maild refuses it. A lookup applies only while its request is still the pending one, so a late answer for an older request changes nothing. A failure with a lost connection (RPCErrorwithCodeNotConnectedfromJsonRpcSession, or a plain error from a failed send) keeps it for the next client.docs/design/desktop.md(One app instance) says so.Tests
app/src/app/openMessage.test.ts, 9 tests (thelistenmock removes its handler on unlisten; deferred lookups settle by hand). On the oldopenMessage.ts, 7 fail: the #149 case (an event with no listener), the lost connection, onestartup_messageacross clients, a newer request replacing an older one, reversed completion, A → B → A, and a client change during a delivery.make ui-check(nsl): passes, 1405 tests.make check: passes.Coder:
github-copilot/claude-sonnet-5.5.Cross-review:
openai/gpt-6.1-sol. The initial review at02a31fdfound 1 blocker (an older request's late lookup could replace a newer selection) and 1 test gap; both fixed in0837252. Re-review 1 at083725250ea5ec05292df3112eb7a001107419c0(base71b37f4): Ready, Blocking: none.Not checked on a real desktop: the update-then-click sequence of the clean-install gate (plan 0013, item 5) was not run again.