@agimon-ai/po-native-dashboard 0.0.0-alpha.10

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 (59) hide show
  1. package/LICENSE +149 -0
  2. package/README.md +5 -0
  3. package/dist/components/ActivityPanel.d.mts +10 -0
  4. package/dist/components/ActivityPanel.d.mts.map +1 -0
  5. package/dist/components/ActivityPanel.mjs +50 -0
  6. package/dist/components/ActivityPanel.mjs.map +1 -0
  7. package/dist/components/CaptureTray.d.mts +12 -0
  8. package/dist/components/CaptureTray.d.mts.map +1 -0
  9. package/dist/components/CaptureTray.mjs +112 -0
  10. package/dist/components/CaptureTray.mjs.map +1 -0
  11. package/dist/components/CompletionSheet.d.mts +46 -0
  12. package/dist/components/CompletionSheet.d.mts.map +1 -0
  13. package/dist/components/CompletionSheet.mjs +392 -0
  14. package/dist/components/CompletionSheet.mjs.map +1 -0
  15. package/dist/components/Composer.d.mts +49 -0
  16. package/dist/components/Composer.d.mts.map +1 -0
  17. package/dist/components/Composer.mjs +451 -0
  18. package/dist/components/Composer.mjs.map +1 -0
  19. package/dist/components/DialogSheet.d.mts +23 -0
  20. package/dist/components/DialogSheet.d.mts.map +1 -0
  21. package/dist/components/DialogSheet.mjs +115 -0
  22. package/dist/components/DialogSheet.mjs.map +1 -0
  23. package/dist/components/MessageActionsSheet.d.mts +16 -0
  24. package/dist/components/MessageActionsSheet.d.mts.map +1 -0
  25. package/dist/components/MessageActionsSheet.mjs +26 -0
  26. package/dist/components/MessageActionsSheet.mjs.map +1 -0
  27. package/dist/components/MoveSessionSheet.d.mts +17 -0
  28. package/dist/components/MoveSessionSheet.d.mts.map +1 -0
  29. package/dist/components/MoveSessionSheet.mjs +145 -0
  30. package/dist/components/MoveSessionSheet.mjs.map +1 -0
  31. package/dist/components/SessionMenus.d.mts +76 -0
  32. package/dist/components/SessionMenus.d.mts.map +1 -0
  33. package/dist/components/SessionMenus.mjs +1187 -0
  34. package/dist/components/SessionMenus.mjs.map +1 -0
  35. package/dist/components/TimelineItem.d.mts +39 -0
  36. package/dist/components/TimelineItem.d.mts.map +1 -0
  37. package/dist/components/TimelineItem.mjs +278 -0
  38. package/dist/components/TimelineItem.mjs.map +1 -0
  39. package/dist/components/sessionGroups.mjs +20 -0
  40. package/dist/components/sessionGroups.mjs.map +1 -0
  41. package/dist/components/sessionTimeline.mjs +20 -0
  42. package/dist/components/sessionTimeline.mjs.map +1 -0
  43. package/dist/components/slotProps.d.mts +23 -0
  44. package/dist/components/slotProps.d.mts.map +1 -0
  45. package/dist/components/slotProps.mjs +68 -0
  46. package/dist/components/slotProps.mjs.map +1 -0
  47. package/dist/index.d.mts +13 -0
  48. package/dist/index.mjs +14 -0
  49. package/dist/screens/SessionScreen.d.mts +63 -0
  50. package/dist/screens/SessionScreen.d.mts.map +1 -0
  51. package/dist/screens/SessionScreen.mjs +562 -0
  52. package/dist/screens/SessionScreen.mjs.map +1 -0
  53. package/dist/screens/SessionsScreen.d.mts +47 -0
  54. package/dist/screens/SessionsScreen.d.mts.map +1 -0
  55. package/dist/screens/SessionsScreen.mjs +1433 -0
  56. package/dist/screens/SessionsScreen.mjs.map +1 -0
  57. package/dist/slotProps.d.mts +2 -0
  58. package/dist/slotProps.mjs +3 -0
  59. package/package.json +92 -0
