@lattices/cli 0.4.14 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +5 -7
  2. package/apps/mac/Info.plist +2 -2
  3. package/apps/mac/Lattices.app/Contents/Info.plist +4 -12
  4. package/apps/mac/Lattices.app/Contents/MacOS/Lattices +0 -0
  5. package/bin/lattices-app.ts +110 -17
  6. package/bin/lattices-build +125 -0
  7. package/bin/lattices-dev +89 -16
  8. package/bin/lattices.ts +977 -16
  9. package/docs/agents.md +81 -4
  10. package/docs/ai-chat-ux-review.md +416 -0
  11. package/docs/api.md +135 -3
  12. package/docs/app.md +30 -8
  13. package/docs/config.md +4 -0
  14. package/docs/mouse-gestures.md +60 -1
  15. package/docs/proposals/LAT-004-interactive-overlay-actors.md +1 -1
  16. package/docs/proposals/LAT-005-action-runtime-product-spine.md +914 -0
  17. package/docs/proposals/LAT-006-mira-in-lattices.md +553 -0
  18. package/docs/reference/dewey.config.ts +2 -2
  19. package/docs/release.md +171 -0
  20. package/docs/repo-structure.md +4 -5
  21. package/docs/voice.md +11 -27
  22. package/package.json +9 -10
  23. package/apps/mac/Package.swift +0 -27
  24. package/apps/mac/Sources/AppShell/App.swift +0 -26
  25. package/apps/mac/Sources/AppShell/AppActivationCoordinator.swift +0 -27
  26. package/apps/mac/Sources/AppShell/AppDelegate.swift +0 -189
  27. package/apps/mac/Sources/AppShell/AppServicesBootstrap.swift +0 -25
  28. package/apps/mac/Sources/AppShell/AppShellView.swift +0 -171
  29. package/apps/mac/Sources/AppShell/AppUpdater.swift +0 -305
  30. package/apps/mac/Sources/AppShell/CliActionLauncher.swift +0 -50
  31. package/apps/mac/Sources/AppShell/HomeDashboardView.swift +0 -133
  32. package/apps/mac/Sources/AppShell/HotkeyBootstrap.swift +0 -87
  33. package/apps/mac/Sources/AppShell/KeyRecorderView.swift +0 -210
  34. package/apps/mac/Sources/AppShell/LatticesRuntime.swift +0 -104
  35. package/apps/mac/Sources/AppShell/MainView.swift +0 -847
  36. package/apps/mac/Sources/AppShell/MainWindow.swift +0 -83
  37. package/apps/mac/Sources/AppShell/MenuBarController.swift +0 -177
  38. package/apps/mac/Sources/AppShell/OnboardingView.swift +0 -483
  39. package/apps/mac/Sources/AppShell/PermissionsAssistantView.swift +0 -366
  40. package/apps/mac/Sources/AppShell/PermissionsAssistantWindow.swift +0 -70
  41. package/apps/mac/Sources/AppShell/Preferences.swift +0 -297
  42. package/apps/mac/Sources/AppShell/SettingsView.swift +0 -3163
  43. package/apps/mac/Sources/AppShell/SettingsWindow.swift +0 -34
  44. package/apps/mac/Sources/AppShell/WorkspaceInspectorPresenter.swift +0 -13
  45. package/apps/mac/Sources/Core/Actions/HotkeyManager.swift +0 -256
  46. package/apps/mac/Sources/Core/Actions/HotkeyStore.swift +0 -399
  47. package/apps/mac/Sources/Core/Actions/IntentEngine.swift +0 -988
  48. package/apps/mac/Sources/Core/Actions/IntentSchema.swift +0 -94
  49. package/apps/mac/Sources/Core/Actions/Intents/CreateLayerIntent.swift +0 -54
  50. package/apps/mac/Sources/Core/Actions/Intents/DistributeIntent.swift +0 -56
  51. package/apps/mac/Sources/Core/Actions/Intents/FocusIntent.swift +0 -69
  52. package/apps/mac/Sources/Core/Actions/Intents/HelpIntent.swift +0 -41
  53. package/apps/mac/Sources/Core/Actions/Intents/KillIntent.swift +0 -47
  54. package/apps/mac/Sources/Core/Actions/Intents/LatticeIntent.swift +0 -53
  55. package/apps/mac/Sources/Core/Actions/Intents/LaunchIntent.swift +0 -67
  56. package/apps/mac/Sources/Core/Actions/Intents/ListSessionsIntent.swift +0 -32
  57. package/apps/mac/Sources/Core/Actions/Intents/ListWindowsIntent.swift +0 -30
  58. package/apps/mac/Sources/Core/Actions/Intents/ScanIntent.swift +0 -52
  59. package/apps/mac/Sources/Core/Actions/Intents/SearchIntent.swift +0 -190
  60. package/apps/mac/Sources/Core/Actions/Intents/SwitchLayerIntent.swift +0 -50
  61. package/apps/mac/Sources/Core/Actions/Intents/TileIntent.swift +0 -61
  62. package/apps/mac/Sources/Core/Actions/PaletteCommand.swift +0 -439
  63. package/apps/mac/Sources/Core/Actions/VoiceIntentResolver.swift +0 -713
  64. package/apps/mac/Sources/Core/Companion/CompanionActivityLog.swift +0 -70
  65. package/apps/mac/Sources/Core/Companion/CompanionKeyboardController.swift +0 -141
  66. package/apps/mac/Sources/Core/Companion/LatticesCompanionBridgeServer.swift +0 -454
  67. package/apps/mac/Sources/Core/Companion/LatticesCompanionCockpit.swift +0 -555
  68. package/apps/mac/Sources/Core/Companion/LatticesCompanionSecurityCoordinator.swift +0 -629
  69. package/apps/mac/Sources/Core/Companion/LatticesCompanionTrackpadController.swift +0 -204
  70. package/apps/mac/Sources/Core/Companion/LatticesDeckHost.swift +0 -1463
  71. package/apps/mac/Sources/Core/Daemon/DaemonProtocol.swift +0 -114
  72. package/apps/mac/Sources/Core/Daemon/DaemonServer.swift +0 -427
  73. package/apps/mac/Sources/Core/Daemon/LatticesApi.swift +0 -2965
  74. package/apps/mac/Sources/Core/Desktop/AccessibilityTextExtractor.swift +0 -111
  75. package/apps/mac/Sources/Core/Desktop/AppTypeClassifier.swift +0 -106
  76. package/apps/mac/Sources/Core/Desktop/DesktopModel.swift +0 -331
  77. package/apps/mac/Sources/Core/Desktop/DesktopModelTypes.swift +0 -73
  78. package/apps/mac/Sources/Core/Desktop/InventoryManager.swift +0 -35
  79. package/apps/mac/Sources/Core/Desktop/InventoryPath.swift +0 -43
  80. package/apps/mac/Sources/Core/Desktop/MouseFinder.swift +0 -527
  81. package/apps/mac/Sources/Core/Desktop/OcrModel.swift +0 -467
  82. package/apps/mac/Sources/Core/Desktop/OcrStore.swift +0 -329
  83. package/apps/mac/Sources/Core/Desktop/PlacementSpec.swift +0 -195
  84. package/apps/mac/Sources/Core/Desktop/SessionWindowLocator.swift +0 -139
  85. package/apps/mac/Sources/Core/Desktop/TilePickerView.swift +0 -209
  86. package/apps/mac/Sources/Core/Desktop/WindowCapture.swift +0 -33
  87. package/apps/mac/Sources/Core/Desktop/WindowDragSnapController.swift +0 -429
  88. package/apps/mac/Sources/Core/Desktop/WindowPreviewCard.swift +0 -100
  89. package/apps/mac/Sources/Core/Desktop/WindowPreviewStore.swift +0 -112
  90. package/apps/mac/Sources/Core/Desktop/WindowSelectionStore.swift +0 -76
  91. package/apps/mac/Sources/Core/Desktop/WindowTiler.swift +0 -2222
  92. package/apps/mac/Sources/Core/Input/EventTapBreaker.swift +0 -124
  93. package/apps/mac/Sources/Core/Input/EventTapThread.swift +0 -54
  94. package/apps/mac/Sources/Core/Input/InputCaptureResetCenter.swift +0 -20
  95. package/apps/mac/Sources/Core/Input/KeyboardRemapConfig.swift +0 -69
  96. package/apps/mac/Sources/Core/Input/KeyboardRemapController.swift +0 -346
  97. package/apps/mac/Sources/Core/Input/KeyboardRemapStore.swift +0 -141
  98. package/apps/mac/Sources/Core/Input/MouseGestureConfig.swift +0 -499
  99. package/apps/mac/Sources/Core/Input/MouseGestureController.swift +0 -2583
  100. package/apps/mac/Sources/Core/Input/MouseInputDeviceStore.swift +0 -98
  101. package/apps/mac/Sources/Core/Input/MouseInputEventViewer.swift +0 -272
  102. package/apps/mac/Sources/Core/Input/MouseShortcutStore.swift +0 -170
  103. package/apps/mac/Sources/Core/Input/SecureEventInputMonitor.swift +0 -39
  104. package/apps/mac/Sources/Core/Input/ShapeRecognizer.swift +0 -624
  105. package/apps/mac/Sources/Core/Input/TapBudgetMeter.swift +0 -56
  106. package/apps/mac/Sources/Core/Overlays/AppWindowShell.swift +0 -63
  107. package/apps/mac/Sources/Core/Overlays/CommandMode/CommandModeState.swift +0 -1566
  108. package/apps/mac/Sources/Core/Overlays/CommandMode/CommandModeView.swift +0 -1927
  109. package/apps/mac/Sources/Core/Overlays/CommandMode/CommandModeWindow.swift +0 -196
  110. package/apps/mac/Sources/Core/Overlays/CommandPalette/CommandPaletteView.swift +0 -307
  111. package/apps/mac/Sources/Core/Overlays/CommandPalette/CommandPaletteWindow.swift +0 -67
  112. package/apps/mac/Sources/Core/Overlays/HUD/CheatSheetHUD.swift +0 -576
  113. package/apps/mac/Sources/Core/Overlays/HUD/HUDBottomBar.swift +0 -279
  114. package/apps/mac/Sources/Core/Overlays/HUD/HUDController.swift +0 -1158
  115. package/apps/mac/Sources/Core/Overlays/HUD/HUDLeftBar.swift +0 -849
  116. package/apps/mac/Sources/Core/Overlays/HUD/HUDMinimap.swift +0 -179
  117. package/apps/mac/Sources/Core/Overlays/HUD/HUDRightBar.swift +0 -596
  118. package/apps/mac/Sources/Core/Overlays/HUD/HUDState.swift +0 -367
  119. package/apps/mac/Sources/Core/Overlays/HUD/HUDTopBar.swift +0 -243
  120. package/apps/mac/Sources/Core/Overlays/HUD/LauncherHUD.swift +0 -334
  121. package/apps/mac/Sources/Core/Overlays/HUD/LayerBezel.swift +0 -203
  122. package/apps/mac/Sources/Core/Overlays/OmniSearch/OmniSearchState.swift +0 -280
  123. package/apps/mac/Sources/Core/Overlays/OmniSearch/OmniSearchView.swift +0 -422
  124. package/apps/mac/Sources/Core/Overlays/OmniSearch/OmniSearchWindow.swift +0 -94
  125. package/apps/mac/Sources/Core/Overlays/OverlayPanelShell.swift +0 -241
  126. package/apps/mac/Sources/Core/Overlays/ScreenMap/ScreenMapState.swift +0 -3135
  127. package/apps/mac/Sources/Core/Overlays/ScreenMap/ScreenMapView.swift +0 -3977
  128. package/apps/mac/Sources/Core/Overlays/ScreenMap/ScreenMapWindowController.swift +0 -119
  129. package/apps/mac/Sources/Core/Overlays/ScreenOverlayCanvasController.swift +0 -1217
  130. package/apps/mac/Sources/Core/Overlays/Voice/VoiceCommandWindow.swift +0 -1575
  131. package/apps/mac/Sources/Core/Pi/PiAuthNextStepCard.swift +0 -148
  132. package/apps/mac/Sources/Core/Pi/PiAuthPromptCard.swift +0 -90
  133. package/apps/mac/Sources/Core/Pi/PiChatDock.swift +0 -564
  134. package/apps/mac/Sources/Core/Pi/PiChatSession.swift +0 -1948
  135. package/apps/mac/Sources/Core/Pi/PiInstallCallout.swift +0 -86
  136. package/apps/mac/Sources/Core/Pi/PiProviderSetupCallout.swift +0 -99
  137. package/apps/mac/Sources/Core/Pi/PiWorkspaceView.swift +0 -510
  138. package/apps/mac/Sources/Core/System/Capability.swift +0 -79
  139. package/apps/mac/Sources/Core/System/DiagnosticLog.swift +0 -373
  140. package/apps/mac/Sources/Core/System/EventBus.swift +0 -31
  141. package/apps/mac/Sources/Core/System/PermissionChecker.swift +0 -224
  142. package/apps/mac/Sources/Core/System/ProcessModel.swift +0 -199
  143. package/apps/mac/Sources/Core/System/ProcessQuery.swift +0 -151
  144. package/apps/mac/Sources/Core/System/SystemTelemetryMonitor.swift +0 -273
  145. package/apps/mac/Sources/Core/Voice/AdvisorLearningStore.swift +0 -90
  146. package/apps/mac/Sources/Core/Voice/AgentSession.swift +0 -377
  147. package/apps/mac/Sources/Core/Voice/AudioProvider.swift +0 -555
  148. package/apps/mac/Sources/Core/Voice/HandsOffSession.swift +0 -839
  149. package/apps/mac/Sources/Core/Voice/VoiceChatView.swift +0 -192
  150. package/apps/mac/Sources/Core/Voice/VoxClient.swift +0 -454
  151. package/apps/mac/Sources/Core/Workspace/Project.swift +0 -28
  152. package/apps/mac/Sources/Core/Workspace/ProjectScanner.swift +0 -141
  153. package/apps/mac/Sources/Core/Workspace/SessionLayerStore.swift +0 -285
  154. package/apps/mac/Sources/Core/Workspace/SessionManager.swift +0 -75
  155. package/apps/mac/Sources/Core/Workspace/Terminal/Terminal.swift +0 -259
  156. package/apps/mac/Sources/Core/Workspace/Terminal/TerminalQuery.swift +0 -156
  157. package/apps/mac/Sources/Core/Workspace/Terminal/TerminalSynthesizer.swift +0 -200
  158. package/apps/mac/Sources/Core/Workspace/Tmux/TmuxModel.swift +0 -60
  159. package/apps/mac/Sources/Core/Workspace/Tmux/TmuxQuery.swift +0 -105
  160. package/apps/mac/Sources/Core/Workspace/WorkspaceManager.swift +0 -1027
  161. package/apps/mac/Sources/UI/ActionRow.swift +0 -78
  162. package/apps/mac/Sources/UI/OrphanRow.swift +0 -129
  163. package/apps/mac/Sources/UI/ProjectRow.swift +0 -368
  164. package/apps/mac/Sources/UI/TabGroupRow.swift +0 -178
  165. package/apps/mac/Sources/UI/Theme.swift +0 -164
  166. package/apps/mac/Tests/StageDragTests.swift +0 -333
  167. package/apps/mac/Tests/StageJoinTests.swift +0 -313
  168. package/apps/mac/Tests/StageManagerTests.swift +0 -280
  169. package/apps/mac/Tests/StageTileTests.swift +0 -353
  170. package/swift/Package.swift +0 -20
  171. package/swift/Sources/DeckKit/DeckAction.swift +0 -51
  172. package/swift/Sources/DeckKit/DeckBridgeSecurity.swift +0 -152
  173. package/swift/Sources/DeckKit/DeckCockpit.swift +0 -82
  174. package/swift/Sources/DeckKit/DeckHost.swift +0 -7
  175. package/swift/Sources/DeckKit/DeckManifest.swift +0 -145
  176. package/swift/Sources/DeckKit/DeckRuntimeSnapshot.swift +0 -533
  177. package/swift/Sources/DeckKit/DeckTrackpad.swift +0 -63
  178. package/swift/Sources/DeckKit/DeckValue.swift +0 -93
  179. package/swift/Sources/DeckKit/DeckVoiceError.swift +0 -88
  180. package/swift/Tests/DeckKitTests/DeckKitTests.swift +0 -286
