Skip to content

Windows deep-link sign-in (cascade://) + web/server handoff#14

Merged
JacobStephens2 merged 1 commit into
mainfrom
add-windows-deeplink-signin
Jun 7, 2026
Merged

Windows deep-link sign-in (cascade://) + web/server handoff#14
JacobStephens2 merged 1 commit into
mainfrom
add-windows-deeplink-signin

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

What

Lets a Windows-initiated sign-in finish in the desktop app instead of only the web app, via a cascade:// magic-link handoff. Also fixes a pre-existing bug where the signed-in/out view didn't update on runtime account changes.

Changes

Windows app

  • Self-registers cascade:// via WinAppSDK ActivationRegistrationManager (real Protocol activation; a hand-written HKCU command only yields Launch).
  • Custom Program.Main: single-instance with activation redirection — cascade://auth?token=… signs into the already-running app, no second window.
  • Routes the URI to AppViewModel.SignInWithLinkAsync and brings the window to front. Sends platform: "windows" on /auth/request.

Server (server/src/main.rs)

  • /auth/request accepts optional platform; "windows" appends &app=windows to the emailed link. Backward-compatible; no DB change.

Web (useSync.ts, AccountControls.tsx)

  • When the link carries app=windows, hand the single-use token to cascade:// (with a visible fallback link) instead of verifying in the browser.

Bug fix

  • Signed-in/out panels used x:Bind function bindings on Account that didn't re-evaluate at runtime, stranding the view after sign-out / a 401. Replaced with notified Visibility properties; marshal the 401 path onto the UI thread.

Verified locally

  • cascade://auth?token=… → routes to running app, no second window, writes account.json, GET /listening200 for the new session.
  • Windows dotnet build clean.

Deploy note

"Click email link → opens Windows app" only takes effect once server + web are deployed. A cascade:// link only works when the email is opened on the same Windows machine.

🤖 Generated with Claude Code

Add a magic-link handoff so a Windows-initiated sign-in can complete in the
desktop app instead of only the web app.

Windows app:
- Self-register the cascade:// URI scheme via WinAppSDK
  ActivationRegistrationManager (delivers a real Protocol activation; a
  hand-written HKCU command only yields a Launch activation).
- Custom Program.Main: single-instance with activation redirection, so a
  cascade://auth?token=... handoff signs into the already-running app rather
  than spawning a second window.
- Route the activating URI to the existing sign-in path
  (AppViewModel.SignInWithLinkAsync) and bring the window to front.

Server:
- /auth/request accepts an optional `platform`; "windows" appends
  &app=windows to the emailed link so the web /auth page can hand the
  single-use token to the desktop app instead of consuming it.

Web:
- When the link carries app=windows, hand the token to cascade:// (with a
  visible fallback link) instead of verifying it in the browser.

Also fix a pre-existing bug where the signed-in/out view didn't update on
runtime account changes: replace the x:Bind function-binding visibility
(which didn't re-evaluate on Account changes) with notified Visibility
properties, and marshal the 401 sign-out path onto the UI thread.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JacobStephens2 JacobStephens2 merged commit e524eb1 into main Jun 7, 2026
1 check passed
JacobStephens2 added a commit that referenced this pull request Jun 7, 2026
PR #13's static /auth page shows the magic-link token with a Copy button and
relies on Apple Universal Links to open the native app automatically. Windows
has no Universal Link for an unpackaged app, so the link minted with
&app=windows (server, #14) only ever showed the copy-the-code fallback.

When app=windows is present, redirect to cascade://auth?token=... so the
desktop app launches and signs in, with an "Open Cascade" button as the
fallback if the browser blocks the programmatic protocol navigation. The
copy-the-code path remains for when the app isn't installed.

Co-authored-by: Jacob Stephens <jstephens@vagabondtours.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants