Open source CapCut alternative.
TypeScript
feat(app): dismiss onboarding on sign-in and recover a stalled attempt
David Le1a671d50b135
diff --git a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swiftindex 944133cd..59563049 100644--- a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift+++ b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift@@ -122,6 +122,12 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {onboardingWindowController = controllerlet isSignedIn = authCoordinator.isAuthenticated+ // Reopening the sign-in surface means the user is back to try again: clear any stalled attempt+ // (e.g. they dismissed the card on "Continue with Google", then closed the browser) so the button+ // is enabled and ready rather than stuck disabled on `.waitingForCallback`.+ if !isSignedIn {+ authCoordinator.resetSignInIfStalled()+ }let pages = OnboardingTour.pages(isSignedIn: isSignedIn)// Signed-out pages are [sign-in, features...]. `.signIn` opens on the landing (0); `.tour` skips@@ -142,8 +148,11 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {continueButtonTitle: "Continue",finishButtonTitle: "Done",onDismiss: { [weak self] in self?.onboardingWindowController = nil },- signInFooter: isSignedIn ? nil : { [authCoordinator] in- AnyView(OnboardingGoogleSignInFooter(authCoordinator: authCoordinator))+ signInFooter: isSignedIn ? nil : { [weak self, authCoordinator] in+ AnyView(OnboardingGoogleSignInFooter(+ authCoordinator: authCoordinator,+ onContinue: { self?.onboardingWindowController?.close() }+ ))})}diff --git a/apps/Donkey/Sources/Donkey/DonkeyAuthCoordinator.swift b/apps/Donkey/Sources/Donkey/DonkeyAuthCoordinator.swiftindex 6d9900ca..34df7123 100644--- a/apps/Donkey/Sources/Donkey/DonkeyAuthCoordinator.swift+++ b/apps/Donkey/Sources/Donkey/DonkeyAuthCoordinator.swift@@ -227,6 +227,21 @@ final class DonkeyAuthCoordinator: ObservableObject {phase = stateStore.loadSession().map(DonkeyAuthPhase.signedIn) ?? .signedOut}+ /// Returns a stalled or failed sign-in to the ready (signed-out) state so the sign-in button is+ /// enabled and its status line is clear when the onboarding card is (re)shown. The common trigger is+ /// the user dismissing the onboarding card on "Continue with Google", then abandoning the browser:+ /// without this, `phase` would sit at `.waitingForCallback` forever and the button would stay disabled.+ /// A live session or an in-progress exchange is left untouched, and the pending state token is kept so a+ /// late but legitimate callback can still complete.+ func resetSignInIfStalled() {+ switch phase {+ case .openingBrowser, .waitingForCallback, .failed:+ phase = .signedOut+ case .signedOut, .exchangingSession, .signedIn:+ break+ }+ }+/// Drops the local session and its native session cookie, returning to the signed-out state. Callers/// should then surface the login flow again.///diff --git a/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift b/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swiftindex 131119ab..06524186 100644--- a/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift+++ b/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift@@ -131,15 +131,19 @@ private struct DonkeyGoogleSignInScreen<StatusText: View>: View {}/// The sign-in slide's call-to-action inside the onboarding card: the same Google button the login window-/// uses, plus a compact status line that tracks the in-flight sign-in. Tapping it starts the real Google-/// flow; the app delegate closes the onboarding card once `authenticationCompleted` fires.+/// uses, plus a compact status line. Tapping it starts the real Google flow and dismisses the onboarding+/// card (via `onContinue`) so the browser sign-in takes over; `authenticationCompleted` then brings up the+/// authenticated surfaces.struct OnboardingGoogleSignInFooter: View {@ObservedObject var authCoordinator: DonkeyAuthCoordinator+ /// Invoked right after sign-in starts, so the host can dismiss the onboarding card.+ var onContinue: (() -> Void)?var body: some View {VStack(spacing: 8) {Button {authCoordinator.beginGoogleSignIn()+ onContinue?()} label: {GoogleContinueAsset().opacity(buttonIsDisabled ? 0.58 : 1)