From 136c1487095392a78990bdcd4bbfd9a6fbcbdf1e Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Sat, 10 Oct 2026 16:25:53 +0800 Subject: [PATCH 1/2] feat(macos): clarify first launch and background operation --- .github/workflows/ci.yml | 4 + apps/macos/Package.swift | 6 + apps/macos/README.md | 17 +++ .../macos/Sequins/Models/AppPreferences.swift | 26 ++++ apps/macos/Sequins/SequinsApp.swift | 43 ++++-- .../ViewModels/AppStateViewModel.swift | 15 +++ .../macos/Sequins/Views/Main/MainWindow.swift | 124 ++++++++++++------ .../Views/Main/MainWindowController.swift | 3 + .../Sequins/Views/Main/WelcomeBanner.swift | 34 +++++ .../Views/Services/ServiceListView.swift | 21 ++- .../Sequins/Views/Settings/SettingsView.swift | 29 +++- .../SequinsTests/AppPreferencesTests.swift | 36 +++++ .../SequinsUITests/FirstUseUITests.swift | 118 +++++++++++++++++ 13 files changed, 424 insertions(+), 52 deletions(-) create mode 100644 apps/macos/Sequins/Models/AppPreferences.swift create mode 100644 apps/macos/Sequins/Views/Main/WelcomeBanner.swift create mode 100644 apps/macos/SequinsTests/AppPreferencesTests.swift create mode 100644 apps/macos/SequinsUITests/FirstUseUITests.swift diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dab72ff..18b18192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,3 +67,7 @@ jobs: - name: Swift test working-directory: apps/macos/SequinsData run: xcrun swift test -Xswiftc -DSPM_BUILD + + - name: Swift app build and unit tests + working-directory: apps/macos + run: xcrun swift test -Xswiftc -DSPM_BUILD diff --git a/apps/macos/Package.swift b/apps/macos/Package.swift index 3a5368c4..2ea1542f 100644 --- a/apps/macos/Package.swift +++ b/apps/macos/Package.swift @@ -22,6 +22,12 @@ let package = Package( path: "Sequins", exclude: ["Assets.xcassets"], swiftSettings: [.swiftLanguageMode(.v5)] + ), + .testTarget( + name: "SequinsTests", + dependencies: ["Sequins"], + path: "SequinsTests", + swiftSettings: [.swiftLanguageMode(.v5)] ) ] ) diff --git a/apps/macos/README.md b/apps/macos/README.md index 38f714ce..5c000788 100644 --- a/apps/macos/README.md +++ b/apps/macos/README.md @@ -8,6 +8,23 @@ Sequins is a local-first observability tool that provides an embedded OTLP endpo ## Features +### Starting and closing Sequins + +Sequins opens its main window by default and always keeps an icon in the menu bar. +Closing the window leaves the app running and telemetry collection active. Click +the menu bar icon and choose **Open Sequins** to reopen it, or **Quit** to stop it. + +To start in the background, open **Settings → General** and turn off **Show main +window when starting**. This preference applies the next time you open the app; +it does not close an already-open window. Menu bar visibility is always enabled. + +On first use, the window explains background operation. Until services arrive, +the local environment shows its configured OTLP endpoints and a copyable exporter +configuration. For remote environments, check the daemon's connection settings +and send telemetry to the daemon instead. + +### Telemetry views + - **Two-Column Layout**: Service list sidebar with main content area - **Tab-Based Navigation**: Traces, Logs, Metrics, Profiles tabs along the top - **Traces View**: Table view of distributed traces with filtering diff --git a/apps/macos/Sequins/Models/AppPreferences.swift b/apps/macos/Sequins/Models/AppPreferences.swift new file mode 100644 index 00000000..9a269e2e --- /dev/null +++ b/apps/macos/Sequins/Models/AppPreferences.swift @@ -0,0 +1,26 @@ +import Foundation +import Observation + +/// App-wide UI preferences, independent of connection environments. +@Observable +final class AppPreferences { + @ObservationIgnored private let defaults: UserDefaults + + var showMainWindowOnLaunch: Bool { + didSet { defaults.set(showMainWindowOnLaunch, forKey: "showMainWindowOnLaunch") } + } + var hasAcknowledgedWelcome: Bool { + didSet { defaults.set(hasAcknowledgedWelcome, forKey: "hasAcknowledgedWelcome") } + } + + init(defaults: UserDefaults = .standard) { + self.defaults = defaults + showMainWindowOnLaunch = defaults.object(forKey: "showMainWindowOnLaunch") == nil + ? true : defaults.bool(forKey: "showMainWindowOnLaunch") + hasAcknowledgedWelcome = defaults.bool(forKey: "hasAcknowledgedWelcome") + } + + func shouldOpenMainWindow(environment: [String: String]) -> Bool { + showMainWindowOnLaunch || environment["SEQUINS_AUTO_OPEN_WINDOW"] != nil + } +} diff --git a/apps/macos/Sequins/SequinsApp.swift b/apps/macos/Sequins/SequinsApp.swift index d4b542ac..60d19670 100644 --- a/apps/macos/Sequins/SequinsApp.swift +++ b/apps/macos/Sequins/SequinsApp.swift @@ -5,6 +5,7 @@ import SequinsData @main struct SequinsApp: App { + @NSApplicationDelegateAdaptor(SequinsAppDelegate.self) private var appDelegate @State private var appState: AppStateViewModel private let modelContainer: ModelContainer @@ -36,20 +37,10 @@ struct SequinsApp: App { // print("🚀 SequinsApp: OTLP server starting on app launch") self._appState = State(initialValue: state) + appDelegate.appState = state // Set up notification service setupNotifications(appState: state) - - // Demo/QA hook: auto-open the main window on launch when requested, so the - // menu-bar app can be driven headlessly. No-op unless the env var is set. - if let tabName = ProcessInfo.processInfo.environment["SEQUINS_AUTO_OPEN_WINDOW"] { - let tab = NavigationItem(rawValue: tabName) ?? .assistant - let launchState = state - DispatchQueue.main.async { - MainWindowController.shared.showWindow(appState: launchState, selectedTab: tab) - NSApp.activate(ignoringOtherApps: true) - } - } } private func setupNotifications(appState: AppStateViewModel) { @@ -86,6 +77,7 @@ struct SequinsApp: App { .environment(appState) } label: { MenuBarIconLabel() + .accessibilityLabel("Sequins") } .menuBarExtraStyle(.window) @@ -98,6 +90,35 @@ struct SequinsApp: App { } } +@MainActor +final class SequinsAppDelegate: NSObject, NSApplicationDelegate { + weak var appState: AppStateViewModel? + + func applicationDidFinishLaunching(_ notification: Notification) { + openWindowIfRequested() + } + + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { + openWindowIfRequested() + return false + } + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + false // Collection continues through the permanent menu bar app. + } + + private func openWindowIfRequested() { + guard let appState else { return } + let environment = ProcessInfo.processInfo.environment + guard appState.preferences.shouldOpenMainWindow(environment: environment) else { return } + // Preserve the QA hook's tab selection and precedence over background mode. + let tab = environment["SEQUINS_AUTO_OPEN_WINDOW"].map { + NavigationItem(rawValue: $0) ?? .assistant + } ?? .health + MainWindowController.shared.showWindow(appState: appState, selectedTab: tab) + } +} + private struct MenuBarIconLabel: View { private static let icon: NSImage? = Bundle.main.url(forResource: "MenuBarIcon", withExtension: "tiff") .flatMap { NSImage(contentsOf: $0) } diff --git a/apps/macos/Sequins/ViewModels/AppStateViewModel.swift b/apps/macos/Sequins/ViewModels/AppStateViewModel.swift index 7f612f8b..3b72199a 100644 --- a/apps/macos/Sequins/ViewModels/AppStateViewModel.swift +++ b/apps/macos/Sequins/ViewModels/AppStateViewModel.swift @@ -6,6 +6,9 @@ import SequinsData @MainActor @Observable final class AppStateViewModel { + let preferences = AppPreferences() + var serviceDiscoveryState: ServiceDiscoveryState = .loading + var selectedSettingsTab: SettingsTab = .general // Environment management let environmentManager = EnvironmentManager() @@ -107,6 +110,8 @@ final class AppStateViewModel { } func connectToEnvironment(_ environment: ConnectionEnvironment) { + selectedService = nil + serviceDiscoveryState = .loading dataSourceError = nil serverStatus = .starting @@ -188,6 +193,16 @@ final class AppStateViewModel { } } +enum ServiceDiscoveryState: Equatable { + case loading + case ready(hasServices: Bool) + case failed(String) +} + +enum SettingsTab: Hashable { + case general, environments, healthRules +} + enum ServerStatus: Equatable { case stopped case starting diff --git a/apps/macos/Sequins/Views/Main/MainWindow.swift b/apps/macos/Sequins/Views/Main/MainWindow.swift index 85952b8c..f9476e8b 100644 --- a/apps/macos/Sequins/Views/Main/MainWindow.swift +++ b/apps/macos/Sequins/Views/Main/MainWindow.swift @@ -31,6 +31,7 @@ struct MainWindow: View { .navigationSplitViewColumnWidth(min: 160, ideal: 220, max: 300) } detail: { VStack(spacing: 0) { + WelcomeBanner() // Expandable resource attributes panel (service tabs only) if let service = appState.selectedService, appState.isServiceAttributesExpanded { ResourceAttributesPanel(service: service) @@ -221,55 +222,100 @@ struct DetailContentView: View { /// Empty state when no service is selected struct NoServiceSelectedView: View { @Environment(AppStateViewModel.self) private var appState + @Environment(\.openSettings) private var openSettings var body: some View { VStack(spacing: 20) { - Image(systemName: "sidebar.left") - .font(.system(size: 64)) - .foregroundStyle(.secondary) - - Text("Select a Service") - .font(.title2) - .foregroundStyle(.secondary) - - Text("Choose a service from the sidebar to view its telemetry data") - .font(.body) - .foregroundStyle(.tertiary) - .multilineTextAlignment(.center) - .frame(maxWidth: 300) + switch appState.serverStatus { + case .starting: + ProgressView("Starting Sequins…") + case .stopped: + statusMessage("Connect an Environment", icon: "network", message: "Open Settings to connect a local or remote environment.") + Button("Open Environment Settings", action: openEnvironmentSettings) + case .error(let message): + failure(message) + case .running, .connected: + switch appState.serviceDiscoveryState { + case .loading: + ProgressView("Loading services…") + case .failed(let message): + failure(message) + case .ready(hasServices: true): + statusMessage("Select a Service", icon: "sidebar.left", message: "Choose a service from the sidebar to view its telemetry data.") + case .ready(hasServices: false): + gettingStarted + } + } + } + .padding(32) + .frame(maxWidth: .infinity, maxHeight: .infinity) + } + private var gettingStarted: some View { + VStack(spacing: 20) { if case .running(let grpcPort, let httpPort) = appState.serverStatus { - VStack(alignment: .leading, spacing: 8) { - Text("Waiting for telemetry data...") - .font(.caption) - .foregroundStyle(.secondary) - - HStack(spacing: 16) { - VStack(alignment: .leading, spacing: 4) { - Text("gRPC") - .font(.caption2) - .foregroundStyle(.tertiary) - Text("localhost:\(String(grpcPort))") - .font(.system(.caption, design: .monospaced)) - .foregroundStyle(.secondary) - } - - VStack(alignment: .leading, spacing: 4) { - Text("HTTP") - .font(.caption2) - .foregroundStyle(.tertiary) - Text("localhost:\(String(httpPort))") - .font(.system(.caption, design: .monospaced)) - .foregroundStyle(.secondary) - } - } + statusMessage("Send your first telemetry", icon: "antenna.radiowaves.left.and.right", message: "Sequins is ready to receive OpenTelemetry data. Point your application's exporter at one of these local endpoints. Services appear automatically when data arrives.") + VStack(alignment: .leading, spacing: 12) { + endpoint("HTTP", value: "http://localhost:\(httpPort)") + endpoint("gRPC", value: "http://localhost:\(grpcPort)") + Divider() + Text("For an OTLP HTTP/protobuf exporter:") + .font(.caption).foregroundStyle(.secondary) + let configuration = "export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:\(httpPort)\nexport OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf" + Text(configuration) + .font(.system(.caption, design: .monospaced)) + .fixedSize(horizontal: false, vertical: true) + .textSelection(.enabled) + Button("Copy exporter configuration") { copy(configuration) } } - .padding() + .padding(16) .background(Color(nsColor: .controlBackgroundColor)) .clipShape(RoundedRectangle(cornerRadius: 8)) + } else { + statusMessage("Waiting for remote telemetry", icon: "network", message: "No services are available in this environment. Send telemetry to your remote Sequins daemon and verify its connection settings.") + Button("Open Environment Settings", action: openEnvironmentSettings) } + Link("OpenTelemetry instrumentation guide", destination: URL(string: "https://opentelemetry.io/docs/languages/")!) } - .frame(maxWidth: .infinity, maxHeight: .infinity) + .frame(maxWidth: 560) + } + + private func statusMessage(_ title: String, icon: String, message: String) -> some View { + VStack(spacing: 16) { + Image(systemName: icon).font(.system(size: 48)).foregroundStyle(.secondary) + Text(title).font(.title2) + Text(message).foregroundStyle(.secondary).multilineTextAlignment(.center) + } + } + + private func failure(_ message: String) -> some View { + VStack(spacing: 16) { + statusMessage("Couldn’t Load Telemetry", icon: "exclamationmark.triangle", message: message) + HStack { + Button("Retry") { appState.reconnect() } + Button("Open Environment Settings", action: openEnvironmentSettings) + } + } + .frame(maxWidth: 560) + } + + private func endpoint(_ label: String, value: String) -> some View { + HStack { + Text(label).frame(width: 45, alignment: .leading) + Text(value).font(.system(.body, design: .monospaced)).textSelection(.enabled) + Spacer() + Button("Copy \(label) endpoint") { copy(value) } + } + } + + private func copy(_ value: String) { + NSPasteboard.general.clearContents() + NSPasteboard.general.setString(value, forType: .string) + } + + private func openEnvironmentSettings() { + appState.selectedSettingsTab = .environments + openSettings() } } diff --git a/apps/macos/Sequins/Views/Main/MainWindowController.swift b/apps/macos/Sequins/Views/Main/MainWindowController.swift index e2425277..80b309e0 100644 --- a/apps/macos/Sequins/Views/Main/MainWindowController.swift +++ b/apps/macos/Sequins/Views/Main/MainWindowController.swift @@ -13,6 +13,9 @@ final class MainWindowController { private init() {} func showWindow(appState: AppStateViewModel, selectedTab: NavigationItem = .health) { + if let window, window.isMiniaturized { + window.deminiaturize(nil) + } if let existingWindow = window, existingWindow.isVisible { existingWindow.makeKeyAndOrderFront(nil) NSApp.activate(ignoringOtherApps: true) diff --git a/apps/macos/Sequins/Views/Main/WelcomeBanner.swift b/apps/macos/Sequins/Views/Main/WelcomeBanner.swift new file mode 100644 index 00000000..38706baf --- /dev/null +++ b/apps/macos/Sequins/Views/Main/WelcomeBanner.swift @@ -0,0 +1,34 @@ +import SwiftUI + +struct WelcomeBanner: View { + @Environment(AppStateViewModel.self) private var appState + @Environment(\.openSettings) private var openSettings + + var body: some View { + if !appState.preferences.hasAcknowledgedWelcome { + HStack(alignment: .top, spacing: 16) { + Image(systemName: "menubar.rectangle") + .font(.title2) + .foregroundStyle(.tint) + VStack(alignment: .leading, spacing: 6) { + Text("Welcome to Sequins").font(.headline) + Text("Sequins keeps collecting telemetry when you close this window. Reopen it from the Sequins menu bar icon. You can change startup behavior in Settings.") + .font(.callout) + .foregroundStyle(.secondary) + HStack { + Button("Open Settings") { + appState.selectedSettingsTab = .general + openSettings() + } + Button("Got it") { appState.preferences.hasAcknowledgedWelcome = true } + } + } + Spacer(minLength: 0) + } + .padding(20) + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color.accentColor.opacity(0.06)) + Divider() + } + } +} diff --git a/apps/macos/Sequins/Views/Services/ServiceListView.swift b/apps/macos/Sequins/Views/Services/ServiceListView.swift index ac03050b..3301af22 100644 --- a/apps/macos/Sequins/Views/Services/ServiceListView.swift +++ b/apps/macos/Sequins/Views/Services/ServiceListView.swift @@ -15,7 +15,9 @@ struct ServiceListView: View { @Bindable var appState = appState List(selection: $selectedServiceName) { - if isLoading { + if case .failed(let message) = appState.serviceDiscoveryState { + ContentUnavailableView("Couldn’t Load Services", systemImage: "exclamationmark.triangle", description: Text(message)) + } else if isLoading { ProgressView() .frame(maxWidth: .infinity, alignment: .center) } else if services.isEmpty { @@ -95,7 +97,16 @@ struct ServiceListView: View { liveStream?.cancel() liveStream = nil } + .onChange(of: liveStream?.errorMessage) { _, message in + if let message { + isLoading = false + appState.serviceDiscoveryState = .failed(message) + } + } .onChange(of: services) { _, newServices in + if !isLoading, liveStream != nil, liveStream?.errorMessage == nil { + appState.serviceDiscoveryState = .ready(hasServices: !newServices.isEmpty) + } // Auto-select first service if none selected if appState.selectedService == nil, let first = newServices.first { selectedServiceName = first.name @@ -118,7 +129,10 @@ struct ServiceListView: View { liveStream = nil resourceRows = [] services = [] + selectedServiceName = nil isLoading = true + appState.serviceDiscoveryState = .loading + let sourceId = appState.dataSourceId do { let stream = try dataSource.executeLiveSeQL( @@ -126,12 +140,15 @@ struct ServiceListView: View { stream.onSchemaCallback = { _ in Task { @MainActor in + guard appState.dataSourceId == sourceId else { return } self.isLoading = false + appState.serviceDiscoveryState = .ready(hasServices: !services.isEmpty) } } stream.onBatchCallback = { batch, _ in Task { @MainActor in + guard appState.dataSourceId == sourceId else { return } self.resourceRows.append(contentsOf: self.parseRows(from: batch)) self.rebuildServices() } @@ -139,6 +156,7 @@ struct ServiceListView: View { stream.onDeltaCallback = { ops in Task { @MainActor in + guard appState.dataSourceId == sourceId else { return } for op in ops { switch op.type { case .append: @@ -162,6 +180,7 @@ struct ServiceListView: View { } catch { print("[ServiceListView] Failed to start live stream: \(error)") isLoading = false + appState.serviceDiscoveryState = .failed(error.localizedDescription) } } diff --git a/apps/macos/Sequins/Views/Settings/SettingsView.swift b/apps/macos/Sequins/Views/Settings/SettingsView.swift index 3c113871..eeac0a56 100644 --- a/apps/macos/Sequins/Views/Settings/SettingsView.swift +++ b/apps/macos/Sequins/Views/Settings/SettingsView.swift @@ -4,7 +4,11 @@ struct SettingsView: View { @Environment(AppStateViewModel.self) private var appState var body: some View { - TabView { + @Bindable var appState = appState + TabView(selection: $appState.selectedSettingsTab) { + GeneralSettingsView() + .tabItem { Label("General", systemImage: "gearshape") } + .tag(SettingsTab.general) // Environments tab HSplitView { // Environment list sidebar @@ -18,17 +22,40 @@ struct SettingsView: View { .tabItem { Label("Environments", systemImage: "network") } + .tag(SettingsTab.environments) // Health rules tab HealthRulesSettingsView() .tabItem { Label("Health Rules", systemImage: "heart.text.square") } + .tag(SettingsTab.healthRules) } .frame(width: 700, height: 500) } } +private struct GeneralSettingsView: View { + @Environment(AppStateViewModel.self) private var appState + + var body: some View { + @Bindable var preferences = appState.preferences + Form { + Section("Startup") { + Toggle("Show main window when starting", isOn: $preferences.showMainWindowOnLaunch) + .toggleStyle(.checkbox) + Text("When disabled, Sequins opens in the background. Use the menu bar icon to open the main window.") + .font(.caption) + .foregroundStyle(.secondary) + } + Section("Background operation") { + Text("Sequins always appears in the menu bar. Closing the main window keeps telemetry collection running. Choose Quit from the menu bar to stop Sequins.") + } + } + .formStyle(.grouped) + } +} + struct EnvironmentDetailView: View { @Environment(AppStateViewModel.self) private var appState diff --git a/apps/macos/SequinsTests/AppPreferencesTests.swift b/apps/macos/SequinsTests/AppPreferencesTests.swift new file mode 100644 index 00000000..bfae29a5 --- /dev/null +++ b/apps/macos/SequinsTests/AppPreferencesTests.swift @@ -0,0 +1,36 @@ +import Foundation +import Testing +@testable import Sequins + +struct AppPreferencesTests { + @Test func firstLaunchShowsWindowUntilUserOptsOut() { + let domain = "SequinsTests.\(UUID().uuidString)" + let defaults = UserDefaults(suiteName: domain)! + defer { defaults.removePersistentDomain(forName: domain) } + + let preferences = AppPreferences(defaults: defaults) + #expect(preferences.shouldOpenMainWindow(environment: [:])) + preferences.showMainWindowOnLaunch = false + let reloaded = AppPreferences(defaults: defaults) + #expect(!reloaded.shouldOpenMainWindow(environment: [:])) + #expect(reloaded.shouldOpenMainWindow(environment: ["SEQUINS_AUTO_OPEN_WINDOW": "Health"])) + reloaded.showMainWindowOnLaunch = true + #expect(AppPreferences(defaults: defaults).shouldOpenMainWindow(environment: [:])) + // UserDefaults launch arguments use strings rather than stored Bool values. + defaults.set("NO", forKey: "showMainWindowOnLaunch") + #expect(!AppPreferences(defaults: defaults).shouldOpenMainWindow(environment: [:])) + } + + @Test func welcomeAcknowledgementPersistsIndependentlyOfLaunchPreference() { + let domain = "SequinsTests.\(UUID().uuidString)" + let defaults = UserDefaults(suiteName: domain)! + defer { defaults.removePersistentDomain(forName: domain) } + + let preferences = AppPreferences(defaults: defaults) + #expect(!preferences.hasAcknowledgedWelcome) + preferences.hasAcknowledgedWelcome = true + let reloaded = AppPreferences(defaults: defaults) + #expect(reloaded.hasAcknowledgedWelcome) + #expect(reloaded.showMainWindowOnLaunch) + } +} diff --git a/apps/macos/SequinsUITests/FirstUseUITests.swift b/apps/macos/SequinsUITests/FirstUseUITests.swift new file mode 100644 index 00000000..a0410484 --- /dev/null +++ b/apps/macos/SequinsUITests/FirstUseUITests.swift @@ -0,0 +1,118 @@ +import XCTest + +final class FirstUseUITests: XCTestCase { + private var testHome: URL! + + private func makeApp() -> XCUIApplication { + let app = XCUIApplication() + // Isolate SwiftData, telemetry storage, and preferences from the user's app. + app.launchEnvironment["CFFIXED_USER_HOME"] = testHome.path + return app + } + + override func setUpWithError() throws { + continueAfterFailure = false + testHome = FileManager.default.temporaryDirectory.appendingPathComponent("SequinsUITests-\(UUID().uuidString)") + try FileManager.default.createDirectory(at: testHome, withIntermediateDirectories: true) + } + + override func tearDownWithError() throws { + XCUIApplication().terminate() + try FileManager.default.removeItem(at: testHome) + } + + @MainActor + func testForegroundLaunchShowsMainWindow() throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "YES"] + app.launch() + XCTAssertTrue(app.windows.firstMatch.waitForExistence(timeout: 10)) + } + + @MainActor + func testBackgroundLaunchDoesNotShowMainWindow() throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "NO"] + app.launch() + XCTAssertFalse(app.windows.firstMatch.waitForExistence(timeout: 3)) + XCTAssertEqual(app.state, .runningBackground) + } + + @MainActor + func testQAOverrideOpensWindowInBackgroundMode() throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "NO"] + app.launchEnvironment["SEQUINS_AUTO_OPEN_WINDOW"] = "Health" + app.launch() + XCTAssertTrue(app.windows.firstMatch.waitForExistence(timeout: 10)) + } + + @MainActor + func testWelcomeCanBeDismissed() throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "YES", "-hasAcknowledgedWelcome", "NO"] + app.launch() + let welcome = app.staticTexts["Welcome to Sequins"] + XCTAssertTrue(welcome.waitForExistence(timeout: 10)) + app.buttons["Got it"].click() + XCTAssertFalse(welcome.exists) + // The main window remains usable after acknowledging the welcome. + XCTAssertTrue(app.windows.firstMatch.exists) + } + + @MainActor + func testWelcomeLinksToStartupPreference() throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "YES", "-hasAcknowledgedWelcome", "NO"] + app.launch() + let settings = app.buttons["Open Settings"] + XCTAssertTrue(settings.waitForExistence(timeout: 10)) + settings.click() + XCTAssertTrue(app.checkBoxes["Show main window when starting"].waitForExistence(timeout: 5)) + } + + @MainActor + func testEmptyLocalEnvironmentExplainsHowToSendTelemetry() throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "YES", "-hasAcknowledgedWelcome", "YES"] + app.launch() + XCTAssertTrue(app.staticTexts["Send your first telemetry"].waitForExistence(timeout: 10)) + XCTAssertTrue(app.buttons["Copy exporter configuration"].exists) + let attachment = XCTAttachment(screenshot: app.screenshot()) + attachment.lifetime = .keepAlways + add(attachment) + } + + @MainActor + func testClosingWindowKeepsCollectorRunningAndMenuBarCanReopenIt() async throws { + let app = makeApp() + app.launchArguments = ["-showMainWindowOnLaunch", "YES", "-hasAcknowledgedWelcome", "YES"] + app.launch() + XCTAssertTrue(app.staticTexts["Send your first telemetry"].waitForExistence(timeout: 10)) + app.windows.firstMatch.buttons[XCUIIdentifierCloseWindow].click() + XCTAssertFalse(app.windows.firstMatch.exists) + + // A successful OTLP response proves that closing the UI leaves ingestion active. + var request = URLRequest(url: URL(string: "http://localhost:4318/v1/traces")!) + request.httpMethod = "POST" + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + request.httpBody = Data("{\"resourceSpans\":[]}".utf8) + let (_, response) = try await URLSession.shared.data(for: request) + XCTAssertEqual((response as? HTTPURLResponse)?.statusCode, 200) + + let statusItem = app.descendants(matching: .statusItem).firstMatch + XCTAssertTrue(statusItem.exists) + if !statusItem.isHittable { + // Reveal an automatically hidden menu bar without changing system settings. + statusItem.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0)) + .withOffset(CGVector(dx: 0, dy: 1 - statusItem.frame.minY)).hover() + let visible = XCTNSPredicateExpectation(predicate: NSPredicate(format: "hittable == true"), object: statusItem) + XCTAssertEqual(XCTWaiter.wait(for: [visible], timeout: 5), .completed) + } + statusItem.click() + let open = app.buttons["Open Sequins"] + XCTAssertTrue(open.waitForExistence(timeout: 5)) + open.click() + XCTAssertTrue(app.windows.firstMatch.waitForExistence(timeout: 5)) + } +} From 099a00c2426e7fb55b0dcdd3ecee5d849b7d53a4 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Sat, 10 Oct 2026 16:43:35 +0800 Subject: [PATCH 2/2] docs: remove unnecessary first-use README additions --- apps/macos/README.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/apps/macos/README.md b/apps/macos/README.md index 5c000788..38f714ce 100644 --- a/apps/macos/README.md +++ b/apps/macos/README.md @@ -8,23 +8,6 @@ Sequins is a local-first observability tool that provides an embedded OTLP endpo ## Features -### Starting and closing Sequins - -Sequins opens its main window by default and always keeps an icon in the menu bar. -Closing the window leaves the app running and telemetry collection active. Click -the menu bar icon and choose **Open Sequins** to reopen it, or **Quit** to stop it. - -To start in the background, open **Settings → General** and turn off **Show main -window when starting**. This preference applies the next time you open the app; -it does not close an already-open window. Menu bar visibility is always enabled. - -On first use, the window explains background operation. Until services arrive, -the local environment shows its configured OTLP endpoints and a copyable exporter -configuration. For remote environments, check the daemon's connection settings -and send telemetry to the daemon instead. - -### Telemetry views - - **Two-Column Layout**: Service list sidebar with main content area - **Tab-Based Navigation**: Traces, Logs, Metrics, Profiles tabs along the top - **Traces View**: Table view of distributed traces with filtering