eleven / ocho Public

Clone
git clone https://amadan.net/eleven/ocho

Plain git — no account needed to clone.

Download

Download this file

1import AppKit
2import LChatCore
3import SwiftUI
4
5// 🤖 Settings → Advanced → "Performance": the Mac face of the shared perf
6// instrumentation (LChatCore Perf.swift) — the same consent toggle as the
7// iOS sheet, plus Reveal-in-Finder for the assembled report (the Mac idiom;
8// iOS shares a file instead).
9struct PerfSettingsSection: View {
10 @AppStorage(Perf.consentKey) private var perfDiagnostics = Perf.defaultEnabled
11 @State private var summary: String?
12
13 var body: some View {
14 Section {
15 Toggle("Record performance diagnostics", isOn: $perfDiagnostics)
16 .onChange(of: perfDiagnostics) { _, next in Perf.setRecording(next) }
17 if perfDiagnostics {
18 HStack {
19 Text(summary.map { "Recorded so far: \($0)." } ?? "Nothing recorded yet.")
20 .font(.footnote)
21 .foregroundStyle(.secondary)
22 Spacer()
23 Button("Show Report in Finder") { revealReport() }
24 }
25 }
26 Text("A private log of how long things take — starting the app, opening chats, moments it freezes. It never includes what's in your messages, and it never leaves this Mac unless you share the report yourself.")
27 .font(.footnote)
28 .foregroundStyle(.secondary)
29 } header: {
30 Text("Performance")
31 }
32 .task(id: perfDiagnostics) {
33 guard perfDiagnostics else { return }
34 let events = await Task.detached { Perf.recordedEvents() }.value
35 summary = PerfEvent.summary(events)
36 }
37 }
38
39 private func revealReport() {
40 Task {
41 let url = await Task.detached { Perf.assembleExport() }.value
42 guard let url else { return }
43 NSWorkspace.shared.activateFileViewerSelecting([url])
44 }
45 }
46}
47