@agimon-ai/po-template-desktop 0.0.0-alpha.132
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/LICENSE +149 -0
- package/README.md +24 -0
- package/dist/extensions/web.mjs +3084 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/webClient.cjs +3085 -0
- package/dist/webClient.cjs.map +1 -0
- package/dist/webClient.d.mts +4 -0
- package/dist/webClient.d.mts.map +1 -0
- package/dist/webClient.mjs +3084 -0
- package/dist/webClient.mjs.map +1 -0
- package/llms.txt +5 -0
- package/package.json +109 -0
|
@@ -0,0 +1,3084 @@
|
|
|
1
|
+
import { defineWebPlugin, defineWebTemplate } from "@agimon-ai/po-core/web";
|
|
2
|
+
import { ActivityIcon, AlertIcon, AppWindowIcon, Avatar, AvatarFallback, AvatarImage, Badge, Button, CheckIcon, Checkbox, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, FileIcon, FolderIcon, GearIcon, HomeIcon, Input, KebabIcon, LiveDuration, LoaderIcon, MessageIcon, MessageItem, NavTab, OptionRow, PlusIcon, Popover, PopoverContent, PopoverTrigger, PuzzleIcon, SearchIcon, ShieldIcon, ShrinkIcon, SlidersIcon, SparklesIcon, Spinner, Textarea, Tooltip, TooltipContent, TooltipTrigger } from "@agimon-ai/po-web-components";
|
|
3
|
+
import { DEFAULT_REPOSITORY_SETTINGS_SECTION, DEFAULT_SETTINGS_SECTION, DashboardRendererProvider, HOST_SLOTS, activityGroupSlot, closeTransientTab, discoverWorkspaceAdmission, dockTabFor, findTransientTab, pluginActivityGroups, refreshWebPluginCompositions, sessionsStore, setDockTab, settingsSection, slotFills, transientTabsStore, uiStore, updateWorkspaceAdmission, useActiveSession, useActiveSessionMeta, useActivityGroups, useDashboardRoute, useDashboardState, useDockFaceBadges, useDockFaces, usePluginSlotProps, useSessionMcp, useTransientTabs, useWebPluginRegistry, watchDashboardTranscript, webTabs, workspaceAdmissionStore } from "@agimon-ai/po-web-dashboard";
|
|
4
|
+
import { AccountSettings, AppearanceSettings, ClientDevices, CommandPalette, Composer, ContextPanel, ContributedSettings, DialogOverlay, ImageSettings, MascotMark, NotificationSettings, PairingApprovalDialog, PluginPage, PluginSurface, PresetSettings, ProviderSettings, RefusedCard, RemoteAccessDialog, RemoteControlSettings, RepositoryWorkspace, SelectionBar, SessionActivity, SessionMcp, SessionRailDialogs, SessionSettings, SessionTranscriptView, SettingsMenu, SettingsPanelHost, ThreadView, Timeline, ToolCard, WorkspacePage, toolOutputDescriptors, useSessionRail } from "@agimon-ai/po-web-dashboard/views";
|
|
5
|
+
import { Link, useNavigate } from "@tanstack/react-router";
|
|
6
|
+
import { Store, useStore } from "@tanstack/react-store";
|
|
7
|
+
import { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/extensions/(frontend)/template/_lib/windowLayout.ts
|
|
10
|
+
const LAYOUT_STORAGE_KEY = "po.web.desktop.v1";
|
|
11
|
+
const EMPTY_LAYOUT = {
|
|
12
|
+
version: 1,
|
|
13
|
+
windows: [],
|
|
14
|
+
z: [],
|
|
15
|
+
widgets: null,
|
|
16
|
+
expanded: [],
|
|
17
|
+
activityHidden: false
|
|
18
|
+
};
|
|
19
|
+
const FULL = [
|
|
20
|
+
0,
|
|
21
|
+
0,
|
|
22
|
+
100,
|
|
23
|
+
100
|
|
24
|
+
];
|
|
25
|
+
/** Where windows that take no slot open. */
|
|
26
|
+
const FLOAT = {
|
|
27
|
+
settings: [
|
|
28
|
+
18,
|
|
29
|
+
8,
|
|
30
|
+
64,
|
|
31
|
+
80
|
|
32
|
+
],
|
|
33
|
+
page: [
|
|
34
|
+
14,
|
|
35
|
+
6,
|
|
36
|
+
72,
|
|
37
|
+
86
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
/** A saved layout past this many windows is rubbish, not a desktop. */
|
|
41
|
+
const MAX_WINDOWS = 40;
|
|
42
|
+
const EDGE = 12;
|
|
43
|
+
const CORNER = 48;
|
|
44
|
+
/** At least this much of a window stays on the desktop, so its title can always be grabbed. */
|
|
45
|
+
const KEEP = 10;
|
|
46
|
+
/** Three windows open side by side from this desktop width. */
|
|
47
|
+
const WIDE = 1600;
|
|
48
|
+
const sessionWindowId = (sessionId) => `session:${sessionId}`;
|
|
49
|
+
const tabWindowId = (sessionId, tabId) => `tab:${sessionId}:${tabId}`;
|
|
50
|
+
/** A tab window belongs to its session's stack; every other window is its own. */
|
|
51
|
+
function stackRoot(win) {
|
|
52
|
+
return win.kind === "tab" && win.sessionId !== void 0 ? sessionWindowId(win.sessionId) : win.id;
|
|
53
|
+
}
|
|
54
|
+
function findWindow(layout, id) {
|
|
55
|
+
return layout.windows.find((win) => win.id === id);
|
|
56
|
+
}
|
|
57
|
+
/** Stacks in open order, members back to front. */
|
|
58
|
+
function stacksOf(layout) {
|
|
59
|
+
const roots = [];
|
|
60
|
+
for (const win of layout.windows) {
|
|
61
|
+
const root = stackRoot(win);
|
|
62
|
+
if (!roots.includes(root)) roots.push(root);
|
|
63
|
+
}
|
|
64
|
+
return roots.map((root) => ({
|
|
65
|
+
root,
|
|
66
|
+
members: layout.windows.filter((win) => stackRoot(win) === root).sort((a, b) => layout.z.indexOf(a.id) - layout.z.indexOf(b.id))
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
/** The topmost window that is not minimised, which is the one the person is using. */
|
|
70
|
+
function frontWindow(layout) {
|
|
71
|
+
for (let index = layout.z.length - 1; index >= 0; index--) {
|
|
72
|
+
const win = findWindow(layout, layout.z[index]);
|
|
73
|
+
if (win !== void 0 && win.minimized !== true) return win;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Default places for `count` session stacks. One fills the desktop, two split it, three put
|
|
78
|
+
* the first in a tall slot (side by side on a wide desktop), four take quarters.
|
|
79
|
+
*/
|
|
80
|
+
function slots(count, widthPx) {
|
|
81
|
+
if (count <= 1) return [FULL];
|
|
82
|
+
if (count === 2) return [[
|
|
83
|
+
0,
|
|
84
|
+
0,
|
|
85
|
+
50,
|
|
86
|
+
100
|
|
87
|
+
], [
|
|
88
|
+
50,
|
|
89
|
+
0,
|
|
90
|
+
50,
|
|
91
|
+
100
|
|
92
|
+
]];
|
|
93
|
+
if (count === 3 && widthPx >= WIDE) return [
|
|
94
|
+
[
|
|
95
|
+
0,
|
|
96
|
+
0,
|
|
97
|
+
100 / 3,
|
|
98
|
+
100
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
100 / 3,
|
|
102
|
+
0,
|
|
103
|
+
100 / 3,
|
|
104
|
+
100
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
200 / 3,
|
|
108
|
+
0,
|
|
109
|
+
100 / 3,
|
|
110
|
+
100
|
|
111
|
+
]
|
|
112
|
+
];
|
|
113
|
+
if (count === 3) return [
|
|
114
|
+
[
|
|
115
|
+
0,
|
|
116
|
+
0,
|
|
117
|
+
50,
|
|
118
|
+
100
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
50,
|
|
122
|
+
0,
|
|
123
|
+
50,
|
|
124
|
+
50
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
50,
|
|
128
|
+
50,
|
|
129
|
+
50,
|
|
130
|
+
50
|
|
131
|
+
]
|
|
132
|
+
];
|
|
133
|
+
const quarters = [
|
|
134
|
+
[
|
|
135
|
+
0,
|
|
136
|
+
0,
|
|
137
|
+
50,
|
|
138
|
+
50
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
50,
|
|
142
|
+
0,
|
|
143
|
+
50,
|
|
144
|
+
50
|
|
145
|
+
],
|
|
146
|
+
[
|
|
147
|
+
0,
|
|
148
|
+
50,
|
|
149
|
+
50,
|
|
150
|
+
50
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
50,
|
|
154
|
+
50,
|
|
155
|
+
50,
|
|
156
|
+
50
|
|
157
|
+
]
|
|
158
|
+
];
|
|
159
|
+
for (let index = 4; index < count; index++) {
|
|
160
|
+
const step = Math.min((index - 3) * 3, 30);
|
|
161
|
+
quarters.push([
|
|
162
|
+
50 - step,
|
|
163
|
+
50 - step,
|
|
164
|
+
50,
|
|
165
|
+
50
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
return quarters;
|
|
169
|
+
}
|
|
170
|
+
/** Where a window is drawn, in percent of the desktop. A stacked tab shares its session's place. */
|
|
171
|
+
function rectOf(layout, id, widthPx) {
|
|
172
|
+
const win = findWindow(layout, id);
|
|
173
|
+
if (win === void 0) return FULL;
|
|
174
|
+
const root = findWindow(layout, stackRoot(win)) ?? win;
|
|
175
|
+
if (root.maximized === true) return FULL;
|
|
176
|
+
if (root.rect !== void 0) return root.rect;
|
|
177
|
+
if (root.kind !== "session" && root.kind !== "tab") return FLOAT[root.kind];
|
|
178
|
+
const sessions = layout.windows.filter((entry) => entry.kind === "session");
|
|
179
|
+
const index = sessions.findIndex((entry) => entry.id === root.id);
|
|
180
|
+
return slots(sessions.length, widthPx)[index] ?? FULL;
|
|
181
|
+
}
|
|
182
|
+
/** Brings a window's whole stack to the front, keeping the stack's own order, and restores it. */
|
|
183
|
+
function focusWindow(layout, id) {
|
|
184
|
+
const win = findWindow(layout, id);
|
|
185
|
+
if (win === void 0) return layout;
|
|
186
|
+
const root = stackRoot(win);
|
|
187
|
+
const members = layout.z.filter((entry) => {
|
|
188
|
+
const member = findWindow(layout, entry);
|
|
189
|
+
return member !== void 0 && stackRoot(member) === root;
|
|
190
|
+
});
|
|
191
|
+
const order = [...layout.z.filter((entry) => !members.includes(entry)), ...members];
|
|
192
|
+
const restored = layout.windows.some((entry) => stackRoot(entry) === root && entry.minimized === true);
|
|
193
|
+
if (!restored && order.every((entry, index) => entry === layout.z[index])) return layout;
|
|
194
|
+
return {
|
|
195
|
+
...layout,
|
|
196
|
+
z: order,
|
|
197
|
+
windows: restored ? layout.windows.map((entry) => stackRoot(entry) === root ? {
|
|
198
|
+
...entry,
|
|
199
|
+
minimized: false
|
|
200
|
+
} : entry) : layout.windows
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** Opens a window, or brings it forward when it is already open. A new tab window goes on top of its stack. */
|
|
204
|
+
function openWindow(layout, win) {
|
|
205
|
+
if (findWindow(layout, win.id) !== void 0) return focusWindow(layout, win.id);
|
|
206
|
+
if (layout.windows.length >= MAX_WINDOWS) return layout;
|
|
207
|
+
return focusWindow({
|
|
208
|
+
...layout,
|
|
209
|
+
windows: [...layout.windows, win],
|
|
210
|
+
z: [...layout.z, win.id]
|
|
211
|
+
}, win.id);
|
|
212
|
+
}
|
|
213
|
+
/** Closing a session window also closes the tab windows stacked on it. */
|
|
214
|
+
function closeWindow(layout, id) {
|
|
215
|
+
const win = findWindow(layout, id);
|
|
216
|
+
if (win === void 0) return layout;
|
|
217
|
+
const gone = new Set(layout.windows.filter((entry) => entry.id === id || win.kind === "session" && stackRoot(entry) === id).map((entry) => entry.id));
|
|
218
|
+
return {
|
|
219
|
+
...layout,
|
|
220
|
+
windows: layout.windows.filter((entry) => !gone.has(entry.id)),
|
|
221
|
+
z: layout.z.filter((entry) => !gone.has(entry))
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/** The bar button of a stack already in front: the top window goes to the back of its stack. */
|
|
225
|
+
function swapStack(layout, root) {
|
|
226
|
+
const stack = stacksOf(layout).find((entry) => entry.root === root);
|
|
227
|
+
if (stack === void 0 || stack.members.length < 2) return focusWindow(layout, root);
|
|
228
|
+
const top = stack.members[stack.members.length - 1];
|
|
229
|
+
const others = stack.members.slice(0, -1).map((entry) => entry.id);
|
|
230
|
+
const order = [
|
|
231
|
+
...layout.z.filter((entry) => entry !== top.id && !others.includes(entry)),
|
|
232
|
+
top.id,
|
|
233
|
+
...others
|
|
234
|
+
];
|
|
235
|
+
return focusWindow({
|
|
236
|
+
...layout,
|
|
237
|
+
z: order
|
|
238
|
+
}, root);
|
|
239
|
+
}
|
|
240
|
+
function updateRoot(layout, id, change) {
|
|
241
|
+
const win = findWindow(layout, id);
|
|
242
|
+
if (win === void 0) return layout;
|
|
243
|
+
const rootId = stackRoot(win);
|
|
244
|
+
return {
|
|
245
|
+
...layout,
|
|
246
|
+
windows: layout.windows.map((entry) => entry.id === rootId ? change(entry) : entry)
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/** Moving or resizing any window of a stack moves the stack: the place lives on its root. */
|
|
250
|
+
function placeWindow(layout, id, rect) {
|
|
251
|
+
return updateRoot(layout, id, (root) => ({
|
|
252
|
+
...root,
|
|
253
|
+
rect: clampRect(rect),
|
|
254
|
+
maximized: false
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
function toggleMaximize(layout, id) {
|
|
258
|
+
return updateRoot(layout, id, (root) => ({
|
|
259
|
+
...root,
|
|
260
|
+
maximized: root.maximized !== true
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
/** Back to the default slot or float place. */
|
|
264
|
+
function resetPlace(layout, id) {
|
|
265
|
+
return updateRoot(layout, id, ({ rect: _rect, ...root }) => ({
|
|
266
|
+
...root,
|
|
267
|
+
maximized: false
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
function minimizeWindow(layout, id) {
|
|
271
|
+
const win = findWindow(layout, id);
|
|
272
|
+
if (win === void 0) return layout;
|
|
273
|
+
const root = stackRoot(win);
|
|
274
|
+
return {
|
|
275
|
+
...layout,
|
|
276
|
+
windows: layout.windows.map((entry) => stackRoot(entry) === root ? {
|
|
277
|
+
...entry,
|
|
278
|
+
minimized: true
|
|
279
|
+
} : entry)
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/** Keeps enough of a window on the desktop to grab its title, at a sane size. */
|
|
283
|
+
function clampRect([left, top, width, height]) {
|
|
284
|
+
const w = Math.min(Math.max(width, KEEP), 100);
|
|
285
|
+
const h = Math.min(Math.max(height, KEEP), 100);
|
|
286
|
+
return [
|
|
287
|
+
Math.min(Math.max(left, KEEP - w), 90),
|
|
288
|
+
Math.min(Math.max(top, 0), 90),
|
|
289
|
+
w,
|
|
290
|
+
h
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
/** Resizing from the right edge, bottom edge or corner; the minimum is in percent of the desktop. */
|
|
294
|
+
function resizeRect([left, top, width, height], edge, dx, dy, min) {
|
|
295
|
+
return [
|
|
296
|
+
left,
|
|
297
|
+
top,
|
|
298
|
+
edge === "s" ? width : Math.min(Math.max(width + dx, min[0]), 100 - left),
|
|
299
|
+
edge === "e" ? height : Math.min(Math.max(height + dy, min[1]), 100 - top)
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
/** The snap target under the pointer while dragging, in desktop pixels. */
|
|
303
|
+
function snapZoneAt(x, y, width, height) {
|
|
304
|
+
const left = x <= EDGE;
|
|
305
|
+
const right = x >= width - EDGE;
|
|
306
|
+
if (y <= EDGE && !left && !right) return "max";
|
|
307
|
+
if (left || right) {
|
|
308
|
+
const side = left ? "left" : "right";
|
|
309
|
+
if (y <= CORNER) return `top-${side}`;
|
|
310
|
+
if (y >= height - CORNER) return `bottom-${side}`;
|
|
311
|
+
return side;
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
function zoneRect(zone) {
|
|
316
|
+
switch (zone) {
|
|
317
|
+
case "left": return [
|
|
318
|
+
0,
|
|
319
|
+
0,
|
|
320
|
+
50,
|
|
321
|
+
100
|
|
322
|
+
];
|
|
323
|
+
case "right": return [
|
|
324
|
+
50,
|
|
325
|
+
0,
|
|
326
|
+
50,
|
|
327
|
+
100
|
|
328
|
+
];
|
|
329
|
+
case "top-left": return [
|
|
330
|
+
0,
|
|
331
|
+
0,
|
|
332
|
+
50,
|
|
333
|
+
50
|
|
334
|
+
];
|
|
335
|
+
case "top-right": return [
|
|
336
|
+
50,
|
|
337
|
+
0,
|
|
338
|
+
50,
|
|
339
|
+
50
|
|
340
|
+
];
|
|
341
|
+
case "bottom-left": return [
|
|
342
|
+
0,
|
|
343
|
+
50,
|
|
344
|
+
50,
|
|
345
|
+
50
|
|
346
|
+
];
|
|
347
|
+
case "bottom-right": return [
|
|
348
|
+
50,
|
|
349
|
+
50,
|
|
350
|
+
50,
|
|
351
|
+
50
|
|
352
|
+
];
|
|
353
|
+
case "max": return FULL;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/** Drops windows whose session was deleted and tab windows whose tab was closed. */
|
|
357
|
+
function pruneLayout(layout, sessionIds, tabOpen) {
|
|
358
|
+
const keep = (win) => {
|
|
359
|
+
if (win.kind === "session") return win.sessionId !== void 0 && sessionIds.has(win.sessionId);
|
|
360
|
+
if (win.kind === "tab") return win.sessionId !== void 0 && win.tabId !== void 0 && sessionIds.has(win.sessionId) && tabOpen(win.sessionId, win.tabId) && layout.windows.some((entry) => entry.id === sessionWindowId(win.sessionId));
|
|
361
|
+
return true;
|
|
362
|
+
};
|
|
363
|
+
if (layout.windows.every(keep)) return layout;
|
|
364
|
+
const windows = layout.windows.filter(keep);
|
|
365
|
+
return {
|
|
366
|
+
...layout,
|
|
367
|
+
windows,
|
|
368
|
+
z: layout.z.filter((id) => windows.some((win) => win.id === id))
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
/** The widgets to draw: the person's choice, limited to groups that exist, or all of them. */
|
|
372
|
+
function chosenWidgets(layout, available) {
|
|
373
|
+
return layout.widgets === null ? available : layout.widgets.filter((name) => available.includes(name));
|
|
374
|
+
}
|
|
375
|
+
function removeWidget(layout, name, available) {
|
|
376
|
+
return {
|
|
377
|
+
...layout,
|
|
378
|
+
widgets: chosenWidgets(layout, available).filter((entry) => entry !== name)
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function addWidget(layout, name, available) {
|
|
382
|
+
const current = chosenWidgets(layout, available);
|
|
383
|
+
return current.includes(name) ? layout : {
|
|
384
|
+
...layout,
|
|
385
|
+
widgets: [...current, name]
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function toggleWidgetExpanded(layout, name) {
|
|
389
|
+
const expanded = layout.expanded.includes(name) ? layout.expanded.filter((entry) => entry !== name) : [...layout.expanded, name];
|
|
390
|
+
return {
|
|
391
|
+
...layout,
|
|
392
|
+
expanded
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const KINDS = [
|
|
396
|
+
"session",
|
|
397
|
+
"tab",
|
|
398
|
+
"settings",
|
|
399
|
+
"page"
|
|
400
|
+
];
|
|
401
|
+
function parseRect(value) {
|
|
402
|
+
if (!Array.isArray(value) || value.length !== 4) return void 0;
|
|
403
|
+
if (!value.every((entry) => typeof entry === "number" && Number.isFinite(entry))) return void 0;
|
|
404
|
+
return clampRect(value);
|
|
405
|
+
}
|
|
406
|
+
function parseWindow(value) {
|
|
407
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
408
|
+
const raw = value;
|
|
409
|
+
if (typeof raw.id !== "string" || !KINDS.includes(raw.kind)) return void 0;
|
|
410
|
+
const kind = raw.kind;
|
|
411
|
+
if (kind === "settings" || kind === "page") return void 0;
|
|
412
|
+
const sessionId = typeof raw.sessionId === "string" ? raw.sessionId : void 0;
|
|
413
|
+
const tabId = typeof raw.tabId === "string" ? raw.tabId : void 0;
|
|
414
|
+
if (kind === "session" && (sessionId === void 0 || raw.id !== sessionWindowId(sessionId))) return void 0;
|
|
415
|
+
if (kind === "tab" && (sessionId === void 0 || tabId === void 0 || raw.id !== tabWindowId(sessionId, tabId))) return void 0;
|
|
416
|
+
const rect = parseRect(raw.rect);
|
|
417
|
+
return {
|
|
418
|
+
id: raw.id,
|
|
419
|
+
kind,
|
|
420
|
+
...sessionId === void 0 ? {} : { sessionId },
|
|
421
|
+
...tabId === void 0 ? {} : { tabId },
|
|
422
|
+
...rect === void 0 ? {} : { rect },
|
|
423
|
+
...raw.minimized === true ? { minimized: true } : {},
|
|
424
|
+
...raw.maximized === true ? { maximized: true } : {}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/** Reads a saved layout, keeping what is valid and dropping the rest; anything unreadable is empty. */
|
|
428
|
+
function parseLayout(raw) {
|
|
429
|
+
if (raw === null) return EMPTY_LAYOUT;
|
|
430
|
+
let value;
|
|
431
|
+
try {
|
|
432
|
+
value = JSON.parse(raw);
|
|
433
|
+
} catch {
|
|
434
|
+
return EMPTY_LAYOUT;
|
|
435
|
+
}
|
|
436
|
+
if (typeof value !== "object" || value === null || value.version !== 1) return EMPTY_LAYOUT;
|
|
437
|
+
const saved = value;
|
|
438
|
+
const windows = [];
|
|
439
|
+
for (const entry of Array.isArray(saved.windows) ? saved.windows.slice(0, MAX_WINDOWS) : []) {
|
|
440
|
+
const win = parseWindow(entry);
|
|
441
|
+
if (win !== void 0 && !windows.some((existing) => existing.id === win.id)) windows.push(win);
|
|
442
|
+
}
|
|
443
|
+
const ids = windows.map((win) => win.id);
|
|
444
|
+
const savedZ = Array.isArray(saved.z) ? saved.z.filter((id) => typeof id === "string" && ids.includes(id)) : [];
|
|
445
|
+
return {
|
|
446
|
+
version: 1,
|
|
447
|
+
windows,
|
|
448
|
+
z: [.../* @__PURE__ */ new Set([...ids.filter((id) => !savedZ.includes(id)), ...savedZ])],
|
|
449
|
+
widgets: Array.isArray(saved.widgets) ? [...new Set(saved.widgets.filter((name) => typeof name === "string"))] : null,
|
|
450
|
+
expanded: Array.isArray(saved.expanded) ? [...new Set(saved.expanded.filter((name) => typeof name === "string"))] : [],
|
|
451
|
+
activityHidden: saved.activityHidden === true
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
/** Settings and page windows follow the route, so they are not saved. */
|
|
455
|
+
function serializeLayout(layout) {
|
|
456
|
+
const windows = layout.windows.filter((win) => win.kind !== "settings" && win.kind !== "page");
|
|
457
|
+
return JSON.stringify({
|
|
458
|
+
...layout,
|
|
459
|
+
windows,
|
|
460
|
+
z: layout.z.filter((id) => windows.some((win) => win.id === id))
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/extensions/(frontend)/template/_components/DesktopFolderBrowser.tsx
|
|
465
|
+
function folderName$1(path) {
|
|
466
|
+
return path.slice(path.lastIndexOf("/") + 1) || path;
|
|
467
|
+
}
|
|
468
|
+
/** Walks the server's folders inline: up, into a child, or pick the current folder. */
|
|
469
|
+
function DesktopFolderBrowser({ start, listDirectory, onSelect }) {
|
|
470
|
+
const [target, setTarget] = useState(start);
|
|
471
|
+
const [listing, setListing] = useState(null);
|
|
472
|
+
const [error, setError] = useState("");
|
|
473
|
+
useEffect(() => {
|
|
474
|
+
let stale = false;
|
|
475
|
+
listDirectory(target).then((result) => {
|
|
476
|
+
if (stale) return;
|
|
477
|
+
if ("error" in result) setError(result.error);
|
|
478
|
+
else {
|
|
479
|
+
setError("");
|
|
480
|
+
setListing(result);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
return () => {
|
|
484
|
+
stale = true;
|
|
485
|
+
};
|
|
486
|
+
}, [target, listDirectory]);
|
|
487
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
488
|
+
"data-testid": "folder-browser",
|
|
489
|
+
className: "flex flex-col gap-1 rounded border border-po-border bg-po-deep p-1",
|
|
490
|
+
children: [
|
|
491
|
+
/* @__PURE__ */ jsxs("div", {
|
|
492
|
+
className: "flex items-center gap-1 px-1",
|
|
493
|
+
children: [
|
|
494
|
+
/* @__PURE__ */ jsx(Button, {
|
|
495
|
+
variant: "ghost",
|
|
496
|
+
size: "icon",
|
|
497
|
+
"data-testid": "folder-browser-up",
|
|
498
|
+
title: "parent folder",
|
|
499
|
+
"aria-label": "parent folder",
|
|
500
|
+
disabled: listing?.parent === void 0,
|
|
501
|
+
onClick: () => listing?.parent !== void 0 && setTarget(listing.parent),
|
|
502
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "h-3 w-3" })
|
|
503
|
+
}),
|
|
504
|
+
/* @__PURE__ */ jsx("span", {
|
|
505
|
+
className: "min-w-0 flex-1 truncate text-sm text-po-dim",
|
|
506
|
+
title: listing?.path,
|
|
507
|
+
children: listing?.path ?? "loading…"
|
|
508
|
+
}),
|
|
509
|
+
/* @__PURE__ */ jsx(Button, {
|
|
510
|
+
variant: "outline",
|
|
511
|
+
size: "xs",
|
|
512
|
+
"data-testid": "folder-browser-select",
|
|
513
|
+
disabled: listing === null,
|
|
514
|
+
onClick: () => listing !== null && onSelect(listing.path),
|
|
515
|
+
children: "use this folder"
|
|
516
|
+
})
|
|
517
|
+
]
|
|
518
|
+
}),
|
|
519
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
520
|
+
className: "px-2 py-1 text-sm text-po-red",
|
|
521
|
+
children: error
|
|
522
|
+
}) : null,
|
|
523
|
+
/* @__PURE__ */ jsxs("div", {
|
|
524
|
+
role: "listbox",
|
|
525
|
+
"aria-label": "folders",
|
|
526
|
+
className: "max-h-40 overflow-y-auto",
|
|
527
|
+
children: [listing !== null && listing.directories.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
528
|
+
className: "px-2 py-1 text-sm text-po-dim",
|
|
529
|
+
children: "no folders here"
|
|
530
|
+
}) : null, listing?.directories.map((directory) => /* @__PURE__ */ jsx(OptionRow, {
|
|
531
|
+
density: "compact",
|
|
532
|
+
"data-testid": "folder-browser-entry",
|
|
533
|
+
onClick: () => setTarget(directory),
|
|
534
|
+
className: "w-full px-2.5 py-1 ",
|
|
535
|
+
children: folderName$1(directory)
|
|
536
|
+
}, directory))]
|
|
537
|
+
})
|
|
538
|
+
]
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/extensions/(frontend)/template/_components/DesktopAddWorkspaceDialog.tsx
|
|
543
|
+
const SUGGESTION_DEBOUNCE_MS = 120;
|
|
544
|
+
const NO_HIGHLIGHT = -1;
|
|
545
|
+
const TRAILING_SEPARATORS = /\/+$/u;
|
|
546
|
+
function folderName(path) {
|
|
547
|
+
const trimmed = path.trim().replace(TRAILING_SEPARATORS, "");
|
|
548
|
+
return trimmed.slice(trimmed.lastIndexOf("/") + 1);
|
|
549
|
+
}
|
|
550
|
+
/** Connects the durable draft and fenced discovery to the production presentation. */
|
|
551
|
+
function DesktopAddWorkspaceDialog({ suggestedPaths, actions }) {
|
|
552
|
+
const draft = useStore(workspaceAdmissionStore, (state) => state);
|
|
553
|
+
const path = draft.path ?? suggestedPaths[0] ?? "";
|
|
554
|
+
const [suggestions, setSuggestions] = useState({
|
|
555
|
+
path: "",
|
|
556
|
+
directories: []
|
|
557
|
+
});
|
|
558
|
+
useEffect(() => {
|
|
559
|
+
const typed = path.trim();
|
|
560
|
+
if (typed === "") return;
|
|
561
|
+
let stale = false;
|
|
562
|
+
const timer = setTimeout(async () => {
|
|
563
|
+
const found = await actions.searchDirectories(typed);
|
|
564
|
+
if (stale) return;
|
|
565
|
+
setSuggestions({
|
|
566
|
+
path,
|
|
567
|
+
directories: found.filter((directory) => directory !== typed)
|
|
568
|
+
});
|
|
569
|
+
}, SUGGESTION_DEBOUNCE_MS);
|
|
570
|
+
return () => {
|
|
571
|
+
stale = true;
|
|
572
|
+
clearTimeout(timer);
|
|
573
|
+
};
|
|
574
|
+
}, [path, actions]);
|
|
575
|
+
useEffect(() => discoverWorkspaceAdmission(path, actions.discoverWorkspaces), [path, actions.discoverWorkspaces]);
|
|
576
|
+
return /* @__PURE__ */ jsx(DesktopAddWorkspaceDialogView, {
|
|
577
|
+
suggestions: path.trim() !== "" && suggestions.path === path ? suggestions.directories : [],
|
|
578
|
+
suggestedPaths,
|
|
579
|
+
actions,
|
|
580
|
+
draft,
|
|
581
|
+
updateDraft: updateWorkspaceAdmission
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
/** Shared by runtime and deterministic approved-state stories. */
|
|
585
|
+
function DesktopAddWorkspaceDialogView({ suggestedPaths, actions, draft, updateDraft, style, suggestions = [] }) {
|
|
586
|
+
const { name, nameEdited, instructions, pending: busy, error, discovery } = draft;
|
|
587
|
+
const path = draft.path ?? suggestedPaths[0] ?? "";
|
|
588
|
+
const setName = (name) => updateDraft({ name });
|
|
589
|
+
const setNameEdited = (nameEdited) => updateDraft({ nameEdited });
|
|
590
|
+
const setPath = (path) => updateDraft({ path });
|
|
591
|
+
const [browsing, setBrowsing] = useState(false);
|
|
592
|
+
const [highlight, setHighlight] = useState(NO_HIGHLIGHT);
|
|
593
|
+
const pathInput = useRef(null);
|
|
594
|
+
const shownName = nameEdited ? name : folderName(path);
|
|
595
|
+
const changePath = (next) => {
|
|
596
|
+
if (busy) return;
|
|
597
|
+
setPath(next);
|
|
598
|
+
setHighlight(NO_HIGHLIGHT);
|
|
599
|
+
};
|
|
600
|
+
const pick = (directory) => {
|
|
601
|
+
changePath(`${directory}/`);
|
|
602
|
+
pathInput.current?.focus();
|
|
603
|
+
};
|
|
604
|
+
const trimmedPath = path.trim().replace(TRAILING_SEPARATORS, "") || (path.trim() === "" ? "" : "/");
|
|
605
|
+
const discovering = draft.discovering || !!path.trim() && actions.discoverWorkspaces !== void 0 && draft.discoveryPath !== path;
|
|
606
|
+
const discoveryError = discovery && "error" in discovery ? discovery.error : "";
|
|
607
|
+
const declarations = discovery && "declarations" in discovery && discovery.declarations.length > 0 ? discovery.declarations : void 0;
|
|
608
|
+
const addedId = (name) => declarations?.find((entry) => entry.name === name)?.workspaceId ?? draft.results.find((entry) => entry.name === name)?.workspaceId;
|
|
609
|
+
const selected = declarations?.filter((entry) => draft.checked.includes(entry.name) && !addedId(entry.name)).map((entry) => entry.name) ?? [];
|
|
610
|
+
const manual = !declarations && !discovering && !discoveryError;
|
|
611
|
+
const canSubmit = !busy && !discovering && !discoveryError && (declarations ? selected.length > 0 && actions.addDeclaredWorkspaces !== void 0 : trimmedPath !== "" || shownName.trim() !== "");
|
|
612
|
+
const submit = async () => {
|
|
613
|
+
if (!canSubmit) return;
|
|
614
|
+
if (declarations) {
|
|
615
|
+
await actions.addDeclaredWorkspaces?.({
|
|
616
|
+
path: discovery && "root" in discovery ? discovery.root : trimmedPath,
|
|
617
|
+
names: selected
|
|
618
|
+
});
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
await actions.addWorkspace({
|
|
622
|
+
...instructions === "" ? {} : { instructions },
|
|
623
|
+
name: shownName.trim(),
|
|
624
|
+
...trimmedPath === "" ? {} : { path: trimmedPath }
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
628
|
+
open: true,
|
|
629
|
+
onOpenChange: (next) => !next && !busy && actions.closeAddWorkspace(),
|
|
630
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
631
|
+
style,
|
|
632
|
+
width: "md",
|
|
633
|
+
"data-testid": "add-workspace-dialog",
|
|
634
|
+
"aria-describedby": void 0,
|
|
635
|
+
children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Add workspace" }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [
|
|
636
|
+
/* @__PURE__ */ jsxs("label", {
|
|
637
|
+
htmlFor: "add-workspace-root",
|
|
638
|
+
className: "flex flex-col gap-1",
|
|
639
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
640
|
+
className: "text-base font-medium text-po-dim",
|
|
641
|
+
children: "Folder"
|
|
642
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
643
|
+
className: "flex items-center gap-1.5",
|
|
644
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
645
|
+
id: "add-workspace-root",
|
|
646
|
+
ref: pathInput,
|
|
647
|
+
"data-testid": "add-workspace-root",
|
|
648
|
+
value: path,
|
|
649
|
+
autoFocus: true,
|
|
650
|
+
disabled: busy,
|
|
651
|
+
onChange: (event) => changePath(event.target.value),
|
|
652
|
+
onKeyDown: (event) => {
|
|
653
|
+
if (event.key === "ArrowDown" && suggestions.length > 0) {
|
|
654
|
+
event.preventDefault();
|
|
655
|
+
setHighlight((current) => (current + 1) % suggestions.length);
|
|
656
|
+
} else if (event.key === "ArrowUp" && suggestions.length > 0) {
|
|
657
|
+
event.preventDefault();
|
|
658
|
+
setHighlight((current) => current <= 0 ? suggestions.length - 1 : current - 1);
|
|
659
|
+
} else if (event.key === "Enter") {
|
|
660
|
+
const chosen = highlight === NO_HIGHLIGHT ? void 0 : suggestions[highlight];
|
|
661
|
+
if (chosen === void 0) submit();
|
|
662
|
+
else pick(chosen);
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
placeholder: "~/workspace/my-project",
|
|
666
|
+
className: "min-w-0 flex-1 font-mono"
|
|
667
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
668
|
+
variant: browsing ? "subtle" : "outline",
|
|
669
|
+
size: "md",
|
|
670
|
+
"data-testid": "add-workspace-browse",
|
|
671
|
+
"aria-pressed": browsing,
|
|
672
|
+
disabled: busy,
|
|
673
|
+
onClick: () => setBrowsing((open) => !open),
|
|
674
|
+
children: "Browse"
|
|
675
|
+
})]
|
|
676
|
+
})]
|
|
677
|
+
}),
|
|
678
|
+
browsing ? /* @__PURE__ */ jsx(DesktopFolderBrowser, {
|
|
679
|
+
...trimmedPath.startsWith("/") ? { start: trimmedPath } : {},
|
|
680
|
+
listDirectory: actions.listDirectory,
|
|
681
|
+
onSelect: (selected) => {
|
|
682
|
+
changePath(selected);
|
|
683
|
+
setBrowsing(false);
|
|
684
|
+
}
|
|
685
|
+
}) : suggestions.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
686
|
+
role: "listbox",
|
|
687
|
+
"aria-label": "matching directories",
|
|
688
|
+
"data-testid": "add-workspace-suggestions",
|
|
689
|
+
className: "max-h-40 overflow-y-auto rounded border border-po-border bg-po-deep p-1",
|
|
690
|
+
children: suggestions.map((directory, index) => /* @__PURE__ */ jsx(OptionRow, {
|
|
691
|
+
density: "compact",
|
|
692
|
+
active: index === highlight,
|
|
693
|
+
"data-testid": "add-workspace-suggestion",
|
|
694
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
695
|
+
onMouseEnter: () => setHighlight(index),
|
|
696
|
+
onClick: () => pick(directory),
|
|
697
|
+
className: "w-full px-2.5 py-1 ",
|
|
698
|
+
children: directory
|
|
699
|
+
}, directory))
|
|
700
|
+
}) : null,
|
|
701
|
+
suggestedPaths.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
702
|
+
className: "flex flex-wrap gap-1",
|
|
703
|
+
children: suggestedPaths.slice(0, 4).map((suggested) => /* @__PURE__ */ jsx(Button, {
|
|
704
|
+
variant: "outline",
|
|
705
|
+
size: "xs",
|
|
706
|
+
disabled: busy,
|
|
707
|
+
onClick: () => changePath(suggested),
|
|
708
|
+
children: suggested
|
|
709
|
+
}, suggested))
|
|
710
|
+
}) : null,
|
|
711
|
+
discovering ? /* @__PURE__ */ jsx("p", {
|
|
712
|
+
role: "status",
|
|
713
|
+
className: "text-sm text-po-dim",
|
|
714
|
+
children: "Reading workspace declarations…"
|
|
715
|
+
}) : null,
|
|
716
|
+
discoveryError ? /* @__PURE__ */ jsx("p", {
|
|
717
|
+
role: "alert",
|
|
718
|
+
className: "text-sm text-po-red",
|
|
719
|
+
children: discoveryError
|
|
720
|
+
}) : null,
|
|
721
|
+
declarations ? /* @__PURE__ */ jsxs("fieldset", {
|
|
722
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
723
|
+
children: [
|
|
724
|
+
/* @__PURE__ */ jsx("legend", {
|
|
725
|
+
className: "mb-1 text-base font-medium text-po-hi",
|
|
726
|
+
children: "Workspaces"
|
|
727
|
+
}),
|
|
728
|
+
/* @__PURE__ */ jsx("p", {
|
|
729
|
+
className: "mb-1 text-sm text-po-dim",
|
|
730
|
+
children: "Declared in .po/config.yaml. Choose which to add."
|
|
731
|
+
}),
|
|
732
|
+
declarations.map((entry, index) => {
|
|
733
|
+
const isAdded = addedId(entry.name) !== void 0;
|
|
734
|
+
const on = isAdded || draft.checked.includes(entry.name);
|
|
735
|
+
const rowError = draft.results.find((result) => result.name === entry.name)?.error;
|
|
736
|
+
return /* @__PURE__ */ jsx("div", {
|
|
737
|
+
"data-checked": on,
|
|
738
|
+
className: "rounded-sm px-2 py-1.5 data-[checked=true]:bg-po-tint-green",
|
|
739
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
740
|
+
htmlFor: `add-workspace-declaration-${index}`,
|
|
741
|
+
className: "flex min-w-0 cursor-pointer items-start gap-2.5",
|
|
742
|
+
children: [
|
|
743
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
744
|
+
id: `add-workspace-declaration-${index}`,
|
|
745
|
+
checked: on,
|
|
746
|
+
disabled: isAdded || busy,
|
|
747
|
+
onCheckedChange: () => updateDraft({ checked: on ? draft.checked.filter((name) => name !== entry.name) : [...draft.checked, entry.name] }),
|
|
748
|
+
className: "mt-1"
|
|
749
|
+
}),
|
|
750
|
+
/* @__PURE__ */ jsxs("span", {
|
|
751
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
752
|
+
children: [
|
|
753
|
+
/* @__PURE__ */ jsx("span", {
|
|
754
|
+
className: "text-base font-semibold text-po-hi",
|
|
755
|
+
children: entry.name
|
|
756
|
+
}),
|
|
757
|
+
/* @__PURE__ */ jsx("span", {
|
|
758
|
+
className: "truncate text-sm text-po-dim",
|
|
759
|
+
title: entry.instructions,
|
|
760
|
+
children: entry.instructions
|
|
761
|
+
}),
|
|
762
|
+
rowError ? /* @__PURE__ */ jsx("span", {
|
|
763
|
+
role: "alert",
|
|
764
|
+
className: "text-sm text-po-red",
|
|
765
|
+
children: rowError
|
|
766
|
+
}) : null
|
|
767
|
+
]
|
|
768
|
+
}),
|
|
769
|
+
isAdded ? /* @__PURE__ */ jsx("span", {
|
|
770
|
+
className: "text-sm text-po-dim",
|
|
771
|
+
children: "Added"
|
|
772
|
+
}) : null
|
|
773
|
+
]
|
|
774
|
+
})
|
|
775
|
+
}, entry.name);
|
|
776
|
+
})
|
|
777
|
+
]
|
|
778
|
+
}) : manual ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("label", {
|
|
779
|
+
htmlFor: "add-workspace-name",
|
|
780
|
+
className: "flex flex-col gap-1",
|
|
781
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
782
|
+
className: "text-base font-medium text-po-dim",
|
|
783
|
+
children: "Name"
|
|
784
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
785
|
+
id: "add-workspace-name",
|
|
786
|
+
"data-testid": "add-workspace-name",
|
|
787
|
+
value: shownName,
|
|
788
|
+
disabled: busy,
|
|
789
|
+
onChange: (event) => {
|
|
790
|
+
setNameEdited(true);
|
|
791
|
+
setName(event.target.value);
|
|
792
|
+
},
|
|
793
|
+
onKeyDown: (event) => {
|
|
794
|
+
if (event.key === "Enter") submit();
|
|
795
|
+
},
|
|
796
|
+
placeholder: "my-project"
|
|
797
|
+
})]
|
|
798
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
799
|
+
htmlFor: "add-workspace-instructions",
|
|
800
|
+
className: "flex flex-col gap-1",
|
|
801
|
+
children: [
|
|
802
|
+
/* @__PURE__ */ jsxs("span", {
|
|
803
|
+
className: "text-base font-medium text-po-dim",
|
|
804
|
+
children: ["Instructions ", /* @__PURE__ */ jsx("span", {
|
|
805
|
+
className: "font-normal",
|
|
806
|
+
children: "(optional)"
|
|
807
|
+
})]
|
|
808
|
+
}),
|
|
809
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
810
|
+
id: "add-workspace-instructions",
|
|
811
|
+
rows: 3,
|
|
812
|
+
value: instructions,
|
|
813
|
+
disabled: busy,
|
|
814
|
+
onChange: (event) => updateDraft({ instructions: event.target.value })
|
|
815
|
+
}),
|
|
816
|
+
/* @__PURE__ */ jsx("span", {
|
|
817
|
+
className: "text-sm text-po-dim",
|
|
818
|
+
children: "For main sessions in this workspace."
|
|
819
|
+
})
|
|
820
|
+
]
|
|
821
|
+
})] }) : null,
|
|
822
|
+
manual && trimmedPath === "" && shownName.trim() !== "" ? /* @__PURE__ */ jsxs("p", {
|
|
823
|
+
"data-testid": "add-workspace-default-hint",
|
|
824
|
+
className: "text-sm text-po-dim",
|
|
825
|
+
children: ["creates ~/.po/workspace/", shownName.trim()]
|
|
826
|
+
}) : null,
|
|
827
|
+
error ? /* @__PURE__ */ jsx("pre", {
|
|
828
|
+
className: "max-h-28 overflow-y-auto rounded border border-po-edge-red bg-po-tint-red/40 px-2.5 py-2 text-sm whitespace-pre-wrap text-po-red",
|
|
829
|
+
children: error
|
|
830
|
+
}) : null,
|
|
831
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
832
|
+
variant: "outline",
|
|
833
|
+
onClick: () => actions.closeAddWorkspace(),
|
|
834
|
+
disabled: busy,
|
|
835
|
+
children: "Cancel"
|
|
836
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
837
|
+
variant: "primary",
|
|
838
|
+
"data-testid": "add-workspace-confirm",
|
|
839
|
+
onClick: () => void submit(),
|
|
840
|
+
disabled: !canSubmit,
|
|
841
|
+
children: busy ? "Adding…" : declarations ? `Add ${selected.length} ${selected.length === 1 ? "workspace" : "workspaces"}` : "Add workspace"
|
|
842
|
+
})] })
|
|
843
|
+
] })]
|
|
844
|
+
})
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
//#endregion
|
|
848
|
+
//#region src/extensions/(frontend)/template/_components/DesktopWindow.tsx
|
|
849
|
+
/** One frosted material for every floating surface, so the desktop reads as one system. */
|
|
850
|
+
const GLASS = "bg-po-panel/75 backdrop-blur-2xl ring-1 ring-po-border-soft";
|
|
851
|
+
/** The smallest window, in pixels; converted to percent of the desktop at the moment of resizing. */
|
|
852
|
+
const MIN_SIZE = [360, 240];
|
|
853
|
+
function place(rect) {
|
|
854
|
+
return {
|
|
855
|
+
left: `${rect[0]}%`,
|
|
856
|
+
top: `${rect[1]}%`,
|
|
857
|
+
width: `${rect[2]}%`,
|
|
858
|
+
height: `${rect[3]}%`
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
const SNAPS = [
|
|
862
|
+
["left", "Snap to left half"],
|
|
863
|
+
["right", "Snap to right half"],
|
|
864
|
+
["top-left", "Snap to top left"],
|
|
865
|
+
["top-right", "Snap to top right"],
|
|
866
|
+
["bottom-left", "Snap to bottom left"],
|
|
867
|
+
["bottom-right", "Snap to bottom right"]
|
|
868
|
+
];
|
|
869
|
+
function Control({ label, onClick, children }) {
|
|
870
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
871
|
+
asChild: true,
|
|
872
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
873
|
+
type: "button",
|
|
874
|
+
"aria-label": label,
|
|
875
|
+
"data-window-control": true,
|
|
876
|
+
onClick,
|
|
877
|
+
className: "grid size-6 place-items-center rounded-full text-po-dim hover:bg-po-rail hover:text-po-hi focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
878
|
+
children
|
|
879
|
+
})
|
|
880
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
881
|
+
side: "bottom",
|
|
882
|
+
children: label
|
|
883
|
+
})] });
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* A floating window: drag it by the title, resize it from the right and bottom edges, snap it by
|
|
887
|
+
* dropping it on an edge or from the title's menu. The live position stays local while the
|
|
888
|
+
* pointer moves; only the final place goes back to the layout.
|
|
889
|
+
*/
|
|
890
|
+
function DesktopWindow({ title, subtitle, rect, layer, focused, minimized, maximized, stacked, narrow, desktop, headerRegion, testId, onFocus, onClose, onMinimize, onToggleMaximize, onPlace, onResetPlace, onSnapPreview, children }) {
|
|
891
|
+
const gesture = useRef(null);
|
|
892
|
+
const [live, setLive] = useState(null);
|
|
893
|
+
const fixed = narrow || maximized;
|
|
894
|
+
const shown = narrow ? [
|
|
895
|
+
0,
|
|
896
|
+
0,
|
|
897
|
+
100,
|
|
898
|
+
100
|
|
899
|
+
] : live ?? rect;
|
|
900
|
+
const percent = (dx, dy) => [dx / Math.max(desktop.width, 1) * 100, dy / Math.max(desktop.height, 1) * 100];
|
|
901
|
+
const begin = (event, next) => {
|
|
902
|
+
if (event.button !== 0 || fixed) return;
|
|
903
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
904
|
+
gesture.current = next;
|
|
905
|
+
};
|
|
906
|
+
const move = (event) => {
|
|
907
|
+
const current = gesture.current;
|
|
908
|
+
if (current === null) return;
|
|
909
|
+
const [dx, dy] = percent(event.clientX - current.x, event.clientY - current.y);
|
|
910
|
+
if (current.kind === "resize") {
|
|
911
|
+
setLive(resizeRect(current.start, current.edge, dx, dy, percent(MIN_SIZE[0], MIN_SIZE[1])));
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
setLive([
|
|
915
|
+
current.start[0] + dx,
|
|
916
|
+
current.start[1] + dy,
|
|
917
|
+
current.start[2],
|
|
918
|
+
current.start[3]
|
|
919
|
+
]);
|
|
920
|
+
const bounds = event.currentTarget.closest("[data-desktop-surface]")?.getBoundingClientRect();
|
|
921
|
+
const zone = bounds === void 0 ? null : snapZoneAt(event.clientX - bounds.left, event.clientY - bounds.top, bounds.width, bounds.height);
|
|
922
|
+
if (zone !== current.zone) {
|
|
923
|
+
current.zone = zone;
|
|
924
|
+
onSnapPreview(zone === null ? null : zoneRect(zone));
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
const end = () => {
|
|
928
|
+
const current = gesture.current;
|
|
929
|
+
gesture.current = null;
|
|
930
|
+
if (current === null) return;
|
|
931
|
+
if (current.kind === "move" && current.zone !== null) onPlace(zoneRect(current.zone));
|
|
932
|
+
else if (live !== null) onPlace(live);
|
|
933
|
+
onSnapPreview(null);
|
|
934
|
+
setLive(null);
|
|
935
|
+
};
|
|
936
|
+
const handles = fixed ? null : /* @__PURE__ */ jsx(Fragment$1, { children: [
|
|
937
|
+
"e",
|
|
938
|
+
"s",
|
|
939
|
+
"se"
|
|
940
|
+
].map((edge) => /* @__PURE__ */ jsx("span", {
|
|
941
|
+
"aria-hidden": true,
|
|
942
|
+
onPointerDown: (event) => begin(event, {
|
|
943
|
+
kind: "resize",
|
|
944
|
+
edge,
|
|
945
|
+
x: event.clientX,
|
|
946
|
+
y: event.clientY,
|
|
947
|
+
start: rect
|
|
948
|
+
}),
|
|
949
|
+
onPointerMove: move,
|
|
950
|
+
onPointerUp: end,
|
|
951
|
+
onPointerCancel: end,
|
|
952
|
+
className: edge === "e" ? "absolute inset-y-4 right-0 w-2 cursor-ew-resize touch-none" : edge === "s" ? "absolute inset-x-4 bottom-0 h-2 cursor-ns-resize touch-none" : "absolute right-0 bottom-0 size-4 cursor-nwse-resize touch-none"
|
|
953
|
+
}, edge)) });
|
|
954
|
+
return /* @__PURE__ */ jsx("div", {
|
|
955
|
+
"data-testid": testId,
|
|
956
|
+
style: {
|
|
957
|
+
...place(shown),
|
|
958
|
+
zIndex: layer + 1
|
|
959
|
+
},
|
|
960
|
+
onPointerDownCapture: (event) => {
|
|
961
|
+
if (event.target.closest("[data-window-control]") !== null) return;
|
|
962
|
+
onFocus();
|
|
963
|
+
},
|
|
964
|
+
"aria-hidden": minimized || void 0,
|
|
965
|
+
className: `absolute p-1.5 ${minimized ? "invisible" : ""} ${stacked === "top" ? "pt-5" : ""} ${stacked === "under" ? "origin-top scale-96" : ""} ${live === null ? "transition-[left,top,width,height] duration-150" : ""}`,
|
|
966
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
967
|
+
"aria-label": title,
|
|
968
|
+
className: `relative flex h-full flex-col overflow-hidden rounded-2xl bg-po-panel/90 ring-1 backdrop-blur-2xl animate-po-pop ${focused ? "shadow-2xl ring-po-border" : "shadow-lg ring-po-border-soft"}`,
|
|
969
|
+
children: [
|
|
970
|
+
/* @__PURE__ */ jsxs("header", {
|
|
971
|
+
"data-po-region": headerRegion,
|
|
972
|
+
onPointerDown: (event) => {
|
|
973
|
+
if (event.target.closest("button") !== null) return;
|
|
974
|
+
begin(event, {
|
|
975
|
+
kind: "move",
|
|
976
|
+
x: event.clientX,
|
|
977
|
+
y: event.clientY,
|
|
978
|
+
start: rect,
|
|
979
|
+
zone: null
|
|
980
|
+
});
|
|
981
|
+
},
|
|
982
|
+
onPointerMove: move,
|
|
983
|
+
onPointerUp: end,
|
|
984
|
+
onPointerCancel: end,
|
|
985
|
+
onDoubleClick: (event) => {
|
|
986
|
+
if (event.target.closest("button") === null && !narrow) onToggleMaximize();
|
|
987
|
+
},
|
|
988
|
+
className: `grid h-11 shrink-0 grid-cols-[1fr_auto_1fr] items-center px-3 select-none ${fixed ? "" : "cursor-grab touch-none active:cursor-grabbing"}`,
|
|
989
|
+
children: [
|
|
990
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
991
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
992
|
+
asChild: true,
|
|
993
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
994
|
+
type: "button",
|
|
995
|
+
"aria-label": `${title} window menu`,
|
|
996
|
+
className: "flex min-w-0 items-baseline gap-2 rounded-lg px-2.5 py-1 hover:bg-po-rail focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
997
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
998
|
+
className: `truncate text-base first-letter:uppercase ${focused ? "font-semibold text-po-hi" : "font-medium text-po-dim"}`,
|
|
999
|
+
children: title
|
|
1000
|
+
}), subtitle ? /* @__PURE__ */ jsx("span", {
|
|
1001
|
+
className: "truncate text-sm text-po-dim max-md:hidden",
|
|
1002
|
+
children: subtitle
|
|
1003
|
+
}) : null]
|
|
1004
|
+
})
|
|
1005
|
+
}), /* @__PURE__ */ jsxs(DropdownMenuContent, {
|
|
1006
|
+
align: "center",
|
|
1007
|
+
className: "min-w-52",
|
|
1008
|
+
children: [
|
|
1009
|
+
narrow ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1010
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1011
|
+
onSelect: onToggleMaximize,
|
|
1012
|
+
children: maximized ? "Restore" : "Maximise"
|
|
1013
|
+
}),
|
|
1014
|
+
SNAPS.map(([zone, label]) => /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1015
|
+
onSelect: () => onPlace(zoneRect(zone)),
|
|
1016
|
+
children: label
|
|
1017
|
+
}, zone)),
|
|
1018
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1019
|
+
onSelect: onResetPlace,
|
|
1020
|
+
children: "Back to default place"
|
|
1021
|
+
}),
|
|
1022
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {})
|
|
1023
|
+
] }),
|
|
1024
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1025
|
+
onSelect: onMinimize,
|
|
1026
|
+
children: "Minimise"
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1029
|
+
onSelect: onClose,
|
|
1030
|
+
children: "Close"
|
|
1031
|
+
})
|
|
1032
|
+
]
|
|
1033
|
+
})] }),
|
|
1034
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1035
|
+
className: `flex justify-end gap-1 ${focused ? "" : "opacity-60"}`,
|
|
1036
|
+
children: [
|
|
1037
|
+
/* @__PURE__ */ jsx(Control, {
|
|
1038
|
+
label: "Minimise",
|
|
1039
|
+
onClick: onMinimize,
|
|
1040
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1041
|
+
"aria-hidden": true,
|
|
1042
|
+
className: "h-px w-2.5 bg-current"
|
|
1043
|
+
})
|
|
1044
|
+
}),
|
|
1045
|
+
narrow ? null : /* @__PURE__ */ jsx(Control, {
|
|
1046
|
+
label: maximized ? "Restore" : "Maximise",
|
|
1047
|
+
onClick: onToggleMaximize,
|
|
1048
|
+
children: maximized ? /* @__PURE__ */ jsx(ShrinkIcon, { className: "size-3" }) : /* @__PURE__ */ jsx(AppWindowIcon, { className: "size-3" })
|
|
1049
|
+
}),
|
|
1050
|
+
/* @__PURE__ */ jsx(Control, {
|
|
1051
|
+
label: "Close",
|
|
1052
|
+
onClick: onClose,
|
|
1053
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { className: "size-3.5" })
|
|
1054
|
+
})
|
|
1055
|
+
]
|
|
1056
|
+
})
|
|
1057
|
+
]
|
|
1058
|
+
}),
|
|
1059
|
+
/* @__PURE__ */ jsx("div", {
|
|
1060
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
1061
|
+
children
|
|
1062
|
+
}),
|
|
1063
|
+
handles
|
|
1064
|
+
]
|
|
1065
|
+
})
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region src/extensions/(frontend)/template/_components/DesktopBar.tsx
|
|
1070
|
+
const ICONS = {
|
|
1071
|
+
session: MessageIcon,
|
|
1072
|
+
tab: FileIcon,
|
|
1073
|
+
settings: GearIcon,
|
|
1074
|
+
page: HomeIcon
|
|
1075
|
+
};
|
|
1076
|
+
/** A profile's face, or its initials until the image loads. */
|
|
1077
|
+
function ProfileAvatar({ profile, className }) {
|
|
1078
|
+
return /* @__PURE__ */ jsxs(Avatar, {
|
|
1079
|
+
className,
|
|
1080
|
+
children: [profile?.avatarUrl ? /* @__PURE__ */ jsx(AvatarImage, {
|
|
1081
|
+
src: profile.avatarUrl,
|
|
1082
|
+
alt: ""
|
|
1083
|
+
}) : null, /* @__PURE__ */ jsx(AvatarFallback, {
|
|
1084
|
+
className: "bg-po-tint-magenta text-2xs font-semibold text-po-magenta",
|
|
1085
|
+
children: profile?.initials ?? "PO"
|
|
1086
|
+
})]
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
function BarButton({ label, tip, shape = "grid size-10 place-items-center", active, pressed, onClick, testId, children }) {
|
|
1090
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
1091
|
+
asChild: true,
|
|
1092
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1093
|
+
type: "button",
|
|
1094
|
+
"aria-label": label,
|
|
1095
|
+
"aria-pressed": pressed,
|
|
1096
|
+
"data-testid": testId,
|
|
1097
|
+
onClick,
|
|
1098
|
+
className: `relative ${shape} shrink-0 rounded-xl focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none ${active ? "bg-po-panel text-po-hi shadow-sm" : "text-po-dim hover:bg-po-panel/70"}`,
|
|
1099
|
+
children
|
|
1100
|
+
})
|
|
1101
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
1102
|
+
side: "top",
|
|
1103
|
+
sideOffset: 8,
|
|
1104
|
+
children: tip ?? label
|
|
1105
|
+
})] });
|
|
1106
|
+
}
|
|
1107
|
+
function StackTip({ stack }) {
|
|
1108
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1109
|
+
"data-testid": `desktop-bar-tip-${stack.root}`,
|
|
1110
|
+
className: "flex max-w-72 flex-col gap-0.5 py-0.5",
|
|
1111
|
+
children: [
|
|
1112
|
+
/* @__PURE__ */ jsx("span", {
|
|
1113
|
+
className: "truncate font-semibold text-po-hi",
|
|
1114
|
+
children: stack.label
|
|
1115
|
+
}),
|
|
1116
|
+
stack.profile ? /* @__PURE__ */ jsx("span", {
|
|
1117
|
+
className: "truncate text-po-dim",
|
|
1118
|
+
children: stack.profile.label
|
|
1119
|
+
}) : null,
|
|
1120
|
+
stack.clock ? /* @__PURE__ */ jsx(LiveDuration, {
|
|
1121
|
+
label: stack.clock.label,
|
|
1122
|
+
since: stack.clock.since,
|
|
1123
|
+
className: "truncate text-po-dim"
|
|
1124
|
+
}) : stack.status ? /* @__PURE__ */ jsx("span", {
|
|
1125
|
+
className: "truncate text-po-dim",
|
|
1126
|
+
children: stack.status
|
|
1127
|
+
}) : null,
|
|
1128
|
+
stack.details.map((line) => /* @__PURE__ */ jsx("span", {
|
|
1129
|
+
className: "truncate text-po-dim",
|
|
1130
|
+
children: line
|
|
1131
|
+
}, line))
|
|
1132
|
+
]
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
function Clock() {
|
|
1136
|
+
const [now, setNow] = useState(() => /* @__PURE__ */ new Date());
|
|
1137
|
+
useEffect(() => {
|
|
1138
|
+
const timer = window.setInterval(() => setNow(/* @__PURE__ */ new Date()), 15e3);
|
|
1139
|
+
return () => window.clearInterval(timer);
|
|
1140
|
+
}, []);
|
|
1141
|
+
return /* @__PURE__ */ jsxs("time", {
|
|
1142
|
+
dateTime: now.toISOString(),
|
|
1143
|
+
className: "flex shrink-0 flex-col items-end px-2 leading-tight max-sm:hidden",
|
|
1144
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1145
|
+
className: "text-base font-semibold text-po-hi",
|
|
1146
|
+
children: new Intl.DateTimeFormat(void 0, {
|
|
1147
|
+
hour: "2-digit",
|
|
1148
|
+
minute: "2-digit"
|
|
1149
|
+
}).format(now)
|
|
1150
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1151
|
+
className: "text-sm text-po-dim",
|
|
1152
|
+
children: new Intl.DateTimeFormat(void 0, {
|
|
1153
|
+
weekday: "short",
|
|
1154
|
+
day: "numeric",
|
|
1155
|
+
month: "short"
|
|
1156
|
+
}).format(now)
|
|
1157
|
+
})]
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* The floating bar: the Po button that opens the menu, one button per window stack, what waits
|
|
1162
|
+
* on the person, remote access, the Activity toggle and the clock.
|
|
1163
|
+
*/
|
|
1164
|
+
function DesktopBar({ menuOpen, menuTrigger, stacks, waiting, remote, faces, face, railShown, onStack, onRemote, onFace }) {
|
|
1165
|
+
const shownFace = railShown ? face : null;
|
|
1166
|
+
return /* @__PURE__ */ jsxs("footer", {
|
|
1167
|
+
className: `relative mx-3 mb-3 flex h-14 shrink-0 items-center gap-1 rounded-2xl px-2 shadow-lg ${GLASS}`,
|
|
1168
|
+
children: [
|
|
1169
|
+
menuTrigger(/* @__PURE__ */ jsxs("button", {
|
|
1170
|
+
type: "button",
|
|
1171
|
+
"aria-label": "Open the Po menu",
|
|
1172
|
+
"data-testid": "desktop-po-button",
|
|
1173
|
+
className: `flex h-10 shrink-0 items-center gap-2 rounded-xl pr-3 pl-1.5 focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none ${menuOpen ? "bg-po-panel shadow-sm" : "hover:bg-po-panel/70"}`,
|
|
1174
|
+
children: [/* @__PURE__ */ jsx(MascotMark, {
|
|
1175
|
+
size: 28,
|
|
1176
|
+
className: "rounded-lg shadow-sm"
|
|
1177
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1178
|
+
className: "text-base font-semibold text-po-hi max-sm:hidden",
|
|
1179
|
+
children: "Po"
|
|
1180
|
+
})]
|
|
1181
|
+
})),
|
|
1182
|
+
/* @__PURE__ */ jsx("span", {
|
|
1183
|
+
"aria-hidden": true,
|
|
1184
|
+
className: "mx-1 h-6 w-px shrink-0 bg-po-border-soft"
|
|
1185
|
+
}),
|
|
1186
|
+
/* @__PURE__ */ jsx("nav", {
|
|
1187
|
+
"aria-label": "Open windows",
|
|
1188
|
+
className: "flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",
|
|
1189
|
+
children: stacks.map((stack) => {
|
|
1190
|
+
const Glyph = ICONS[stack.kind];
|
|
1191
|
+
return /* @__PURE__ */ jsxs(BarButton, {
|
|
1192
|
+
testId: `desktop-bar-${stack.root}`,
|
|
1193
|
+
label: [
|
|
1194
|
+
stack.label,
|
|
1195
|
+
stack.running ? "running" : void 0,
|
|
1196
|
+
stack.waiting ? `${stack.waiting} waiting for you` : void 0,
|
|
1197
|
+
stack.size > 1 ? `${stack.size} windows stacked. Swap the stack` : void 0
|
|
1198
|
+
].filter(Boolean).join(", "),
|
|
1199
|
+
tip: /* @__PURE__ */ jsx(StackTip, { stack }),
|
|
1200
|
+
shape: "flex h-10 max-w-48 items-center gap-2 pr-3 pl-2",
|
|
1201
|
+
active: stack.focused,
|
|
1202
|
+
pressed: stack.focused,
|
|
1203
|
+
onClick: () => onStack(stack.root),
|
|
1204
|
+
children: [
|
|
1205
|
+
stack.kind === "session" || stack.kind === "tab" ? /* @__PURE__ */ jsxs("span", {
|
|
1206
|
+
className: "relative shrink-0",
|
|
1207
|
+
children: [
|
|
1208
|
+
/* @__PURE__ */ jsx(ProfileAvatar, {
|
|
1209
|
+
profile: stack.profile,
|
|
1210
|
+
className: "size-6"
|
|
1211
|
+
}),
|
|
1212
|
+
stack.running ? /* @__PURE__ */ jsx("span", {
|
|
1213
|
+
"aria-hidden": true,
|
|
1214
|
+
"data-testid": `desktop-bar-running-${stack.root}`,
|
|
1215
|
+
className: "absolute -inset-1 animate-spin rounded-full border-2 border-po-green/25 border-t-po-green motion-reduce:animate-none"
|
|
1216
|
+
}) : null,
|
|
1217
|
+
stack.waiting ? /* @__PURE__ */ jsx("span", {
|
|
1218
|
+
"aria-hidden": true,
|
|
1219
|
+
"data-testid": `desktop-bar-waiting-${stack.root}`,
|
|
1220
|
+
className: "absolute -top-2 -right-2 min-w-4 rounded-full bg-po-magenta px-1 text-center text-2xs leading-4 font-semibold text-po-bg",
|
|
1221
|
+
children: stack.waiting > 99 ? "99+" : stack.waiting
|
|
1222
|
+
}) : null
|
|
1223
|
+
]
|
|
1224
|
+
}) : /* @__PURE__ */ jsx(Glyph, {
|
|
1225
|
+
"aria-hidden": true,
|
|
1226
|
+
className: "size-5 shrink-0"
|
|
1227
|
+
}),
|
|
1228
|
+
/* @__PURE__ */ jsx("span", {
|
|
1229
|
+
className: "min-w-0 truncate text-sm font-medium",
|
|
1230
|
+
children: stack.label
|
|
1231
|
+
}),
|
|
1232
|
+
stack.size > 1 ? /* @__PURE__ */ jsx("span", {
|
|
1233
|
+
"aria-hidden": true,
|
|
1234
|
+
className: "absolute -top-0.5 -right-0.5 grid size-4 place-items-center rounded-full bg-po-panel text-2xs font-semibold text-po-hi shadow-sm ring-1 ring-po-border",
|
|
1235
|
+
children: stack.size
|
|
1236
|
+
}) : null,
|
|
1237
|
+
/* @__PURE__ */ jsx("span", {
|
|
1238
|
+
"aria-hidden": true,
|
|
1239
|
+
className: `absolute bottom-0.5 left-1/2 h-1 -translate-x-1/2 rounded-full ${stack.focused ? "w-4 bg-po-green" : stack.minimized ? "w-1 bg-po-faint" : "w-1.5 bg-po-dim"}`
|
|
1240
|
+
})
|
|
1241
|
+
]
|
|
1242
|
+
}, stack.root);
|
|
1243
|
+
})
|
|
1244
|
+
}),
|
|
1245
|
+
waiting > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
1246
|
+
className: "flex shrink-0 items-center gap-1.5 rounded-full bg-po-tint-magenta px-2.5 py-1 text-sm text-po-magenta max-sm:hidden",
|
|
1247
|
+
children: [
|
|
1248
|
+
/* @__PURE__ */ jsx("span", {
|
|
1249
|
+
"aria-hidden": true,
|
|
1250
|
+
className: "size-1.5 rounded-full bg-po-magenta"
|
|
1251
|
+
}),
|
|
1252
|
+
waiting,
|
|
1253
|
+
" waiting for you"
|
|
1254
|
+
]
|
|
1255
|
+
}) : null,
|
|
1256
|
+
/* @__PURE__ */ jsx(BarButton, {
|
|
1257
|
+
label: remote === "on" ? "Remote access is on" : "Remote access",
|
|
1258
|
+
active: remote === "on",
|
|
1259
|
+
onClick: onRemote,
|
|
1260
|
+
testId: "desktop-remote",
|
|
1261
|
+
children: /* @__PURE__ */ jsx(ShieldIcon, {
|
|
1262
|
+
"aria-hidden": true,
|
|
1263
|
+
className: `size-4 ${remote === "failed" ? "text-po-red" : ""}`
|
|
1264
|
+
})
|
|
1265
|
+
}),
|
|
1266
|
+
/* @__PURE__ */ jsx("span", {
|
|
1267
|
+
"aria-hidden": true,
|
|
1268
|
+
className: "mx-1 h-6 w-px shrink-0 bg-po-border-soft max-sm:hidden"
|
|
1269
|
+
}),
|
|
1270
|
+
/* @__PURE__ */ jsx("nav", {
|
|
1271
|
+
"aria-label": "Rail",
|
|
1272
|
+
className: "flex shrink-0 items-center gap-0.5 max-sm:hidden",
|
|
1273
|
+
children: faces.map(({ id, label, icon: Glyph, badge }) => /* @__PURE__ */ jsxs(BarButton, {
|
|
1274
|
+
testId: `desktop-face-${id}`,
|
|
1275
|
+
label: `${shownFace === id ? `Hide ${label}` : label}${badge > 0 ? `, ${badge} new` : ""}`,
|
|
1276
|
+
active: shownFace === id,
|
|
1277
|
+
pressed: shownFace === id,
|
|
1278
|
+
onClick: () => onFace(id),
|
|
1279
|
+
children: [/* @__PURE__ */ jsx(Glyph, {
|
|
1280
|
+
"aria-hidden": true,
|
|
1281
|
+
className: "size-4"
|
|
1282
|
+
}), badge > 0 ? /* @__PURE__ */ jsx("span", {
|
|
1283
|
+
"aria-hidden": true,
|
|
1284
|
+
className: "absolute top-0.5 right-0 rounded-full bg-po-green px-1 text-2xs leading-4 font-semibold text-po-on-selected",
|
|
1285
|
+
children: badge > 99 ? "99+" : badge
|
|
1286
|
+
}) : null]
|
|
1287
|
+
}, id))
|
|
1288
|
+
}),
|
|
1289
|
+
/* @__PURE__ */ jsx("span", {
|
|
1290
|
+
className: "sm:hidden",
|
|
1291
|
+
children: /* @__PURE__ */ jsx(BarButton, {
|
|
1292
|
+
label: shownFace === null ? "Show the rail" : "Hide the rail",
|
|
1293
|
+
active: shownFace !== null,
|
|
1294
|
+
pressed: shownFace !== null,
|
|
1295
|
+
onClick: () => onFace(face),
|
|
1296
|
+
testId: "desktop-rail-toggle",
|
|
1297
|
+
children: /* @__PURE__ */ jsx(ActivityIcon, {
|
|
1298
|
+
"aria-hidden": true,
|
|
1299
|
+
className: "size-4"
|
|
1300
|
+
})
|
|
1301
|
+
})
|
|
1302
|
+
}),
|
|
1303
|
+
/* @__PURE__ */ jsx(Clock, {})
|
|
1304
|
+
]
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
//#endregion
|
|
1308
|
+
//#region src/extensions/(frontend)/template/_components/DesktopMenu.tsx
|
|
1309
|
+
/** The rail's status copy is the only running signal a template gets; the menu and the bar share this reading. */
|
|
1310
|
+
function sessionRunning(session) {
|
|
1311
|
+
return session.status.startsWith("running") || session.status.startsWith("workflow");
|
|
1312
|
+
}
|
|
1313
|
+
const SESSION_DIALOG_KEY = "desktop/session-dialog";
|
|
1314
|
+
function SessionRow({ session, actions, onOpen, onDialog }) {
|
|
1315
|
+
const failed = session.error !== void 0 || session.status.includes("failed");
|
|
1316
|
+
const running = sessionRunning(session);
|
|
1317
|
+
const name = session.name || "Untitled";
|
|
1318
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1319
|
+
className: "relative",
|
|
1320
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
1321
|
+
type: "button",
|
|
1322
|
+
"data-testid": `desktop-menu-session-${session.id}`,
|
|
1323
|
+
"aria-current": session.active ? "true" : void 0,
|
|
1324
|
+
onClick: onOpen,
|
|
1325
|
+
className: `flex w-full items-center gap-3 rounded-xl py-2 pr-12 pl-3 text-left hover:bg-po-rail focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none ${session.nested ? "pl-8" : ""} ${session.active ? "bg-po-rail/70" : ""}`,
|
|
1326
|
+
children: [
|
|
1327
|
+
/* @__PURE__ */ jsx("span", {
|
|
1328
|
+
className: `grid size-8 shrink-0 place-items-center rounded-lg ${failed ? "bg-po-tint-red text-po-red" : running ? "bg-po-tint-yellow text-po-yellow" : "bg-po-rail text-po-dim"}`,
|
|
1329
|
+
children: failed ? /* @__PURE__ */ jsx(AlertIcon, {
|
|
1330
|
+
"aria-hidden": true,
|
|
1331
|
+
className: "size-4"
|
|
1332
|
+
}) : running ? /* @__PURE__ */ jsx(LoaderIcon, {
|
|
1333
|
+
"aria-hidden": true,
|
|
1334
|
+
className: "size-4 animate-spin"
|
|
1335
|
+
}) : /* @__PURE__ */ jsx(MessageIcon, {
|
|
1336
|
+
"aria-hidden": true,
|
|
1337
|
+
className: "size-4"
|
|
1338
|
+
})
|
|
1339
|
+
}),
|
|
1340
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1341
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
1342
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1343
|
+
className: "truncate text-base font-medium text-po-hi",
|
|
1344
|
+
children: session.name
|
|
1345
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1346
|
+
className: "truncate text-sm text-po-dim",
|
|
1347
|
+
children: session.clock ? /* @__PURE__ */ jsx(LiveDuration, {
|
|
1348
|
+
label: session.clock.label,
|
|
1349
|
+
since: session.clock.since
|
|
1350
|
+
}) : session.status
|
|
1351
|
+
})]
|
|
1352
|
+
}),
|
|
1353
|
+
session.awaitingInput || (session.waitingCount ?? 0) > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
1354
|
+
className: "flex shrink-0 items-center",
|
|
1355
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1356
|
+
"aria-hidden": true,
|
|
1357
|
+
className: "size-2 rounded-full bg-po-magenta"
|
|
1358
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1359
|
+
className: "sr-only",
|
|
1360
|
+
children: "Waiting for you"
|
|
1361
|
+
})]
|
|
1362
|
+
}) : null
|
|
1363
|
+
]
|
|
1364
|
+
}), /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
1365
|
+
asChild: true,
|
|
1366
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
1367
|
+
variant: "ghost",
|
|
1368
|
+
size: "icon-md",
|
|
1369
|
+
"aria-label": `Actions for ${name}`,
|
|
1370
|
+
title: "Session actions",
|
|
1371
|
+
"data-testid": `desktop-menu-session-actions-${session.id}`,
|
|
1372
|
+
className: "absolute top-1/2 right-2 -translate-y-1/2 rounded-full text-po-dim hover:text-po-hi",
|
|
1373
|
+
children: /* @__PURE__ */ jsx(KebabIcon, {
|
|
1374
|
+
"aria-hidden": true,
|
|
1375
|
+
className: "size-4"
|
|
1376
|
+
})
|
|
1377
|
+
})
|
|
1378
|
+
}), /* @__PURE__ */ jsxs(DropdownMenuContent, {
|
|
1379
|
+
align: "end",
|
|
1380
|
+
"data-testid": `desktop-menu-session-actions-list-${session.id}`,
|
|
1381
|
+
children: [
|
|
1382
|
+
actions.renderSessionMenuItems(session.id),
|
|
1383
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1384
|
+
"data-testid": `desktop-session-rename-${session.id}`,
|
|
1385
|
+
onSelect: () => onDialog("rename"),
|
|
1386
|
+
children: "Rename"
|
|
1387
|
+
}),
|
|
1388
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1389
|
+
onSelect: () => actions.resumeSession(session.id),
|
|
1390
|
+
children: "Resume"
|
|
1391
|
+
}),
|
|
1392
|
+
actions.openMoveSession && session.move ? /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1393
|
+
disabled: session.restarting || session.move.blocked,
|
|
1394
|
+
onSelect: () => actions.openMoveSession?.(session.id),
|
|
1395
|
+
children: "Move to workspace…"
|
|
1396
|
+
}) : null,
|
|
1397
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1398
|
+
disabled: session.restarting || session.restartBlocked === true,
|
|
1399
|
+
onSelect: () => actions.restartSession(session.id),
|
|
1400
|
+
children: "Restart"
|
|
1401
|
+
}),
|
|
1402
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
1403
|
+
variant: "destructive",
|
|
1404
|
+
"data-testid": `desktop-session-remove-${session.id}`,
|
|
1405
|
+
onSelect: () => onDialog("remove"),
|
|
1406
|
+
children: "Remove"
|
|
1407
|
+
})
|
|
1408
|
+
]
|
|
1409
|
+
})] })]
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Rename and remove, asked for from a session's menu. Mounted by the desktop rather than the menu,
|
|
1414
|
+
* because the menu closes when a dialog takes the focus.
|
|
1415
|
+
*/
|
|
1416
|
+
function DesktopSessionDialogs({ actions }) {
|
|
1417
|
+
const [dialog, setDialog] = useDashboardState(SESSION_DIALOG_KEY, null);
|
|
1418
|
+
const [draft, setDraft] = useState("");
|
|
1419
|
+
const [error, setError] = useState("");
|
|
1420
|
+
const [removing, setRemoving] = useState(false);
|
|
1421
|
+
const [shown, setShown] = useState(null);
|
|
1422
|
+
if (dialog !== shown) {
|
|
1423
|
+
setShown(dialog);
|
|
1424
|
+
setDraft(dialog?.name ?? "");
|
|
1425
|
+
setError("");
|
|
1426
|
+
}
|
|
1427
|
+
const close = () => setDialog(null);
|
|
1428
|
+
const remove = async (sessionId) => {
|
|
1429
|
+
if (removing) return;
|
|
1430
|
+
setRemoving(true);
|
|
1431
|
+
const result = await actions.removeSession(sessionId);
|
|
1432
|
+
setRemoving(false);
|
|
1433
|
+
if (result !== void 0) setError(result.error);
|
|
1434
|
+
else close();
|
|
1435
|
+
};
|
|
1436
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Dialog, {
|
|
1437
|
+
open: dialog?.mode === "rename",
|
|
1438
|
+
onOpenChange: (next) => !next && close(),
|
|
1439
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
1440
|
+
width: "sm",
|
|
1441
|
+
"data-testid": "desktop-session-rename-dialog",
|
|
1442
|
+
"aria-describedby": void 0,
|
|
1443
|
+
children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Rename session" }) }), /* @__PURE__ */ jsx(DialogBody, { children: /* @__PURE__ */ jsxs("form", {
|
|
1444
|
+
className: "flex flex-col gap-3",
|
|
1445
|
+
onSubmit: (event) => {
|
|
1446
|
+
event.preventDefault();
|
|
1447
|
+
if (dialog === null || draft.trim() === "") return;
|
|
1448
|
+
actions.renameSession(dialog.sessionId, draft);
|
|
1449
|
+
close();
|
|
1450
|
+
},
|
|
1451
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
1452
|
+
"aria-label": "Session name",
|
|
1453
|
+
"data-testid": "desktop-session-name-input",
|
|
1454
|
+
value: draft,
|
|
1455
|
+
onChange: (event) => setDraft(event.target.value)
|
|
1456
|
+
}), /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1457
|
+
type: "button",
|
|
1458
|
+
variant: "outline",
|
|
1459
|
+
size: "md",
|
|
1460
|
+
onClick: close,
|
|
1461
|
+
children: "Cancel"
|
|
1462
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1463
|
+
type: "submit",
|
|
1464
|
+
variant: "primary",
|
|
1465
|
+
size: "md",
|
|
1466
|
+
disabled: draft.trim() === "",
|
|
1467
|
+
children: "Rename"
|
|
1468
|
+
})] })]
|
|
1469
|
+
}) })]
|
|
1470
|
+
})
|
|
1471
|
+
}), /* @__PURE__ */ jsx(Dialog, {
|
|
1472
|
+
open: dialog?.mode === "remove",
|
|
1473
|
+
onOpenChange: (next) => !next && close(),
|
|
1474
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
1475
|
+
width: "sm",
|
|
1476
|
+
"data-testid": "desktop-session-remove-dialog",
|
|
1477
|
+
"aria-describedby": void 0,
|
|
1478
|
+
children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Remove session" }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [
|
|
1479
|
+
/* @__PURE__ */ jsxs(DialogDescription, { children: [
|
|
1480
|
+
"This stops ",
|
|
1481
|
+
/* @__PURE__ */ jsx("span", {
|
|
1482
|
+
className: "font-semibold text-po-hi",
|
|
1483
|
+
children: dialog?.name
|
|
1484
|
+
}),
|
|
1485
|
+
" and removes it from the list. Anything it is running ends now. You can restore it for 7 days."
|
|
1486
|
+
] }),
|
|
1487
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
1488
|
+
className: "text-sm text-po-red",
|
|
1489
|
+
children: error
|
|
1490
|
+
}) : null,
|
|
1491
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1492
|
+
variant: "outline",
|
|
1493
|
+
size: "md",
|
|
1494
|
+
onClick: close,
|
|
1495
|
+
children: "Cancel"
|
|
1496
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1497
|
+
variant: "danger",
|
|
1498
|
+
size: "md",
|
|
1499
|
+
disabled: removing,
|
|
1500
|
+
"data-testid": "desktop-session-remove-confirm",
|
|
1501
|
+
onClick: () => dialog && void remove(dialog.sessionId),
|
|
1502
|
+
children: "Remove"
|
|
1503
|
+
})] })
|
|
1504
|
+
] })]
|
|
1505
|
+
})
|
|
1506
|
+
})] });
|
|
1507
|
+
}
|
|
1508
|
+
/** Search, every session by workspace, and the person's corner at the foot. */
|
|
1509
|
+
function DesktopMenu({ rail, onClose }) {
|
|
1510
|
+
const { scrollRef, actions, pluginContent } = rail;
|
|
1511
|
+
const [query, setQuery] = useState("");
|
|
1512
|
+
const needle = query.trim().toLowerCase();
|
|
1513
|
+
const workspaces = rail.workspaces.map((workspace) => ({
|
|
1514
|
+
...workspace,
|
|
1515
|
+
sessions: needle === "" ? workspace.sessions : workspace.sessions.filter((session) => session.name.toLowerCase().includes(needle))
|
|
1516
|
+
})).filter((workspace) => needle === "" || workspace.sessions.length > 0);
|
|
1517
|
+
const empty = rail.workspaces.length === 0;
|
|
1518
|
+
const focused = rail.workspaces.flatMap((workspace) => workspace.sessions).find((session) => session.active);
|
|
1519
|
+
const profile = focused?.profile;
|
|
1520
|
+
const [, setDialog] = useDashboardState(SESSION_DIALOG_KEY, null);
|
|
1521
|
+
const act = (action) => {
|
|
1522
|
+
action();
|
|
1523
|
+
onClose();
|
|
1524
|
+
};
|
|
1525
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1526
|
+
/* @__PURE__ */ jsxs("label", {
|
|
1527
|
+
className: "m-4 mb-2 flex items-center gap-2.5 rounded-xl bg-po-panel px-3.5 py-2.5 ring-1 ring-po-border-soft focus-within:ring-po-green",
|
|
1528
|
+
children: [/* @__PURE__ */ jsx(SearchIcon, {
|
|
1529
|
+
"aria-hidden": true,
|
|
1530
|
+
className: "size-4 text-po-dim"
|
|
1531
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
1532
|
+
"aria-label": "Search sessions",
|
|
1533
|
+
placeholder: "Search sessions",
|
|
1534
|
+
value: query,
|
|
1535
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1536
|
+
className: "min-w-0 flex-1 bg-transparent text-lg text-po-text outline-none placeholder:text-po-dim"
|
|
1537
|
+
})]
|
|
1538
|
+
}),
|
|
1539
|
+
/* @__PURE__ */ jsxs("section", {
|
|
1540
|
+
ref: scrollRef,
|
|
1541
|
+
"data-po-region": "rail",
|
|
1542
|
+
"aria-label": "Sessions",
|
|
1543
|
+
className: "flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-2 py-2",
|
|
1544
|
+
children: [
|
|
1545
|
+
empty ? /* @__PURE__ */ jsxs("div", {
|
|
1546
|
+
className: "flex flex-col items-center gap-3 px-6 py-8 text-center",
|
|
1547
|
+
children: [
|
|
1548
|
+
/* @__PURE__ */ jsx("p", {
|
|
1549
|
+
className: "text-base font-semibold text-po-hi",
|
|
1550
|
+
children: "Nothing here yet"
|
|
1551
|
+
}),
|
|
1552
|
+
/* @__PURE__ */ jsx("p", {
|
|
1553
|
+
className: "text-sm text-po-dim",
|
|
1554
|
+
children: "Add a folder for Po to work in. Each session opens in its own window."
|
|
1555
|
+
}),
|
|
1556
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
1557
|
+
variant: "primary",
|
|
1558
|
+
size: "md",
|
|
1559
|
+
className: "gap-1.5 rounded-full px-4",
|
|
1560
|
+
onClick: () => act(actions.openAddWorkspace),
|
|
1561
|
+
children: [/* @__PURE__ */ jsx(FolderIcon, { className: "size-4" }), "Add workspace"]
|
|
1562
|
+
}),
|
|
1563
|
+
actions.createGeneralSession ? /* @__PURE__ */ jsx(Button, {
|
|
1564
|
+
variant: "ghost",
|
|
1565
|
+
size: "sm",
|
|
1566
|
+
onClick: () => act(actions.createGeneralSession),
|
|
1567
|
+
children: "Start a session without a folder"
|
|
1568
|
+
}) : null
|
|
1569
|
+
]
|
|
1570
|
+
}) : workspaces.map((workspace) => /* @__PURE__ */ jsxs("div", {
|
|
1571
|
+
className: "flex flex-col",
|
|
1572
|
+
children: [
|
|
1573
|
+
workspace.kind === "session" ? null : /* @__PURE__ */ jsxs("span", {
|
|
1574
|
+
className: "flex items-center justify-between px-3 pt-1 pb-1",
|
|
1575
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1576
|
+
className: "truncate text-sm font-semibold text-po-dim",
|
|
1577
|
+
children: workspace.name
|
|
1578
|
+
}), workspace.legacy || !workspace.available ? null : /* @__PURE__ */ jsx(Button, {
|
|
1579
|
+
variant: "ghost",
|
|
1580
|
+
size: "icon",
|
|
1581
|
+
"aria-label": `New session in ${workspace.name}`,
|
|
1582
|
+
title: `New session in ${workspace.name}`,
|
|
1583
|
+
onClick: () => act(() => actions.createSession(workspace.id)),
|
|
1584
|
+
className: "size-6 rounded-full text-po-dim",
|
|
1585
|
+
children: /* @__PURE__ */ jsx(PlusIcon, { className: "size-3.5" })
|
|
1586
|
+
})]
|
|
1587
|
+
}),
|
|
1588
|
+
workspace.sessions.map((session) => /* @__PURE__ */ jsx(SessionRow, {
|
|
1589
|
+
session,
|
|
1590
|
+
actions,
|
|
1591
|
+
onOpen: () => act(() => actions.openSession(session.id)),
|
|
1592
|
+
onDialog: (mode) => act(() => setDialog({
|
|
1593
|
+
mode,
|
|
1594
|
+
sessionId: session.id,
|
|
1595
|
+
name: session.name || "Untitled"
|
|
1596
|
+
}))
|
|
1597
|
+
}, session.id)),
|
|
1598
|
+
workspace.sessions.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1599
|
+
className: "px-3 py-1 text-sm text-po-dim",
|
|
1600
|
+
children: "No sessions yet."
|
|
1601
|
+
}) : null
|
|
1602
|
+
]
|
|
1603
|
+
}, workspace.id)),
|
|
1604
|
+
needle !== "" && workspaces.length === 0 ? /* @__PURE__ */ jsxs("p", {
|
|
1605
|
+
className: "px-3 py-2 text-sm text-po-dim",
|
|
1606
|
+
children: [
|
|
1607
|
+
"No session matches “",
|
|
1608
|
+
query.trim(),
|
|
1609
|
+
"”."
|
|
1610
|
+
]
|
|
1611
|
+
}) : null,
|
|
1612
|
+
pluginContent
|
|
1613
|
+
]
|
|
1614
|
+
}),
|
|
1615
|
+
/* @__PURE__ */ jsxs("footer", {
|
|
1616
|
+
className: "flex items-center gap-2 border-t border-po-border-soft bg-po-rail/50 px-4 py-3",
|
|
1617
|
+
children: [
|
|
1618
|
+
/* @__PURE__ */ jsx(ProfileAvatar, {
|
|
1619
|
+
profile,
|
|
1620
|
+
className: "size-8"
|
|
1621
|
+
}),
|
|
1622
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1623
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
1624
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1625
|
+
className: "truncate text-base font-semibold text-po-hi",
|
|
1626
|
+
children: profile?.label ?? "Default profile"
|
|
1627
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1628
|
+
className: "truncate text-sm text-po-dim",
|
|
1629
|
+
children: focused ? `Working in ${focused.name}` : "No session focused"
|
|
1630
|
+
})]
|
|
1631
|
+
}),
|
|
1632
|
+
empty ? null : /* @__PURE__ */ jsx(Button, {
|
|
1633
|
+
variant: "ghost",
|
|
1634
|
+
size: "icon-md",
|
|
1635
|
+
"aria-label": "Add workspace",
|
|
1636
|
+
title: "Add workspace",
|
|
1637
|
+
onClick: () => act(actions.openAddWorkspace),
|
|
1638
|
+
className: "rounded-full text-po-dim",
|
|
1639
|
+
children: /* @__PURE__ */ jsx(FolderIcon, { className: "size-4" })
|
|
1640
|
+
}),
|
|
1641
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1642
|
+
variant: "ghost",
|
|
1643
|
+
size: "icon-md",
|
|
1644
|
+
"aria-label": "Settings",
|
|
1645
|
+
title: "Settings",
|
|
1646
|
+
"data-testid": "desktop-menu-settings",
|
|
1647
|
+
onClick: () => act(actions.openSettings),
|
|
1648
|
+
className: "rounded-full text-po-dim",
|
|
1649
|
+
children: /* @__PURE__ */ jsx(GearIcon, { className: "size-4" })
|
|
1650
|
+
})
|
|
1651
|
+
]
|
|
1652
|
+
})
|
|
1653
|
+
] });
|
|
1654
|
+
}
|
|
1655
|
+
//#endregion
|
|
1656
|
+
//#region src/extensions/(frontend)/template/_components/DesktopRail.tsx
|
|
1657
|
+
/**
|
|
1658
|
+
* A rail tab other than Activity, filling the right column with the panel its package draws.
|
|
1659
|
+
* The tab itself lives in the bar, so this frame carries only the name and the count.
|
|
1660
|
+
*/
|
|
1661
|
+
function DesktopRail({ face, ownsScroll, overlay, children }) {
|
|
1662
|
+
const Glyph = face.icon;
|
|
1663
|
+
return /* @__PURE__ */ jsx("aside", {
|
|
1664
|
+
"data-po-region": "activity",
|
|
1665
|
+
"data-testid": `desktop-rail-${face.id}`,
|
|
1666
|
+
"aria-label": face.label,
|
|
1667
|
+
className: `flex w-[22rem] max-w-[calc(100%-1.5rem)] shrink-0 flex-col py-3 pr-3 pl-2 ${overlay ? "absolute inset-y-0 right-0 z-[60] pl-3" : ""}`,
|
|
1668
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
1669
|
+
className: `flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl shadow-sm ${GLASS}`,
|
|
1670
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
1671
|
+
className: "flex h-11 shrink-0 items-center gap-2 px-4",
|
|
1672
|
+
children: [
|
|
1673
|
+
/* @__PURE__ */ jsx(Glyph, {
|
|
1674
|
+
"aria-hidden": true,
|
|
1675
|
+
className: "size-4 text-po-dim"
|
|
1676
|
+
}),
|
|
1677
|
+
/* @__PURE__ */ jsx("span", {
|
|
1678
|
+
className: "truncate text-base font-semibold text-po-hi",
|
|
1679
|
+
children: face.label
|
|
1680
|
+
}),
|
|
1681
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
1682
|
+
face.badge > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
1683
|
+
className: "shrink-0 text-sm text-po-dim",
|
|
1684
|
+
children: [face.badge, " new"]
|
|
1685
|
+
}) : null
|
|
1686
|
+
]
|
|
1687
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1688
|
+
className: `flex min-h-0 flex-1 flex-col ${ownsScroll ? "" : "overflow-y-auto overscroll-contain"}`,
|
|
1689
|
+
children
|
|
1690
|
+
})]
|
|
1691
|
+
})
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
//#endregion
|
|
1695
|
+
//#region src/extensions/(frontend)/template/_components/DockedSheet.tsx
|
|
1696
|
+
const KEY_STEP = 16;
|
|
1697
|
+
/**
|
|
1698
|
+
* A side sheet docked beside the main column: it narrows the column instead of covering it (on a phone it
|
|
1699
|
+
* slides over), its inner edge resizes, and it stays mounted so opening and closing slide its width.
|
|
1700
|
+
*/
|
|
1701
|
+
function DockedSheet({ side, open, label, defaultWidth, minWidth, maxWidth, testId, region, fixed = false, children }) {
|
|
1702
|
+
const [width, setWidth] = useState(defaultWidth);
|
|
1703
|
+
const [resizing, setResizing] = useState(false);
|
|
1704
|
+
const [opened, setOpened] = useState(open);
|
|
1705
|
+
if (open && !opened) setOpened(true);
|
|
1706
|
+
const clamp = (next) => Math.round(Math.min(maxWidth, Math.max(minWidth, next)));
|
|
1707
|
+
const grow = side === "right" ? -1 : 1;
|
|
1708
|
+
const startResize = (event) => {
|
|
1709
|
+
const handle = event.currentTarget;
|
|
1710
|
+
const startX = event.clientX;
|
|
1711
|
+
handle.setPointerCapture(event.pointerId);
|
|
1712
|
+
setResizing(true);
|
|
1713
|
+
const move = (next) => setWidth(clamp(width + grow * (next.clientX - startX)));
|
|
1714
|
+
const end = () => {
|
|
1715
|
+
setResizing(false);
|
|
1716
|
+
handle.removeEventListener("pointermove", move);
|
|
1717
|
+
handle.removeEventListener("pointerup", end);
|
|
1718
|
+
handle.removeEventListener("pointercancel", end);
|
|
1719
|
+
};
|
|
1720
|
+
handle.addEventListener("pointermove", move);
|
|
1721
|
+
handle.addEventListener("pointerup", end);
|
|
1722
|
+
handle.addEventListener("pointercancel", end);
|
|
1723
|
+
};
|
|
1724
|
+
const resizeByKey = (event) => {
|
|
1725
|
+
const direction = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
1726
|
+
if (direction === 0) return;
|
|
1727
|
+
event.preventDefault();
|
|
1728
|
+
setWidth(clamp(width + grow * direction * KEY_STEP));
|
|
1729
|
+
};
|
|
1730
|
+
return /* @__PURE__ */ jsx("aside", {
|
|
1731
|
+
"aria-label": label,
|
|
1732
|
+
"aria-hidden": !open,
|
|
1733
|
+
inert: !open,
|
|
1734
|
+
"data-testid": testId,
|
|
1735
|
+
"data-open": open,
|
|
1736
|
+
"data-po-region": region,
|
|
1737
|
+
style: { "--sheet-width": `${width}px` },
|
|
1738
|
+
className: `relative flex shrink-0 flex-col overflow-hidden bg-po-bg motion-reduce:transition-none max-md:absolute max-md:inset-y-0 max-md:z-30 ${side === "right" ? "items-end max-md:right-0" : "items-start max-md:left-0"} ${resizing ? "" : "transition-[width] duration-200 ease-out"} ${open ? "max-md:w-full md:w-(--sheet-width)" : "w-0"}`,
|
|
1739
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1740
|
+
className: `relative flex h-full shrink-0 flex-col border-po-border-soft max-md:w-screen md:w-(--sheet-width) ${fixed ? "" : side === "right" ? "border-l" : "border-r"}`,
|
|
1741
|
+
children: [fixed ? null : /* @__PURE__ */ jsx("div", {
|
|
1742
|
+
role: "separator",
|
|
1743
|
+
"aria-orientation": "vertical",
|
|
1744
|
+
"aria-label": `Resize ${label.toLowerCase()}`,
|
|
1745
|
+
"aria-valuenow": width,
|
|
1746
|
+
"aria-valuemin": minWidth,
|
|
1747
|
+
"aria-valuemax": maxWidth,
|
|
1748
|
+
tabIndex: 0,
|
|
1749
|
+
onPointerDown: startResize,
|
|
1750
|
+
onKeyDown: resizeByKey,
|
|
1751
|
+
className: `absolute inset-y-0 z-10 w-2 cursor-col-resize touch-none outline-none hover:bg-po-blue/20 focus-visible:bg-po-blue/30 max-md:hidden ${side === "right" ? "left-0" : "right-0"}`
|
|
1752
|
+
}), opened ? children : null]
|
|
1753
|
+
})
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
//#endregion
|
|
1757
|
+
//#region src/extensions/(frontend)/template/_lib/responseRows.ts
|
|
1758
|
+
/**
|
|
1759
|
+
* Tool calls stay with the message that introduced them, so "Now checking it:" is followed by its own
|
|
1760
|
+
* activity, not by the next message. Calls before any message form their own run; a person's steering
|
|
1761
|
+
* message starts a new run, and so does any row shown inline (an error, a note from another session),
|
|
1762
|
+
* which keeps it after the calls that came before it. Each host maps its own entry shape to a fold.
|
|
1763
|
+
*/
|
|
1764
|
+
function responseRows(sequence, fold) {
|
|
1765
|
+
const rows = [];
|
|
1766
|
+
let run = [];
|
|
1767
|
+
const close = () => {
|
|
1768
|
+
if (run.length > 0) rows.push({
|
|
1769
|
+
kind: "activity",
|
|
1770
|
+
key: run[0].id,
|
|
1771
|
+
items: run
|
|
1772
|
+
});
|
|
1773
|
+
run = [];
|
|
1774
|
+
};
|
|
1775
|
+
for (const entry of sequence) {
|
|
1776
|
+
const kind = fold(entry);
|
|
1777
|
+
if (kind === "skip") continue;
|
|
1778
|
+
if (kind === "activity") {
|
|
1779
|
+
run.push(entry);
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1782
|
+
close();
|
|
1783
|
+
rows.push({
|
|
1784
|
+
kind: "entry",
|
|
1785
|
+
entry
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
close();
|
|
1789
|
+
return rows;
|
|
1790
|
+
}
|
|
1791
|
+
//#endregion
|
|
1792
|
+
//#region src/extensions/(frontend)/template/_components/ResponseActivitySheet.tsx
|
|
1793
|
+
/** The run the sheet lists, or null while it is closed. A message's "View activity" sets it. */
|
|
1794
|
+
const responseActivityStore = new Store(null);
|
|
1795
|
+
/** One message's tool calls, docked on the right; it keeps the last list while it slides closed. */
|
|
1796
|
+
function ResponseActivitySheet() {
|
|
1797
|
+
const sessionId = useStore(sessionsStore, (state) => state.activeId);
|
|
1798
|
+
const slotProps = usePluginSlotProps(sessionId);
|
|
1799
|
+
const statuses = useActiveSession((state) => state.statuses);
|
|
1800
|
+
const activity = useStore(responseActivityStore, (state) => state);
|
|
1801
|
+
const open = activity !== null && activity.sessionId === sessionId;
|
|
1802
|
+
const [shown, setShown] = useState(activity);
|
|
1803
|
+
if (open && activity !== shown) setShown(activity);
|
|
1804
|
+
return /* @__PURE__ */ jsxs(DockedSheet, {
|
|
1805
|
+
side: "right",
|
|
1806
|
+
open,
|
|
1807
|
+
label: "Activity",
|
|
1808
|
+
defaultWidth: 384,
|
|
1809
|
+
minWidth: 280,
|
|
1810
|
+
maxWidth: 800,
|
|
1811
|
+
testId: "response-activity-sheet",
|
|
1812
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
1813
|
+
className: "flex shrink-0 items-center justify-between gap-2 px-4 pt-3 pb-2",
|
|
1814
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
1815
|
+
className: "text-lg font-semibold text-po-hi",
|
|
1816
|
+
children: "Activity"
|
|
1817
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1818
|
+
variant: "ghost",
|
|
1819
|
+
size: "icon-md",
|
|
1820
|
+
"aria-label": "Close activity",
|
|
1821
|
+
onClick: () => responseActivityStore.setState(() => null),
|
|
1822
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {
|
|
1823
|
+
"aria-hidden": true,
|
|
1824
|
+
className: "size-4"
|
|
1825
|
+
})
|
|
1826
|
+
})]
|
|
1827
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1828
|
+
className: "min-h-0 flex-1 overflow-y-auto px-4 pb-4",
|
|
1829
|
+
children: /* @__PURE__ */ jsx(MessageItem, {
|
|
1830
|
+
className: "divide-y divide-po-border-soft rounded-none border-0",
|
|
1831
|
+
children: (shown?.items ?? []).map((entry) => /* @__PURE__ */ jsx("div", {
|
|
1832
|
+
className: "py-1.5",
|
|
1833
|
+
children: entry.kind === "tool" ? /* @__PURE__ */ jsx(ToolCard, {
|
|
1834
|
+
entry,
|
|
1835
|
+
slotProps,
|
|
1836
|
+
statuses,
|
|
1837
|
+
suppressOutputs: true
|
|
1838
|
+
}) : /* @__PURE__ */ jsxs("p", {
|
|
1839
|
+
className: "flex items-start gap-2 py-1 text-sm text-po-dim",
|
|
1840
|
+
children: [/* @__PURE__ */ jsx(SparklesIcon, {
|
|
1841
|
+
"aria-hidden": true,
|
|
1842
|
+
className: "mt-0.5 size-3.5 shrink-0"
|
|
1843
|
+
}), entry.text]
|
|
1844
|
+
})
|
|
1845
|
+
}, entry.id))
|
|
1846
|
+
})
|
|
1847
|
+
})]
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
//#endregion
|
|
1851
|
+
//#region src/extensions/(frontend)/template/_components/ResponseOutputs.tsx
|
|
1852
|
+
/** A single mounted tree per output, including while expanded or on another slide. */
|
|
1853
|
+
function ResponseOutputs({ items, initialOutput = 0, initiallyExpanded = false }) {
|
|
1854
|
+
const [selectedId, setSelectedId] = useState(items[initialOutput]?.id);
|
|
1855
|
+
const [expanded, setExpanded] = useState(initiallyExpanded);
|
|
1856
|
+
const dialog = useRef(null);
|
|
1857
|
+
const selected = Math.max(0, items.findIndex((item) => item.id === selectedId));
|
|
1858
|
+
const active = items[selected];
|
|
1859
|
+
useEffect(() => {
|
|
1860
|
+
const element = dialog.current;
|
|
1861
|
+
if (initiallyExpanded && element) {
|
|
1862
|
+
element.close();
|
|
1863
|
+
element.showModal();
|
|
1864
|
+
}
|
|
1865
|
+
}, [initiallyExpanded]);
|
|
1866
|
+
if (!active) return null;
|
|
1867
|
+
return /* @__PURE__ */ jsx("section", {
|
|
1868
|
+
"aria-label": "Response outputs",
|
|
1869
|
+
"aria-roledescription": "carousel",
|
|
1870
|
+
className: "mt-5 overflow-hidden rounded-lg border border-po-border-soft bg-po-panel",
|
|
1871
|
+
children: /* @__PURE__ */ jsxs("dialog", {
|
|
1872
|
+
ref: dialog,
|
|
1873
|
+
open: true,
|
|
1874
|
+
role: expanded ? "dialog" : "group",
|
|
1875
|
+
"aria-label": expanded ? "Response outputs" : "Output previews",
|
|
1876
|
+
"aria-modal": expanded,
|
|
1877
|
+
className: expanded ? "fixed inset-3 m-0 flex h-[calc(100dvh-24px)] w-[calc(100vw-24px)] max-h-none max-w-none flex-col overflow-hidden rounded-lg border border-po-border bg-po-panel p-0 text-po-text shadow-2xl backdrop:bg-po-deep/70" : "static m-0 w-full max-w-none border-0 bg-po-panel p-0 text-po-text",
|
|
1878
|
+
onClose: (event) => {
|
|
1879
|
+
if (event.currentTarget.open) return;
|
|
1880
|
+
event.currentTarget.show();
|
|
1881
|
+
setExpanded(false);
|
|
1882
|
+
},
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1885
|
+
className: "flex items-center justify-between gap-2 border-b border-po-border-soft px-4 py-2",
|
|
1886
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
1887
|
+
className: "text-base font-semibold text-po-hi",
|
|
1888
|
+
children: expanded ? "Response outputs" : "Outputs"
|
|
1889
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1890
|
+
variant: "ghost",
|
|
1891
|
+
size: "sm",
|
|
1892
|
+
"aria-label": expanded ? "Close outputs" : "Expand outputs",
|
|
1893
|
+
onClick: () => {
|
|
1894
|
+
const element = dialog.current;
|
|
1895
|
+
if (!element) return;
|
|
1896
|
+
element.close();
|
|
1897
|
+
if (!expanded) {
|
|
1898
|
+
element.showModal();
|
|
1899
|
+
setExpanded(true);
|
|
1900
|
+
}
|
|
1901
|
+
},
|
|
1902
|
+
children: expanded ? /* @__PURE__ */ jsx(CloseIcon, {
|
|
1903
|
+
"aria-hidden": true,
|
|
1904
|
+
className: "size-4"
|
|
1905
|
+
}) : "Expand outputs"
|
|
1906
|
+
})]
|
|
1907
|
+
}),
|
|
1908
|
+
/* @__PURE__ */ jsx("div", {
|
|
1909
|
+
className: expanded ? "min-h-0 flex-1 overflow-auto" : "max-h-64 min-h-32 overflow-auto",
|
|
1910
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx("div", {
|
|
1911
|
+
hidden: index !== selected,
|
|
1912
|
+
className: index === selected ? "flex min-h-full flex-col items-center justify-center p-3 *:self-center" : "hidden",
|
|
1913
|
+
children: item.content
|
|
1914
|
+
}, item.id))
|
|
1915
|
+
}),
|
|
1916
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1917
|
+
role: "group",
|
|
1918
|
+
"aria-label": "Output navigation",
|
|
1919
|
+
className: "flex items-center gap-2 border-t border-po-border-soft px-3 py-2",
|
|
1920
|
+
children: [
|
|
1921
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1922
|
+
variant: "ghost",
|
|
1923
|
+
size: "icon-md",
|
|
1924
|
+
"aria-label": "Previous output",
|
|
1925
|
+
disabled: selected === 0,
|
|
1926
|
+
onClick: () => setSelectedId(items[selected - 1].id),
|
|
1927
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
1928
|
+
"aria-hidden": true,
|
|
1929
|
+
className: "size-4 rotate-180"
|
|
1930
|
+
})
|
|
1931
|
+
}),
|
|
1932
|
+
/* @__PURE__ */ jsxs("output", {
|
|
1933
|
+
"aria-live": "polite",
|
|
1934
|
+
className: "min-w-0 flex-1 text-center text-sm text-po-dim",
|
|
1935
|
+
children: [
|
|
1936
|
+
selected + 1,
|
|
1937
|
+
" of ",
|
|
1938
|
+
items.length,
|
|
1939
|
+
" · ",
|
|
1940
|
+
active.title
|
|
1941
|
+
]
|
|
1942
|
+
}),
|
|
1943
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1944
|
+
variant: "ghost",
|
|
1945
|
+
size: "icon-md",
|
|
1946
|
+
"aria-label": "Next output",
|
|
1947
|
+
disabled: selected === items.length - 1,
|
|
1948
|
+
onClick: () => setSelectedId(items[selected + 1].id),
|
|
1949
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
1950
|
+
"aria-hidden": true,
|
|
1951
|
+
className: "size-4"
|
|
1952
|
+
})
|
|
1953
|
+
})
|
|
1954
|
+
]
|
|
1955
|
+
})
|
|
1956
|
+
]
|
|
1957
|
+
})
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
//#endregion
|
|
1961
|
+
//#region src/extensions/(frontend)/template/_components/QuietTurn.tsx
|
|
1962
|
+
/**
|
|
1963
|
+
* Status notices and failed calls fold in with the calls (the red count flags a failure); only error
|
|
1964
|
+
* notices, which the agent did not recover from, stay inline. No avatar until the agent has words.
|
|
1965
|
+
*/
|
|
1966
|
+
function webFold(entry) {
|
|
1967
|
+
if (entry.kind === "settled") return "skip";
|
|
1968
|
+
if (entry.kind === "assistant" && !entry.text.trim()) return "skip";
|
|
1969
|
+
if (entry.kind === "tool" || entry.kind === "notice" && entry.tone === "info") return "activity";
|
|
1970
|
+
return "entry";
|
|
1971
|
+
}
|
|
1972
|
+
/** The template arranges public transcript data; the host keeps history and actions. */
|
|
1973
|
+
function QuietTurn({ turn, sessionId, slotProps, statuses, renderEntry }) {
|
|
1974
|
+
const rows = responseRows(turn.sequence, webFold);
|
|
1975
|
+
const tools = turn.sequence.filter((entry) => entry.kind === "tool");
|
|
1976
|
+
const runs = rows.filter((row) => row.kind === "activity");
|
|
1977
|
+
const lastRun = runs.at(-1);
|
|
1978
|
+
const working = !turn.settled || tools.some((entry) => entry.running);
|
|
1979
|
+
const failed = tools.at(-1)?.isError === true;
|
|
1980
|
+
const openKey = useStore(responseActivityStore, (state) => state?.sessionId === sessionId ? state.key : null);
|
|
1981
|
+
useEffect(() => {
|
|
1982
|
+
const open = runs.find((run) => run.key === openKey);
|
|
1983
|
+
if (open) responseActivityStore.setState(() => ({
|
|
1984
|
+
sessionId,
|
|
1985
|
+
key: open.key,
|
|
1986
|
+
items: open.items
|
|
1987
|
+
}));
|
|
1988
|
+
});
|
|
1989
|
+
const outputsOf = (items) => items.flatMap((entry) => entry.kind === "tool" ? toolOutputDescriptors(entry, slotProps, statuses) : []);
|
|
1990
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1991
|
+
"data-testid": "quiet-turn",
|
|
1992
|
+
"data-turn-id": turn.id,
|
|
1993
|
+
className: "flex flex-col gap-5",
|
|
1994
|
+
children: [rows.map((row) => row.kind === "entry" ? /* @__PURE__ */ jsx(Fragment, { children: renderEntry(row.entry) }, row.entry.id) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ActivityRow, {
|
|
1995
|
+
items: row.items,
|
|
1996
|
+
open: openKey === row.key,
|
|
1997
|
+
working: row.items.some((entry) => entry.kind === "tool" && entry.running) || working && row === lastRun,
|
|
1998
|
+
ended: failed && !working && row === lastRun,
|
|
1999
|
+
onToggle: () => responseActivityStore.setState(() => openKey === row.key ? null : {
|
|
2000
|
+
sessionId,
|
|
2001
|
+
key: row.key,
|
|
2002
|
+
items: row.items
|
|
2003
|
+
})
|
|
2004
|
+
}), /* @__PURE__ */ jsx(RunOutputs, { items: outputsOf(row.items) })] }, row.key)), working && rows.at(-1)?.kind !== "activity" ? /* @__PURE__ */ jsx("div", {
|
|
2005
|
+
className: "ml-12 flex min-h-8 items-center",
|
|
2006
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2007
|
+
className: "ml-auto px-2.5",
|
|
2008
|
+
children: /* @__PURE__ */ jsx(Spinner, {
|
|
2009
|
+
label: "Po is working",
|
|
2010
|
+
className: "size-3.5 text-po-green"
|
|
2011
|
+
})
|
|
2012
|
+
})
|
|
2013
|
+
}) : null]
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
/** A run's gallery, under the run it came from; nothing when the run made nothing. */
|
|
2017
|
+
function RunOutputs({ items }) {
|
|
2018
|
+
if (items.length === 0) return null;
|
|
2019
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2020
|
+
className: "ml-12 min-w-0",
|
|
2021
|
+
children: /* @__PURE__ */ jsx(ResponseOutputs, { items })
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
function ActivityRow({ items, open, working, ended, onToggle }) {
|
|
2025
|
+
const tools = items.filter((entry) => entry.kind === "tool");
|
|
2026
|
+
const succeeded = tools.filter((entry) => !entry.running && !entry.isError).length;
|
|
2027
|
+
const errored = tools.filter((entry) => entry.isError).length;
|
|
2028
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2029
|
+
"data-testid": "activity-row",
|
|
2030
|
+
className: "ml-12 flex min-h-8 items-center gap-2 text-sm text-po-dim",
|
|
2031
|
+
children: [ended ? /* @__PURE__ */ jsxs("span", {
|
|
2032
|
+
className: "flex items-center gap-1.5",
|
|
2033
|
+
children: [/* @__PURE__ */ jsx(AlertIcon, {
|
|
2034
|
+
"aria-hidden": true,
|
|
2035
|
+
className: "size-3.5 text-po-red"
|
|
2036
|
+
}), "Turn ended"]
|
|
2037
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
2038
|
+
className: "ml-auto flex items-center gap-2",
|
|
2039
|
+
children: [
|
|
2040
|
+
succeeded > 0 ? /* @__PURE__ */ jsxs(Badge, {
|
|
2041
|
+
tone: "green",
|
|
2042
|
+
size: "xs",
|
|
2043
|
+
children: [
|
|
2044
|
+
/* @__PURE__ */ jsx(CheckIcon, {
|
|
2045
|
+
"aria-hidden": true,
|
|
2046
|
+
className: "size-3"
|
|
2047
|
+
}),
|
|
2048
|
+
succeeded,
|
|
2049
|
+
/* @__PURE__ */ jsx("span", {
|
|
2050
|
+
className: "sr-only",
|
|
2051
|
+
children: "succeeded"
|
|
2052
|
+
})
|
|
2053
|
+
]
|
|
2054
|
+
}) : null,
|
|
2055
|
+
errored > 0 ? /* @__PURE__ */ jsxs(Badge, {
|
|
2056
|
+
tone: "red",
|
|
2057
|
+
size: "xs",
|
|
2058
|
+
children: [
|
|
2059
|
+
/* @__PURE__ */ jsx(AlertIcon, {
|
|
2060
|
+
"aria-hidden": true,
|
|
2061
|
+
className: "size-3"
|
|
2062
|
+
}),
|
|
2063
|
+
errored,
|
|
2064
|
+
/* @__PURE__ */ jsx("span", {
|
|
2065
|
+
className: "sr-only",
|
|
2066
|
+
children: "failed"
|
|
2067
|
+
})
|
|
2068
|
+
]
|
|
2069
|
+
}) : null,
|
|
2070
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
2071
|
+
variant: "ghost",
|
|
2072
|
+
size: "sm",
|
|
2073
|
+
"aria-expanded": open,
|
|
2074
|
+
"aria-busy": working,
|
|
2075
|
+
onClick: onToggle,
|
|
2076
|
+
children: [
|
|
2077
|
+
working ? /* @__PURE__ */ jsx(Spinner, { className: "size-3.5 text-po-green" }) : null,
|
|
2078
|
+
"View activity ",
|
|
2079
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
2080
|
+
"aria-hidden": true,
|
|
2081
|
+
className: "size-3.5"
|
|
2082
|
+
})
|
|
2083
|
+
]
|
|
2084
|
+
})
|
|
2085
|
+
]
|
|
2086
|
+
})]
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
//#endregion
|
|
2090
|
+
//#region src/extensions/(frontend)/template/_components/DesktopSessionWindow.tsx
|
|
2091
|
+
const TAB = "flex h-8 shrink-0 items-center rounded-lg px-3 text-base focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none";
|
|
2092
|
+
const TAB_ACTIVE = "bg-po-rail font-semibold text-po-hi";
|
|
2093
|
+
const TAB_IDLE = "font-medium text-po-dim hover:bg-po-rail/60";
|
|
2094
|
+
function noBadge() {
|
|
2095
|
+
return 0;
|
|
2096
|
+
}
|
|
2097
|
+
/** A declared plugin tab; one component per tab keeps its badge hook unconditional. */
|
|
2098
|
+
function PluginTab({ tab, sessionId, active }) {
|
|
2099
|
+
const count = (tab.useBadge ?? noBadge)(sessionId);
|
|
2100
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
2101
|
+
to: "/session/$sessionId/$tabId",
|
|
2102
|
+
params: {
|
|
2103
|
+
sessionId,
|
|
2104
|
+
tabId: tab.id
|
|
2105
|
+
},
|
|
2106
|
+
"data-testid": `tab-${tab.id}`,
|
|
2107
|
+
"aria-current": active ? "page" : void 0,
|
|
2108
|
+
className: `${TAB} gap-1.5 ${active ? TAB_ACTIVE : TAB_IDLE}`,
|
|
2109
|
+
children: [tab.label, count > 0 ? /* @__PURE__ */ jsx("span", {
|
|
2110
|
+
className: "rounded-full bg-po-panel px-1.5 text-sm text-po-dim",
|
|
2111
|
+
children: count
|
|
2112
|
+
}) : null]
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
/** A tab a plugin opened at runtime: close it, or open it in its own window stacked on this one. */
|
|
2116
|
+
function TemporaryTab({ tab, sessionId, active, onOpenInWindow }) {
|
|
2117
|
+
const action = "grid size-6 place-items-center rounded-full text-po-dim hover:bg-po-panel hover:text-po-hi focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none";
|
|
2118
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
2119
|
+
"data-testid": `tab-${tab.id}-chip`,
|
|
2120
|
+
className: `flex h-8 shrink-0 items-center gap-0.5 rounded-lg pr-1 ${active ? TAB_ACTIVE : TAB_IDLE}`,
|
|
2121
|
+
children: [
|
|
2122
|
+
/* @__PURE__ */ jsx(Link, {
|
|
2123
|
+
to: "/session/$sessionId/$tabId",
|
|
2124
|
+
params: {
|
|
2125
|
+
sessionId,
|
|
2126
|
+
tabId: tab.id
|
|
2127
|
+
},
|
|
2128
|
+
"data-testid": `tab-${tab.id}`,
|
|
2129
|
+
title: tab.label,
|
|
2130
|
+
"aria-current": active ? "page" : void 0,
|
|
2131
|
+
className: "max-w-40 truncate rounded-lg py-1 pr-1 pl-3 focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
2132
|
+
children: tab.label
|
|
2133
|
+
}),
|
|
2134
|
+
active ? /* @__PURE__ */ jsx("button", {
|
|
2135
|
+
type: "button",
|
|
2136
|
+
"aria-label": `Open ${tab.label} in its own window`,
|
|
2137
|
+
title: `Open ${tab.label} in its own window`,
|
|
2138
|
+
onClick: onOpenInWindow,
|
|
2139
|
+
className: action,
|
|
2140
|
+
children: /* @__PURE__ */ jsx(AppWindowIcon, {
|
|
2141
|
+
"aria-hidden": true,
|
|
2142
|
+
className: "size-3"
|
|
2143
|
+
})
|
|
2144
|
+
}) : null,
|
|
2145
|
+
/* @__PURE__ */ jsx("button", {
|
|
2146
|
+
type: "button",
|
|
2147
|
+
"aria-label": `Close ${tab.label}`,
|
|
2148
|
+
title: `Close ${tab.label}`,
|
|
2149
|
+
"data-testid": `tab-${tab.id}-close`,
|
|
2150
|
+
onClick: () => closeTransientTab(sessionId, tab.id),
|
|
2151
|
+
className: action,
|
|
2152
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {
|
|
2153
|
+
"aria-hidden": true,
|
|
2154
|
+
className: "size-3"
|
|
2155
|
+
})
|
|
2156
|
+
})
|
|
2157
|
+
]
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
/** Elegant's reading column: the scroller spans the window so its scrollbar sits at the edge. */
|
|
2161
|
+
const READING_SCROLLER = "px-[max(1rem,calc((100%-896px)/2))]";
|
|
2162
|
+
/**
|
|
2163
|
+
* The focused session: the one interactive window, laid out as Elegant's conversation. Tool calls
|
|
2164
|
+
* fold into a "View activity" row whose list docks on the window's right, and the quiet composer's
|
|
2165
|
+
* gear opens the session's settings beside it. Tabs sit under the title; a tab opened in its own
|
|
2166
|
+
* window leaves this row.
|
|
2167
|
+
*/
|
|
2168
|
+
const FocusedSession = memo(function FocusedSession({ sessionId, tabId, windowedTabs: windowedList, onOpenInWindow }) {
|
|
2169
|
+
const windowedTabs = windowedList === "" ? [] : windowedList.split("\n");
|
|
2170
|
+
const slotProps = usePluginSlotProps(sessionId);
|
|
2171
|
+
const workspaceId = useStore(sessionsStore, (state) => state.byId[sessionId]?.summary.workspaceId);
|
|
2172
|
+
const mcp = useSessionMcp(workspaceId, sessionId);
|
|
2173
|
+
const shownTabId = tabId !== void 0 && windowedTabs.includes(tabId) ? void 0 : tabId;
|
|
2174
|
+
const mcpView = shownTabId === "mcp";
|
|
2175
|
+
const mcpEnabled = mcp.snapshot?.enabled === true || mcpView;
|
|
2176
|
+
const transferLabel = useStore(sessionsStore, (state) => {
|
|
2177
|
+
if (state.transferringToId === null) return null;
|
|
2178
|
+
return state.byId[state.transferringToId]?.summary.name ?? "destination session";
|
|
2179
|
+
});
|
|
2180
|
+
const dormant = useActiveSessionMeta()?.summary.dormant === true;
|
|
2181
|
+
const transientTabs = useTransientTabs(sessionId).filter((tab) => !windowedTabs.includes(tab.id));
|
|
2182
|
+
const pluginTabs = webTabs(sessionId);
|
|
2183
|
+
const storedTransientTab = useStore(transientTabsStore, (state) => findTransientTab(state, sessionId, shownTabId));
|
|
2184
|
+
const transientTab = storedTransientTab === void 0 ? void 0 : pluginActivityGroups(sessionId).map((group) => group.transientTab?.()).find((candidate) => candidate?.id === storedTransientTab.id) ?? storedTransientTab;
|
|
2185
|
+
const tab = (shownTabId === void 0 ? void 0 : pluginTabs.find((entry) => entry.id === shownTabId)) ?? transientTab;
|
|
2186
|
+
const composerContext = tab === transientTab ? transientTab?.composerContext : void 0;
|
|
2187
|
+
const view = mcpView ? "mcp" : tab?.id ?? "conversation";
|
|
2188
|
+
const hasTabs = mcpEnabled || pluginTabs.length > 0 || transientTabs.length > 0;
|
|
2189
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
2190
|
+
const controlsAllowed = !mcpView && (!tab || tab.targetSessionId !== void 0) && !dormant;
|
|
2191
|
+
const composerShown = !mcpView && (!tab || tab.retainComposer === true);
|
|
2192
|
+
const settingsShown = settingsOpen && controlsAllowed && composerShown;
|
|
2193
|
+
const content = mcpView ? /* @__PURE__ */ jsx(SessionMcp, { state: mcp }, sessionId) : tab ? /* @__PURE__ */ jsx(tab.panel, { ...slotProps }) : /* @__PURE__ */ jsx(Timeline, {
|
|
2194
|
+
renderTurn: QuietTurn,
|
|
2195
|
+
showThinking: false,
|
|
2196
|
+
scrollerClassName: READING_SCROLLER
|
|
2197
|
+
});
|
|
2198
|
+
const composer = composerShown ? /* @__PURE__ */ jsx(Composer, {
|
|
2199
|
+
composerContext,
|
|
2200
|
+
quiet: true,
|
|
2201
|
+
toolbar: controlsAllowed ? /* @__PURE__ */ jsx(Button, {
|
|
2202
|
+
variant: "ghost",
|
|
2203
|
+
size: "icon-md",
|
|
2204
|
+
"aria-label": "Session settings",
|
|
2205
|
+
title: "Session settings",
|
|
2206
|
+
"aria-expanded": settingsOpen,
|
|
2207
|
+
"data-testid": "session-settings-open",
|
|
2208
|
+
onClick: () => setSettingsOpen(!settingsOpen),
|
|
2209
|
+
className: settingsOpen ? "text-po-hi" : "text-po-dim",
|
|
2210
|
+
children: /* @__PURE__ */ jsx(GearIcon, {
|
|
2211
|
+
"aria-hidden": true,
|
|
2212
|
+
className: "size-4"
|
|
2213
|
+
})
|
|
2214
|
+
}) : void 0
|
|
2215
|
+
}) : null;
|
|
2216
|
+
const controls = controlsAllowed && !composerShown ? /* @__PURE__ */ jsx(SelectionBar, {}) : null;
|
|
2217
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2218
|
+
hasTabs ? /* @__PURE__ */ jsxs("nav", {
|
|
2219
|
+
"aria-label": "Conversation views",
|
|
2220
|
+
className: "flex shrink-0 items-center gap-1 overflow-x-auto px-3 pb-2",
|
|
2221
|
+
children: [
|
|
2222
|
+
/* @__PURE__ */ jsx(Link, {
|
|
2223
|
+
to: "/session/$sessionId",
|
|
2224
|
+
params: { sessionId },
|
|
2225
|
+
"data-testid": "tab-conversation",
|
|
2226
|
+
"aria-current": view === "conversation" ? "page" : void 0,
|
|
2227
|
+
className: `${TAB} ${view === "conversation" ? TAB_ACTIVE : TAB_IDLE}`,
|
|
2228
|
+
children: "Chat"
|
|
2229
|
+
}),
|
|
2230
|
+
mcpEnabled ? /* @__PURE__ */ jsx(Link, {
|
|
2231
|
+
to: "/session/$sessionId/$tabId",
|
|
2232
|
+
params: {
|
|
2233
|
+
sessionId,
|
|
2234
|
+
tabId: "mcp"
|
|
2235
|
+
},
|
|
2236
|
+
"data-testid": "tab-mcp",
|
|
2237
|
+
"aria-current": mcpView ? "page" : void 0,
|
|
2238
|
+
className: `${TAB} ${mcpView ? TAB_ACTIVE : TAB_IDLE}`,
|
|
2239
|
+
children: "MCP"
|
|
2240
|
+
}) : null,
|
|
2241
|
+
pluginTabs.map((entry) => /* @__PURE__ */ jsx(PluginTab, {
|
|
2242
|
+
tab: entry,
|
|
2243
|
+
sessionId,
|
|
2244
|
+
active: view === entry.id
|
|
2245
|
+
}, entry.id)),
|
|
2246
|
+
transientTabs.map((entry) => /* @__PURE__ */ jsx(TemporaryTab, {
|
|
2247
|
+
tab: entry,
|
|
2248
|
+
sessionId,
|
|
2249
|
+
active: view === entry.id,
|
|
2250
|
+
onOpenInWindow: () => onOpenInWindow(sessionId, entry.id)
|
|
2251
|
+
}, entry.id))
|
|
2252
|
+
]
|
|
2253
|
+
}) : null,
|
|
2254
|
+
transferLabel === null ? null : /* @__PURE__ */ jsxs("output", {
|
|
2255
|
+
"data-testid": "voice-transfer-transition",
|
|
2256
|
+
className: "border-y border-po-cyan/30 bg-po-cyan/10 px-4 py-2 text-center text-base font-medium text-po-cyan",
|
|
2257
|
+
children: [
|
|
2258
|
+
"Transferring voice to ",
|
|
2259
|
+
transferLabel,
|
|
2260
|
+
"..."
|
|
2261
|
+
]
|
|
2262
|
+
}),
|
|
2263
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2264
|
+
className: "flex min-h-0 flex-1 overflow-hidden",
|
|
2265
|
+
children: [
|
|
2266
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2267
|
+
"data-po-region": "content",
|
|
2268
|
+
className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
|
|
2269
|
+
children: [content, /* @__PURE__ */ jsxs("div", {
|
|
2270
|
+
className: tab || mcpView ? "shrink-0" : "mx-auto w-full max-w-[960px] shrink-0 px-2 sm:px-6",
|
|
2271
|
+
children: [composer === null ? null : /* @__PURE__ */ jsx("div", {
|
|
2272
|
+
className: "mb-2 sm:mb-4",
|
|
2273
|
+
children: composer
|
|
2274
|
+
}), controls]
|
|
2275
|
+
})]
|
|
2276
|
+
}),
|
|
2277
|
+
tab || mcpView ? null : /* @__PURE__ */ jsx(ResponseActivitySheet, {}),
|
|
2278
|
+
settingsShown ? /* @__PURE__ */ jsx(DockedSheet, {
|
|
2279
|
+
side: "right",
|
|
2280
|
+
open: true,
|
|
2281
|
+
label: "Session",
|
|
2282
|
+
defaultWidth: 360,
|
|
2283
|
+
minWidth: 360,
|
|
2284
|
+
maxWidth: 360,
|
|
2285
|
+
fixed: true,
|
|
2286
|
+
testId: "session-settings-sheet",
|
|
2287
|
+
region: "settings",
|
|
2288
|
+
children: /* @__PURE__ */ jsx(SessionSettings, { onClose: () => setSettingsOpen(false) })
|
|
2289
|
+
}) : null
|
|
2290
|
+
]
|
|
2291
|
+
})
|
|
2292
|
+
] });
|
|
2293
|
+
});
|
|
2294
|
+
/** Any other session: a live, read-only transcript. Clicking the window focuses the session. */
|
|
2295
|
+
const WatchingSession = memo(function WatchingSession({ sessionId }) {
|
|
2296
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
2297
|
+
className: "mx-auto flex min-h-0 w-full max-w-[960px] flex-1 flex-col overflow-hidden px-2 sm:px-4",
|
|
2298
|
+
children: /* @__PURE__ */ jsx(SessionTranscriptView, {
|
|
2299
|
+
sessionId,
|
|
2300
|
+
watch: watchDashboardTranscript,
|
|
2301
|
+
renderTurn: QuietTurn,
|
|
2302
|
+
showThinking: false
|
|
2303
|
+
})
|
|
2304
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
2305
|
+
className: "shrink-0 px-6 pb-4 text-center text-sm text-po-dim",
|
|
2306
|
+
children: "Click to focus and reply"
|
|
2307
|
+
})] });
|
|
2308
|
+
});
|
|
2309
|
+
/** A temporary tab in its own window: the panel it was opened with, and the composer when it keeps one. */
|
|
2310
|
+
const TabWindowBody = memo(function TabWindowBody({ sessionId, tabId, focused }) {
|
|
2311
|
+
const slotProps = usePluginSlotProps(sessionId);
|
|
2312
|
+
const tab = useStore(transientTabsStore, (state) => findTransientTab(state, sessionId, tabId));
|
|
2313
|
+
const activeId = useStore(sessionsStore, (state) => state.activeId);
|
|
2314
|
+
if (tab === void 0) return null;
|
|
2315
|
+
const Panel = tab.panel;
|
|
2316
|
+
const composer = tab.retainComposer === true && focused && activeId === sessionId;
|
|
2317
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2318
|
+
"data-po-region": "content",
|
|
2319
|
+
className: "flex min-h-0 flex-1 flex-col overflow-hidden",
|
|
2320
|
+
children: [/* @__PURE__ */ jsx(Panel, { ...slotProps }), composer ? /* @__PURE__ */ jsx(Composer, { composerContext: tab.composerContext }) : null]
|
|
2321
|
+
});
|
|
2322
|
+
});
|
|
2323
|
+
//#endregion
|
|
2324
|
+
//#region src/extensions/(frontend)/template/_components/DesktopSettings.tsx
|
|
2325
|
+
/** Settings in a window: the window title says Settings and its close button leaves, so neither is repeated here. */
|
|
2326
|
+
function DesktopSettings() {
|
|
2327
|
+
useWebPluginRegistry();
|
|
2328
|
+
const { section, workspaceId } = useDashboardRoute();
|
|
2329
|
+
const navigate = useNavigate();
|
|
2330
|
+
const [loadError, setLoadError] = useState();
|
|
2331
|
+
const [repositoryReady, setRepositoryReady] = useState(false);
|
|
2332
|
+
const [templateTarget, setTemplateTarget] = useDashboardState("settings/template-target", "global");
|
|
2333
|
+
const current = settingsSection(section);
|
|
2334
|
+
const workspace = current?.workspace ?? (section?.startsWith("repository-") ? "repository" : "general");
|
|
2335
|
+
useEffect(() => {
|
|
2336
|
+
if (current) return;
|
|
2337
|
+
if (workspace === "repository" && !repositoryReady) return;
|
|
2338
|
+
let cancelled = false;
|
|
2339
|
+
refreshWebPluginCompositions().then(() => {
|
|
2340
|
+
if (cancelled || settingsSection(section)) return;
|
|
2341
|
+
navigate({
|
|
2342
|
+
to: "/settings/$section",
|
|
2343
|
+
params: { section: DEFAULT_SETTINGS_SECTION },
|
|
2344
|
+
search: { workspace: workspaceId },
|
|
2345
|
+
replace: true
|
|
2346
|
+
});
|
|
2347
|
+
}).catch((error) => {
|
|
2348
|
+
if (!cancelled) setLoadError(error instanceof Error ? error.message : String(error));
|
|
2349
|
+
});
|
|
2350
|
+
return () => {
|
|
2351
|
+
cancelled = true;
|
|
2352
|
+
};
|
|
2353
|
+
}, [
|
|
2354
|
+
current,
|
|
2355
|
+
section,
|
|
2356
|
+
navigate,
|
|
2357
|
+
workspace,
|
|
2358
|
+
workspaceId,
|
|
2359
|
+
repositoryReady
|
|
2360
|
+
]);
|
|
2361
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2362
|
+
"data-testid": "settings",
|
|
2363
|
+
"data-po-region": "content",
|
|
2364
|
+
className: "flex h-full min-h-0 min-w-0 flex-col overflow-hidden",
|
|
2365
|
+
children: [/* @__PURE__ */ jsx("header", {
|
|
2366
|
+
className: "flex shrink-0 justify-center border-b border-po-border-soft px-3 pb-2",
|
|
2367
|
+
children: /* @__PURE__ */ jsxs("nav", {
|
|
2368
|
+
className: "flex w-full items-center gap-1 rounded-lg bg-po-rail p-1 sm:w-auto",
|
|
2369
|
+
"aria-label": "settings workspace",
|
|
2370
|
+
children: [/* @__PURE__ */ jsx(NavTab, {
|
|
2371
|
+
asChild: true,
|
|
2372
|
+
active: workspace === "general",
|
|
2373
|
+
className: "min-h-8 flex-1 justify-center rounded-md px-4 focus-visible:ring-2 focus-visible:ring-po-green sm:flex-none",
|
|
2374
|
+
"aria-current": workspace === "general" ? "true" : void 0,
|
|
2375
|
+
children: /* @__PURE__ */ jsx(Link, {
|
|
2376
|
+
to: "/settings/$section",
|
|
2377
|
+
params: { section: DEFAULT_SETTINGS_SECTION },
|
|
2378
|
+
search: { workspace: workspaceId },
|
|
2379
|
+
"data-testid": "settings-workspace-general",
|
|
2380
|
+
children: "General"
|
|
2381
|
+
})
|
|
2382
|
+
}), /* @__PURE__ */ jsx(NavTab, {
|
|
2383
|
+
asChild: true,
|
|
2384
|
+
active: workspace === "repository",
|
|
2385
|
+
className: "min-h-8 flex-1 justify-center rounded-md px-4 focus-visible:ring-2 focus-visible:ring-po-green sm:flex-none",
|
|
2386
|
+
"aria-current": workspace === "repository" ? "true" : void 0,
|
|
2387
|
+
children: /* @__PURE__ */ jsx(Link, {
|
|
2388
|
+
to: "/settings/$section",
|
|
2389
|
+
params: { section: DEFAULT_REPOSITORY_SETTINGS_SECTION },
|
|
2390
|
+
search: { workspace: workspaceId },
|
|
2391
|
+
"data-testid": "settings-workspace-repository",
|
|
2392
|
+
children: "Workspaces"
|
|
2393
|
+
})
|
|
2394
|
+
})]
|
|
2395
|
+
})
|
|
2396
|
+
}), /* @__PURE__ */ jsx("main", {
|
|
2397
|
+
className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
|
|
2398
|
+
children: workspace === "repository" ? /* @__PURE__ */ jsx(RepositoryWorkspace, {
|
|
2399
|
+
current: current ?? {
|
|
2400
|
+
id: section ?? "",
|
|
2401
|
+
label: "",
|
|
2402
|
+
detail: "",
|
|
2403
|
+
workspace: "repository"
|
|
2404
|
+
},
|
|
2405
|
+
initialRepositoryId: workspaceId,
|
|
2406
|
+
onRepositoryChange: (nextWorkspaceId) => {
|
|
2407
|
+
navigate({
|
|
2408
|
+
to: "/settings/$section",
|
|
2409
|
+
params: { section: current?.id ?? section ?? DEFAULT_REPOSITORY_SETTINGS_SECTION },
|
|
2410
|
+
search: { workspace: nextWorkspaceId },
|
|
2411
|
+
replace: true
|
|
2412
|
+
});
|
|
2413
|
+
},
|
|
2414
|
+
onReady: setRepositoryReady
|
|
2415
|
+
}, workspaceId ?? "remembered-workspace") : /* @__PURE__ */ jsxs("div", {
|
|
2416
|
+
className: "flex min-h-0 flex-1 flex-col lg:flex-row",
|
|
2417
|
+
children: [/* @__PURE__ */ jsx(SettingsMenu, {
|
|
2418
|
+
active: current?.id,
|
|
2419
|
+
workspace: "general",
|
|
2420
|
+
repositoryId: workspaceId
|
|
2421
|
+
}), /* @__PURE__ */ jsx("section", {
|
|
2422
|
+
"data-testid": "settings-content",
|
|
2423
|
+
className: "min-w-0 flex-1 overflow-y-auto px-4 py-6 sm:px-6 sm:py-8 lg:px-8 lg:py-10",
|
|
2424
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2425
|
+
className: "mx-auto flex w-full max-w-5xl flex-col gap-8",
|
|
2426
|
+
children: [
|
|
2427
|
+
!current && loadError ? /* @__PURE__ */ jsx("p", {
|
|
2428
|
+
role: "alert",
|
|
2429
|
+
children: loadError
|
|
2430
|
+
}) : null,
|
|
2431
|
+
current?.id === "providers" ? /* @__PURE__ */ jsx(ProviderSettings, {}) : null,
|
|
2432
|
+
current?.id === "devices" ? /* @__PURE__ */ jsx(ClientDevices, {}) : null,
|
|
2433
|
+
current?.id === "appearance" ? /* @__PURE__ */ jsx(AppearanceSettings, {
|
|
2434
|
+
templateTarget,
|
|
2435
|
+
onTemplateTargetChange: setTemplateTarget
|
|
2436
|
+
}) : null,
|
|
2437
|
+
current?.id === "notifications" ? /* @__PURE__ */ jsx(NotificationSettings, {}) : null,
|
|
2438
|
+
current?.id === "images" ? /* @__PURE__ */ jsx(ImageSettings, {}) : null,
|
|
2439
|
+
current?.id === "remote" ? /* @__PURE__ */ jsx(RemoteControlSettings, {}) : null,
|
|
2440
|
+
current?.id === "presets" ? /* @__PURE__ */ jsx(PresetSettings, {}) : null,
|
|
2441
|
+
current?.id === "account" ? /* @__PURE__ */ jsx(AccountSettings, {}) : null,
|
|
2442
|
+
current?.contribution === void 0 ? null : /* @__PURE__ */ jsx(ContributedSettings, {
|
|
2443
|
+
section: current.contribution,
|
|
2444
|
+
scope: "global"
|
|
2445
|
+
}),
|
|
2446
|
+
current?.panel === void 0 ? null : /* @__PURE__ */ jsx(SettingsPanelHost, { panel: current.panel })
|
|
2447
|
+
]
|
|
2448
|
+
})
|
|
2449
|
+
})]
|
|
2450
|
+
})
|
|
2451
|
+
})]
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
//#endregion
|
|
2455
|
+
//#region src/extensions/(frontend)/template/_components/DesktopWidgets.tsx
|
|
2456
|
+
/** Plugin group names are lowercase identifiers; the heading reads in sentence case. */
|
|
2457
|
+
function sentenceCase$1(name) {
|
|
2458
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* One activity group. Folded it shows its name and one summary line, so every group fits the
|
|
2462
|
+
* column; unfolded it shows what the group's package renders.
|
|
2463
|
+
*/
|
|
2464
|
+
function Widget({ group, slotProps, editing, expanded, onRemove, onToggle }) {
|
|
2465
|
+
const detailed = slotFills(activityGroupSlot(group.name)).length > 0;
|
|
2466
|
+
const open = detailed && expanded;
|
|
2467
|
+
const Glyph = group.icon ?? ActivityIcon;
|
|
2468
|
+
const label = sentenceCase$1(group.name);
|
|
2469
|
+
const folded = group.summary || (group.active ? "Working" : detailed ? null : "Idle");
|
|
2470
|
+
const heading = /* @__PURE__ */ jsxs("span", {
|
|
2471
|
+
className: "flex min-w-0 items-center gap-1.5 text-sm font-medium text-po-dim",
|
|
2472
|
+
children: [/* @__PURE__ */ jsx(Glyph, {
|
|
2473
|
+
"aria-hidden": true,
|
|
2474
|
+
className: `size-3.5 shrink-0 ${group.active ? "text-po-yellow" : ""}`
|
|
2475
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2476
|
+
className: "truncate",
|
|
2477
|
+
children: label
|
|
2478
|
+
})]
|
|
2479
|
+
});
|
|
2480
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
2481
|
+
"aria-label": label,
|
|
2482
|
+
"data-testid": `desktop-widget-${group.name}`,
|
|
2483
|
+
"data-active": group.active,
|
|
2484
|
+
className: `relative flex shrink-0 flex-col gap-2 rounded-2xl px-4 py-3.5 shadow-sm ${GLASS}`,
|
|
2485
|
+
children: [
|
|
2486
|
+
editing ? /* @__PURE__ */ jsx("button", {
|
|
2487
|
+
type: "button",
|
|
2488
|
+
"aria-label": `Remove ${label}`,
|
|
2489
|
+
onClick: onRemove,
|
|
2490
|
+
className: "absolute -top-1.5 -left-1.5 grid size-5 place-items-center rounded-full bg-po-panel text-po-dim shadow-md ring-1 ring-po-border hover:text-po-hi focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
2491
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2492
|
+
"aria-hidden": true,
|
|
2493
|
+
className: "h-px w-2.5 bg-current"
|
|
2494
|
+
})
|
|
2495
|
+
}) : null,
|
|
2496
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2497
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
2498
|
+
children: [group.transientTab === void 0 ? heading : /* @__PURE__ */ jsxs("button", {
|
|
2499
|
+
type: "button",
|
|
2500
|
+
title: `Open ${group.name}`,
|
|
2501
|
+
onClick: () => {
|
|
2502
|
+
const tab = group.transientTab?.();
|
|
2503
|
+
if (tab !== void 0) slotProps.openTransientTab(tab);
|
|
2504
|
+
},
|
|
2505
|
+
className: "group/heading flex min-w-0 items-center gap-1 text-left focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
2506
|
+
children: [heading, /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
2507
|
+
"aria-hidden": true,
|
|
2508
|
+
className: "size-3.5 shrink-0 text-po-faint group-hover/heading:text-po-dim"
|
|
2509
|
+
})]
|
|
2510
|
+
}), detailed ? /* @__PURE__ */ jsx("button", {
|
|
2511
|
+
type: "button",
|
|
2512
|
+
"aria-expanded": open,
|
|
2513
|
+
"aria-label": open ? `Fold ${label}` : `Unfold ${label}`,
|
|
2514
|
+
title: open ? "Show less" : "Show more",
|
|
2515
|
+
"data-testid": `desktop-widget-toggle-${group.name}`,
|
|
2516
|
+
onClick: onToggle,
|
|
2517
|
+
className: "grid size-6 shrink-0 place-items-center rounded-full text-po-dim hover:bg-po-rail hover:text-po-hi focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
2518
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
2519
|
+
"aria-hidden": true,
|
|
2520
|
+
className: `size-3.5 transition-transform ${open ? "rotate-180" : ""}`
|
|
2521
|
+
})
|
|
2522
|
+
}) : null]
|
|
2523
|
+
}),
|
|
2524
|
+
open ? slotProps.renderSlot(activityGroupSlot(group.name)) : folded === null ? null : /* @__PURE__ */ jsx("p", {
|
|
2525
|
+
"data-testid": `desktop-widget-summary-${group.name}`,
|
|
2526
|
+
className: `truncate text-base first-letter:uppercase ${group.active ? "text-po-yellow" : "text-po-hi"}`,
|
|
2527
|
+
children: folded
|
|
2528
|
+
})
|
|
2529
|
+
]
|
|
2530
|
+
});
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Activity as widgets the person chooses: one card per activity group the focused session's
|
|
2534
|
+
* plugins declare. Customise removes with the minus and adds from the tray. The other rail tabs
|
|
2535
|
+
* (Context and the plugins' faces) are picked in the bar and take this column's place.
|
|
2536
|
+
*/
|
|
2537
|
+
function DesktopWidgets({ layout, activeId, editing, overlay, onEditingChange, onRemove, onAdd, onToggleExpanded }) {
|
|
2538
|
+
const statuses = useActiveSession((state) => state.statuses);
|
|
2539
|
+
const widgets = useActiveSession((state) => state.widgets);
|
|
2540
|
+
const groups = useActivityGroups(statuses, widgets, activeId);
|
|
2541
|
+
const slotProps = usePluginSlotProps(activeId);
|
|
2542
|
+
const available = groups.map((group) => group.name);
|
|
2543
|
+
const chosen = chosenWidgets(layout, available);
|
|
2544
|
+
const shown = chosen.flatMap((name) => groups.filter((group) => group.name === name));
|
|
2545
|
+
const hidden = groups.filter((group) => !chosen.includes(group.name));
|
|
2546
|
+
return /* @__PURE__ */ jsxs("aside", {
|
|
2547
|
+
"data-po-region": "activity",
|
|
2548
|
+
"data-testid": "desktop-widgets",
|
|
2549
|
+
"aria-label": "Activity",
|
|
2550
|
+
className: `flex min-h-0 w-72 shrink-0 flex-col gap-3 overflow-y-auto overscroll-contain py-3 pr-3 pl-2 [scrollbar-width:thin] ${overlay ? "absolute inset-y-0 right-0 z-[60] pl-3" : ""}`,
|
|
2551
|
+
children: [
|
|
2552
|
+
shown.map((group) => /* @__PURE__ */ jsx(Widget, {
|
|
2553
|
+
group,
|
|
2554
|
+
slotProps,
|
|
2555
|
+
editing,
|
|
2556
|
+
expanded: layout.expanded.includes(group.name),
|
|
2557
|
+
onRemove: () => onRemove(group.name, available),
|
|
2558
|
+
onToggle: () => onToggleExpanded(group.name)
|
|
2559
|
+
}, group.name)),
|
|
2560
|
+
shown.length === 0 && !editing ? /* @__PURE__ */ jsx("p", {
|
|
2561
|
+
className: `rounded-2xl px-4 py-3.5 text-sm text-po-dim ${GLASS}`,
|
|
2562
|
+
children: groups.length === 0 ? "Nothing supervised yet." : "No widgets chosen."
|
|
2563
|
+
}) : null,
|
|
2564
|
+
editing ? /* @__PURE__ */ jsxs("div", {
|
|
2565
|
+
className: `flex flex-col gap-0.5 rounded-2xl p-2 ${GLASS}`,
|
|
2566
|
+
children: [
|
|
2567
|
+
/* @__PURE__ */ jsx("span", {
|
|
2568
|
+
className: "px-2 pt-1 pb-1 text-sm font-medium text-po-dim",
|
|
2569
|
+
children: "Add a widget"
|
|
2570
|
+
}),
|
|
2571
|
+
hidden.map((group) => {
|
|
2572
|
+
const Glyph = group.icon ?? ActivityIcon;
|
|
2573
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
2574
|
+
type: "button",
|
|
2575
|
+
onClick: () => onAdd(group.name, available),
|
|
2576
|
+
className: "flex items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-base font-medium text-po-text hover:bg-po-rail focus-visible:ring-2 focus-visible:ring-po-green focus-visible:outline-none",
|
|
2577
|
+
children: [
|
|
2578
|
+
/* @__PURE__ */ jsx(Glyph, {
|
|
2579
|
+
"aria-hidden": true,
|
|
2580
|
+
className: "size-4 text-po-dim"
|
|
2581
|
+
}),
|
|
2582
|
+
/* @__PURE__ */ jsx("span", {
|
|
2583
|
+
className: "flex-1",
|
|
2584
|
+
children: sentenceCase$1(group.name)
|
|
2585
|
+
}),
|
|
2586
|
+
/* @__PURE__ */ jsx(PlusIcon, {
|
|
2587
|
+
"aria-hidden": true,
|
|
2588
|
+
className: "size-3.5 text-po-dim"
|
|
2589
|
+
})
|
|
2590
|
+
]
|
|
2591
|
+
}, group.name);
|
|
2592
|
+
}),
|
|
2593
|
+
hidden.length === 0 ? /* @__PURE__ */ jsx("span", {
|
|
2594
|
+
className: "px-2 pb-1 text-sm text-po-dim",
|
|
2595
|
+
children: "Every widget is showing."
|
|
2596
|
+
}) : null
|
|
2597
|
+
]
|
|
2598
|
+
}) : null,
|
|
2599
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
2600
|
+
variant: editing ? "primary" : "ghost",
|
|
2601
|
+
size: "sm",
|
|
2602
|
+
onClick: () => onEditingChange(!editing),
|
|
2603
|
+
className: `shrink-0 gap-1.5 self-center rounded-full ${editing ? "px-5" : "text-po-dim"}`,
|
|
2604
|
+
children: [editing ? null : /* @__PURE__ */ jsx(SlidersIcon, { className: "size-3.5" }), editing ? "Done" : "Customise"]
|
|
2605
|
+
})
|
|
2606
|
+
]
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
//#endregion
|
|
2610
|
+
//#region src/extensions/(frontend)/template/_components/DesktopDashboard.tsx
|
|
2611
|
+
const renderers = {
|
|
2612
|
+
thread: (id, threadId, options) => /* @__PURE__ */ jsx(ThreadView, {
|
|
2613
|
+
sessionId: id,
|
|
2614
|
+
threadId,
|
|
2615
|
+
options
|
|
2616
|
+
}),
|
|
2617
|
+
activity: (id, open) => /* @__PURE__ */ jsx(SessionActivity, {
|
|
2618
|
+
sessionId: id,
|
|
2619
|
+
onOpenConversation: open
|
|
2620
|
+
}),
|
|
2621
|
+
transcript: (id, options) => /* @__PURE__ */ jsx(SessionTranscriptView, {
|
|
2622
|
+
sessionId: id,
|
|
2623
|
+
options,
|
|
2624
|
+
watch: watchDashboardTranscript
|
|
2625
|
+
})
|
|
2626
|
+
};
|
|
2627
|
+
/** Below this width every window fills the screen and Activity floats over them. */
|
|
2628
|
+
const NARROW = 768;
|
|
2629
|
+
/** Storage is optional: a browser that refuses it starts from a clean desktop. */
|
|
2630
|
+
function readSavedLayout() {
|
|
2631
|
+
try {
|
|
2632
|
+
return parseLayout(window.localStorage.getItem(LAYOUT_STORAGE_KEY));
|
|
2633
|
+
} catch {
|
|
2634
|
+
return EMPTY_LAYOUT;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
/** Watches an element's size; zero until it mounts. */
|
|
2638
|
+
function useSize() {
|
|
2639
|
+
const [size, setSize] = useState({
|
|
2640
|
+
width: 0,
|
|
2641
|
+
height: 0
|
|
2642
|
+
});
|
|
2643
|
+
return [useCallback((element) => {
|
|
2644
|
+
if (element === null) return;
|
|
2645
|
+
const read = () => setSize({
|
|
2646
|
+
width: element.clientWidth,
|
|
2647
|
+
height: element.clientHeight
|
|
2648
|
+
});
|
|
2649
|
+
read();
|
|
2650
|
+
const observer = new ResizeObserver(read);
|
|
2651
|
+
observer.observe(element);
|
|
2652
|
+
return () => observer.disconnect();
|
|
2653
|
+
}, []), size];
|
|
2654
|
+
}
|
|
2655
|
+
/** The default backdrop, painted from theme tones only. */
|
|
2656
|
+
function Wallpaper() {
|
|
2657
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2658
|
+
"aria-hidden": true,
|
|
2659
|
+
className: "pointer-events-none absolute inset-0 overflow-hidden bg-po-bg",
|
|
2660
|
+
children: [/* @__PURE__ */ jsx("div", { className: "absolute -top-1/3 -left-1/4 size-[70vmax] rounded-full bg-po-green opacity-25 blur-3xl" }), /* @__PURE__ */ jsx("div", { className: "absolute -right-1/4 -bottom-1/2 size-[70vmax] rounded-full bg-po-magenta opacity-20 blur-3xl" })]
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
/** The window the route asks for: its session, Settings, or a workspace or plugin page. */
|
|
2664
|
+
function routeWindowFor(kind, sessionId, workspaceId) {
|
|
2665
|
+
if (kind === "session" && sessionId !== void 0) return {
|
|
2666
|
+
id: sessionWindowId(sessionId),
|
|
2667
|
+
kind: "session",
|
|
2668
|
+
sessionId
|
|
2669
|
+
};
|
|
2670
|
+
if (kind === "settings") return {
|
|
2671
|
+
id: "settings",
|
|
2672
|
+
kind: "settings"
|
|
2673
|
+
};
|
|
2674
|
+
if (kind === "page" || kind === "workspace" && workspaceId !== void 0) return {
|
|
2675
|
+
id: "page",
|
|
2676
|
+
kind: "page"
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
function sentenceCase(name) {
|
|
2680
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
2681
|
+
}
|
|
2682
|
+
/**
|
|
2683
|
+
* The Desktop template: Po as a calm desktop. Sessions open in floating windows at default slots,
|
|
2684
|
+
* the Po button opens sessions and options, and Activity is a column of chosen widgets. Only the
|
|
2685
|
+
* focused session (the route's) is interactive; every other session window reads along.
|
|
2686
|
+
*/
|
|
2687
|
+
function DesktopDashboard() {
|
|
2688
|
+
useWebPluginRegistry();
|
|
2689
|
+
const route = useDashboardRoute();
|
|
2690
|
+
const navigate = useNavigate();
|
|
2691
|
+
const activeId = useStore(sessionsStore, (state) => state.activeId);
|
|
2692
|
+
const hydrated = useStore(sessionsStore, (state) => state.hydrated);
|
|
2693
|
+
const sessionIdList = useStore(sessionsStore, (state) => Object.keys(state.byId).join("\n"));
|
|
2694
|
+
const transient = useStore(transientTabsStore);
|
|
2695
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
2696
|
+
const [editing, setEditing] = useState(false);
|
|
2697
|
+
const [narrowActivity, setNarrowActivity] = useState(false);
|
|
2698
|
+
const [snap, setSnap] = useState(null);
|
|
2699
|
+
const [stored, setStored] = useDashboardState("desktop/layout", readSavedLayout);
|
|
2700
|
+
const rail = useSessionRail({ onDismiss: () => setMenuOpen(false) });
|
|
2701
|
+
const [rootRef, rootSize] = useSize();
|
|
2702
|
+
const [surfaceRef, surface] = useSize();
|
|
2703
|
+
const narrow = rootSize.width > 0 && rootSize.width < NARROW;
|
|
2704
|
+
const routeWindow = routeWindowFor(route.kind, route.sessionId, route.workspaceId);
|
|
2705
|
+
const sessionIds = useMemo(() => new Set(sessionIdList.split("\n").filter(Boolean)), [sessionIdList]);
|
|
2706
|
+
let layout = hydrated ? pruneLayout(stored, sessionIds, (sessionId, tabId) => findTransientTab(transient, sessionId, tabId) !== void 0) : stored;
|
|
2707
|
+
if (routeWindow?.kind !== "settings") layout = closeWindow(layout, "settings");
|
|
2708
|
+
if (routeWindow?.kind !== "page") layout = closeWindow(layout, "page");
|
|
2709
|
+
if (routeWindow !== void 0 && findWindow(layout, routeWindow.id) === void 0) layout = openWindow(layout, routeWindow);
|
|
2710
|
+
useEffect(() => {
|
|
2711
|
+
if (layout !== stored) setStored(layout);
|
|
2712
|
+
}, [
|
|
2713
|
+
layout,
|
|
2714
|
+
stored,
|
|
2715
|
+
setStored
|
|
2716
|
+
]);
|
|
2717
|
+
useEffect(() => {
|
|
2718
|
+
try {
|
|
2719
|
+
window.localStorage.setItem(LAYOUT_STORAGE_KEY, serializeLayout(stored));
|
|
2720
|
+
} catch {
|
|
2721
|
+
return;
|
|
2722
|
+
}
|
|
2723
|
+
}, [stored]);
|
|
2724
|
+
const { kind, sessionId: routeSessionId, tabId: routeTabId, pageId, workspaceId: routeWorkspaceId } = route;
|
|
2725
|
+
useEffect(() => {
|
|
2726
|
+
const target = routeWindowFor(kind, routeSessionId, routeWorkspaceId);
|
|
2727
|
+
if (target === void 0) return;
|
|
2728
|
+
setStored((previous) => {
|
|
2729
|
+
const next = openWindow(previous, target);
|
|
2730
|
+
const tabWindow = routeSessionId !== void 0 && routeTabId !== void 0 ? tabWindowId(routeSessionId, routeTabId) : void 0;
|
|
2731
|
+
return tabWindow !== void 0 && findWindow(next, tabWindow) !== void 0 ? focusWindow(next, tabWindow) : next;
|
|
2732
|
+
});
|
|
2733
|
+
}, [
|
|
2734
|
+
kind,
|
|
2735
|
+
routeSessionId,
|
|
2736
|
+
routeTabId,
|
|
2737
|
+
pageId,
|
|
2738
|
+
routeWorkspaceId,
|
|
2739
|
+
setStored
|
|
2740
|
+
]);
|
|
2741
|
+
const update = (change) => setStored(change);
|
|
2742
|
+
const openTabWindow = useCallback((sessionId, tabId) => {
|
|
2743
|
+
setStored((current) => openWindow(current, {
|
|
2744
|
+
id: tabWindowId(sessionId, tabId),
|
|
2745
|
+
kind: "tab",
|
|
2746
|
+
sessionId,
|
|
2747
|
+
tabId
|
|
2748
|
+
}));
|
|
2749
|
+
navigate({
|
|
2750
|
+
to: "/session/$sessionId",
|
|
2751
|
+
params: { sessionId }
|
|
2752
|
+
});
|
|
2753
|
+
}, [navigate, setStored]);
|
|
2754
|
+
const focus = (win) => {
|
|
2755
|
+
update((current) => focusWindow(current, win.id));
|
|
2756
|
+
if ((win.kind === "session" || win.kind === "tab") && win.sessionId !== void 0 && win.sessionId !== activeId) rail.actions.openSession(win.sessionId);
|
|
2757
|
+
};
|
|
2758
|
+
const leaveRoute = () => {
|
|
2759
|
+
if (activeId !== null && route.kind !== "session") navigate({
|
|
2760
|
+
to: "/session/$sessionId",
|
|
2761
|
+
params: { sessionId: activeId }
|
|
2762
|
+
});
|
|
2763
|
+
else rail.actions.openHome();
|
|
2764
|
+
};
|
|
2765
|
+
const close = (win) => {
|
|
2766
|
+
if (win.kind === "settings" || win.kind === "page") {
|
|
2767
|
+
leaveRoute();
|
|
2768
|
+
return;
|
|
2769
|
+
}
|
|
2770
|
+
if (win.kind === "tab" && win.sessionId !== void 0 && win.tabId !== void 0) closeTransientTab(win.sessionId, win.tabId);
|
|
2771
|
+
if (win.kind === "session" && win.sessionId === route.sessionId) rail.actions.openHome();
|
|
2772
|
+
update((current) => closeWindow(current, win.id));
|
|
2773
|
+
};
|
|
2774
|
+
const stacks = stacksOf(layout);
|
|
2775
|
+
const front = frontWindow(layout);
|
|
2776
|
+
const frontRoot = front === void 0 ? void 0 : stackRoot(front);
|
|
2777
|
+
const titleOf = (win) => {
|
|
2778
|
+
if (win.kind === "settings") return { title: "Settings" };
|
|
2779
|
+
if (win.kind === "page") {
|
|
2780
|
+
const workspace = rail.workspaces.find((entry) => entry.id === route.workspaceId);
|
|
2781
|
+
return { title: route.pageId !== void 0 ? sentenceCase(route.pageId) : workspace?.name ?? "Workspace" };
|
|
2782
|
+
}
|
|
2783
|
+
const workspace = rail.workspaces.find((entry) => entry.sessions.some((session) => session.id === win.sessionId));
|
|
2784
|
+
const railSession = workspace?.sessions.find((session) => session.id === win.sessionId);
|
|
2785
|
+
if (win.kind === "tab") return {
|
|
2786
|
+
title: findTransientTab(transient, win.sessionId, win.tabId)?.label ?? "Tab",
|
|
2787
|
+
subtitle: railSession?.name
|
|
2788
|
+
};
|
|
2789
|
+
const where = [workspace?.kind === "session" ? void 0 : workspace?.name, railSession?.git?.branch].filter(Boolean).join(" · ");
|
|
2790
|
+
return {
|
|
2791
|
+
title: railSession?.name || "Untitled",
|
|
2792
|
+
subtitle: win.sessionId === activeId ? where || void 0 : "read only"
|
|
2793
|
+
};
|
|
2794
|
+
};
|
|
2795
|
+
const bodyOf = (win, isFront) => {
|
|
2796
|
+
if (win.kind === "settings") return /* @__PURE__ */ jsx(DesktopSettings, {});
|
|
2797
|
+
if (win.kind === "page") return route.pageId !== void 0 ? /* @__PURE__ */ jsx(PluginPage, {
|
|
2798
|
+
pageId: route.pageId,
|
|
2799
|
+
sessionId: null,
|
|
2800
|
+
workspaceId: route.workspaceId,
|
|
2801
|
+
onShowSessions: () => setMenuOpen(true)
|
|
2802
|
+
}) : route.workspaceId !== void 0 ? /* @__PURE__ */ jsx(WorkspacePage, {
|
|
2803
|
+
workspaceId: route.workspaceId,
|
|
2804
|
+
onShowSessions: () => setMenuOpen(true)
|
|
2805
|
+
}) : null;
|
|
2806
|
+
if (win.sessionId === void 0) return null;
|
|
2807
|
+
if (win.kind === "tab") return win.tabId === void 0 ? null : /* @__PURE__ */ jsx(TabWindowBody, {
|
|
2808
|
+
sessionId: win.sessionId,
|
|
2809
|
+
tabId: win.tabId,
|
|
2810
|
+
focused: isFront
|
|
2811
|
+
});
|
|
2812
|
+
if (win.sessionId !== activeId) return /* @__PURE__ */ jsx(WatchingSession, { sessionId: win.sessionId });
|
|
2813
|
+
const sessionId = win.sessionId;
|
|
2814
|
+
const windowedTabs = layout.windows.filter((entry) => entry.kind === "tab" && entry.sessionId === sessionId).map((entry) => entry.tabId).join("\n");
|
|
2815
|
+
return /* @__PURE__ */ jsx(FocusedSession, {
|
|
2816
|
+
sessionId,
|
|
2817
|
+
tabId: route.sessionId === sessionId ? route.tabId : void 0,
|
|
2818
|
+
windowedTabs,
|
|
2819
|
+
onOpenInWindow: openTabWindow
|
|
2820
|
+
});
|
|
2821
|
+
};
|
|
2822
|
+
const barStacks = stacks.map((stack) => {
|
|
2823
|
+
const top = stack.members[stack.members.length - 1];
|
|
2824
|
+
const base = {
|
|
2825
|
+
root: stack.root,
|
|
2826
|
+
kind: top.kind,
|
|
2827
|
+
size: stack.members.length,
|
|
2828
|
+
focused: stack.root === frontRoot
|
|
2829
|
+
};
|
|
2830
|
+
const minimized = top.minimized === true;
|
|
2831
|
+
const swap = stack.members.length > 1 ? `${stack.members.length} windows stacked, click again to swap` : void 0;
|
|
2832
|
+
const workspace = rail.workspaces.find((entry) => entry.sessions.some((session) => session.id === top.sessionId));
|
|
2833
|
+
const railSession = workspace?.sessions.find((session) => session.id === top.sessionId);
|
|
2834
|
+
if (railSession === void 0) return {
|
|
2835
|
+
...base,
|
|
2836
|
+
minimized,
|
|
2837
|
+
label: titleOf(top).title,
|
|
2838
|
+
details: [swap].filter((line) => line !== void 0)
|
|
2839
|
+
};
|
|
2840
|
+
const where = [workspace?.kind === "session" ? void 0 : workspace?.name, railSession.git ? `${railSession.git.branch}${railSession.git.dirty ? ", changed" : ""}` : void 0].filter(Boolean).join(" · ");
|
|
2841
|
+
const waiting = railSession.waitingCount ?? 0;
|
|
2842
|
+
const details = [
|
|
2843
|
+
top.kind === "tab" ? `Showing ${titleOf(top).title}` : void 0,
|
|
2844
|
+
where || void 0,
|
|
2845
|
+
waiting > 0 ? `${waiting} waiting for you` : void 0,
|
|
2846
|
+
railSession.id === activeId ? void 0 : "Read only, click to focus and reply",
|
|
2847
|
+
minimized ? "Minimized" : void 0,
|
|
2848
|
+
swap
|
|
2849
|
+
];
|
|
2850
|
+
return {
|
|
2851
|
+
...base,
|
|
2852
|
+
minimized,
|
|
2853
|
+
label: railSession.name || "Untitled",
|
|
2854
|
+
profile: railSession.profile,
|
|
2855
|
+
running: sessionRunning(railSession),
|
|
2856
|
+
waiting,
|
|
2857
|
+
status: railSession.status,
|
|
2858
|
+
clock: railSession.clock,
|
|
2859
|
+
details: details.filter((line) => line !== void 0)
|
|
2860
|
+
};
|
|
2861
|
+
});
|
|
2862
|
+
const onStack = (root) => {
|
|
2863
|
+
const stack = stacks.find((entry) => entry.root === root);
|
|
2864
|
+
if (stack === void 0) return;
|
|
2865
|
+
const top = stack.members[stack.members.length - 1];
|
|
2866
|
+
if (root !== frontRoot || top.minimized === true) {
|
|
2867
|
+
focus(top);
|
|
2868
|
+
return;
|
|
2869
|
+
}
|
|
2870
|
+
if (stack.members.length > 1) {
|
|
2871
|
+
const next = stack.members[stack.members.length - 2];
|
|
2872
|
+
update((current) => swapStack(current, root));
|
|
2873
|
+
if (next.sessionId !== void 0 && next.sessionId !== activeId) rail.actions.openSession(next.sessionId);
|
|
2874
|
+
} else update((current) => minimizeWindow(current, root));
|
|
2875
|
+
};
|
|
2876
|
+
const waiting = rail.workspaces.flatMap((workspace) => workspace.sessions).reduce((total, session) => total + (session.waitingCount ?? (session.awaitingInput ? 1 : 0)), 0);
|
|
2877
|
+
const activityShown = narrow ? narrowActivity : !layout.activityHidden;
|
|
2878
|
+
const slotProps = usePluginSlotProps(activeId);
|
|
2879
|
+
const declaredFaces = useDockFaces(activeId).filter((entry) => entry.requiredMinorMode === void 0 || slotProps.activeMinorModes?.includes(entry.requiredMinorMode));
|
|
2880
|
+
const badges = useDockFaceBadges(declaredFaces, activeId);
|
|
2881
|
+
const railFaces = [
|
|
2882
|
+
{
|
|
2883
|
+
id: "activity",
|
|
2884
|
+
label: "Activity",
|
|
2885
|
+
icon: ActivityIcon,
|
|
2886
|
+
badge: 0
|
|
2887
|
+
},
|
|
2888
|
+
...declaredFaces.map((entry) => ({
|
|
2889
|
+
id: entry.id,
|
|
2890
|
+
label: entry.label,
|
|
2891
|
+
icon: entry.icon ?? PuzzleIcon,
|
|
2892
|
+
badge: badges[entry.id] ?? 0
|
|
2893
|
+
})),
|
|
2894
|
+
{
|
|
2895
|
+
id: "context",
|
|
2896
|
+
label: "Context",
|
|
2897
|
+
icon: PuzzleIcon,
|
|
2898
|
+
badge: 0
|
|
2899
|
+
}
|
|
2900
|
+
];
|
|
2901
|
+
const savedFace = useStore(uiStore, (state) => dockTabFor(state, activeId));
|
|
2902
|
+
const face = railFaces.some((entry) => entry.id === savedFace) ? savedFace : "activity";
|
|
2903
|
+
const shownRailFace = railFaces.find((entry) => entry.id === face);
|
|
2904
|
+
const contributedFace = declaredFaces.find((entry) => entry.id === face);
|
|
2905
|
+
const visible = layout.windows.filter((win) => win.minimized !== true);
|
|
2906
|
+
return /* @__PURE__ */ jsxs(DashboardRendererProvider, {
|
|
2907
|
+
value: renderers,
|
|
2908
|
+
children: [
|
|
2909
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2910
|
+
ref: rootRef,
|
|
2911
|
+
"data-testid": "desktop",
|
|
2912
|
+
className: "relative isolate flex h-full min-w-0 flex-col overflow-hidden font-sans text-po-text",
|
|
2913
|
+
children: [
|
|
2914
|
+
/* @__PURE__ */ jsx(Wallpaper, {}),
|
|
2915
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2916
|
+
className: "relative flex min-h-0 flex-1",
|
|
2917
|
+
children: [/* @__PURE__ */ jsx("main", {
|
|
2918
|
+
"aria-label": "Desktop",
|
|
2919
|
+
className: "relative isolate min-h-0 min-w-0 flex-1 p-1.5",
|
|
2920
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2921
|
+
ref: surfaceRef,
|
|
2922
|
+
"data-desktop-surface": true,
|
|
2923
|
+
className: "relative h-full",
|
|
2924
|
+
children: [
|
|
2925
|
+
visible.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
2926
|
+
className: "absolute inset-0 grid place-items-center px-6 text-center text-base text-po-dim",
|
|
2927
|
+
children: rail.workspaces.length === 0 ? "Open Po to add a folder to work in." : "Open Po to pick up a session."
|
|
2928
|
+
}) : null,
|
|
2929
|
+
snap !== null ? /* @__PURE__ */ jsx("div", {
|
|
2930
|
+
"aria-hidden": true,
|
|
2931
|
+
style: place(snap),
|
|
2932
|
+
className: "absolute z-[55] p-1.5",
|
|
2933
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full rounded-2xl bg-po-panel/40 ring-2 ring-po-green backdrop-blur-sm animate-po-fade" })
|
|
2934
|
+
}) : null,
|
|
2935
|
+
layout.windows.map((win) => {
|
|
2936
|
+
const members = stacks.find((entry) => entry.root === stackRoot(win))?.members ?? [];
|
|
2937
|
+
const isFront = front?.id === win.id;
|
|
2938
|
+
const { title, subtitle } = titleOf(win);
|
|
2939
|
+
const root = findWindow(layout, stackRoot(win)) ?? win;
|
|
2940
|
+
return /* @__PURE__ */ jsx(DesktopWindow, {
|
|
2941
|
+
testId: `desktop-window-${win.id}`,
|
|
2942
|
+
title,
|
|
2943
|
+
subtitle,
|
|
2944
|
+
rect: rectOf(layout, win.id, surface.width),
|
|
2945
|
+
layer: layout.z.indexOf(win.id),
|
|
2946
|
+
focused: isFront,
|
|
2947
|
+
minimized: win.minimized === true,
|
|
2948
|
+
maximized: root.maximized === true,
|
|
2949
|
+
stacked: members.length < 2 ? "alone" : members[members.length - 1]?.id === win.id ? "top" : "under",
|
|
2950
|
+
narrow,
|
|
2951
|
+
desktop: surface,
|
|
2952
|
+
headerRegion: win.kind === "session" && win.sessionId === activeId ? "header" : void 0,
|
|
2953
|
+
onFocus: () => focus(win),
|
|
2954
|
+
onClose: () => close(win),
|
|
2955
|
+
onMinimize: () => update((current) => minimizeWindow(current, win.id)),
|
|
2956
|
+
onToggleMaximize: () => update((current) => toggleMaximize(current, win.id)),
|
|
2957
|
+
onPlace: (rect) => update((current) => placeWindow(current, win.id, rect)),
|
|
2958
|
+
onResetPlace: () => update((current) => resetPlace(current, win.id)),
|
|
2959
|
+
onSnapPreview: setSnap,
|
|
2960
|
+
children: bodyOf(win, isFront)
|
|
2961
|
+
}, win.id);
|
|
2962
|
+
})
|
|
2963
|
+
]
|
|
2964
|
+
})
|
|
2965
|
+
}), !activityShown ? null : face === "activity" ? /* @__PURE__ */ jsx(DesktopWidgets, {
|
|
2966
|
+
layout,
|
|
2967
|
+
activeId,
|
|
2968
|
+
editing,
|
|
2969
|
+
overlay: narrow,
|
|
2970
|
+
onEditingChange: setEditing,
|
|
2971
|
+
onRemove: (name, available) => update((current) => removeWidget(current, name, available)),
|
|
2972
|
+
onAdd: (name, available) => update((current) => addWidget(current, name, available)),
|
|
2973
|
+
onToggleExpanded: (name) => update((current) => toggleWidgetExpanded(current, name))
|
|
2974
|
+
}) : shownRailFace !== void 0 ? /* @__PURE__ */ jsx(DesktopRail, {
|
|
2975
|
+
face: shownRailFace,
|
|
2976
|
+
ownsScroll: contributedFace?.ownsScroll === true,
|
|
2977
|
+
overlay: narrow,
|
|
2978
|
+
children: contributedFace !== void 0 ? /* @__PURE__ */ jsx(contributedFace.panel, { ...slotProps }) : /* @__PURE__ */ jsx(ContextPanel, {})
|
|
2979
|
+
}) : null]
|
|
2980
|
+
}),
|
|
2981
|
+
/* @__PURE__ */ jsxs(Popover, {
|
|
2982
|
+
open: menuOpen,
|
|
2983
|
+
onOpenChange: setMenuOpen,
|
|
2984
|
+
children: [/* @__PURE__ */ jsx(DesktopBar, {
|
|
2985
|
+
menuOpen,
|
|
2986
|
+
menuTrigger: (button) => /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
2987
|
+
asChild: true,
|
|
2988
|
+
children: button
|
|
2989
|
+
}),
|
|
2990
|
+
stacks: barStacks,
|
|
2991
|
+
waiting,
|
|
2992
|
+
remote: rail.remote.status,
|
|
2993
|
+
faces: railFaces,
|
|
2994
|
+
face,
|
|
2995
|
+
railShown: activityShown,
|
|
2996
|
+
onStack,
|
|
2997
|
+
onRemote: rail.actions.openRemoteAccess,
|
|
2998
|
+
onFace: (id) => {
|
|
2999
|
+
if (activityShown && id === face) {
|
|
3000
|
+
if (narrow) setNarrowActivity(false);
|
|
3001
|
+
else update((current) => ({
|
|
3002
|
+
...current,
|
|
3003
|
+
activityHidden: true
|
|
3004
|
+
}));
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
setDockTab(activeId, id);
|
|
3008
|
+
if (narrow) setNarrowActivity(true);
|
|
3009
|
+
else update((current) => current.activityHidden ? {
|
|
3010
|
+
...current,
|
|
3011
|
+
activityHidden: false
|
|
3012
|
+
} : current);
|
|
3013
|
+
}
|
|
3014
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
3015
|
+
side: "top",
|
|
3016
|
+
align: "start",
|
|
3017
|
+
sideOffset: 10,
|
|
3018
|
+
"aria-label": "Po",
|
|
3019
|
+
className: `flex max-h-[min(40rem,calc(100vh-6rem))] w-[min(28rem,calc(100vw-1.5rem))] flex-col rounded-3xl border-0 shadow-2xl ${GLASS}`,
|
|
3020
|
+
children: /* @__PURE__ */ jsx(DesktopMenu, {
|
|
3021
|
+
rail,
|
|
3022
|
+
onClose: () => setMenuOpen(false)
|
|
3023
|
+
})
|
|
3024
|
+
})]
|
|
3025
|
+
})
|
|
3026
|
+
]
|
|
3027
|
+
}),
|
|
3028
|
+
rail.addWorkspace ? /* @__PURE__ */ jsx(DesktopAddWorkspaceDialog, {
|
|
3029
|
+
suggestedPaths: rail.addWorkspace.suggestedPaths,
|
|
3030
|
+
actions: rail.actions
|
|
3031
|
+
}) : null,
|
|
3032
|
+
/* @__PURE__ */ jsx(SessionRailDialogs, {}),
|
|
3033
|
+
/* @__PURE__ */ jsx(DesktopSessionDialogs, { actions: rail.actions }),
|
|
3034
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
3035
|
+
/* @__PURE__ */ jsx(RefusedCard, {}),
|
|
3036
|
+
/* @__PURE__ */ jsx(CommandPalette, {}),
|
|
3037
|
+
/* @__PURE__ */ jsx(PluginSurface, {
|
|
3038
|
+
slot: HOST_SLOTS.overlay,
|
|
3039
|
+
sessionId: activeId
|
|
3040
|
+
}),
|
|
3041
|
+
/* @__PURE__ */ jsx(RemoteAccessDialog, {}),
|
|
3042
|
+
/* @__PURE__ */ jsx(PairingApprovalDialog, {})
|
|
3043
|
+
]
|
|
3044
|
+
});
|
|
3045
|
+
}
|
|
3046
|
+
//#endregion
|
|
3047
|
+
//#region src/extensions/(frontend)/template/_lib/definition.ts
|
|
3048
|
+
const desktopTemplate = {
|
|
3049
|
+
label: "Desktop",
|
|
3050
|
+
description: "Po as a calm desktop: sessions in floating windows, a Po menu, and Activity widgets you choose.",
|
|
3051
|
+
contractVersion: 2,
|
|
3052
|
+
app: DesktopDashboard
|
|
3053
|
+
};
|
|
3054
|
+
//#endregion
|
|
3055
|
+
//#region src/extensions/(frontend)/template/po-template-desktop.web.ts
|
|
3056
|
+
var po_template_desktop_web_default$2 = defineWebTemplate(desktopTemplate);
|
|
3057
|
+
//#endregion
|
|
3058
|
+
//#region src/extensions/workspaces/(frontend)/template/po-template-desktop.web.ts
|
|
3059
|
+
var po_template_desktop_web_default$1 = defineWebTemplate(desktopTemplate);
|
|
3060
|
+
//#endregion
|
|
3061
|
+
//#region src/extensions/workspaces/sessions/(frontend)/template/po-template-desktop.web.ts
|
|
3062
|
+
var po_template_desktop_web_default = defineWebTemplate(desktopTemplate);
|
|
3063
|
+
//#endregion
|
|
3064
|
+
//#region generated/web.ts
|
|
3065
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
3066
|
+
...identity,
|
|
3067
|
+
...value
|
|
3068
|
+
};
|
|
3069
|
+
const webPlugin = defineWebPlugin({
|
|
3070
|
+
id: "template-desktop",
|
|
3071
|
+
global: { get templates() {
|
|
3072
|
+
return [via({ id: "po-template-desktop" }, po_template_desktop_web_default$2)];
|
|
3073
|
+
} },
|
|
3074
|
+
workspace: { get templates() {
|
|
3075
|
+
return [via({ id: "po-template-desktop" }, po_template_desktop_web_default$1)];
|
|
3076
|
+
} },
|
|
3077
|
+
session: { get templates() {
|
|
3078
|
+
return [via({ id: "po-template-desktop" }, po_template_desktop_web_default)];
|
|
3079
|
+
} }
|
|
3080
|
+
});
|
|
3081
|
+
//#endregion
|
|
3082
|
+
export { webPlugin };
|
|
3083
|
+
|
|
3084
|
+
//# sourceMappingURL=web.mjs.map
|