paseo-office 0.2.0 → 0.2.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 (143) hide show
  1. package/OVERVIEW.md +27 -0
  2. package/README.md +65 -134
  3. package/client/action-button.tsx +4 -1
  4. package/client/activity-panel.tsx +6 -4
  5. package/client/agent-appearance.tsx +257 -0
  6. package/client/agent-card.tsx +2 -1
  7. package/client/agent-picker-text.ts +23 -4
  8. package/client/agent-picker.tsx +5 -8
  9. package/client/board-sheet.tsx +48 -16
  10. package/client/board-text.ts +12 -2
  11. package/client/brand.ts +1 -0
  12. package/client/chat-chrome.tsx +318 -0
  13. package/client/chat-compose-tools.tsx +314 -0
  14. package/client/chat-dictation.tsx +133 -0
  15. package/client/chat-more.tsx +119 -0
  16. package/client/chat-panel.tsx +401 -146
  17. package/client/chat-quick.tsx +198 -0
  18. package/client/chat-text.ts +25 -6
  19. package/client/column-sheet.tsx +93 -23
  20. package/client/conversation-model.ts +19 -5
  21. package/client/duty-sheet.tsx +321 -0
  22. package/client/duty-text.ts +20 -0
  23. package/client/fullscreen-header.tsx +28 -13
  24. package/client/fullscreen-theme.ts +38 -0
  25. package/client/host-details.tsx +269 -0
  26. package/client/host-styles.ts +129 -0
  27. package/client/host-switches.tsx +212 -83
  28. package/client/incidents-card.tsx +2 -1
  29. package/client/janitor-card.tsx +1 -1
  30. package/client/library-card.tsx +2 -1
  31. package/client/list-text.ts +8 -6
  32. package/client/lobby-board.tsx +73 -53
  33. package/client/machine-card.tsx +225 -85
  34. package/client/messenger-styles.ts +216 -0
  35. package/client/new-agent-form.tsx +153 -61
  36. package/client/new-agent-model.ts +2 -0
  37. package/client/notes-card.tsx +111 -83
  38. package/client/notes-days.tsx +1 -1
  39. package/client/office-brand-context.ts +44 -0
  40. package/client/office-column.tsx +2 -1
  41. package/client/office-keyboard.ts +79 -0
  42. package/client/office-link.ts +7 -1
  43. package/client/office-mark.tsx +29 -0
  44. package/client/office-modal.tsx +440 -0
  45. package/client/office-settings.tsx +75 -30
  46. package/client/office-state.ts +12 -2
  47. package/client/office-surface.tsx +591 -81
  48. package/client/pixel/actors.ts +2 -1
  49. package/client/pixel/art.ts +33 -19
  50. package/client/pixel/pixel-office.tsx +2 -2
  51. package/client/prompt-coach.tsx +152 -0
  52. package/client/qa-card.tsx +2 -1
  53. package/client/review-card.tsx +2 -1
  54. package/client/room-board.tsx +26 -2
  55. package/client/scene-picker.tsx +158 -0
  56. package/client/scene-previews.ts +10 -0
  57. package/client/session-pane.tsx +25 -5
  58. package/client/session-panel-detail.tsx +238 -0
  59. package/client/session-panel.tsx +222 -137
  60. package/client/session-styles.ts +224 -1
  61. package/client/session-transcript.tsx +243 -0
  62. package/client/sessions-panel.tsx +181 -22
  63. package/client/sessions-text.ts +18 -0
  64. package/client/settings-sections.tsx +126 -0
  65. package/client/sidebar-launcher.ts +29 -0
  66. package/client/ssh-hosts.tsx +331 -0
  67. package/client/ssh-metrics.ts +76 -0
  68. package/client/standup-card.tsx +2 -1
  69. package/client/structure-view.tsx +20 -3
  70. package/client/styles.ts +170 -62
  71. package/client/team-chat-preview.tsx +96 -0
  72. package/client/tracker-connections.tsx +252 -0
  73. package/client/transcript-styles.ts +90 -0
  74. package/client/use-device-switch.ts +21 -12
  75. package/client/use-duty-actions.ts +43 -0
  76. package/client/use-group-photo.ts +48 -0
  77. package/client/use-new-agent.ts +4 -0
  78. package/client/use-street.ts +8 -0
  79. package/client/workspace-office-tools.tsx +102 -0
  80. package/client/workspace-overlay-route.web.ts +47 -0
  81. package/client/workspace-overlay.tsx +195 -0
  82. package/client/world/adapter.ts +37 -2
  83. package/client/world/escape.ts +58 -0
  84. package/client/world/use-world-feed.ts +6 -2
  85. package/client/world/workspace-dock.ts +6 -0
  86. package/client/world/world-api.ts +45 -4
  87. package/client/world/world-bridge-page.ts +14 -3
  88. package/client/world/world-bridge.ts +50 -5
  89. package/client/world/world-frame.web.ts +8 -0
  90. package/client/world/world-view-native.tsx +31 -10
  91. package/client/world/world-view-shared.ts +36 -7
  92. package/client/world/world-view.tsx +93 -21
  93. package/docs/office.md +165 -64
  94. package/index.client.tsx +13 -6
  95. package/index.server.ts +232 -16
  96. package/package.json +2 -1
  97. package/server/activity.ts +42 -19
  98. package/server/agent-tools.ts +11 -5
  99. package/server/board-service.ts +381 -10
  100. package/server/brand-logo.ts +34 -0
  101. package/server/chat-group.ts +83 -0
  102. package/server/chat-service.ts +406 -62
  103. package/server/chat-store.ts +1 -4
  104. package/server/directory.ts +22 -7
  105. package/server/duty-service.ts +230 -0
  106. package/server/group-photo.ts +39 -0
  107. package/server/home-departure.ts +47 -0
  108. package/server/hub.ts +43 -1
  109. package/server/incidents-jira.ts +19 -7
  110. package/server/incidents-schedule.ts +10 -10
  111. package/server/incidents-sentry.ts +34 -8
  112. package/server/live-ports.ts +114 -18
  113. package/server/lobby-pickup.ts +170 -0
  114. package/server/machine/details.ts +91 -0
  115. package/server/mention-queue.ts +14 -0
  116. package/server/office.ts +110 -6
  117. package/server/paths.ts +14 -0
  118. package/server/ssh/LICENSE.paseo +211 -0
  119. package/server/ssh/client.ts +401 -0
  120. package/server/ssh/discovery.ts +230 -0
  121. package/server/ssh/installed.ts +104 -0
  122. package/server/ssh/monitor.ts +104 -0
  123. package/server/ssh/pid-files.ts +194 -0
  124. package/server/ssh/read.ts +136 -0
  125. package/server/subagent-names.ts +4 -0
  126. package/server/tracker-credentials.ts +141 -0
  127. package/server/words.generated.ts +1 -1
  128. package/server/world.generated.ts +1 -1
  129. package/shared/appearance.ts +43 -0
  130. package/shared/branding.ts +53 -0
  131. package/shared/chat-words.ts +2 -2
  132. package/shared/contracts.ts +199 -5
  133. package/shared/duties.ts +100 -0
  134. package/shared/host-details.ts +25 -0
  135. package/shared/lobby-assignment.ts +34 -0
  136. package/shared/model.ts +9 -1
  137. package/shared/names.ts +2 -0
  138. package/shared/settings.ts +14 -3
  139. package/shared/ssh.ts +34 -0
  140. package/shared/upstream/README.md +1 -3
  141. package/shared/upstream/chat-engine.d.ts +4 -0
  142. package/shared/upstream/prompt-coach.d.ts +6 -0
  143. package/shared/upstream/prompt-coach.js +178 -0
