fix(sync): show preview popup after loopback sign-in#80
Draft
vreshch wants to merge 1 commit into
Draft
Conversation
#78 hooked the post-sign-in sync-preview popup on the obsidian:// protocol-handler callback, but #79 completes desktop sign-in via the loopback server + auth-flow, which never hits that handler - so the popup was missed after a loopback sign-in. Add an onSignedIn callback to auth-flow, fired once from exchangeAndStore (the shared tail of BOTH the loopback and obsidian:// paths), never on sign-out/expiry/startup. main wires it to autoSyncOnReady(true) and drops the now-redundant trigger from the protocol handler, so the popup fires exactly once per sign-in on either path.
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ |
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 gap
#78 shows a sync-preview popup right after sign-in. It hooked that popup on the
obsidian://protocol-handler callback (registerObsidianProtocolHandler(CALLBACK_ACTION, ...) -> autoSyncOnReady(true)).#79 (RFC 8252 loopback) makes desktop sign-in complete a different way: the browser redirects to a
127.0.0.1listener andauth-flowfinishes the exchange insignInViaLoopback->onChange. That path never hits the protocol handler, so after a loopback sign-in (the desktop default) the preview popup never fired.The fix
Add an
onSignedIncallback toauth-flow, invoked once fromexchangeAndStore- the shared tail of both the loopback andobsidian://code-exchange paths. It fires only on a real sign-in, never on sign-out, token-refresh, session-expiry, or startup hydration (those don't runexchangeAndStore).mainwiresonSignedIn: () => this.autoSyncOnReady(true)next to the existingonChange.autoSyncOnReady(true)is dropped from the protocol handler (its re-render + popup are both driven byonChange/onSignedInnow).Net: the popup fires exactly once per sign-in, on either path.
Tests
Added to
auth-flow.test.ts:onSignedInfires exactly once on theobsidian://(handleCallback) pathonSignedInfires exactly once on the loopback pathonSignedIndoes NOT fire on disconnect or on a 4xx session expirynpm run verify+npm run test:coveragegreen (88 tests; branch coverage 79% > 70%).