@@ -0,0 +1,1433 @@
1
+ import { AddWorkspaceSheet, SessionGroupsSheet, SessionMenuSheet, SetupMenuSheet, WorkspaceMenuSheet } from "../components/SessionMenus.mjs";
2
+ import { sessionTimeline as sessionTimeline$1 } from "../components/sessionTimeline.mjs";
3
+ import { View } from "react-native-unistyles/components/native/View";
4
+ import { Text } from "react-native-unistyles/components/native/Text";
5
+ import { ActivityIcon, AlertIcon, Badge, BranchIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, ComputerRow, CountBadge, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, EmptyState, FolderIcon, ForkIcon, HostTag, InfoStrip, KebabIcon, ListRow, LiveDuration, MessageIcon, MonitorIcon, PlusIcon, SectionLabel, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, SlidersIcon, Spinner, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
6
+ import { StyleSheet } from "react-native-unistyles";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { Pressable } from "react-native-unistyles/components/native/Pressable";
9
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
10
+ import { SectionList } from "react-native-unistyles/components/native/SectionList";
11
+
12
+ //#region src/screens/SessionsScreen.tsx
13
+ const NO_HOSTS = [];
14
+ const MINUTE_MS = 6e4;
15
+ const VIEWS = [{
16
+ value: "workspaces",
17
+ title: "Workspaces",
18
+ description: "Sessions grouped by workspace",
19
+ Icon: FolderIcon
20
+ }, {
21
+ value: "sessions",
22
+ title: "Sessions",
23
+ description: "Needs you first, then latest change",
24
+ Icon: MessageIcon
25
+ }];
26
+ /** How long ago a session last moved: "<1m", "12m", "3h", "2d". */
27
+ function ageText(since, now) {
28
+ const elapsed = Math.max(0, now - since);
29
+ const minutes = Math.floor(elapsed / MINUTE_MS);
30
+ return {
31
+ text: minutes < 1 ? "<1m" : minutes < 60 ? `${String(minutes)}m` : minutes < 1440 ? `${String(Math.floor(minutes / 60))}h` : `${String(Math.floor(minutes / 1440))}d`,
32
+ nextMs: MINUTE_MS - elapsed % MINUTE_MS
33
+ };
34
+ }
35
+ /** `waiting` marks the Elegant rail's rose age; absent keeps the cockpit card's dim one. */
36
+ function SessionAge({ since, waiting }) {
37
+ const clock = useCallback((now) => ageText(since, now), [since]);
38
+ return /* @__PURE__ */ jsx(LiveDuration, {
39
+ clock,
40
+ style: waiting === void 0 ? styles.age : styles.quietAge(waiting)
41
+ });
42
+ }
43
+ /** The same reading of the status line as the cockpit card. */
44
+ function statusTone(status) {
45
+ if (status.startsWith("failed") || status.includes(" failed")) return "failed";
46
+ if (status.startsWith("running")) return "running";
47
+ return "quiet";
48
+ }
49
+ /** A 44 point icon target, as the cockpit's ghost icon buttons. */
50
+ function IconButton({ label, onPress, children, disabled = false }) {
51
+ return /* @__PURE__ */ jsx(Pressable, {
52
+ accessibilityRole: "button",
53
+ accessibilityLabel: label,
54
+ accessibilityState: { disabled },
55
+ disabled,
56
+ hitSlop: 6,
57
+ onPress,
58
+ style: ({ pressed }) => [styles.iconButton, pressed && styles.iconPressed],
59
+ children
60
+ });
61
+ }
62
+ function SessionCard({ session, onOpen, onMenu, onSetupMenu, hostLabel, scope, stale = false, flat = false, workspaceName, age }) {
63
+ const tone = stale ? "quiet" : statusTone(session.status);
64
+ const name = session.name || "Untitled";
65
+ const markColor = session.active ? "green" : "faint";
66
+ const waiting = stale ? 0 : session.waitingCount ?? (session.awaitingInput ? 1 : 0);
67
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Pressable, {
68
+ accessibilityRole: "button",
69
+ accessibilityLabel: waiting > 0 ? `Open ${name}, ${String(waiting)} waiting for you` : `Open ${name}`,
70
+ disabled: stale,
71
+ accessibilityState: { disabled: stale },
72
+ onPress: () => onOpen(session.id),
73
+ style: ({ pressed }) => [
74
+ styles.card,
75
+ session.nested && !flat && styles.nested,
76
+ pressed && styles.cardPressed,
77
+ !stale && session.active && styles.cardActive
78
+ ],
79
+ children: [
80
+ /* @__PURE__ */ jsxs(View, {
81
+ style: styles.cardHead,
82
+ children: [/* @__PURE__ */ jsxs(View, {
83
+ style: styles.cardText,
84
+ children: [/* @__PURE__ */ jsxs(View, {
85
+ style: styles.nameRow,
86
+ children: [
87
+ session.nested && session.provenance === "workflow-session" ? /* @__PURE__ */ jsx(ActivityIcon, {
88
+ size: 13,
89
+ color: markColor,
90
+ accessibilityLabel: "workflow session"
91
+ }) : session.nested && session.provenance ? /* @__PURE__ */ jsx(ForkIcon, {
92
+ size: 13,
93
+ color: markColor,
94
+ accessibilityLabel: session.provenance === "worktree" ? "automatic per-conversation worktree" : session.provenance
95
+ }) : null,
96
+ /* @__PURE__ */ jsx(Text, {
97
+ style: styles.name,
98
+ numberOfLines: 2,
99
+ children: name
100
+ }),
101
+ /* @__PURE__ */ jsx(CountBadge, {
102
+ count: waiting,
103
+ style: styles.nameBadge
104
+ }),
105
+ age === void 0 ? null : /* @__PURE__ */ jsx(SessionAge, { since: age })
106
+ ]
107
+ }), /* @__PURE__ */ jsxs(View, {
108
+ style: styles.detailRow,
109
+ children: [/* @__PURE__ */ jsxs(View, {
110
+ style: styles.statusRow,
111
+ children: [
112
+ stale ? null : session.restarting ? /* @__PURE__ */ jsx(Spinner, {
113
+ size: "small",
114
+ color: "dim",
115
+ label: "Restarting"
116
+ }) : tone === "running" ? /* @__PURE__ */ jsx(Spinner, {
117
+ size: "small",
118
+ color: "yellow"
119
+ }) : tone === "failed" ? /* @__PURE__ */ jsx(AlertIcon, {
120
+ size: 12,
121
+ color: "red"
122
+ }) : null,
123
+ !stale && session.clock ? /* @__PURE__ */ jsx(LiveDuration, {
124
+ style: styles.status(tone),
125
+ label: session.clock.label,
126
+ since: session.clock.since
127
+ }) : /* @__PURE__ */ jsx(Text, {
128
+ style: styles.status(tone),
129
+ numberOfLines: 1,
130
+ children: stale ? "Last known" : session.status
131
+ }),
132
+ session.git || workspaceName ? /* @__PURE__ */ jsxs(View, {
133
+ style: styles.branchRow,
134
+ children: [workspaceName ? /* @__PURE__ */ jsx(Text, {
135
+ style: styles.branch,
136
+ numberOfLines: 1,
137
+ children: workspaceName
138
+ }) : null, session.git ? /* @__PURE__ */ jsxs(Fragment, { children: [
139
+ /* @__PURE__ */ jsx(BranchIcon, {
140
+ size: 13,
141
+ color: "dim"
142
+ }),
143
+ /* @__PURE__ */ jsx(Text, {
144
+ style: styles.branch,
145
+ numberOfLines: 1,
146
+ children: session.git.branch
147
+ }),
148
+ session.git.dirty ? /* @__PURE__ */ jsx(Text, {
149
+ style: styles.modified,
150
+ children: "modified"
151
+ }) : null
152
+ ] }) : null]
153
+ }) : null
154
+ ]
155
+ }), session.profile ? /* @__PURE__ */ jsx(View, {
156
+ style: styles.avatar,
157
+ accessibilityLabel: session.profile.label,
158
+ children: /* @__PURE__ */ jsx(Text, {
159
+ style: styles.initials,
160
+ children: session.profile.initials
161
+ })
162
+ }) : null]
163
+ })]
164
+ }), !stale ? /* @__PURE__ */ jsx(IconButton, {
165
+ label: `${name} actions`,
166
+ onPress: () => onMenu(session),
167
+ children: /* @__PURE__ */ jsx(KebabIcon, {
168
+ size: 16,
169
+ color: "dim"
170
+ })
171
+ }) : null]
172
+ }),
173
+ session.coordinator ? /* @__PURE__ */ jsxs(Text, {
174
+ style: styles.branch,
175
+ children: ["Coordinator · ", scope]
176
+ }) : null,
177
+ hostLabel ? /* @__PURE__ */ jsx(HostTag, { label: hostLabel }) : null,
178
+ session.groups !== void 0 && session.groups.length > 0 ? /* @__PURE__ */ jsxs(View, {
179
+ style: styles.groupsRow,
180
+ accessibilityLabel: "groups",
181
+ children: [/* @__PURE__ */ jsx(UsersIcon, {
182
+ size: 13,
183
+ color: "dim"
184
+ }), /* @__PURE__ */ jsx(View, {
185
+ style: styles.groups,
186
+ children: session.groups.map((group) => /* @__PURE__ */ jsx(Badge, {
187
+ tone: "magenta",
188
+ size: "xs",
189
+ children: group
190
+ }, group))
191
+ })]
192
+ }) : null,
193
+ session.error ? /* @__PURE__ */ jsx(Text, {
194
+ style: styles.error,
195
+ numberOfLines: 3,
196
+ children: session.error
197
+ }) : null
198
+ ]
199
+ }), session.pendingSetups.map((setup) => /* @__PURE__ */ jsxs(View, {
200
+ style: styles.setup,
201
+ children: [
202
+ /* @__PURE__ */ jsxs(View, {
203
+ style: styles.setupHead,
204
+ children: [/* @__PURE__ */ jsx(Text, {
205
+ style: [styles.name, styles.setupName],
206
+ numberOfLines: 1,
207
+ children: setup.name
208
+ }), !stale && onSetupMenu ? /* @__PURE__ */ jsx(IconButton, {
209
+ label: `${setup.name} setup actions`,
210
+ onPress: () => onSetupMenu(setup),
211
+ children: /* @__PURE__ */ jsx(KebabIcon, {
212
+ size: 16,
213
+ color: "dim"
214
+ })
215
+ }) : null]
216
+ }),
217
+ /* @__PURE__ */ jsx(Text, {
218
+ style: styles.setupStatus(setup.failed),
219
+ children: setup.status
220
+ }),
221
+ setup.recovery ? /* @__PURE__ */ jsx(Text, {
222
+ style: styles.recovery,
223
+ accessibilityRole: setup.failed ? "alert" : void 0,
224
+ children: setup.recovery
225
+ }) : null
226
+ ]
227
+ }, setup.id))] });
228
+ }
229
+ /** The Elegant rail's chat-list row: who is on it, what they last said, whether they need you. */
230
+ function QuietSessionCard({ session, onOpen, onMenu, onSetupMenu, hostLabel, scope, stale = false, flat = false, workspaceName, age }) {
231
+ const tone = stale ? "quiet" : statusTone(session.status);
232
+ const name = session.name || "Untitled";
233
+ const waiting = stale ? 0 : session.waitingCount ?? (session.awaitingInput ? 1 : 0);
234
+ const nested = session.nested && !flat;
235
+ const since = age ?? (nested ? void 0 : session.lastActivityAt);
236
+ const agent = session.profile?.label ?? "Po";
237
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Pressable, {
238
+ accessibilityRole: "button",
239
+ accessibilityLabel: waiting > 0 ? `Open ${name}, ${String(waiting)} waiting for you` : `Open ${name}`,
240
+ disabled: stale,
241
+ accessibilityState: { disabled: stale },
242
+ onPress: () => onOpen(session.id),
243
+ style: ({ pressed }) => [
244
+ styles.quietCard,
245
+ nested && styles.quietNested,
246
+ pressed && styles.cardPressed,
247
+ !stale && session.active && styles.cardPressed
248
+ ],
249
+ children: [
250
+ /* @__PURE__ */ jsxs(View, {
251
+ style: [styles.quietAvatar, nested && styles.quietAvatarNested],
252
+ accessibilityLabel: agent,
253
+ children: [/* @__PURE__ */ jsx(Text, {
254
+ style: styles.initials,
255
+ children: session.profile?.initials ?? "PO"
256
+ }), tone === "running" || tone === "failed" ? /* @__PURE__ */ jsx(View, { style: styles.presence(tone) }) : null]
257
+ }),
258
+ /* @__PURE__ */ jsxs(View, {
259
+ style: styles.cardText,
260
+ children: [
261
+ /* @__PURE__ */ jsxs(View, {
262
+ style: styles.nameRow,
263
+ children: [
264
+ session.nested && session.provenance === "workflow-session" ? /* @__PURE__ */ jsx(ActivityIcon, {
265
+ size: 13,
266
+ color: "dim",
267
+ accessibilityLabel: "workflow session"
268
+ }) : session.nested && session.provenance ? /* @__PURE__ */ jsx(ForkIcon, {
269
+ size: 13,
270
+ color: "dim",
271
+ accessibilityLabel: session.provenance === "worktree" ? "automatic per-conversation worktree" : session.provenance
272
+ }) : null,
273
+ session.coordinator ? /* @__PURE__ */ jsx(UsersIcon, {
274
+ size: 13,
275
+ color: "dim",
276
+ accessibilityLabel: "coordinator"
277
+ }) : null,
278
+ /* @__PURE__ */ jsx(View, {
279
+ style: styles.quietName,
280
+ children: /* @__PURE__ */ jsx(Text, {
281
+ style: [styles.name, nested && styles.quietNestedName],
282
+ numberOfLines: 1,
283
+ children: name
284
+ })
285
+ }),
286
+ since === void 0 ? null : /* @__PURE__ */ jsx(SessionAge, {
287
+ since,
288
+ waiting: waiting > 0
289
+ })
290
+ ]
291
+ }),
292
+ /* @__PURE__ */ jsxs(View, {
293
+ style: styles.nameRow,
294
+ children: [/* @__PURE__ */ jsxs(View, {
295
+ style: styles.statusRow,
296
+ children: [/* @__PURE__ */ jsxs(Text, {
297
+ style: styles.quietAgent,
298
+ children: [agent, " ·"]
299
+ }), !stale && session.clock ? /* @__PURE__ */ jsx(LiveDuration, {
300
+ style: styles.quietStatus(waiting > 0 ? "waiting" : tone),
301
+ label: session.clock.label,
302
+ since: session.clock.since
303
+ }) : /* @__PURE__ */ jsx(Text, {
304
+ style: styles.quietStatus(waiting > 0 ? "waiting" : tone),
305
+ numberOfLines: session.active ? 2 : 1,
306
+ children: stale ? "Last known" : session.status
307
+ })]
308
+ }), /* @__PURE__ */ jsx(CountBadge, {
309
+ count: waiting,
310
+ style: styles.nameBadge
311
+ })]
312
+ }),
313
+ session.git || workspaceName ? /* @__PURE__ */ jsxs(View, {
314
+ style: styles.branchRow,
315
+ children: [workspaceName ? /* @__PURE__ */ jsx(Text, {
316
+ style: styles.branch,
317
+ numberOfLines: 1,
318
+ children: workspaceName
319
+ }) : null, session.git ? /* @__PURE__ */ jsxs(Fragment, { children: [
320
+ /* @__PURE__ */ jsx(BranchIcon, {
321
+ size: 13,
322
+ color: "dim"
323
+ }),
324
+ /* @__PURE__ */ jsx(Text, {
325
+ style: styles.branch,
326
+ numberOfLines: 1,
327
+ children: session.git.branch
328
+ }),
329
+ session.git.dirty ? /* @__PURE__ */ jsx(Text, {
330
+ style: styles.modified,
331
+ children: "modified"
332
+ }) : null
333
+ ] }) : null]
334
+ }) : null,
335
+ session.coordinator && scope ? /* @__PURE__ */ jsxs(Text, {
336
+ style: styles.branch,
337
+ children: ["Coordinator · ", scope]
338
+ }) : null,
339
+ hostLabel ? /* @__PURE__ */ jsx(HostTag, { label: hostLabel }) : null,
340
+ session.groups !== void 0 && session.groups.length > 0 ? /* @__PURE__ */ jsx(View, {
341
+ style: styles.groups,
342
+ accessibilityLabel: "groups",
343
+ children: session.groups.map((group) => /* @__PURE__ */ jsx(Badge, {
344
+ tone: "magenta",
345
+ size: "xs",
346
+ children: group
347
+ }, group))
348
+ }) : null,
349
+ session.error ? /* @__PURE__ */ jsx(Text, {
350
+ style: styles.error,
351
+ numberOfLines: 3,
352
+ children: session.error
353
+ }) : null
354
+ ]
355
+ }),
356
+ !stale ? /* @__PURE__ */ jsx(IconButton, {
357
+ label: `${name} actions`,
358
+ onPress: () => onMenu(session),
359
+ children: /* @__PURE__ */ jsx(KebabIcon, {
360
+ size: 16,
361
+ color: "dim"
362
+ })
363
+ }) : null
364
+ ]
365
+ }), session.pendingSetups.map((setup) => /* @__PURE__ */ jsxs(View, {
366
+ style: [styles.quietCard, styles.quietNested],
367
+ children: [
368
+ /* @__PURE__ */ jsx(View, {
369
+ style: [
370
+ styles.quietAvatar,
371
+ styles.quietAvatarNested,
372
+ styles.quietSetupMark
373
+ ],
374
+ children: setup.failed ? /* @__PURE__ */ jsx(AlertIcon, {
375
+ size: 13,
376
+ color: "red"
377
+ }) : /* @__PURE__ */ jsx(ForkIcon, {
378
+ size: 13,
379
+ color: "dim"
380
+ })
381
+ }),
382
+ /* @__PURE__ */ jsxs(View, {
383
+ style: styles.cardText,
384
+ children: [
385
+ /* @__PURE__ */ jsx(Text, {
386
+ style: [styles.name, styles.quietNestedName],
387
+ numberOfLines: 1,
388
+ children: setup.name
389
+ }),
390
+ /* @__PURE__ */ jsx(Text, {
391
+ style: styles.setupStatus(setup.failed),
392
+ children: setup.status
393
+ }),
394
+ setup.recovery ? /* @__PURE__ */ jsx(Text, {
395
+ style: styles.recovery,
396
+ accessibilityRole: setup.failed ? "alert" : void 0,
397
+ children: setup.recovery
398
+ }) : null
399
+ ]
400
+ }),
401
+ !stale && onSetupMenu ? /* @__PURE__ */ jsx(IconButton, {
402
+ label: `${setup.name} setup actions`,
403
+ onPress: () => onSetupMenu(setup),
404
+ children: /* @__PURE__ */ jsx(KebabIcon, {
405
+ size: 16,
406
+ color: "dim"
407
+ })
408
+ }) : null
409
+ ]
410
+ }, setup.id))] });
411
+ }
412
+ function WorkspaceHeader({ workspace, actions, onWorkspaceMenu, onCreate, onOpen, merged = false, stale = false, compact = false, quiet = false }) {
413
+ const canCreate = !workspace.legacy && workspace.available && (!stale || merged);
414
+ const create = onCreate ?? (() => actions.createSession(workspace.id));
415
+ const row = /* @__PURE__ */ jsxs(Fragment, { children: [
416
+ quiet ? null : /* @__PURE__ */ jsx(FolderIcon, {
417
+ size: 16,
418
+ color: "dim"
419
+ }),
420
+ /* @__PURE__ */ jsx(Pressable, {
421
+ style: [styles.groupText, styles.workspaceLink],
422
+ accessibilityRole: onOpen ? "button" : "header",
423
+ accessibilityLabel: onOpen ? `Open ${workspace.name} workspace` : workspace.name,
424
+ disabled: !onOpen,
425
+ onPress: onOpen,
426
+ children: /* @__PURE__ */ jsx(Text, {
427
+ style: quiet ? styles.quietGroupName : compact ? styles.compactName : styles.groupName,
428
+ numberOfLines: 1,
429
+ children: workspace.name
430
+ })
431
+ }),
432
+ workspace.legacy ? null : /* @__PURE__ */ jsxs(Fragment, { children: [canCreate ? /* @__PURE__ */ jsx(IconButton, {
433
+ label: `New session in ${workspace.name}`,
434
+ onPress: create,
435
+ children: /* @__PURE__ */ jsx(PlusIcon, {
436
+ size: 18,
437
+ color: "dim"
438
+ })
439
+ }) : null, !stale || merged ? /* @__PURE__ */ jsx(IconButton, {
440
+ label: `${workspace.name} actions`,
441
+ onPress: () => onWorkspaceMenu(workspace),
442
+ children: /* @__PURE__ */ jsx(KebabIcon, {
443
+ size: 16,
444
+ color: "dim"
445
+ })
446
+ }) : null] })
447
+ ] });
448
+ return /* @__PURE__ */ jsx(View, {
449
+ style: styles.group,
450
+ children: /* @__PURE__ */ jsx(View, {
451
+ style: [styles.groupHead, compact && styles.compactHead],
452
+ accessibilityRole: "header",
453
+ children: row
454
+ })
455
+ });
456
+ }
457
+ /** Workspaces without sessions, folded into one quiet group below the list. */
458
+ function OtherWorkspaces({ count, open, afterList, onToggle, children, quiet = false }) {
459
+ return /* @__PURE__ */ jsxs(View, {
460
+ style: [styles.other, afterList && styles.otherAfterList],
461
+ children: [/* @__PURE__ */ jsxs(Pressable, {
462
+ accessibilityRole: "button",
463
+ accessibilityLabel: `Other workspaces, ${String(count)} without sessions`,
464
+ accessibilityState: { expanded: open },
465
+ onPress: onToggle,
466
+ style: ({ pressed }) => [styles.otherHead, pressed && styles.iconPressed],
467
+ children: [
468
+ open ? /* @__PURE__ */ jsx(ChevronDownIcon, {
469
+ size: 16,
470
+ color: "dim"
471
+ }) : /* @__PURE__ */ jsx(ChevronRightIcon, {
472
+ size: 16,
473
+ color: "dim"
474
+ }),
475
+ /* @__PURE__ */ jsx(Text, {
476
+ style: quiet ? styles.quietGroupName : styles.otherLabel,
477
+ children: "Other workspaces"
478
+ }),
479
+ /* @__PURE__ */ jsx(Text, {
480
+ style: styles.otherCount,
481
+ children: count
482
+ })
483
+ ]
484
+ }), open ? children : null]
485
+ });
486
+ }
487
+ /** Display grouping never rewrites workspace or session identity. */
488
+ function sessionSections(workspaces, presentation, selectedHost = null) {
489
+ const filter = presentation?.hosts.some(({ id }) => id === selectedHost) ? selectedHost : null;
490
+ const visible = workspaces.filter((workspace) => {
491
+ const owner = presentation?.hostForId[workspace.id];
492
+ if (owner && !presentation?.hosts.some(({ id }) => id === owner)) return false;
493
+ return filter === null || owner === filter;
494
+ });
495
+ const sections = [];
496
+ for (const workspace of [...visible.filter((item) => item.kind === "session"), ...visible.filter((item) => item.kind !== "session")]) {
497
+ if (workspace.kind === "session" && workspace.sessions.length === 0) continue;
498
+ const existing = workspace.kind === "session" ? sections.find((section) => section.workspace.kind === "session") : presentation && presentation.hosts.length > 1 && !workspace.legacy ? sections.find((section) => section.workspace.kind !== "session" && !section.workspace.legacy && section.workspace.name === workspace.name) : void 0;
499
+ if (existing) {
500
+ existing.members.push(workspace);
501
+ existing.data = [...existing.data, ...workspace.sessions];
502
+ existing.workspace = {
503
+ ...existing.workspace,
504
+ available: existing.workspace.available || workspace.available
505
+ };
506
+ } else sections.push({
507
+ key: workspace.id,
508
+ workspace,
509
+ members: [workspace],
510
+ data: workspace.sessions
511
+ });
512
+ }
513
+ return sections.flatMap((section) => {
514
+ if (section.workspace.kind === "session") return [{
515
+ ...section,
516
+ showWorkspace: false
517
+ }];
518
+ const busy = section.members.filter((workspace) => workspace.sessions.length > 0);
519
+ return (busy.length > 0 ? busy : section.members).map((workspace, index) => ({
520
+ key: workspace.id,
521
+ workspace,
522
+ members: section.members,
523
+ data: workspace.sessions,
524
+ showWorkspace: index === 0
525
+ }));
526
+ });
527
+ }
528
+ /** The Sessions view over the shown workspaces, each row naming its workspace. */
529
+ function sessionTimeline(sections) {
530
+ return sessionTimeline$1(sections.flatMap((section) => section.data.map((session) => ({
531
+ session,
532
+ workspaceName: section.workspace.kind === "session" ? void 0 : section.workspace.name
533
+ }))));
534
+ }
535
+ function SessionCreateMenu({ onCreateWorkspace, onCreateSession, onCreateCoordinator, coordinatorDisabled = false, workspaceDisabled = false, sessionDisabled = false, defaultOpen = false }) {
536
+ return /* @__PURE__ */ jsxs(DropdownMenu, {
537
+ defaultOpen,
538
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
539
+ variant: "ghost",
540
+ size: "icon",
541
+ accessibilityLabel: "Create workspace or session",
542
+ children: /* @__PURE__ */ jsx(PlusIcon, {
543
+ size: 18,
544
+ color: "dim"
545
+ })
546
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, { children: [
547
+ onCreateCoordinator ? /* @__PURE__ */ jsx(DropdownMenuItem, {
548
+ disabled: coordinatorDisabled,
549
+ onSelect: onCreateCoordinator,
550
+ children: "Create coordinator"
551
+ }) : null,
552
+ onCreateWorkspace ? /* @__PURE__ */ jsx(DropdownMenuItem, {
553
+ disabled: workspaceDisabled,
554
+ onSelect: onCreateWorkspace,
555
+ children: "Create workspace"
556
+ }) : null,
557
+ onCreateSession ? /* @__PURE__ */ jsx(DropdownMenuItem, {
558
+ disabled: sessionDisabled,
559
+ onSelect: onCreateSession,
560
+ children: "Create session"
561
+ }) : null
562
+ ] })]
563
+ });
564
+ }
565
+ /**
566
+ * The cockpit's workspace groups, with quiet computer subgroups in the All hosts view.
567
+ * `quiet` draws the Elegant rail's look: chat-list rows and small labels, no boxes or folder marks.
568
+ */
569
+ function SessionsScreen({ workspaces, openSession, openWorkspace, actions, setHeaderAction, hostPresentation, otherWorkspacesOpen, setOtherWorkspacesOpen, sessionView, setSessionView, notices, updateRequired, quiet = false }) {
570
+ const [selectedHost, setSelectedHost] = useState(hostPresentation?.initialHostId ?? null);
571
+ const selected = hostPresentation?.hosts.some(({ id }) => id === selectedHost) ? selectedHost : null;
572
+ if (selectedHost !== selected) setSelectedHost(selected);
573
+ const { sections, idle, timeline } = useMemo(() => {
574
+ const all = sessionSections(workspaces, hostPresentation, selected);
575
+ const isIdle = (section) => section.workspace.kind !== "session" && section.members.every((member) => member.sessions.length === 0);
576
+ return {
577
+ sections: all.filter((section) => !isIdle(section)),
578
+ idle: all.filter((section) => section.showWorkspace && isIdle(section)),
579
+ timeline: sessionTimeline(all)
580
+ };
581
+ }, [
582
+ workspaces,
583
+ hostPresentation,
584
+ selected
585
+ ]);
586
+ const [localOtherOpen, setLocalOtherOpen] = useState(false);
587
+ const otherOpen = otherWorkspacesOpen ?? localOtherOpen;
588
+ const [localView, setLocalView] = useState("workspaces");
589
+ const view = sessionView ?? localView;
590
+ const [viewing, setViewing] = useState(false);
591
+ const hosts = hostPresentation?.hosts ?? NO_HOSTS;
592
+ const hostOf = (id) => hosts.find((host) => host.id === hostPresentation?.hostForId[id]);
593
+ const stale = (id) => hostPresentation !== void 0 && hostOf(id)?.status !== "connected";
594
+ const [choosing, setChoosing] = useState(null);
595
+ const [chooseAction, setChooseAction] = useState("create");
596
+ const [addHost, setAddHost] = useState(null);
597
+ const [sessionMenu, setSessionMenu] = useState(null);
598
+ const [workspaceMenu, setWorkspaceMenu] = useState(null);
599
+ const [groupsFor, setGroupsFor] = useState(null);
600
+ const [setupMenu, setSetupMenu] = useState(null);
601
+ const [adding, setAdding] = useState(false);
602
+ const { addWorkspace, searchDirectories, listDirectory } = actions;
603
+ const addActions = hosts.length > 0 ? hosts.find(({ id }) => id === addHost)?.addWorkspaceActions : addWorkspace && searchDirectories && listDirectory ? {
604
+ addWorkspace,
605
+ searchDirectories,
606
+ listDirectory
607
+ } : void 0;
608
+ const canAdd = hosts.length > 0 ? hosts.some((host) => host.addWorkspaceActions !== void 0) : addActions !== void 0;
609
+ const beginAdd = useCallback(() => {
610
+ if (hosts.length > 1) {
611
+ setChoosing("add");
612
+ return;
613
+ }
614
+ if (hosts.length === 1) {
615
+ if (hosts[0].status !== "connected") return;
616
+ setAddHost(hosts[0].id);
617
+ }
618
+ setAdding(true);
619
+ }, [hosts]);
620
+ const generalAction = useRef(actions.createGeneralSession);
621
+ const coordinatorAction = useRef(actions.addCoordinator);
622
+ useEffect(() => {
623
+ generalAction.current = actions.createGeneralSession;
624
+ coordinatorAction.current = actions.addCoordinator;
625
+ }, [actions.createGeneralSession, actions.addCoordinator]);
626
+ const canGeneral = hosts.length > 0 ? hosts.some((host) => host.createGeneralSession !== void 0) : actions.createGeneralSession !== void 0;
627
+ const beginGeneral = useCallback(() => {
628
+ const host = hosts.find((host) => host.id === selected) ?? (hosts.length === 1 ? hosts[0] : void 0);
629
+ if (host) {
630
+ if (host.status === "connected") host.createGeneralSession?.();
631
+ } else if (hosts.length > 1) setChoosing("general");
632
+ else generalAction.current?.();
633
+ }, [hosts, selected]);
634
+ const [coordinatorError, setCoordinatorError] = useState("");
635
+ const [coordinatorBusy, setCoordinatorBusy] = useState(false);
636
+ const homeCoordinated = useCallback((hostId) => workspaces.some((workspace) => workspace.kind === "session" && (!hostId || hostPresentation?.hostForId[workspace.id] === hostId) && workspace.sessions.some((session) => session.coordinator)), [workspaces, hostPresentation]);
637
+ const coordinatorHosts = useMemo(() => hosts.filter((host) => host.createCoordinator && !homeCoordinated(host.id)), [hosts, homeCoordinated]);
638
+ const canCoordinator = hosts.length > 0 ? coordinatorHosts.length > 0 : actions.addCoordinator !== void 0 && !homeCoordinated();
639
+ const createCoordinator = useCallback(async (host) => {
640
+ if (coordinatorBusy || host && host.status !== "connected") return;
641
+ setCoordinatorBusy(true);
642
+ setCoordinatorError("");
643
+ try {
644
+ const result = host ? await host.createCoordinator?.() : await coordinatorAction.current?.();
645
+ if (result) setCoordinatorError(result.error);
646
+ } catch (cause) {
647
+ setCoordinatorError(cause instanceof Error ? cause.message : "Could not create coordinator");
648
+ } finally {
649
+ setCoordinatorBusy(false);
650
+ }
651
+ }, [coordinatorBusy]);
652
+ const beginCoordinator = useCallback(() => {
653
+ const host = hosts.find((entry) => entry.id === selected) ?? (hosts.length === 1 ? hosts[0] : void 0);
654
+ if (host || hosts.length === 0) createCoordinator(host);
655
+ else setChoosing("coordinator");
656
+ }, [
657
+ hosts,
658
+ selected,
659
+ createCoordinator
660
+ ]);
661
+ const workspaceDisabled = hosts.length === 1 && hosts[0].status !== "connected";
662
+ const generalHost = hosts.find((host) => host.id === selected) ?? (hosts.length === 1 ? hosts[0] : void 0);
663
+ const sessionDisabled = generalHost !== void 0 && (generalHost.status !== "connected" || generalHost.createGeneralSession === void 0);
664
+ const createMenu = useMemo(() => /* @__PURE__ */ jsx(SessionCreateMenu, {
665
+ onCreateCoordinator: canCoordinator && (!generalHost || coordinatorHosts.includes(generalHost)) ? beginCoordinator : void 0,
666
+ coordinatorDisabled: coordinatorBusy || generalHost !== void 0 && generalHost.status !== "connected",
667
+ onCreateWorkspace: canAdd ? beginAdd : void 0,
668
+ onCreateSession: canGeneral ? beginGeneral : void 0,
669
+ workspaceDisabled,
670
+ sessionDisabled
671
+ }), [
672
+ canAdd,
673
+ canGeneral,
674
+ beginAdd,
675
+ beginGeneral,
676
+ workspaceDisabled,
677
+ sessionDisabled,
678
+ canCoordinator,
679
+ coordinatorBusy,
680
+ generalHost,
681
+ coordinatorHosts,
682
+ beginCoordinator
683
+ ]);
684
+ const viewTitle = VIEWS.find(({ value }) => value === view).title;
685
+ const headerAction = useMemo(() => /* @__PURE__ */ jsxs(View, {
686
+ style: styles.titleActions,
687
+ children: [/* @__PURE__ */ jsx(IconButton, {
688
+ label: `View: ${viewTitle}`,
689
+ onPress: () => setViewing(true),
690
+ children: /* @__PURE__ */ jsx(SlidersIcon, {
691
+ size: 18,
692
+ color: "dim"
693
+ })
694
+ }), canGeneral || canAdd || canCoordinator ? createMenu : null]
695
+ }), [
696
+ viewTitle,
697
+ canGeneral,
698
+ canAdd,
699
+ canCoordinator,
700
+ createMenu
701
+ ]);
702
+ useEffect(() => {
703
+ if (!setHeaderAction) return;
704
+ setHeaderAction(headerAction);
705
+ return () => setHeaderAction(null);
706
+ }, [setHeaderAction, headerAction]);
707
+ const sessions = workspaces.flatMap((workspace) => workspace.sessions).filter((session) => !stale(session.id));
708
+ const { setSessionGroups, renameGroup, deleteGroup, removePendingSetup } = actions;
709
+ const groupActions = setSessionGroups && renameGroup && deleteGroup ? {
710
+ setSessionGroups,
711
+ renameGroup,
712
+ deleteGroup
713
+ } : void 0;
714
+ const workspaceHeader = (section, compact = false) => /* @__PURE__ */ jsx(WorkspaceHeader, {
715
+ workspace: {
716
+ ...section.workspace,
717
+ available: section.members.some((member) => member.available)
718
+ },
719
+ actions,
720
+ onOpen: openWorkspace && !section.workspace.legacy ? () => {
721
+ const members = workspaces.filter((entry) => !entry.legacy && entry.name === section.workspace.name);
722
+ if (hosts.length > 1 && members.length > 1) {
723
+ setChooseAction("open");
724
+ setChoosing(members);
725
+ } else openWorkspace(section.workspace.id);
726
+ } : void 0,
727
+ onWorkspaceMenu: (entry) => {
728
+ const members = workspaces.filter((workspace) => !workspace.legacy && workspace.name === entry.name);
729
+ if (hosts.length > 1 && members.length > 1) {
730
+ setChooseAction("menu");
731
+ setChoosing(members);
732
+ } else if (!stale(entry.id)) setWorkspaceMenu(entry.id);
733
+ },
734
+ stale: stale(section.workspace.id),
735
+ merged: section.members.length > 1,
736
+ compact,
737
+ quiet,
738
+ onCreate: () => {
739
+ const members = workspaces.filter((entry) => !entry.legacy && entry.name === section.workspace.name);
740
+ if (hosts.length > 1 && members.length > 1) {
741
+ setChooseAction("create");
742
+ setChoosing(members);
743
+ } else if (!stale(section.workspace.id)) actions.createSession(section.workspace.id);
744
+ }
745
+ });
746
+ const Card = quiet ? QuietSessionCard : SessionCard;
747
+ const sessionCard = (session, hostLabel, flat) => /* @__PURE__ */ jsx(View, {
748
+ style: styles.sessionRow,
749
+ children: /* @__PURE__ */ jsx(Card, {
750
+ session,
751
+ scope: workspaces.find((workspace) => workspace.sessions.some((entry) => entry.id === session.id))?.kind === "session" ? "Home" : workspaces.find((workspace) => workspace.sessions.some((entry) => entry.id === session.id))?.name,
752
+ stale: stale(session.id),
753
+ hostLabel,
754
+ ...flat ? {
755
+ flat: true,
756
+ ...flat
757
+ } : {},
758
+ onOpen: openSession,
759
+ onMenu: (entry) => setSessionMenu(entry.id),
760
+ ...removePendingSetup ? { onSetupMenu: (setup) => setSetupMenu({
761
+ sessionId: session.id,
762
+ setup
763
+ }) } : {}
764
+ })
765
+ });
766
+ const listEmpty = /* @__PURE__ */ jsx(EmptyState, {
767
+ title: selected ? "No sessions on this computer." : "No sessions yet.",
768
+ description: canGeneral ? "Start a session to work with Po. No workspace needed." : "Add a workspace to start working with Po."
769
+ });
770
+ const listHeader = /* @__PURE__ */ jsxs(View, {
771
+ style: styles.listHeader,
772
+ children: [
773
+ notices?.map(({ id, message }) => /* @__PURE__ */ jsx(InfoStrip, { message }, id)),
774
+ updateRequired ? /* @__PURE__ */ jsx(Text, {
775
+ style: styles.updateRequired,
776
+ accessibilityLiveRegion: "polite",
777
+ children: updateRequired
778
+ }) : null,
779
+ hosts.filter((host) => host.status !== "connected" && (selected === null || selected === host.id)).map((host) => /* @__PURE__ */ jsx(InfoStrip, {
780
+ message: host.status === "update_required" ? `${host.label} needs an app update. Sessions are read-only.` : `${host.label} is offline. Showing last known sessions.`,
781
+ actionLabel: "Retry",
782
+ onAction: host.onRetry
783
+ }, host.id)),
784
+ coordinatorError ? /* @__PURE__ */ jsx(Text, {
785
+ style: styles.error,
786
+ accessibilityRole: "alert",
787
+ children: coordinatorError
788
+ }) : null,
789
+ setHeaderAction ? null : headerAction
790
+ ]
791
+ });
792
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
793
+ view === "sessions" ? /* @__PURE__ */ jsx(SectionList, {
794
+ style: styles.screen,
795
+ contentContainerStyle: styles.listContent,
796
+ contentInsetAdjustmentBehavior: "automatic",
797
+ sections: timeline,
798
+ keyExtractor: ({ session }) => session.id,
799
+ stickySectionHeadersEnabled: false,
800
+ initialNumToRender: 12,
801
+ maxToRenderPerBatch: 12,
802
+ windowSize: 5,
803
+ renderSectionHeader: ({ section }) => /* @__PURE__ */ jsx(SectionLabel, {
804
+ style: styles.timelineLabel,
805
+ children: section.title
806
+ }),
807
+ renderSectionFooter: ({ section }) => section === timeline[timeline.length - 1] ? null : /* @__PURE__ */ jsx(View, { style: styles.sectionGap }),
808
+ renderItem: ({ item, section }) => sessionCard(item.session, hosts.length > 1 && selected === null ? hostOf(item.session.id)?.label : void 0, {
809
+ ...item.workspaceName === void 0 ? {} : { workspaceName: item.workspaceName },
810
+ ...section.key === "recent" && item.session.lastActivityAt !== void 0 ? { age: item.session.lastActivityAt } : {}
811
+ }),
812
+ ListEmptyComponent: listEmpty,
813
+ ListHeaderComponent: listHeader
814
+ }) : /* @__PURE__ */ jsx(SectionList, {
815
+ style: styles.screen,
816
+ contentContainerStyle: styles.listContent,
817
+ contentInsetAdjustmentBehavior: "automatic",
818
+ sections,
819
+ keyExtractor: (session) => session.id,
820
+ stickySectionHeadersEnabled: false,
821
+ initialNumToRender: 12,
822
+ maxToRenderPerBatch: 12,
823
+ windowSize: 5,
824
+ renderSectionHeader: ({ section }) => section.workspace.kind === "session" ? null : /* @__PURE__ */ jsxs(Fragment, { children: [section.showWorkspace ? workspaceHeader(section) : null, /* @__PURE__ */ jsxs(View, {
825
+ style: styles.hostGroup,
826
+ children: [
827
+ quiet && !(hosts.length > 1 && selected === null && hostOf(section.workspace.id)) ? null : /* @__PURE__ */ jsxs(View, {
828
+ style: quiet ? styles.quietHostRow : styles.hostRow,
829
+ accessibilityRole: "header",
830
+ children: [hosts.length > 1 && selected === null && hostOf(section.workspace.id) ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MonitorIcon, {
831
+ size: 14,
832
+ color: "dim"
833
+ }), /* @__PURE__ */ jsxs(Text, {
834
+ style: styles.hostLabel,
835
+ numberOfLines: 1,
836
+ children: [hostOf(section.workspace.id).label, quiet ? "" : " ·"]
837
+ })] }) : null, quiet ? null : /* @__PURE__ */ jsx(Text, {
838
+ style: styles.groupRoot,
839
+ numberOfLines: 1,
840
+ ellipsizeMode: "middle",
841
+ children: section.workspace.root
842
+ })]
843
+ }),
844
+ !section.workspace.available ? /* @__PURE__ */ jsx(Text, {
845
+ style: styles.unavailable,
846
+ children: "Workspace unavailable"
847
+ }) : null,
848
+ section.data.length === 0 ? /* @__PURE__ */ jsx(Text, {
849
+ style: styles.noSessions,
850
+ children: "No sessions yet. Start or resume one."
851
+ }) : null
852
+ ]
853
+ })] }),
854
+ renderSectionFooter: ({ section }) => {
855
+ const next = sections[sections.indexOf(section) + 1];
856
+ return /* @__PURE__ */ jsx(View, { style: next === void 0 ? void 0 : next.showWorkspace ? styles.sectionGap : styles.hostGap });
857
+ },
858
+ renderItem: ({ item: session, section }) => sessionCard(session, section.workspace.kind === "session" && hosts.length > 1 && selected === null ? hostOf(session.id)?.label : void 0),
859
+ ListFooterComponent: idle.length > 0 ? /* @__PURE__ */ jsx(OtherWorkspaces, {
860
+ count: idle.length,
861
+ open: otherOpen,
862
+ afterList: sections.length > 0,
863
+ quiet,
864
+ onToggle: () => {
865
+ setLocalOtherOpen(!otherOpen);
866
+ setOtherWorkspacesOpen?.(!otherOpen);
867
+ },
868
+ children: idle.map((section) => /* @__PURE__ */ jsxs(View, {
869
+ style: styles.otherRow,
870
+ children: [workspaceHeader(section, true), !section.members.some((member) => member.available) ? /* @__PURE__ */ jsx(Text, {
871
+ style: styles.unavailable,
872
+ children: "Workspace unavailable"
873
+ }) : null]
874
+ }, section.key))
875
+ }) : void 0,
876
+ ListEmptyComponent: listEmpty,
877
+ ListHeaderComponent: listHeader
878
+ }),
879
+ /* @__PURE__ */ jsx(SessionMenuSheet, {
880
+ session: sessions.find((session) => session.id === sessionMenu) ?? null,
881
+ actions,
882
+ scope: workspaces.find((workspace) => workspace.sessions.some((session) => session.id === sessionMenu))?.kind === "session" ? "Home" : workspaces.find((workspace) => workspace.sessions.some((session) => session.id === sessionMenu))?.name,
883
+ ...groupActions ? { onGroups: (session) => setGroupsFor(session.id) } : {},
884
+ onClose: () => setSessionMenu(null)
885
+ }),
886
+ /* @__PURE__ */ jsx(WorkspaceMenuSheet, {
887
+ workspace: workspaces.find((workspace) => workspace.id === workspaceMenu && !stale(workspace.id)) ?? null,
888
+ actions,
889
+ onClose: () => setWorkspaceMenu(null)
890
+ }),
891
+ groupActions ? /* @__PURE__ */ jsx(SessionGroupsSheet, {
892
+ session: sessions.find((session) => session.id === groupsFor) ?? null,
893
+ sessions,
894
+ actions: groupActions,
895
+ onClose: () => setGroupsFor(null)
896
+ }) : null,
897
+ removePendingSetup ? /* @__PURE__ */ jsx(SetupMenuSheet, {
898
+ target: setupMenu,
899
+ removePendingSetup,
900
+ onClose: () => setSetupMenu(null)
901
+ }) : null,
902
+ addActions && (hosts.length === 0 || hosts.find(({ id }) => id === addHost)?.status === "connected") ? /* @__PURE__ */ jsx(AddWorkspaceSheet, {
903
+ open: adding,
904
+ actions: addActions,
905
+ onClose: () => {
906
+ setAdding(false);
907
+ setAddHost(null);
908
+ }
909
+ }) : null,
910
+ /* @__PURE__ */ jsx(Sheet, {
911
+ open: choosing !== null,
912
+ onOpenChange: (open) => {
913
+ if (!open) setChoosing(null);
914
+ },
915
+ children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: choosing === "add" ? "Add a workspace on" : choosing === "coordinator" ? "Add a coordinator on" : choosing !== "general" && chooseAction === "open" ? "Open on" : choosing !== "general" && chooseAction === "menu" ? "Which computer?" : "Start a session on" }) }), /* @__PURE__ */ jsx(SheetBody, { children: choosing === "coordinator" ? coordinatorHosts.map((host) => /* @__PURE__ */ jsx(ComputerRow, {
916
+ name: host.label,
917
+ status: host.status,
918
+ disabled: coordinatorBusy || host.status !== "connected",
919
+ onPress: () => {
920
+ setChoosing(null);
921
+ createCoordinator(host);
922
+ }
923
+ }, host.id)) : choosing === "general" ? hosts.map((host) => /* @__PURE__ */ jsx(ComputerRow, {
924
+ name: host.label,
925
+ status: host.status,
926
+ disabled: host.status !== "connected" || !host.createGeneralSession,
927
+ onPress: () => {
928
+ setChoosing(null);
929
+ host.createGeneralSession?.();
930
+ }
931
+ }, host.id)) : choosing === "add" ? hosts.map((host) => /* @__PURE__ */ jsx(ComputerRow, {
932
+ name: host.label,
933
+ status: host.status,
934
+ disabled: host.status !== "connected" || !host.addWorkspaceActions,
935
+ onPress: () => {
936
+ setAddHost(host.id);
937
+ setChoosing(null);
938
+ setAdding(true);
939
+ }
940
+ }, host.id)) : choosing?.map((workspace) => /* @__PURE__ */ jsx(ComputerRow, {
941
+ name: hostOf(workspace.id)?.label ?? workspace.name,
942
+ path: workspace.root,
943
+ status: hostOf(workspace.id)?.status ?? "connected",
944
+ disabled: chooseAction !== "open" && (stale(workspace.id) || !workspace.available),
945
+ onPress: () => {
946
+ setChoosing(null);
947
+ if (chooseAction === "open") openWorkspace?.(workspace.id);
948
+ else if (chooseAction === "menu") setWorkspaceMenu(workspace.id);
949
+ else actions.createSession(workspace.id);
950
+ }
951
+ }, workspace.id)) })] })
952
+ }),
953
+ /* @__PURE__ */ jsx(SessionViewSheet, {
954
+ open: viewing,
955
+ view,
956
+ onClose: () => setViewing(false),
957
+ onChoose: (value) => {
958
+ setLocalView(value);
959
+ setSessionView?.(value);
960
+ setViewing(false);
961
+ }
962
+ })
963
+ ] });
964
+ }
965
+ /** The View sheet: how the Sessions screen lists its sessions. */
966
+ function SessionViewSheet({ open, view, onClose, onChoose }) {
967
+ return /* @__PURE__ */ jsx(Sheet, {
968
+ open,
969
+ onOpenChange: (next) => {
970
+ if (!next) onClose();
971
+ },
972
+ children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "View" }) }), /* @__PURE__ */ jsx(SheetBody, { children: /* @__PURE__ */ jsx(View, {
973
+ style: styles.viewOptions,
974
+ children: VIEWS.map(({ value, title, description, Icon }) => /* @__PURE__ */ jsx(ListRow, {
975
+ title,
976
+ description,
977
+ leading: /* @__PURE__ */ jsx(Icon, {
978
+ size: 20,
979
+ color: value === view ? "green" : "dim"
980
+ }),
981
+ trailing: value === view ? /* @__PURE__ */ jsx(CheckIcon, {
982
+ size: 18,
983
+ color: "green"
984
+ }) : null,
985
+ selected: value === view,
986
+ disclosure: false,
987
+ style: [styles.viewOption, value === view && styles.viewOptionSelected],
988
+ onPress: () => onChoose(value)
989
+ }, value))
990
+ }) })] })
991
+ });
992
+ }
993
+ const styles = StyleSheet.create((theme) => {
994
+ const sans = fontOf(theme.fontFamily.sans);
995
+ const text = (size, color) => ({
996
+ fontFamily: sans,
997
+ fontSize: theme.fontSize[size],
998
+ lineHeight: theme.lineHeight[size],
999
+ color
1000
+ });
1001
+ return {
1002
+ screen: {
1003
+ flex: 1,
1004
+ backgroundColor: theme.colors.rail,
1005
+ uni__dependencies: [0]
1006
+ },
1007
+ content: {
1008
+ padding: theme.spacing(4),
1009
+ gap: theme.spacing(6),
1010
+ uni__dependencies: [0]
1011
+ },
1012
+ listContent: {
1013
+ padding: theme.spacing(4),
1014
+ uni__dependencies: [0]
1015
+ },
1016
+ listHeader: {
1017
+ gap: theme.spacing(3),
1018
+ paddingBottom: theme.spacing(4),
1019
+ uni__dependencies: [0]
1020
+ },
1021
+ titleActions: {
1022
+ flexDirection: "row",
1023
+ alignItems: "center"
1024
+ },
1025
+ timelineLabel: {
1026
+ paddingHorizontal: theme.spacing(1),
1027
+ paddingBottom: theme.spacing(1),
1028
+ uni__dependencies: [0]
1029
+ },
1030
+ viewOptions: {
1031
+ gap: theme.spacing(2),
1032
+ uni__dependencies: [0]
1033
+ },
1034
+ viewOption: {
1035
+ borderRadius: theme.borderRadius.lg,
1036
+ borderWidth: 1,
1037
+ borderColor: theme.colors["border-soft"],
1038
+ uni__dependencies: [0]
1039
+ },
1040
+ viewOptionSelected: {
1041
+ borderColor: theme.colors["edge-green"],
1042
+ uni__dependencies: [0]
1043
+ },
1044
+ sectionGap: {
1045
+ height: theme.spacing(6),
1046
+ uni__dependencies: [0]
1047
+ },
1048
+ sessionRow: {
1049
+ gap: theme.spacing(1),
1050
+ paddingTop: theme.spacing(1),
1051
+ uni__dependencies: [0]
1052
+ },
1053
+ group: {
1054
+ gap: theme.spacing(1),
1055
+ uni__dependencies: [0]
1056
+ },
1057
+ railHead: {
1058
+ flexDirection: "row",
1059
+ alignItems: "center",
1060
+ paddingHorizontal: theme.spacing(1),
1061
+ marginBottom: -theme.spacing(4),
1062
+ uni__dependencies: [0]
1063
+ },
1064
+ listRailHead: {
1065
+ marginBottom: theme.spacing(2),
1066
+ uni__dependencies: [0]
1067
+ },
1068
+ railTitle: {
1069
+ ...text("lg", theme.colors.hi),
1070
+ fontWeight: theme.fontWeight.semibold,
1071
+ flex: 1,
1072
+ uni__dependencies: [0]
1073
+ },
1074
+ groupHead: {
1075
+ flexDirection: "row",
1076
+ alignItems: "center",
1077
+ gap: theme.spacing(2),
1078
+ paddingHorizontal: theme.spacing(1),
1079
+ paddingBottom: theme.spacing(2),
1080
+ uni__dependencies: [0]
1081
+ },
1082
+ groupText: {
1083
+ flex: 1,
1084
+ minWidth: 0
1085
+ },
1086
+ workspaceLink: {
1087
+ minHeight: 44,
1088
+ justifyContent: "center"
1089
+ },
1090
+ groupName: {
1091
+ ...text("lg", theme.colors.hi),
1092
+ fontWeight: theme.fontWeight.semibold,
1093
+ uni__dependencies: [0]
1094
+ },
1095
+ groupRoot: {
1096
+ ...text("sm", theme.colors.dim),
1097
+ fontFamily: fontOf(theme.fontFamily.mono),
1098
+ flexShrink: 1,
1099
+ uni__dependencies: [0]
1100
+ },
1101
+ hostGroup: {
1102
+ gap: theme.spacing(1),
1103
+ paddingHorizontal: theme.spacing(1),
1104
+ paddingBottom: theme.spacing(1),
1105
+ uni__dependencies: [0]
1106
+ },
1107
+ hostGap: {
1108
+ height: theme.spacing(3),
1109
+ uni__dependencies: [0]
1110
+ },
1111
+ hostRow: {
1112
+ flexDirection: "row",
1113
+ alignItems: "center",
1114
+ gap: theme.spacing(1.5),
1115
+ paddingBottom: theme.spacing(2),
1116
+ borderBottomWidth: 1,
1117
+ borderColor: theme.colors["border-soft"],
1118
+ uni__dependencies: [0]
1119
+ },
1120
+ hostLabel: {
1121
+ ...text("sm", theme.colors.dim),
1122
+ flexShrink: 0,
1123
+ maxWidth: "60%",
1124
+ uni__dependencies: [0]
1125
+ },
1126
+ noSessions: {
1127
+ ...text("sm", theme.colors.dim),
1128
+ paddingHorizontal: theme.spacing(1),
1129
+ paddingBottom: theme.spacing(2),
1130
+ uni__dependencies: [0]
1131
+ },
1132
+ unavailable: {
1133
+ ...text("sm", theme.colors.red),
1134
+ paddingHorizontal: theme.spacing(1),
1135
+ uni__dependencies: [0]
1136
+ },
1137
+ other: {
1138
+ gap: theme.spacing(1),
1139
+ uni__dependencies: [0]
1140
+ },
1141
+ otherAfterList: {
1142
+ marginTop: theme.spacing(6),
1143
+ uni__dependencies: [0]
1144
+ },
1145
+ otherHead: {
1146
+ flexDirection: "row",
1147
+ alignItems: "center",
1148
+ gap: theme.spacing(2),
1149
+ minHeight: 44,
1150
+ paddingHorizontal: theme.spacing(1),
1151
+ borderRadius: theme.borderRadius.lg,
1152
+ uni__dependencies: [0]
1153
+ },
1154
+ otherLabel: {
1155
+ ...text("lg", theme.colors.hi),
1156
+ fontWeight: theme.fontWeight.semibold,
1157
+ flex: 1,
1158
+ uni__dependencies: [0]
1159
+ },
1160
+ otherCount: {
1161
+ ...text("xs", theme.colors.dim),
1162
+ minWidth: 22,
1163
+ paddingHorizontal: theme.spacing(1.5),
1164
+ borderRadius: 11,
1165
+ overflow: "hidden",
1166
+ textAlign: "center",
1167
+ backgroundColor: theme.colors.panel,
1168
+ uni__dependencies: [0]
1169
+ },
1170
+ otherRow: {
1171
+ marginLeft: theme.spacing(4),
1172
+ uni__dependencies: [0]
1173
+ },
1174
+ compactHead: { paddingBottom: 0 },
1175
+ compactName: {
1176
+ ...text("base", theme.colors.hi),
1177
+ fontWeight: theme.fontWeight.medium,
1178
+ uni__dependencies: [0]
1179
+ },
1180
+ empty: {
1181
+ gap: theme.spacing(3),
1182
+ paddingHorizontal: theme.spacing(4),
1183
+ paddingVertical: theme.spacing(5),
1184
+ borderRadius: theme.borderRadius.lg,
1185
+ borderWidth: 1,
1186
+ borderStyle: "dashed",
1187
+ borderColor: theme.colors.border,
1188
+ uni__dependencies: [0]
1189
+ },
1190
+ emptyText: text("sm", theme.colors.dim),
1191
+ emptyButton: {
1192
+ justifyContent: "flex-start",
1193
+ backgroundColor: theme.colors.panel,
1194
+ uni__dependencies: [0]
1195
+ },
1196
+ card: {
1197
+ gap: theme.spacing(2),
1198
+ padding: theme.spacing(3),
1199
+ borderRadius: theme.borderRadius.lg,
1200
+ borderWidth: 1,
1201
+ borderColor: "transparent",
1202
+ uni__dependencies: [0]
1203
+ },
1204
+ cardPressed: {
1205
+ backgroundColor: theme.colors.panel,
1206
+ uni__dependencies: [0]
1207
+ },
1208
+ cardActive: {
1209
+ backgroundColor: theme.colors["tint-green"],
1210
+ borderColor: theme.colors["edge-green"],
1211
+ uni__dependencies: [0]
1212
+ },
1213
+ quietCard: {
1214
+ flexDirection: "row",
1215
+ alignItems: "flex-start",
1216
+ gap: theme.spacing(3),
1217
+ paddingVertical: theme.spacing(2.5),
1218
+ paddingLeft: theme.spacing(2.5),
1219
+ borderRadius: theme.borderRadius.lg,
1220
+ uni__dependencies: [0]
1221
+ },
1222
+ quietNested: {
1223
+ marginLeft: theme.spacing(7),
1224
+ paddingVertical: theme.spacing(1.5),
1225
+ borderLeftWidth: 1,
1226
+ borderTopLeftRadius: 0,
1227
+ borderBottomLeftRadius: 0,
1228
+ borderColor: theme.colors["border-soft"],
1229
+ uni__dependencies: [0]
1230
+ },
1231
+ quietAvatar: {
1232
+ width: 40,
1233
+ height: 40,
1234
+ borderRadius: 20,
1235
+ alignItems: "center",
1236
+ justifyContent: "center",
1237
+ backgroundColor: theme.colors["tint-green"],
1238
+ uni__dependencies: [0]
1239
+ },
1240
+ quietAvatarNested: {
1241
+ width: 28,
1242
+ height: 28,
1243
+ borderRadius: 14
1244
+ },
1245
+ presence: (tone) => ({
1246
+ position: "absolute",
1247
+ right: -2,
1248
+ bottom: -2,
1249
+ width: 12,
1250
+ height: 12,
1251
+ borderRadius: 6,
1252
+ borderWidth: 2,
1253
+ borderColor: theme.colors.rail,
1254
+ backgroundColor: tone === "failed" ? theme.colors.red : theme.colors.green,
1255
+ uni__dependencies: [0]
1256
+ }),
1257
+ quietName: {
1258
+ flex: 1,
1259
+ minWidth: 0
1260
+ },
1261
+ quietNestedName: {
1262
+ fontWeight: theme.fontWeight.regular,
1263
+ uni__dependencies: [0]
1264
+ },
1265
+ quietAgent: {
1266
+ ...text("sm", theme.colors.text),
1267
+ fontWeight: theme.fontWeight.medium,
1268
+ uni__dependencies: [0]
1269
+ },
1270
+ quietStatus: (tone) => ({
1271
+ ...text("sm", tone === "failed" ? theme.colors.red : tone === "waiting" ? theme.colors.magenta : tone === "running" ? theme.colors.green : theme.colors.dim),
1272
+ flexShrink: 1,
1273
+ uni__dependencies: [0]
1274
+ }),
1275
+ quietAge: (waiting) => ({
1276
+ ...text("sm", waiting ? theme.colors.magenta : theme.colors.dim),
1277
+ textAlign: "right",
1278
+ uni__dependencies: [0]
1279
+ }),
1280
+ quietGroupName: {
1281
+ ...text("sm", theme.colors.dim),
1282
+ fontWeight: theme.fontWeight.medium,
1283
+ uni__dependencies: [0]
1284
+ },
1285
+ quietHostRow: {
1286
+ flexDirection: "row",
1287
+ alignItems: "center",
1288
+ gap: theme.spacing(1.5),
1289
+ paddingBottom: theme.spacing(1),
1290
+ uni__dependencies: [0]
1291
+ },
1292
+ quietSetupMark: {
1293
+ backgroundColor: theme.colors.panel,
1294
+ uni__dependencies: [0]
1295
+ },
1296
+ nested: {
1297
+ marginLeft: theme.spacing(5),
1298
+ uni__dependencies: [0]
1299
+ },
1300
+ iconButton: {
1301
+ width: 44,
1302
+ height: 44,
1303
+ borderRadius: theme.borderRadius.lg,
1304
+ alignItems: "center",
1305
+ justifyContent: "center",
1306
+ uni__dependencies: [0]
1307
+ },
1308
+ iconPressed: {
1309
+ backgroundColor: theme.colors.panel,
1310
+ uni__dependencies: [0]
1311
+ },
1312
+ cardHead: {
1313
+ flexDirection: "row",
1314
+ alignItems: "flex-start",
1315
+ gap: theme.spacing(2.5),
1316
+ uni__dependencies: [0]
1317
+ },
1318
+ avatar: {
1319
+ width: 24,
1320
+ height: 24,
1321
+ borderRadius: 12,
1322
+ alignItems: "center",
1323
+ justifyContent: "center",
1324
+ backgroundColor: theme.colors["tint-green"],
1325
+ uni__dependencies: [0]
1326
+ },
1327
+ initials: {
1328
+ ...text("xs", theme.colors.green),
1329
+ fontWeight: theme.fontWeight.semibold,
1330
+ uni__dependencies: [0]
1331
+ },
1332
+ nameBadge: {
1333
+ borderColor: theme.colors.bg,
1334
+ uni__dependencies: [0]
1335
+ },
1336
+ cardText: {
1337
+ flex: 1,
1338
+ minWidth: 0,
1339
+ gap: theme.spacing(1),
1340
+ uni__dependencies: [0]
1341
+ },
1342
+ nameRow: {
1343
+ flexDirection: "row",
1344
+ alignItems: "center",
1345
+ gap: theme.spacing(1.5),
1346
+ uni__dependencies: [0]
1347
+ },
1348
+ name: {
1349
+ ...text("base", theme.colors.hi),
1350
+ fontWeight: theme.fontWeight.semibold,
1351
+ flexShrink: 1,
1352
+ uni__dependencies: [0]
1353
+ },
1354
+ detailRow: {
1355
+ flexDirection: "row",
1356
+ alignItems: "center",
1357
+ gap: theme.spacing(2),
1358
+ uni__dependencies: [0]
1359
+ },
1360
+ statusRow: {
1361
+ flex: 1,
1362
+ minWidth: 0,
1363
+ flexDirection: "row",
1364
+ flexWrap: "wrap",
1365
+ alignItems: "center",
1366
+ columnGap: theme.spacing(1.5),
1367
+ rowGap: 2,
1368
+ uni__dependencies: [0]
1369
+ },
1370
+ status: (tone) => ({
1371
+ ...text("sm", tone === "failed" ? theme.colors.red : tone === "running" ? theme.colors.yellow : theme.colors.dim),
1372
+ flexShrink: 1,
1373
+ uni__dependencies: [0]
1374
+ }),
1375
+ branchRow: {
1376
+ flexDirection: "row",
1377
+ alignItems: "center",
1378
+ gap: theme.spacing(1),
1379
+ uni__dependencies: [0]
1380
+ },
1381
+ branch: {
1382
+ ...text("sm", theme.colors.dim),
1383
+ fontFamily: fontOf(theme.fontFamily.mono),
1384
+ flexShrink: 1,
1385
+ uni__dependencies: [0]
1386
+ },
1387
+ modified: text("sm", theme.colors.yellow),
1388
+ age: {
1389
+ ...text("xs", theme.colors.dim),
1390
+ marginLeft: "auto",
1391
+ uni__dependencies: [0]
1392
+ },
1393
+ groupsRow: {
1394
+ flexDirection: "row",
1395
+ alignItems: "flex-start",
1396
+ gap: theme.spacing(1.5),
1397
+ uni__dependencies: [0]
1398
+ },
1399
+ groups: {
1400
+ flex: 1,
1401
+ flexDirection: "row",
1402
+ flexWrap: "wrap",
1403
+ gap: theme.spacing(1),
1404
+ uni__dependencies: [0]
1405
+ },
1406
+ setup: {
1407
+ gap: theme.spacing(1),
1408
+ marginLeft: theme.spacing(4),
1409
+ padding: theme.spacing(3),
1410
+ borderRadius: theme.borderRadius.md,
1411
+ borderWidth: 1,
1412
+ borderColor: theme.colors["border-soft"],
1413
+ backgroundColor: theme.colors.panel,
1414
+ uni__dependencies: [0]
1415
+ },
1416
+ setupStatus: (failed) => text("sm", failed ? theme.colors.red : theme.colors.dim),
1417
+ setupHead: {
1418
+ flexDirection: "row",
1419
+ alignItems: "center",
1420
+ gap: theme.spacing(2),
1421
+ marginVertical: -theme.spacing(2),
1422
+ uni__dependencies: [0]
1423
+ },
1424
+ setupName: { flex: 1 },
1425
+ recovery: text("sm", theme.colors.dim),
1426
+ error: text("sm", theme.colors.red),
1427
+ updateRequired: text("sm", theme.colors.magenta)
1428
+ };
1429
+ });
1430
+
1431
+ //#endregion
1432
+ export { SessionCreateMenu, SessionViewSheet, SessionsScreen, ageText, sessionSections, sessionTimeline };
1433
+ //# sourceMappingURL=SessionsScreen.mjs.map