Skip to content

Commit 33ddebb

Browse files
committed
fix(macos): prioritize onboarding before lock screen
Signed-off-by: xunzhuo <xunzhuo@vllm-semantic-router.ai>
1 parent 9db8bd5 commit 33ddebb

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

apps/macos/Sources/AppModel.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,14 @@ final class ElephantAppModel: ObservableObject {
12631263
return UserDefaults.standard.bool(forKey: key)
12641264
}
12651265

1266+
private static func hasCompletedOnboarding() -> Bool {
1267+
UserDefaults.standard.bool(forKey: onboardingCompleteKey)
1268+
}
1269+
12661270
private static func shouldPresentLaunchLockScreen() -> Bool {
1267-
!onboardingPreviewMode && storedAppLockPasswordRecord() != nil
1271+
!onboardingPreviewMode
1272+
&& hasCompletedOnboarding()
1273+
&& storedAppLockPasswordRecord() != nil
12681274
}
12691275

12701276
private static func localizedText(_ language: AppLanguage, en: String, zh: String, fr: String, de: String) -> String {
@@ -1360,10 +1366,15 @@ final class ElephantAppModel: ObservableObject {
13601366
try await refreshDashboard()
13611367
corePhase = .ready
13621368
startReadinessPollingIfNeeded()
1363-
if Self.onboardingPreviewMode || !snapshot.hasElephant || snapshot.providerID.isEmpty {
1369+
let needsOnboarding = Self.onboardingPreviewMode || !snapshot.hasElephant || snapshot.providerID.isEmpty
1370+
if needsOnboarding {
1371+
if !Self.onboardingPreviewMode {
1372+
UserDefaults.standard.set(false, forKey: Self.onboardingCompleteKey)
1373+
}
13641374
isSleepDisplayPresented = false
13651375
showingOnboarding = true
13661376
} else if hasAppLockPassword {
1377+
UserDefaults.standard.set(true, forKey: Self.onboardingCompleteKey)
13671378
beginSleepDisplay(reason: "launch")
13681379
}
13691380
if UserDefaults.standard.bool(forKey: Self.onboardingLetterPendingKey) {
@@ -1887,7 +1898,7 @@ final class ElephantAppModel: ObservableObject {
18871898
}
18881899

18891900
func beginSleepDisplay(reason: String = "manual") {
1890-
guard !showingOnboarding else { return }
1901+
guard Self.hasCompletedOnboarding(), !showingOnboarding else { return }
18911902
speechOutput.stop()
18921903
sleepDisplayReason = reason
18931904
sleepUnlockPassword = ""

apps/macos/Sources/Views.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct RootView: View {
2424
.blur(radius: model.showingOnboardingLetterEnvelope ? 8 : 0)
2525
.animation(.easeInOut(duration: 0.18), value: sidebarVisible)
2626

27-
if model.isSleepDisplayPresented {
27+
if model.isSleepDisplayPresented && !model.showingOnboarding {
2828
SleepDisplayView()
2929
.environmentObject(model)
3030
.transition(.opacity.combined(with: .scale(scale: 1.015)))
@@ -70,7 +70,12 @@ struct RootView: View {
7070
.animation(.spring(response: 0.42, dampingFraction: 0.88), value: model.showingOnboardingLetterPrompt)
7171
.animation(.spring(response: 0.46, dampingFraction: 0.86), value: model.showingOnboardingLetterEnvelope)
7272
.onChange(of: model.snapshot.hasElephant) { hasElephant in
73-
if hasElephant {
73+
if hasElephant && !model.snapshot.providerID.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
74+
onboardingComplete = true
75+
}
76+
}
77+
.onChange(of: model.snapshot.providerID) { providerID in
78+
if model.snapshot.hasElephant && !providerID.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
7479
onboardingComplete = true
7580
}
7681
}

0 commit comments

Comments
 (0)