fix(deep-link): deliver cold-start auth links via pending state - #153
Merged
Merged
Conversation
A sqlkit://auth link that launches the app emitted the parsed payload during setup — long before the webview's listeners existed, and Tauri events are not queued, so the token was silently dropped. Park the payload in a PendingAuthState instead: the cold-start branch writes it, the running-instance listener double-writes it (covering the window before frontend listeners exist) and still emits, and the frontend pulls it via consume_pending_auth after registering its listeners. consume() takes-and-clears so a delivered token can never be replayed.
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.
The bug
A
sqlkit://authsign-in link that launches the app silently dropped the token. The cold-start branch insetupparsed the URL and calledemit("sqlkit://auth")\) — but the webview hadn't started loading yet, and Tauri events are not queued. The frontend'slisten()only registers inonMounted`, several hundred milliseconds later. The URL arrived, the token was parsed, the handoff to the frontend never happened.The fix
Park the parsed payload in a
PendingAuthState(managedMutex<Option<AuthPayload>>) instead of firing it into the void:setupwrites the payload; the frontend pulls it via a newconsume_pending_authcommand after registering its listeners (pull is a query, so no timing dependency).deep-link://new-urllistener now double-writes — stores to the pending slot and emits — covering the window where the app just started and the frontend is still loading.consume()takes-and-clears, so a delivered token can never be replayed.handleAuth(setAuth → refreshEntitlement → ensureActivated), so double delivery is harmless.Listener registration is ordered before the pull, so an event arriving between the two is still received.
Verification
cargo check/cargo test --lib(385 passing)npm test(533 passing) /lint:check/npm run build(vue-tsc)Manual check that remains: on a packaged Linux build (the
.desktoptemplate with%ufrom #151), click asqlkit://auth?...link from a cold state and confirm sign-in completes.