Skip to content

fix(deep-link): deliver cold-start auth links via pending state - #153

Merged
Blankll merged 1 commit into
masterfrom
fix/deep-link-cold-start
Sep 16, 2026
Merged

Blankll merged 1 commit into
masterfrom
fix/deep-link-cold-start

Conversation

@Blankll

@Blankll Blankll commented Sep 16, 2026

Copy link
Copy Markdown
Member

The bug

A sqlkit://auth sign-in link that launches the app silently dropped the token. The cold-start branch in setup parsed the URL and called emit("sqlkit://auth")\) — but the webview hadn't started loading yet, and Tauri events are not queued. The frontend's listen()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 (managed Mutex<Option<AuthPayload>>) instead of firing it into the void:

  • Cold start: setup writes the payload; the frontend pulls it via a new consume_pending_auth command after registering its listeners (pull is a query, so no timing dependency).
  • Running instance: the deep-link://new-url listener 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.
  • The frontend funnels both delivery paths through one idempotent 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 .desktop template with %u from #151), click a sqlkit://auth?... link from a cold state and confirm sign-in completes.

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.
@Blankll
Blankll merged commit f84ff80 into master Sep 16, 2026
3 checks passed
@Blankll
Blankll deleted the fix/deep-link-cold-start branch September 16, 2026 16:46
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.

1 participant