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

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