paseo-office 0.2.0 → 0.2.1
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.
- package/OVERVIEW.md +27 -0
- package/README.md +65 -134
- package/client/action-button.tsx +4 -1
- package/client/activity-panel.tsx +6 -4
- package/client/agent-appearance.tsx +257 -0
- package/client/agent-card.tsx +2 -1
- package/client/agent-picker-text.ts +23 -4
- package/client/agent-picker.tsx +5 -8
- package/client/board-sheet.tsx +48 -16
- package/client/board-text.ts +12 -2
- package/client/brand.ts +1 -0
- package/client/chat-chrome.tsx +318 -0
- package/client/chat-compose-tools.tsx +314 -0
- package/client/chat-dictation.tsx +133 -0
- package/client/chat-more.tsx +119 -0
- package/client/chat-panel.tsx +401 -146
- package/client/chat-quick.tsx +198 -0
- package/client/chat-text.ts +25 -6
- package/client/column-sheet.tsx +93 -23
- package/client/conversation-model.ts +19 -5
- package/client/duty-sheet.tsx +321 -0
- package/client/duty-text.ts +20 -0
- package/client/fullscreen-header.tsx +28 -13
- package/client/fullscreen-theme.ts +38 -0
- package/client/host-details.tsx +269 -0
- package/client/host-styles.ts +129 -0
- package/client/host-switches.tsx +197 -73
- package/client/incidents-card.tsx +2 -1
- package/client/janitor-card.tsx +1 -1
- package/client/library-card.tsx +2 -1
- package/client/list-text.ts +8 -6
- package/client/lobby-board.tsx +73 -53
- package/client/machine-card.tsx +225 -85
- package/client/messenger-styles.ts +216 -0
- package/client/new-agent-form.tsx +153 -61
- package/client/new-agent-model.ts +2 -0
- package/client/notes-card.tsx +111 -83
- package/client/notes-days.tsx +1 -1
- package/client/office-brand-context.ts +44 -0
- package/client/office-column.tsx +2 -1
- package/client/office-keyboard.ts +79 -0
- package/client/office-link.ts +7 -1
- package/client/office-mark.tsx +29 -0
- package/client/office-modal.tsx +440 -0
- package/client/office-settings.tsx +75 -30
- package/client/office-state.ts +12 -2
- package/client/office-surface.tsx +591 -81
- package/client/pixel/actors.ts +2 -1
- package/client/pixel/art.ts +33 -19
- package/client/pixel/pixel-office.tsx +2 -2
- package/client/prompt-coach.tsx +152 -0
- package/client/qa-card.tsx +2 -1
- package/client/review-card.tsx +2 -1
- package/client/room-board.tsx +26 -2
- package/client/scene-picker.tsx +158 -0
- package/client/scene-previews.ts +10 -0
- package/client/session-pane.tsx +25 -5
- package/client/session-panel-detail.tsx +238 -0
- package/client/session-panel.tsx +222 -137
- package/client/session-styles.ts +224 -1
- package/client/session-transcript.tsx +243 -0
- package/client/sessions-panel.tsx +181 -22
- package/client/sessions-text.ts +18 -0
- package/client/settings-sections.tsx +126 -0
- package/client/sidebar-launcher.ts +29 -0
- package/client/ssh-hosts.tsx +331 -0
- package/client/ssh-metrics.ts +76 -0
- package/client/standup-card.tsx +2 -1
- package/client/structure-view.tsx +20 -3
- package/client/styles.ts +170 -62
- package/client/team-chat-preview.tsx +96 -0
- package/client/transcript-styles.ts +90 -0
- package/client/use-device-switch.ts +21 -12
- package/client/use-duty-actions.ts +43 -0
- package/client/use-group-photo.ts +48 -0
- package/client/use-new-agent.ts +4 -0
- package/client/use-street.ts +8 -0
- package/client/workspace-office-tools.tsx +102 -0
- package/client/workspace-overlay-route.web.ts +47 -0
- package/client/workspace-overlay.tsx +195 -0
- package/client/world/adapter.ts +37 -2
- package/client/world/escape.ts +58 -0
- package/client/world/use-world-feed.ts +6 -2
- package/client/world/workspace-dock.ts +6 -0
- package/client/world/world-api.ts +45 -4
- package/client/world/world-bridge-page.ts +14 -3
- package/client/world/world-bridge.ts +50 -5
- package/client/world/world-frame.web.ts +8 -0
- package/client/world/world-view-native.tsx +31 -10
- package/client/world/world-view-shared.ts +36 -7
- package/client/world/world-view.tsx +93 -21
- package/docs/office.md +148 -58
- package/index.client.tsx +13 -6
- package/index.server.ts +125 -9
- package/package.json +2 -1
- package/server/activity.ts +42 -19
- package/server/agent-tools.ts +11 -5
- package/server/board-service.ts +381 -10
- package/server/brand-logo.ts +34 -0
- package/server/chat-group.ts +83 -0
- package/server/chat-service.ts +406 -62
- package/server/chat-store.ts +1 -4
- package/server/directory.ts +22 -7
- package/server/duty-service.ts +230 -0
- package/server/group-photo.ts +39 -0
- package/server/home-departure.ts +47 -0
- package/server/hub.ts +43 -1
- package/server/live-ports.ts +114 -18
- package/server/lobby-pickup.ts +170 -0
- package/server/machine/details.ts +91 -0
- package/server/mention-queue.ts +14 -0
- package/server/office.ts +110 -6
- package/server/paths.ts +9 -0
- package/server/ssh/LICENSE.paseo +211 -0
- package/server/ssh/client.ts +401 -0
- package/server/ssh/discovery.ts +230 -0
- package/server/ssh/installed.ts +104 -0
- package/server/ssh/monitor.ts +104 -0
- package/server/ssh/pid-files.ts +194 -0
- package/server/ssh/read.ts +136 -0
- package/server/subagent-names.ts +4 -0
- package/server/words.generated.ts +1 -1
- package/server/world.generated.ts +1 -1
- package/shared/appearance.ts +43 -0
- package/shared/branding.ts +53 -0
- package/shared/chat-words.ts +2 -2
- package/shared/contracts.ts +135 -4
- package/shared/duties.ts +100 -0
- package/shared/host-details.ts +25 -0
- package/shared/lobby-assignment.ts +34 -0
- package/shared/model.ts +9 -1
- package/shared/names.ts +2 -0
- package/shared/settings.ts +14 -3
- package/shared/ssh.ts +34 -0
- package/shared/upstream/README.md +1 -3
- package/shared/upstream/chat-engine.d.ts +4 -0
- package/shared/upstream/prompt-coach.d.ts +6 -0
- 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
|
+
}
|
package/client/standup-card.tsx
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
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 =
|
|
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>
|