@@ -1,564 +0,0 @@
1
- import SwiftUI
2
-
3
- struct PiChatDock: View {
4
- @ObservedObject var session: PiChatSession
5
- @FocusState private var composerFocused: Bool
6
- @FocusState private var authFieldFocused: Bool
7
- @State private var resizeStartHeight: CGFloat?
8
-
9
- private static let timeFormatter: DateFormatter = {
10
- let formatter = DateFormatter()
11
- formatter.dateFormat = "HH:mm"
12
- return formatter
13
- }()
14
-
15
- var body: some View {
16
- VStack(spacing: 0) {
17
- topHandle
18
-
19
- transcript
20
-
21
- Rectangle()
22
- .fill(Palette.border)
23
- .frame(height: 0.5)
24
-
25
- if session.hasPiBinary && !session.needsProviderSetup {
26
- composer
27
- } else if session.needsProviderSetup {
28
- providerSettingsBar
29
- } else {
30
- PiInstallCallout(session: session, compact: true)
31
- .padding(.horizontal, 10)
32
- .padding(.vertical, 10)
33
- .background(Color.black.opacity(0.62))
34
- }
35
-
36
- Rectangle()
37
- .fill(Palette.border)
38
- .frame(height: 0.5)
39
-
40
- footerBar
41
- }
42
- .frame(maxWidth: .infinity)
43
- .frame(height: session.dockHeight)
44
- .background(
45
- LinearGradient(
46
- colors: [
47
- Color.black.opacity(0.96),
48
- Color(red: 0.02, green: 0.05, blue: 0.03),
49
- ],
50
- startPoint: .top,
51
- endPoint: .bottom
52
- )
53
- )
54
- .overlay(
55
- RoundedRectangle(cornerRadius: 0)
56
- .strokeBorder(Palette.border, lineWidth: 0.5)
57
- )
58
- .onAppear {
59
- session.prepareForDisplay()
60
- if session.hasPiBinary && !session.needsProviderSetup {
61
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
62
- composerFocused = true
63
- }
64
- }
65
- }
66
- }
67
-
68
- private var topHandle: some View {
69
- HStack {
70
- Spacer()
71
-
72
- Capsule()
73
- .fill(Palette.borderLit)
74
- .frame(width: 64, height: 4)
75
-
76
- Spacer()
77
-
78
- Button {
79
- session.isVisible = false
80
- } label: {
81
- Image(systemName: "xmark")
82
- .font(.system(size: 9, weight: .bold))
83
- .foregroundColor(Palette.textMuted)
84
- .padding(6)
85
- .background(
86
- Circle()
87
- .fill(Color.white.opacity(0.03))
88
- .overlay(
89
- Circle()
90
- .strokeBorder(Palette.border, lineWidth: 0.5)
91
- )
92
- )
93
- }
94
- .buttonStyle(.plain)
95
- }
96
- .padding(.horizontal, 10)
97
- .padding(.vertical, 8)
98
- .contentShape(Rectangle())
99
- .gesture(
100
- DragGesture(minimumDistance: 1)
101
- .onChanged { value in
102
- if resizeStartHeight == nil {
103
- resizeStartHeight = session.dockHeight
104
- }
105
- let start = resizeStartHeight ?? session.dockHeight
106
- session.dockHeight = start - value.translation.height
107
- }
108
- .onEnded { _ in
109
- resizeStartHeight = nil
110
- }
111
- )
112
- }
113
-
114
- private var authPanel: some View {
115
- VStack(alignment: .leading, spacing: 10) {
116
- if session.isAuthenticating {
117
- VStack(alignment: .leading, spacing: 4) {
118
- Text("Finish Setup")
119
- .font(Typo.geistMonoBold(10))
120
- .foregroundColor(Palette.text)
121
-
122
- Text("Ignore the rest for a second and just do the next step below.")
123
- .font(Typo.mono(9))
124
- .foregroundColor(Palette.textDim)
125
- .fixedSize(horizontal: false, vertical: true)
126
- }
127
-
128
- HStack(spacing: 8) {
129
- capsuleLabel(session.currentProvider.name.uppercased(), tint: Palette.text)
130
- capsuleLabel("IN PROGRESS", tint: Palette.detach)
131
- Spacer()
132
- }
133
-
134
- if let prompt = session.pendingAuthPrompt {
135
- PiAuthPromptCard(session: session, prompt: prompt, compact: true, focus: $authFieldFocused)
136
- } else {
137
- PiAuthNextStepCard(session: session, compact: true)
138
- }
139
- } else {
140
- if session.needsProviderSetup {
141
- VStack(alignment: .leading, spacing: 4) {
142
- Text("Set Up Your AI")
143
- .font(Typo.geistMonoBold(10))
144
- .foregroundColor(Palette.text)
145
-
146
- Text("Choose a provider, connect it once, and the chat box unlocks automatically.")
147
- .font(Typo.mono(9))
148
- .foregroundColor(Palette.textDim)
149
- .fixedSize(horizontal: false, vertical: true)
150
- }
151
- }
152
-
153
- HStack(spacing: 8) {
154
- Text(session.needsProviderSetup ? "choose provider" : "provider")
155
- .font(Typo.geistMonoBold(9))
156
- .foregroundColor(Palette.textMuted)
157
-
158
- Picker("Provider", selection: $session.authProviderID) {
159
- ForEach(session.providerOptions) { provider in
160
- Text(provider.name).tag(provider.id)
161
- }
162
- }
163
- .labelsHidden()
164
- .pickerStyle(.menu)
165
- .font(Typo.mono(10))
166
-
167
- Spacer()
168
-
169
- capsuleLabel(
170
- session.currentProvider.authMode == .oauth ? "OAUTH" : "TOKEN",
171
- tint: session.currentProvider.authMode == .oauth ? Palette.detach : Palette.running
172
- )
173
- }
174
-
175
- Text(session.currentProvider.helpText)
176
- .font(Typo.mono(10))
177
- .foregroundColor(Palette.textDim)
178
- .fixedSize(horizontal: false, vertical: true)
179
-
180
- if session.currentProvider.authMode == .apiKey {
181
- if session.hasSelectedCredential && !session.isEditingStoredCredential {
182
- HStack(spacing: 8) {
183
- Circle()
184
- .fill(Palette.running)
185
- .frame(width: 6, height: 6)
186
-
187
- Text("credential saved")
188
- .font(Typo.mono(9))
189
- .foregroundColor(Palette.textDim)
190
-
191
- Spacer()
192
-
193
- footerButton("replace") {
194
- session.beginReplacingSelectedCredential()
195
- }
196
-
197
- footerButton("clear") {
198
- session.removeSelectedCredential()
199
- }
200
- }
201
- .padding(.horizontal, 10)
202
- .padding(.vertical, 8)
203
- .background(authCardBackground(tint: Palette.running))
204
- } else {
205
- HStack(spacing: 8) {
206
- SecureField(session.currentProvider.tokenPlaceholder, text: $session.authToken)
207
- .textFieldStyle(.plain)
208
- .font(Typo.mono(11))
209
- .foregroundColor(Palette.text)
210
- .focused($authFieldFocused)
211
- .onSubmit {
212
- session.saveSelectedToken()
213
- }
214
-
215
- footerButton("save key") {
216
- session.saveSelectedToken()
217
- }
218
-
219
- if session.hasSelectedCredential {
220
- footerButton("cancel") {
221
- session.cancelReplacingSelectedCredential()
222
- }
223
- }
224
- }
225
- .padding(.horizontal, 10)
226
- .padding(.vertical, 8)
227
- .background(authCardBackground(tint: Palette.running))
228
- }
229
- } else {
230
- HStack(spacing: 8) {
231
- footerButton("connect") {
232
- session.startSelectedAuthFlow()
233
- }
234
-
235
- if session.hasSelectedCredential {
236
- footerButton("clear") {
237
- session.removeSelectedCredential()
238
- }
239
- }
240
- }
241
- .padding(.horizontal, 10)
242
- .padding(.vertical, 8)
243
- .background(authCardBackground(tint: Palette.running))
244
- }
245
- }
246
-
247
- if !session.isAuthenticating, let notice = session.authNoticeText, !notice.isEmpty {
248
- Text(notice)
249
- .font(Typo.mono(9))
250
- .foregroundColor(Palette.textDim)
251
- .fixedSize(horizontal: false, vertical: true)
252
- }
253
-
254
- if let error = session.authErrorText, !error.isEmpty {
255
- Text(error)
256
- .font(Typo.mono(9))
257
- .foregroundColor(Palette.kill)
258
- .fixedSize(horizontal: false, vertical: true)
259
- }
260
- }
261
- .padding(.horizontal, 10)
262
- .padding(.vertical, 10)
263
- .background(
264
- LinearGradient(
265
- colors: [
266
- Palette.running.opacity(0.07),
267
- Color.black.opacity(0.26),
268
- ],
269
- startPoint: .topLeading,
270
- endPoint: .bottomTrailing
271
- )
272
- )
273
- .onAppear {
274
- focusAuthFieldIfNeeded()
275
- }
276
- .onChange(of: session.authProviderID) { _ in
277
- focusAuthFieldIfNeeded()
278
- }
279
- .onChange(of: session.pendingAuthPrompt?.message) { prompt in
280
- if prompt != nil {
281
- focusAuthFieldIfNeeded()
282
- }
283
- }
284
- }
285
-
286
- private var transcript: some View {
287
- ScrollViewReader { proxy in
288
- ScrollView(.vertical, showsIndicators: true) {
289
- LazyVStack(alignment: .leading, spacing: 8) {
290
- ForEach(session.messages) { message in
291
- row(message)
292
- .id(message.id)
293
- }
294
- }
295
- .padding(.horizontal, 10)
296
- .padding(.vertical, 10)
297
- }
298
- .background(Color.black.opacity(0.35))
299
- .onAppear {
300
- if let last = session.messages.last?.id {
301
- proxy.scrollTo(last, anchor: .bottom)
302
- }
303
- }
304
- .onChange(of: session.messages.count) { _ in
305
- if let last = session.messages.last?.id {
306
- withAnimation(.easeOut(duration: 0.15)) {
307
- proxy.scrollTo(last, anchor: .bottom)
308
- }
309
- }
310
- }
311
- }
312
- }
313
-
314
- private func row(_ message: PiChatMessage) -> some View {
315
- HStack(alignment: .top, spacing: 10) {
316
- VStack(alignment: .leading, spacing: 4) {
317
- capsuleLabel(roleLabel(for: message.role).uppercased(), tint: roleColor(for: message.role))
318
-
319
- Text(timestamp(for: message.timestamp))
320
- .font(Typo.mono(8))
321
- .foregroundColor(Palette.textMuted)
322
- }
323
- .frame(width: 52, alignment: .leading)
324
-
325
- VStack(alignment: .leading, spacing: 6) {
326
- Rectangle()
327
- .fill(roleColor(for: message.role).opacity(0.9))
328
- .frame(width: 14, height: 1.5)
329
-
330
- Text(message.text)
331
- .font(Typo.mono(11))
332
- .foregroundColor(Palette.text)
333
- .textSelection(.enabled)
334
- .frame(maxWidth: .infinity, alignment: .leading)
335
- }
336
- }
337
- .padding(.horizontal, 10)
338
- .padding(.vertical, 9)
339
- .background(
340
- RoundedRectangle(cornerRadius: 6)
341
- .fill(roleColor(for: message.role).opacity(message.role == .assistant ? 0.11 : 0.06))
342
- .overlay(
343
- RoundedRectangle(cornerRadius: 6)
344
- .strokeBorder(roleColor(for: message.role).opacity(0.22), lineWidth: 0.5)
345
- )
346
- )
347
- }
348
-
349
- private var composer: some View {
350
- HStack(spacing: 10) {
351
- HStack(spacing: 8) {
352
- Text(">")
353
- .font(Typo.geistMonoBold(11))
354
- .foregroundColor(Palette.running)
355
-
356
- TextField("Ask about settings...", text: $session.draft, axis: .vertical)
357
- .textFieldStyle(.plain)
358
- .font(Typo.mono(11))
359
- .foregroundColor(Palette.text)
360
- .lineLimit(1...4)
361
- .focused($composerFocused)
362
- .onSubmit {
363
- session.sendDraft()
364
- }
365
- }
366
- .padding(.horizontal, 10)
367
- .padding(.vertical, 9)
368
- .background(
369
- RoundedRectangle(cornerRadius: 6)
370
- .fill(Color.black.opacity(0.38))
371
- .overlay(
372
- RoundedRectangle(cornerRadius: 6)
373
- .strokeBorder(Palette.running.opacity(0.16), lineWidth: 0.5)
374
- )
375
- )
376
-
377
- footerButton("send", tint: Palette.running) {
378
- session.sendDraft()
379
- }
380
- .disabled(session.isSending)
381
- }
382
- .padding(.horizontal, 10)
383
- .padding(.vertical, 10)
384
- .background(Color.black.opacity(0.62))
385
- }
386
-
387
- private var footerBar: some View {
388
- HStack(spacing: 8) {
389
- Circle()
390
- .fill(session.hasPiBinary ? Palette.running : Palette.kill)
391
- .frame(width: 6, height: 6)
392
-
393
- Text("ASSISTANT")
394
- .font(Typo.geistMonoBold(9))
395
- .foregroundColor(Palette.text)
396
-
397
- Text(footerStatusText)
398
- .font(Typo.mono(9))
399
- .foregroundColor(Palette.textMuted)
400
- .lineLimit(1)
401
-
402
- Spacer()
403
-
404
- footerIconButton(systemName: "gearshape") {
405
- SettingsWindowController.shared.showAssistant()
406
- }
407
-
408
- footerButton("reset") {
409
- session.clearConversation()
410
- }
411
- }
412
- .padding(.horizontal, 10)
413
- .padding(.vertical, 7)
414
- .background(Color.white.opacity(0.015))
415
- }
416
-
417
- private var providerSettingsBar: some View {
418
- HStack(alignment: .center, spacing: 8) {
419
- Circle()
420
- .fill(Palette.detach)
421
- .frame(width: 6, height: 6)
422
-
423
- VStack(alignment: .leading, spacing: 2) {
424
- Text("CONNECT A PROVIDER")
425
- .font(Typo.geistMonoBold(9))
426
- .foregroundColor(Palette.text)
427
-
428
- Text("Choose a chat provider in Settings.")
429
- .font(Typo.mono(9))
430
- .foregroundColor(Palette.textDim)
431
- .fixedSize(horizontal: false, vertical: true)
432
- }
433
-
434
- Spacer()
435
-
436
- footerButton("settings", tint: Palette.running) {
437
- SettingsWindowController.shared.showAssistant()
438
- }
439
- }
440
- .padding(.horizontal, 10)
441
- .padding(.vertical, 10)
442
- .background(Color.black.opacity(0.62))
443
- }
444
-
445
- private var footerStatusText: String {
446
- if session.statusText == "idle" || session.needsProviderSetup || session.isAuthenticating || !session.hasPiBinary {
447
- return session.setupStatusSummary
448
- }
449
- return "\(session.currentProvider.name) · \(session.statusText)"
450
- }
451
-
452
- private func focusAuthFieldIfNeeded() {
453
- if session.currentProvider.authMode == .apiKey || session.pendingAuthPrompt != nil {
454
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
455
- authFieldFocused = true
456
- }
457
- }
458
- }
459
-
460
- private var setupLockedBar: some View {
461
- HStack(alignment: .center, spacing: 8) {
462
- Circle()
463
- .fill(Palette.detach)
464
- .frame(width: 6, height: 6)
465
-
466
- VStack(alignment: .leading, spacing: 2) {
467
- Text("SETUP IN PROGRESS")
468
- .font(Typo.geistMonoBold(9))
469
- .foregroundColor(Palette.text)
470
-
471
- Text(session.isAuthenticating
472
- ? "Stay with the setup panel above for now. The chat box unlocks as soon as you finish that step."
473
- : "Finish the setup panel above to unlock the chat box.")
474
- .font(Typo.mono(9))
475
- .foregroundColor(Palette.textDim)
476
- .fixedSize(horizontal: false, vertical: true)
477
- }
478
-
479
- Spacer()
480
- }
481
- .padding(.horizontal, 10)
482
- .padding(.vertical, 10)
483
- .background(Color.black.opacity(0.62))
484
- }
485
-
486
- private func roleLabel(for role: PiChatMessage.Role) -> String {
487
- switch role {
488
- case .system: return "system"
489
- case .user: return "you"
490
- case .assistant: return "assistant"
491
- }
492
- }
493
-
494
- private func roleColor(for role: PiChatMessage.Role) -> Color {
495
- switch role {
496
- case .system: return Palette.detach
497
- case .user: return Palette.textDim
498
- case .assistant: return Palette.running
499
- }
500
- }
501
-
502
- private func timestamp(for date: Date) -> String {
503
- Self.timeFormatter.string(from: date)
504
- }
505
-
506
- private func capsuleLabel(_ text: String, tint: Color) -> some View {
507
- Text(text)
508
- .font(Typo.geistMonoBold(9))
509
- .foregroundColor(tint.opacity(0.95))
510
- .padding(.horizontal, 7)
511
- .padding(.vertical, 4)
512
- .background(
513
- Capsule()
514
- .fill(tint.opacity(0.10))
515
- .overlay(
516
- Capsule()
517
- .strokeBorder(tint.opacity(0.28), lineWidth: 0.5)
518
- )
519
- )
520
- }
521
-
522
- private func footerButton(_ label: String, tint: Color = Palette.textMuted, disabled: Bool = false, action: @escaping () -> Void) -> some View {
523
- Button(label, action: action)
524
- .buttonStyle(.plain)
525
- .font(Typo.geistMonoBold(9))
526
- .foregroundColor(disabled ? Palette.textMuted : tint)
527
- .padding(.horizontal, 8)
528
- .padding(.vertical, 5)
529
- .background(
530
- Capsule()
531
- .fill(Color.white.opacity(0.03))
532
- .overlay(
533
- Capsule()
534
- .strokeBorder(Palette.border, lineWidth: 0.5)
535
- )
536
- )
537
- .opacity(disabled ? 0.65 : 1)
538
- .disabled(disabled)
539
- }
540
-
541
- private func footerIconButton(systemName: String, tint: Color = Palette.textMuted, action: @escaping () -> Void) -> some View {
542
- Button(action: action) {
543
- Image(systemName: systemName)
544
- .font(.system(size: 10, weight: .semibold))
545
- .foregroundColor(tint)
546
- .frame(width: 24, height: 22)
547
- .background(
548
- Capsule()
549
- .fill(Color.white.opacity(0.03))
550
- .overlay(Capsule().strokeBorder(Palette.border, lineWidth: 0.5))
551
- )
552
- }
553
- .buttonStyle(.plain)
554
- }
555
-
556
- private func authCardBackground(tint: Color) -> some View {
557
- RoundedRectangle(cornerRadius: 6)
558
- .fill(tint.opacity(0.06))
559
- .overlay(
560
- RoundedRectangle(cornerRadius: 6)
561
- .strokeBorder(tint.opacity(0.24), lineWidth: 0.5)
562
- )
563
- }
564
- }