@@ -0,0 +1,331 @@
1
+ import { useCallback, useEffect, useMemo, useState, type ReactNode } from "react";
2
+ import { Pressable, Text, View, type ViewStyle } from "react-native";
3
+ import { useRpc } from "@getpaseo/plugin/client";
4
+ import { Icon } from "@getpaseo/plugin/client/ui";
5
+ import { sshReadingRpc, sshServersRpc, type SshDiscovery, type SshReading } from "../shared/ssh.js";
6
+ import {
7
+ STATUS_ORDER,
8
+ summarizeHost,
9
+ usedOf,
10
+ type HostSummary,
11
+ type RemoteMeter,
12
+ } from "./ssh-metrics.js";
13
+ import type { OfficeStyles } from "./styles.js";
14
+
15
+ export type { SshDiscovery } from "../shared/ssh.js";
16
+ export const NO_SSH: SshDiscovery = { servers: [], discoveryIncomplete: false };
17
+
18
+ const DISCOVERY_UNAVAILABLE: SshDiscovery = { servers: [], discoveryIncomplete: true };
19
+
20
+ export function useSshServers(enabled: boolean): SshDiscovery {
21
+ const discover = useRpc(sshServersRpc);
22
+ const [result, setResult] = useState(NO_SSH);
23
+ useEffect(() => {
24
+ if (!enabled) {
25
+ setResult(NO_SSH);
26
+ return;
27
+ }
28
+ let current = true;
29
+ async function load() {
30
+ let found: SshDiscovery;
31
+ try {
32
+ found = await discover({});
33
+ } catch {
34
+ found = DISCOVERY_UNAVAILABLE;
35
+ }
36
+ if (current) setResult(found);
37
+ }
38
+ void load();
39
+ return () => {
40
+ current = false;
41
+ };
42
+ }, [enabled, discover]);
43
+ return enabled ? result : NO_SSH;
44
+ }
45
+
46
+ interface TabProps {
47
+ id: string;
48
+ label: string;
49
+ selected: boolean;
50
+ select(id: string): void;
51
+ styles: OfficeStyles;
52
+ }
53
+
54
+ function Tab({ id, label, selected, select, styles }: TabProps) {
55
+ const press = useCallback(() => select(id), [id, select]);
56
+ return (
57
+ <Pressable
58
+ accessibilityRole="tab"
59
+ accessibilityLabel={label}
60
+ aria-selected={selected}
61
+ style={styles.segment}
62
+ onPress={press}
63
+ >
64
+ {selected && <View style={styles.segmentFill} />}
65
+ <Text style={selected ? styles.segmentTextSelected : styles.segmentText}>{label}</Text>
66
+ </Pressable>
67
+ );
68
+ }
69
+
70
+ function SshMeter({ meter, styles }: { meter: RemoteMeter; styles: OfficeStyles }) {
71
+ const { host } = styles;
72
+ const color = host[meter.tone].color;
73
+ const fill = useMemo(
74
+ (): ViewStyle => ({
75
+ height: "100%",
76
+ borderRadius: 3,
77
+ width: `${Math.min(100, Math.max(0, meter.value ?? 0))}%`,
78
+ backgroundColor: color,
79
+ }),
80
+ [meter.value, color],
81
+ );
82
+ return (
83
+ <View style={host.remoteMeter} accessible accessibilityLabel={`${meter.label}: ${meter.text}`}>
84
+ <Text style={host.note}>{meter.label}</Text>
85
+ <Text style={host.name}>{meter.text}</Text>
86
+ <View style={host.track}>{meter.value !== null && <View style={fill} />}</View>
87
+ </View>
88
+ );
89
+ }
90
+
91
+ const TONES = {
92
+ OK: "healthy",
93
+ Partial: "warning",
94
+ Warning: "warning",
95
+ Critical: "critical",
96
+ Unreachable: "critical",
97
+ } as const;
98
+ const ICONS = {
99
+ OK: "CircleCheck",
100
+ Partial: "CircleHelp",
101
+ Warning: "TriangleAlert",
102
+ Critical: "CircleAlert",
103
+ Unreachable: "CircleX",
104
+ } as const;
105
+
106
+ function HostDetails({ summary, styles }: { summary: HostSummary; styles: OfficeStyles }) {
107
+ const { host } = summary;
108
+ const averages = [host.load1, host.load5, host.load15]
109
+ .map((v) => v?.toFixed(2) ?? "—")
110
+ .join(" / ");
111
+ return (
112
+ <View style={styles.host.details}>
113
+ <Text style={styles.host.note}>
114
+ Memory used / total · {usedOf(host.memoryUsedBytes, host.memoryTotalBytes)}
115
+ </Text>
116
+ <Text style={styles.host.note}>Load averages (1 / 5 / 15 min) · {averages}</Text>
117
+ <Text style={styles.host.note}>CPU cores · {host.cores ?? "Unavailable"}</Text>
118
+ <Text style={styles.host.note}>
119
+ Disk used / total{host.diskMount && ` (${host.diskMount})`} ·{" "}
120
+ {usedOf(host.diskUsedBytes, host.diskTotalBytes)}
121
+ </Text>
122
+ </View>
123
+ );
124
+ }
125
+
126
+ function HostRow({
127
+ summary,
128
+ expanded,
129
+ toggle,
130
+ styles,
131
+ }: {
132
+ summary: HostSummary;
133
+ expanded: boolean;
134
+ toggle(name: string): void;
135
+ styles: OfficeStyles;
136
+ }) {
137
+ const { host, status, meters } = summary;
138
+ const tone = styles.host[TONES[status]];
139
+ const press = useCallback(() => toggle(host.name), [toggle, host.name]);
140
+ return (
141
+ <View style={styles.host.remoteCard}>
142
+ <View style={styles.host.remoteHeading}>
143
+ <Icon name={ICONS[status]} size={15} color={tone.color} />
144
+ <Text style={styles.host.remoteName}>{host.name}</Text>
145
+ <Text style={tone}>{status}</Text>
146
+ </View>
147
+ {host.reachable && (
148
+ <>
149
+ <View style={styles.host.meters}>
150
+ {meters.map((meter) => (
151
+ <SshMeter key={meter.label} meter={meter} styles={styles} />
152
+ ))}
153
+ </View>
154
+ <Pressable
155
+ accessibilityRole="button"
156
+ accessibilityLabel={`Details for ${host.name}`}
157
+ aria-expanded={expanded}
158
+ onPress={press}
159
+ style={styles.host.detailsButton}
160
+ >
161
+ <Text style={styles.host.note}>Details</Text>
162
+ <Icon
163
+ name={expanded ? "ChevronUp" : "ChevronDown"}
164
+ size={14}
165
+ color={styles.host.note.color}
166
+ />
167
+ </Pressable>
168
+ {expanded && <HostDetails summary={summary} styles={styles} />}
169
+ </>
170
+ )}
171
+ </View>
172
+ );
173
+ }
174
+
175
+ // Wait for a read to finish before scheduling the next. Switching tabs unmounts this panel.
176
+ const POLL_MS = 30_000;
177
+ function useRemoteReading(id: string) {
178
+ const read = useRpc(sshReadingRpc);
179
+ const [result, setResult] = useState<SshReading | null>(null);
180
+ useEffect(() => {
181
+ let current = true;
182
+ let inFlight = false;
183
+ let timer: ReturnType<typeof setTimeout>;
184
+ const page = typeof document === "undefined" ? undefined : document;
185
+ async function poll() {
186
+ clearTimeout(timer);
187
+ if (!current || inFlight || page?.hidden) return;
188
+ inFlight = true;
189
+ let reading: SshReading;
190
+ try {
191
+ reading = await read({ id });
192
+ } catch {
193
+ reading = { status: "unavailable", hosts: [] };
194
+ }
195
+ inFlight = false;
196
+ if (current) {
197
+ setResult(reading);
198
+ if (!page?.hidden) timer = setTimeout(poll, POLL_MS);
199
+ }
200
+ }
201
+ const visibilityChanged = () => void poll();
202
+ page?.addEventListener("visibilitychange", visibilityChanged);
203
+ void poll();
204
+ return () => {
205
+ current = false;
206
+ page?.removeEventListener("visibilitychange", visibilityChanged);
207
+ clearTimeout(timer);
208
+ };
209
+ }, [id, read]);
210
+ return result;
211
+ }
212
+
213
+ function ServerPanel({ id, styles }: { id: string; styles: OfficeStyles }) {
214
+ const reading = useRemoteReading(id);
215
+ const rows = useMemo(
216
+ () =>
217
+ (reading?.hosts ?? [])
218
+ .map(summarizeHost)
219
+ .sort((a, b) => STATUS_ORDER[a.status] - STATUS_ORDER[b.status]),
220
+ [reading],
221
+ );
222
+ const [expanded, setExpanded] = useState<string[]>([]);
223
+ const toggle = useCallback(
224
+ (name: string) =>
225
+ setExpanded((prev) =>
226
+ prev.includes(name) ? prev.filter((n) => n !== name) : [...prev, name],
227
+ ),
228
+ [],
229
+ );
230
+ const available = rows.filter(({ host }) => host.reachable);
231
+ const allOpen = available.every(({ host }) => expanded.includes(host.name));
232
+ const toggleAll = useCallback(
233
+ () => setExpanded(allOpen ? [] : available.map(({ host }) => host.name)),
234
+ [allOpen, available],
235
+ );
236
+ if (!reading) return <Text style={styles.host.note}>Reading SSH hosts…</Text>;
237
+ if (reading.status === "unavailable")
238
+ return (
239
+ <Text accessibilityRole="alert" style={styles.host.critical}>
240
+ Unable to read this SSH server.
241
+ </Text>
242
+ );
243
+ if (!rows.length)
244
+ return <Text style={styles.host.note}>No SSH hosts configured on this server.</Text>;
245
+ const attention = rows.filter((row) => row.status !== "OK").length;
246
+ return (
247
+ <View style={styles.host.group}>
248
+ <View style={styles.host.groupHead}>
249
+ <Text accessibilityRole="header" style={styles.host.title}>
250
+ {rows.length} {rows.length === 1 ? "host" : "hosts"}
251
+ {attention > 0 && ` · ${attention} need${attention === 1 ? "s" : ""} attention`}
252
+ </Text>
253
+ {available.length > 1 && (
254
+ <Pressable
255
+ accessibilityRole="button"
256
+ onPress={toggleAll}
257
+ style={styles.host.detailsButton}
258
+ >
259
+ <Text style={styles.host.note}>{allOpen ? "Collapse all" : "Expand all"}</Text>
260
+ </Pressable>
261
+ )}
262
+ </View>
263
+ {rows.map((summary) => (
264
+ <HostRow
265
+ key={summary.host.name}
266
+ summary={summary}
267
+ expanded={expanded.includes(summary.host.name)}
268
+ toggle={toggle}
269
+ styles={styles}
270
+ />
271
+ ))}
272
+ </View>
273
+ );
274
+ }
275
+
276
+ function SshPanel({ discovery, styles }: { discovery: SshDiscovery; styles: OfficeStyles }) {
277
+ const { servers } = discovery;
278
+ const [id, select] = useState(servers[0].id);
279
+ const server = servers.find((each) => each.id === id) ?? servers[0];
280
+ return (
281
+ <View style={styles.host.group}>
282
+ {servers.length > 1 && (
283
+ <View accessibilityRole="tablist" accessibilityLabel="SSH servers" style={styles.host.tabs}>
284
+ {servers.map((each) => (
285
+ <Tab
286
+ key={each.id}
287
+ id={each.id}
288
+ label={each.name}
289
+ selected={each.id === server.id}
290
+ select={select}
291
+ styles={styles}
292
+ />
293
+ ))}
294
+ </View>
295
+ )}
296
+ {discovery.discoveryIncomplete && (
297
+ <Text style={styles.host.note}>Some SSH configurations could not be read.</Text>
298
+ )}
299
+ <ServerPanel key={server.id} id={server.id} styles={styles} />
300
+ </View>
301
+ );
302
+ }
303
+
304
+ export function HostViews({
305
+ discovery,
306
+ hasLocal,
307
+ styles,
308
+ children,
309
+ }: {
310
+ discovery: SshDiscovery;
311
+ hasLocal: boolean;
312
+ styles: OfficeStyles;
313
+ children: ReactNode;
314
+ }) {
315
+ const [tab, select] = useState(hasLocal ? "local" : "ssh");
316
+ if (!discovery.servers.length) return children;
317
+ const ssh = tab === "ssh";
318
+ return (
319
+ <View style={styles.host.body}>
320
+ <View
321
+ accessibilityRole="tablist"
322
+ accessibilityLabel="Host resources"
323
+ style={styles.host.tabs}
324
+ >
325
+ <Tab id="local" label="This instance" selected={!ssh} select={select} styles={styles} />
326
+ <Tab id="ssh" label="SSH" selected={ssh} select={select} styles={styles} />
327
+ </View>
328
+ {ssh ? <SshPanel discovery={discovery} styles={styles} /> : children}
329
+ </View>
330
+ );
331
+ }
@@ -0,0 +1,76 @@
1
+ import type { SshHost } from "../shared/ssh.js";
2
+ import { formatBytes } from "../shared/machine-text.js";
3
+
4
+ export type MetricTone = "ok" | "warning" | "critical";
5
+
6
+ function percent(used: number | null, total: number | null): number | null {
7
+ return used !== null && total !== null && total > 0 ? (used / total) * 100 : null;
8
+ }
9
+
10
+ function metric(
11
+ label: string,
12
+ value: number | null,
13
+ note: string | null,
14
+ warning: number,
15
+ critical: number,
16
+ ) {
17
+ let tone: MetricTone = "ok";
18
+ if (value !== null && value >= critical) tone = "critical";
19
+ else if (value !== null && value >= warning) tone = "warning";
20
+ const amount = value === null ? null : `${Math.round(value)}%`;
21
+ return {
22
+ label,
23
+ value,
24
+ tone,
25
+ text: amount === null ? "Unavailable" : [amount, note].filter(Boolean).join(" · "),
26
+ };
27
+ }
28
+
29
+ export function summarizeHost(host: SshHost) {
30
+ const {
31
+ cores,
32
+ load1,
33
+ memoryUsedBytes,
34
+ memoryTotalBytes,
35
+ diskMount,
36
+ diskUsedBytes,
37
+ diskTotalBytes,
38
+ } = host;
39
+ const memory = metric(
40
+ "Memory",
41
+ percent(memoryUsedBytes, memoryTotalBytes),
42
+ memoryUsedBytes === null ? null : formatBytes(memoryUsedBytes),
43
+ 80,
44
+ 90,
45
+ );
46
+ const load = metric(
47
+ "Load",
48
+ percent(load1, cores),
49
+ cores === null ? null : `${cores} ${cores === 1 ? "core" : "cores"}`,
50
+ 100,
51
+ 200,
52
+ );
53
+ const disk = metric("Disk", percent(diskUsedBytes, diskTotalBytes), diskMount, 85, 95);
54
+ const meters = [memory, load, disk];
55
+ let status: "Unreachable" | "Critical" | "Warning" | "Partial" | "OK" = "OK";
56
+ if (!host.reachable) status = "Unreachable";
57
+ else if (meters.some((each) => each.tone === "critical")) status = "Critical";
58
+ else if (meters.some((each) => each.tone === "warning")) status = "Warning";
59
+ else if (meters.some((each) => each.value === null)) status = "Partial";
60
+ return { host, meters, status };
61
+ }
62
+
63
+ export type HostSummary = ReturnType<typeof summarizeHost>;
64
+ export type RemoteMeter = HostSummary["meters"][number];
65
+ export const STATUS_ORDER: Record<HostSummary["status"], number> = {
66
+ Unreachable: 0,
67
+ Critical: 1,
68
+ Warning: 2,
69
+ Partial: 3,
70
+ OK: 4,
71
+ };
72
+
73
+ export function usedOf(used: number | null, total: number | null): string {
74
+ if (used === null || total === null) return "Unavailable";
75
+ return `${formatBytes(used)} of ${formatBytes(total)}`;
76
+ }
@@ -1,6 +1,7 @@
1
1
  import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
  import { Text, View } from "react-native";
