Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion macos/Codescribe/Screens/Onboarding/OnboardingSteps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ struct HotkeyModeStepView: View {

struct AgenticReadinessStepView: View {
@ObservedObject var model: OnboardingViewModel
// macOS 14+ action to open the app's Settings scene. This accessory /
// LSUIElement app has no responder for the private `showSettingsWindow:`
// selector, so the SwiftUI environment action is the only reliable open path
// (matching TrayMenuView / AgentChatView). The Settings scene activates the
// app and orders its window front, above the wizard.
@Environment(\.openSettings) private var openSettings

var body: some View {
VStack(alignment: .leading, spacing: 16) {
Expand Down Expand Up @@ -298,7 +304,8 @@ struct AgenticReadinessStepView: View {
.fixedSize(horizontal: false, vertical: true)
HStack(spacing: 10) {
OnboardingButton(title: "Set up MCP servers", kind: .primary) {
model.openMcpSettings()
model.prepareMcpSettingsDeepLink()
openSettings()
}
OnboardingButton(title: "Skip for now", kind: .secondary) {
model.dismissMcpSetupPrompt()
Expand Down
17 changes: 8 additions & 9 deletions macos/Codescribe/Screens/Onboarding/OnboardingViewModel.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import AppKit
import SwiftUI

// State machine for the first-run wizard: current step index (persisted on every
Expand Down Expand Up @@ -217,15 +216,15 @@ final class OnboardingViewModel: ObservableObject {
mcpStatus = agentStatus.mcpStatus()
}

/// Route the user to the live MCP management surface (Settings › Engine) via a
/// one-shot deep-link, then open the standard Settings window. The wizard stays
/// open behind it, so the user can wire a server and return to continue.
func openMcpSettings() {
/// Arm the one-shot deep-link so the Settings window lands on the MCP surface
/// (Settings › Engine). The view owns the actual open via SwiftUI's
/// `@Environment(\.openSettings)` — the only reliable path in this accessory /
/// LSUIElement app, where the private `showSettingsWindow:` selector has no
/// responder (matching TrayMenuView / AgentChatView). Call this immediately
/// before `openSettings()`; the wizard stays open behind Settings so the user
/// can wire a server and return to continue.
func prepareMcpSettingsDeepLink() {
SettingsDeepLink.pendingSection = .engine
if !NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) {
// Older selector name kept as a defensive fallback.
_ = NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
}
}

/// Dismiss the MCP setup prompt for this session so onboarding proceeds without
Expand Down
Loading