Skip to content

fix(sync): show preview popup after loopback sign-in#80

Draft
vreshch wants to merge 1 commit into
masterfrom
feature/popup-onauth
Draft

fix(sync): show preview popup after loopback sign-in#80
vreshch wants to merge 1 commit into
masterfrom
feature/popup-onauth

Conversation

@vreshch

@vreshch vreshch commented Jul 6, 2026

Copy link
Copy Markdown
Member

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.1 listener and auth-flow finishes the exchange in signInViaLoopback -> 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 onSignedIn callback to auth-flow, invoked once from exchangeAndStore - the shared tail of both the loopback and obsidian:// 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 run exchangeAndStore).

  • main wires onSignedIn: () => this.autoSyncOnReady(true) next to the existing onChange.
  • The now-redundant autoSyncOnReady(true) is dropped from the protocol handler (its re-render + popup are both driven by onChange/onSignedIn now).

Net: the popup fires exactly once per sign-in, on either path.

Tests

Added to auth-flow.test.ts:

  • onSignedIn fires exactly once on the obsidian:// (handleCallback) path
  • onSignedIn fires exactly once on the loopback path
  • onSignedIn does NOT fire on disconnect or on a 4xx session expiry

npm run verify + npm run test:coverage green (88 tests; branch coverage 79% > 70%).

#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.
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🎉 PR Validation ✅ PASSED

Commit: 13630c8e01184000d5291ac03b20c648f9863f6a
Branch: feature/popup-onauth

Checks:

  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests + coverage passed
  • ✅ Build successful
  • ✅ Store-compliance checks passed
  • ✅ Bundle is mobile-safe

Ready to merge!


🔗 View workflow run

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