Skip to content

Commit 76cb418

Browse files
steipetePeter Steinbergerclaude
authored
fix(macos): reopen AI choice, fix daemon error text, hand onboarding off to the dashboard custodian (#117921)
* fix(macos): let onboarding replace an auto-connected AI The AI page auto-tests the best detected candidate and connects without asking, then hides every alternative route. Add 'Choose a different AI' to the connected banner: a re-detect pass with auto-activation suppressed that ends at the picker (candidates, provider sign-in, API keys). Also disable the manual key Connect button while another test runs (submitManualKey silently dropped the tap), and isolate a test that read the machine's real resume store. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(macos): surface real daemon errors past the Node banner Gateway daemon failures summarized as 'Node.js v26.5.1' because the summary takes the last non-empty line and Node fatal errors end with a version banner. Drop trailing banner lines and prefer the last error-shaped line above them; all other output keeps its last line. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(macos): hand onboarding off to the dashboard custodian Native onboarding now ends once inference verifies: welcome, connection, install (when needed), AI setup. Finish opens the dashboard at /custodian?onboarding=1, where the custodian onboarding owns memory import, channels, app recommendations, and the hatch (browser-first per the onboarding redesign). The native memory-import and permissions pages leave the first-run flow; 'Set up later' keeps the native ready page. The native navigation bridge gains a validated optional search field so the handoff can request onboarding chrome; the URL fallback carries the query alongside the token fragment. Co-Authored-By: Claude Fable 5 <[email protected]> * refactor(macos): delete the unreachable native memory-import module The dashboard handoff removed the memory-import page from every flow, leaving the module reachable only from tests. CI's dead-code scan rightly flagged the first orphans; remove the whole path (model, page, mascot wiring, tests) instead of trimming symbol by symbol. The dashboard's own memory-import surface owns the feature. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 85a8551 commit 76cb418

29 files changed

Lines changed: 535 additions & 2499 deletions

‎apps/.i18n/native-source.json‎

Lines changed: 151 additions & 335 deletions
Large diffs are not rendered by default.

‎apps/macos/Sources/OpenClaw/AppNavigationActions.swift‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import AppKit
2+
import OpenClawKit
23

34
@MainActor
45
enum AppNavigationActions {
56
static func openDashboard() {
67
DashboardManager.shared.presentDashboard()
78
}
89

10+
/// Post-AI-setup handoff: land in the dashboard's custodian onboarding,
11+
/// which owns everything after working inference (memory import, channels,
12+
/// app recommendations, hatch).
13+
static func openDashboardOnboarding() {
14+
Task { @MainActor in
15+
await DashboardManager.shared.show(
16+
atPath: DashboardRouteMap.custodianPagePath,
17+
search: DashboardRouteMap.custodianOnboardingSearch)
18+
}
19+
}
20+
921
static func openChat(sessionKey: String? = nil, agentID: String? = nil, draft: String? = nil) {
1022
NSApp.activate(ignoringOtherApps: true)
1123
Task { @MainActor in

‎apps/macos/Sources/OpenClaw/DashboardManager.swift‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ final class DashboardManager {
424424
Task { _ = try? await ControlChannel.shared.health(timeout: 3) }
425425
}
426426

427-
func show(atPath path: String) async {
427+
func show(atPath path: String, search: String? = nil) async {
428428
self.navigationGeneration &+= 1
429429
let generation = self.navigationGeneration
430430
do {
@@ -433,9 +433,13 @@ final class DashboardManager {
433433
guard let controller,
434434
let fallbackURL = DashboardRouteMap.dashboardURL(
435435
byAppendingSameAppPath: path,
436+
search: search,
436437
to: controller.dashboardBaseURL)
437438
else { return }
438-
controller.dispatchNativeNavigation(DashboardNativeNavigation(path: path, fallbackURL: fallbackURL))
439+
controller.dispatchNativeNavigation(DashboardNativeNavigation(
440+
path: path,
441+
search: search,
442+
fallbackURL: fallbackURL))
439443
} catch {
440444
guard generation == self.navigationGeneration else { return }
441445
self.showFailure(error)

‎apps/macos/Sources/OpenClaw/DashboardWindow.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ enum DashboardNativeCommand: String {
6363

6464
struct DashboardNativeNavigation: Equatable {
6565
let path: String
66+
var search: String?
6667
let fallbackURL: URL
6768
}
6869

‎apps/macos/Sources/OpenClaw/DashboardWindowController.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,11 +1221,12 @@ extension DashboardWindowController {
12211221
private func evaluateNativeNavigation(_ navigation: DashboardNativeNavigation) {
12221222
let generation = self.navigationGeneration
12231223
let sourceURL = self.currentURL
1224+
let searchLiteral = navigation.search.map(Self.jsStringLiteral) ?? "undefined"
12241225
let script =
12251226
"""
12261227
(() => !window.dispatchEvent(new CustomEvent('openclaw:native-navigate', {
12271228
cancelable: true,
1228-
detail: {path: \(Self.jsStringLiteral(navigation.path))}
1229+
detail: {path: \(Self.jsStringLiteral(navigation.path)), search: \(searchLiteral)}
12291230
})))()
12301231
"""
12311232
Task { @MainActor [weak self] in

‎apps/macos/Sources/OpenClaw/Onboarding.swift‎

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ struct OnboardingView: View {
625625
@State var onboardingSkillsModel = SkillsSettingsModel()
626626
@State var systemAgentState = OnboardingSystemAgentChatState()
627627
@State var aiSetup = OnboardingAISetupModel()
628-
@State var memoryImport = OnboardingMemoryImportModel()
629628
@State var configuredGatewayProbe = OnboardingConfiguredGatewayProbe()
630629
@State var didLoadOnboardingSkills = false
631630
@State var localGatewayProbe: LocalGatewayProbe?
@@ -635,7 +634,6 @@ struct OnboardingView: View {
635634
let systemAgentDefaults: UserDefaults
636635
let aiSetupRouteIdentityProvider: @MainActor () -> String?
637636
let gatewaySelectionPersister: @MainActor () -> Bool
638-
let memoryImportGateway: GatewayConnection
639637

640638
static let windowWidth: CGFloat = 630
641639
static let windowHeight: CGFloat = 752 // ~+10% to fit full onboarding content
@@ -645,7 +643,6 @@ struct OnboardingView: View {
645643
let connectionPageIndex = 1
646644
let cliPageIndex = 2
647645
let aiPageIndex = 3
648-
let memoryImportPageIndex = 4
649646
let onboardingChatPageIndex = 8
650647
let readyPageIndex = 9
651648

@@ -672,45 +669,22 @@ struct OnboardingView: View {
672669

673670
static func pageOrder(
674671
for mode: AppState.ConnectionMode,
675-
requiresCLIInstall: Bool,
676-
memoryImportEligible: Bool = false) -> [Int]
672+
requiresCLIInstall: Bool) -> [Int]
677673
{
678674
switch mode {
679-
case .remote:
680-
// Remote mode skips local Gateway/workspace setup, but its Mac node
681-
// still runs the matching CLI node-host runtime inside the app.
682-
let setupPages = requiresCLIInstall ? [0, 1, 2, 3, 5] : [0, 1, 3, 5]
683-
return setupPages + [9]
675+
case .remote, .local:
676+
// Native onboarding ends once inference works: install (when
677+
// needed) plus AI setup. Everything after — memory import,
678+
// permissions, channels, hatch — belongs to the dashboard's
679+
// custodian onboarding, which Finish opens.
680+
requiresCLIInstall ? [0, 1, 2, 3] : [0, 1, 3]
684681
case .unconfigured:
685-
return [0, 1, 9]
686-
case .local:
687-
let memoryPages = memoryImportEligible ? [4] : []
688-
let setupPages = (requiresCLIInstall ? [0, 1, 2, 3] : [0, 1, 3]) + memoryPages + [5]
689-
return setupPages + [9]
682+
// "Set up later" has no gateway to hand off to; keep the native
683+
// ready page so the flow still ends with a visible outcome.
684+
[0, 1, 9]
690685
}
691686
}
692687

693-
static func shouldIncludeMemoryImportPage(
694-
for mode: AppState.ConnectionMode,
695-
modelEligible: Bool) -> Bool
696-
{
697-
mode == .local && modelEligible
698-
}
699-
700-
static func reconciledPageCursor(
701-
currentPage: Int,
702-
previousOrder: [Int],
703-
newOrder: [Int]) -> Int
704-
{
705-
guard !newOrder.isEmpty else { return 0 }
706-
guard !previousOrder.isEmpty else { return min(max(0, currentPage), newOrder.count - 1) }
707-
let previousCursor = min(max(0, currentPage), previousOrder.count - 1)
708-
let previousPage = previousOrder[previousCursor]
709-
if let exact = newOrder.firstIndex(of: previousPage) { return exact }
710-
if let next = newOrder.firstIndex(where: { $0 > previousPage }) { return next }
711-
return newOrder.count - 1
712-
}
713-
714688
static func shouldActivateLocalGateway(afterCLIInstallFor mode: AppState.ConnectionMode) -> Bool {
715689
mode == .local
716690
}
@@ -727,14 +701,9 @@ struct OnboardingView: View {
727701
}
728702

729703
var pageOrder: [Int] {
730-
let requiresCLIInstall = !self.cliInstalled
731-
let includeMemoryImport = Self.shouldIncludeMemoryImportPage(
732-
for: self.state.connectionMode,
733-
modelEligible: self.memoryImport.pageEligible)
734-
return Self.pageOrder(
704+
Self.pageOrder(
735705
for: self.state.connectionMode,
736-
requiresCLIInstall: requiresCLIInstall,
737-
memoryImportEligible: includeMemoryImport)
706+
requiresCLIInstall: !self.cliInstalled)
738707
}
739708

740709
var pageCount: Int {
@@ -783,7 +752,7 @@ struct OnboardingView: View {
783752
}
784753

785754
var canAdvance: Bool {
786-
!self.isCLIBlocking && !self.isAISetupBlocking && !self.memoryImport.isApplying
755+
!self.isCLIBlocking && !self.isAISetupBlocking
787756
}
788757

789758
struct LocalGatewayProbe: Equatable {
@@ -815,7 +784,6 @@ struct OnboardingView: View {
815784
self.gatewaySelectionPersister = gatewaySelectionPersister ?? {
816785
state.syncGatewayConfigNow()
817786
}
818-
self.memoryImportGateway = aiSetupGateway
819787
_defaultsToLocalGateway = State(
820788
initialValue: !state.onboardingSeen && state.connectionMode == .unconfigured)
821789
_gatewayDiscovery = State(initialValue: discoveryModel)

‎apps/macos/Sources/OpenClaw/OnboardingAISetup.swift‎

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ final class OnboardingAISetupModel {
124124
private let routeIdentityProvider: @MainActor () -> String?
125125
private var started = false
126126
private var attemptToken = UUID()
127+
/// One-shot: the next detection pass lists choices without auto-activating,
128+
/// so the connected-state "choose a different AI" path ends at a picker
129+
/// instead of re-connecting the same auto candidate.
130+
@ObservationIgnored private var suppressNextAutoActivation = false
127131
@ObservationIgnored private var pendingVerification: PendingVerification?
128132
@ObservationIgnored private var pendingActivationOwner: OnboardingSystemAgentResumeStore.ActivationOwner?
129133
@ObservationIgnored private var completedHandoff: CompletedHandoff?
@@ -135,7 +139,9 @@ final class OnboardingAISetupModel {
135139
/// Only a just-completed provider flow may trust setupComplete without re-probing.
136140
@ObservationIgnored private var providerAuthReconciliationPending = false
137141

138-
private struct PersistedActivationState: Equatable {
142+
/// Internal (not private): the persisted-transition helper lives in
143+
/// OnboardingAISetupSupport.swift with the other pure statics.
144+
struct PersistedActivationState: Equatable {
139145
let setupComplete: Bool
140146
let configuredModel: String?
141147
}
@@ -231,6 +237,25 @@ final class OnboardingAISetupModel {
231237
scheduleDetection()
232238
}
233239

240+
/// Escape hatch from a successful auto-connect: re-detect and present every
241+
/// candidate, provider, and API-key route without auto-activating, so the
242+
/// user can replace the auto-chosen AI with one they pick themselves.
243+
func chooseDifferentAI() {
244+
guard self.beginChooseDifferentAI() else { return }
245+
self.scheduleDetection()
246+
}
247+
248+
/// Split from `chooseDifferentAI` so tests can drive the detection await.
249+
@discardableResult
250+
func beginChooseDifferentAI() -> Bool {
251+
guard self.connected else { return false }
252+
self.resetForGatewayChange()
253+
self.suppressNextAutoActivation = true
254+
self.started = true
255+
self.phase = .detecting
256+
return true
257+
}
258+
234259
func showConfiguredGatewayProbeUnavailable() {
235260
guard !self.ownsInferenceTransition ||
236261
self.configuredGatewayProbeUnavailable ||
@@ -658,6 +683,7 @@ final class OnboardingAISetupModel {
658683
self.manualError = nil
659684
self.manualTesting = false
660685
self.showManualEntry = false
686+
self.suppressNextAutoActivation = false
661687
if let authSessionToCancel, let authServerLease {
662688
Task {
663689
await self.gateway.cancelWizardSession(authSessionToCancel, on: authServerLease)
@@ -775,6 +801,13 @@ extension OnboardingAISetupModel {
775801
self.statuses[candidate.kind] = .untried
776802
}
777803
self.phase = .ready
804+
if self.suppressNextAutoActivation {
805+
// "Choose a different AI" pass: list every route and let the
806+
// user pick; auto-activating here would redo the undone choice.
807+
self.suppressNextAutoActivation = false
808+
self.showManualEntry = !self.manualProviders.isEmpty
809+
return
810+
}
778811
if let preparedChoiceID {
779812
// Detection kinds encode the provider-auth choice ID, while
780813
// PrepareOption.brandId owns the model-ref namespace.
@@ -794,14 +827,15 @@ extension OnboardingAISetupModel {
794827
return
795828
}
796829
if let first = autoCandidateAfter(kind: nil) {
797-
// Candidate found: connect without asking. Switching later
798-
// stays one click away while the test runs server-side.
830+
// Candidate found: connect without asking. The connected banner
831+
// keeps "Choose a different AI" so this choice stays reversible.
799832
await self.activate(kind: first.kind, context: context)
800833
} else {
801834
self.showManualEntry = !self.manualProviders.isEmpty
802835
}
803836
} catch {
804837
guard self.isCurrentAttempt(context) else { return }
838+
self.suppressNextAutoActivation = false
805839
self.phase = .ready
806840
self.detectError = Self.transportFailure(error.localizedDescription)
807841
self.showManualEntry = self.candidates.isEmpty
@@ -841,16 +875,6 @@ extension OnboardingAISetupModel {
841875
"No Gateway is selected. Select a Gateway, then try again.")
842876
}
843877

844-
private static func activationTransitionWasPersisted(
845-
expectedModel: String,
846-
before: PersistedActivationState?,
847-
after: PersistedActivationState?) -> Bool
848-
{
849-
guard let before, let after else { return false }
850-
let wasAlreadyPersisted = before.setupComplete && before.configuredModel == expectedModel
851-
return !wasAlreadyPersisted && after.setupComplete && after.configuredModel == expectedModel
852-
}
853-
854878
/// Candidates the automatic ladder may try: skip definitively logged-out
855879
/// installs and anything already attempted.
856880
private func autoCandidateAfter(kind: String?) -> Candidate? {
@@ -1123,16 +1147,6 @@ extension OnboardingAISetupModel {
11231147
activationOwner: activationOwner)
11241148
return self.connected
11251149
}
1126-
1127-
private static func remainingMilliseconds(
1128-
until deadline: ContinuousClock.Instant,
1129-
clock: ContinuousClock,
1130-
cappedAt capMs: Int) -> Int
1131-
{
1132-
let components = clock.now.duration(to: deadline).components
1133-
let milliseconds = components.seconds * 1000 + components.attoseconds / 1_000_000_000_000_000
1134-
return max(0, min(capMs, Int(milliseconds)))
1135-
}
11361150
}
11371151

11381152
extension OnboardingAISetupModel {

‎apps/macos/Sources/OpenClaw/OnboardingAISetupSupport.swift‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,24 @@ extension OnboardingAISetupModel {
261261
var connectedSetupCopyText: String {
262262
connectedSetupLines.joined(separator: "\n")
263263
}
264+
265+
static func activationTransitionWasPersisted(
266+
expectedModel: String,
267+
before: PersistedActivationState?,
268+
after: PersistedActivationState?) -> Bool
269+
{
270+
guard let before, let after else { return false }
271+
let wasAlreadyPersisted = before.setupComplete && before.configuredModel == expectedModel
272+
return !wasAlreadyPersisted && after.setupComplete && after.configuredModel == expectedModel
273+
}
274+
275+
static func remainingMilliseconds(
276+
until deadline: ContinuousClock.Instant,
277+
clock: ContinuousClock,
278+
cappedAt capMs: Int) -> Int
279+
{
280+
let components = clock.now.duration(to: deadline).components
281+
let milliseconds = components.seconds * 1000 + components.attoseconds / 1_000_000_000_000_000
282+
return max(0, min(capMs, Int(milliseconds)))
283+
}
264284
}

‎apps/macos/Sources/OpenClaw/OnboardingAISetupView.swift‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,14 @@ struct OnboardingAISetupView: View {
322322
.buttonStyle(.link)
323323
.font(.caption)
324324
}
325+
326+
Button {
327+
self.model.chooseDifferentAI()
328+
} label: {
329+
Label("Choose a different AI…", systemImage: "arrow.triangle.2.circlepath")
330+
}
331+
.buttonStyle(.link)
332+
.font(.caption)
325333
}
326334
.padding(12)
327335
.frame(maxWidth: .infinity, alignment: .leading)
@@ -858,7 +866,10 @@ struct OnboardingAISetupView: View {
858866
}
859867
}
860868
.buttonStyle(.borderedProminent)
861-
.disabled(self.model.manualTesting ||
869+
// isBusy, not just manualTesting: submitManualKey drops the tap
870+
// while another test runs, so an enabled button would be a
871+
// silent no-op.
872+
.disabled(self.model.isBusy ||
862873
self.model.manualKey.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
863874
}
864875
Text(self.manualProviderHelp)

0 commit comments

Comments
 (0)