3
- import { ExternalLink, Modal, copyText, useToast } from "@getpaseo/plugin/client/ui";
3
+ import { ExternalLink, copyText, useToast } from "@getpaseo/plugin/client/ui";
4
+ import { OfficeModal as Modal } from "./office-modal.js";
4
5
  import type { NotesState } from "../shared/contracts.js";
5
6
  import { ActionButton, failureText } from "./action-button.js";
6
7
  import { WriterLine } from "./notes-card.js";
@@ -48,6 +48,7 @@ function clockInterval(rooms: readonly OfficeRoom[]): number | null {
48
48
  let interval: number | null = null;
49
49
  for (const room of rooms) {
50
50
  for (const { agent } of room.rows) {
51
+ if (agent.permissions.length && agent.permissionSince) interval = MINUTE;
51
52
  if (attentionReason(agent) !== null) continue;
52
53
  if (agent.status === "running" && agent.promptedAt !== undefined) return SECOND;
53
54
  if (agent.status === "idle") interval = MINUTE;
@@ -57,7 +58,8 @@ function clockInterval(rooms: readonly OfficeRoom[]): number | null {
57
58
  }
58
59
 
59
60
  /** The time now, read again every `intervalMs`; kept as it was while that is null. */
60
- function useNow(intervalMs: number | null): number {
61
+ export function useRowClock(rooms: readonly OfficeRoom[]): number {
62
+ const intervalMs = clockInterval(rooms);
61
63
  const [now, setNow] = useState(() => Date.now());
62
64
  useEffect(() => {
63
65
  if (intervalMs === null) return undefined;
@@ -213,6 +215,7 @@ interface RoomCardProps {
213
215
  onSelectAgent(agentId: string): void;
214
216
  onOpenSession: ((agentId: string) => void) | undefined;
215
217
  onOpenBoard(roomId: string): void;
218
+ onOpenDuties: (() => void) | undefined;
216
219
  }
217
220
 
218
221
  function RoomCard({
@@ -225,6 +228,7 @@ function RoomCard({
225
228
  onSelectAgent,
226
229
  onOpenSession,
227
230
  onOpenBoard,
231
+ onOpenDuties,
228
232
  }: RoomCardProps) {
229
233
  return (
230
234
  <View style={styles.card}>
@@ -253,7 +257,13 @@ function RoomCard({
253
257
  onOpenSession={onOpenSession}
254
258
  />
255
259
  ))}
256
- <RoomBoard room={room} name={name} styles={styles} onOpenBoard={onOpenBoard} />
260
+ <RoomBoard
261
+ room={room}
262
+ name={name}
263
+ styles={styles}
264
+ onOpenBoard={onOpenBoard}
265
+ onOpenDuties={onOpenDuties}
266
+ />
257
267
  </View>
258
268
  );
259
269
  }
@@ -370,6 +380,11 @@ export interface StructureViewProps {
370
380
  /** Opens an agent's session from its row, in the office's column. The surface always supplies it. */
371
381
  onOpenSession?(agentId: string): void;
372
382
  onOpenBoard(roomId: string): void;
383
+ /**
384
+ * The duty board's editor, from the lobby's card: the way to it without the 3D floor. Absent
385
+ * while the host has sent no duty list.
386
+ */
387
+ onOpenDuties?: (() => void) | undefined;
373
388
  }
374
389
 
375
390
  /**
@@ -385,12 +400,13 @@ export function StructureView({
385
400
  onSelectAgent,
386
401
  onOpenSession,
387
402
  onOpenBoard,
403
+ onOpenDuties,
388
404
  }: StructureViewProps) {
389
405
  const [tab, setTab] = useState<ListTab>("all");
390
406
  const [query, setQuery] = useState("");
391
407
  const counts = useMemo(() => tabCounts(rooms.flatMap((room) => room.rows)), [rooms]);
392
408
  const shown = useMemo(() => filterRooms(rooms, tab, query), [rooms, tab, query]);
393
- const now = useNow(clockInterval(shown));
409
+ const now = useRowClock(shown);
394
410
  useEffect(() => (Platform.OS === "web" ? listenForSlash(SEARCH_ID) : undefined), []);
395
411
  // An office without agents keeps its rooms' own "No agents"; a filter that finds none says so.
396
412
  const found = counts.all === 0 || shown.some((room) => room.rows.length > 0);
@@ -418,6 +434,7 @@ export function StructureView({
418
434
  onSelectAgent={onSelectAgent}
419
435
  onOpenSession={onOpenSession}
420
436
  onOpenBoard={onOpenBoard}
437
+ onOpenDuties={onOpenDuties}
421
438
  />
422
439
  ))}
423
440
  </ScrollView>