@hollis-labs/surface-page 0.1.0 → 0.3.0

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/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  } from "./chunks/chunk-ZT6LTRMY.js";
19
19
 
20
20
  // ../../web/src/boot.tsx
21
- import { StrictMode, useEffect as useEffect9, useState as useState8 } from "react";
21
+ import { StrictMode, useEffect as useEffect13, useState as useState11 } from "react";
22
22
  import { createRoot } from "react-dom/client";
23
23
 
24
24
  // ../../web/src/cards/views.tsx
@@ -27,6 +27,149 @@ import { Button } from "@/components/ui/button";
27
27
  import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
28
28
  import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
29
29
 
30
+ // ../../web/src/desk/store.ts
31
+ import { useSyncExternalStore } from "react";
32
+ var notYetKept = (w) => !!w.opened_by && w.opened_by !== "owner" && !w.kept;
33
+ var manifest = null;
34
+ var state = { wins: [], focus: "", tree: { root: { type: "row" } }, layout: "tile", ratio: 0.56, rev: -1 };
35
+ var subs = /* @__PURE__ */ new Set();
36
+ var emit = () => {
37
+ for (const fn of subs) fn();
38
+ };
39
+ onEvent("desk.changed", (ev) => {
40
+ const next = ev.data;
41
+ if (next && next.rev >= state.rev) {
42
+ state = next;
43
+ emit();
44
+ }
45
+ });
46
+ async function loadManifest() {
47
+ manifest = await call("GET", "/api/app");
48
+ return manifest;
49
+ }
50
+ var app = () => {
51
+ if (!manifest) throw new Error("the app manifest is not loaded yet");
52
+ return manifest;
53
+ };
54
+ var viewById = (id) => manifest?.views.find((v) => v.id === id);
55
+ function viewForFile(name) {
56
+ const base2 = name.toLowerCase().split("/").pop() ?? "";
57
+ const matches2 = (pattern) => {
58
+ const p = pattern.toLowerCase();
59
+ if (p.startsWith("*")) return base2.endsWith(p.slice(1));
60
+ return base2 === p;
61
+ };
62
+ return manifest?.views.find((v) => v.opens?.some(matches2));
63
+ }
64
+ var deskState = () => state;
65
+ var subscribe = (fn) => {
66
+ subs.add(fn);
67
+ return () => {
68
+ subs.delete(fn);
69
+ };
70
+ };
71
+ function useDeskState() {
72
+ return useSyncExternalStore(subscribe, deskState);
73
+ }
74
+ async function act(action) {
75
+ const res = await call("POST", "/api/desk/actions", action);
76
+ return res.window;
77
+ }
78
+ var toWin = (w, focus) => ({
79
+ id: w.id,
80
+ view: w.view,
81
+ module: w.module,
82
+ title: w.title,
83
+ key: w.key,
84
+ args: w.args ?? {},
85
+ state: w.state,
86
+ focused: w.id === focus
87
+ });
88
+ var pendingReports = /* @__PURE__ */ new Map();
89
+ var reportTimer;
90
+ function flushReports() {
91
+ reportTimer = void 0;
92
+ for (const [id, st] of pendingReports) {
93
+ void act({ type: "state", id, state: st }).catch(() => {
94
+ });
95
+ }
96
+ pendingReports.clear();
97
+ }
98
+ var confirmImpl = async (q) => window.confirm(q.title);
99
+ var setConfirm = (fn) => {
100
+ confirmImpl = fn;
101
+ };
102
+ var clientRunner = () => void 0;
103
+ var setClientRunner = (fn) => {
104
+ clientRunner = fn;
105
+ };
106
+ async function runCommand(id, args) {
107
+ const local = clientRunner(id, args);
108
+ if (local !== void 0) return await local;
109
+ const res = await call("POST", `/api/commands/${encodeURIComponent(id)}`, { args: args ?? {} });
110
+ return res.result;
111
+ }
112
+ async function closeWindow(id) {
113
+ const w = state.wins.find((x) => x.id === id);
114
+ if (w?.dirty && getSetting("surface.confirm_close_dirty") === false) {
115
+ await act({ type: "close", id, force: true });
116
+ return;
117
+ }
118
+ if (w?.dirty) {
119
+ const yes = await confirmImpl({
120
+ title: `Close \u201C${w.title}\u201D?`,
121
+ message: "It holds unsaved work.",
122
+ confirmLabel: "Close anyway",
123
+ danger: true
124
+ });
125
+ if (!yes) return;
126
+ await act({ type: "close", id, force: true });
127
+ return;
128
+ }
129
+ await act({ type: "close", id });
130
+ }
131
+ function unlessGone(err) {
132
+ if (err instanceof ApiError && /no window/.test(err.message)) return void 0;
133
+ throw err;
134
+ }
135
+ var desk = {
136
+ async open(view, opts) {
137
+ const w = await act({ type: "open", view, ...opts });
138
+ if (!w) throw new Error(`could not open ${view}`);
139
+ return toWin(w, w.id);
140
+ },
141
+ async openFile(name, opts) {
142
+ const view = viewForFile(name);
143
+ return view ? desk.open(view.id, opts) : null;
144
+ },
145
+ close: closeWindow,
146
+ async focus(id) {
147
+ await act({ type: "focus", id }).catch(unlessGone);
148
+ },
149
+ async setTitle(id, title) {
150
+ await act({ type: "title", id, title }).catch(unlessGone);
151
+ },
152
+ async setArgs(id, args) {
153
+ await act({ type: "args", id, args }).catch(unlessGone);
154
+ },
155
+ report(id, st) {
156
+ pendingReports.set(id, st);
157
+ if (reportTimer === void 0) reportTimer = window.setTimeout(flushReports, 250);
158
+ },
159
+ setDirty(id, dirty) {
160
+ const w = state.wins.find((x) => x.id === id);
161
+ if (w && !!w.dirty !== dirty) void act({ type: "dirty", id, dirty }).catch(() => {
162
+ });
163
+ },
164
+ run: runCommand,
165
+ confirm: (q) => confirmImpl(q),
166
+ windows: () => state.wins.map((w) => toWin(w, state.focus))
167
+ };
168
+ var listLayouts = () => call("GET", "/api/layouts");
169
+ var saveLayout = (name, about) => call("POST", "/api/layouts", { name, about });
170
+ var loadLayout = (name) => call("POST", `/api/layouts/${encodeURIComponent(name)}/load`);
171
+ var deleteLayout = (name) => call("DELETE", `/api/layouts/${encodeURIComponent(name)}`);
172
+
30
173
  // ../../web/src/cards/renderers.tsx
31
174
  import {
32
175
  classifyPriorResponse,
@@ -51,7 +194,7 @@ import {
51
194
  GenuiController,
52
195
  parseRecovery
53
196
  } from "@hollis-labs/surface-genui";
54
- import { useEffect, useMemo, useSyncExternalStore } from "react";
197
+ import { useEffect, useMemo, useSyncExternalStore as useSyncExternalStore2 } from "react";
55
198
  import { GenuiSurface } from "@/components/ui/genui-surface";
56
199
  import { jsx } from "react/jsx-runtime";
57
200
  async function send(method, path, body, signal) {
@@ -118,7 +261,7 @@ function GenuiCard({ card }) {
118
261
  const raw = useMemo(() => JSON.stringify(card.payload?.envelope ?? null), [card.payload]);
119
262
  const controller = useMemo(() => new GenuiController(raw, transport), [raw]);
120
263
  useEffect(() => () => controller.dispose(), [controller]);
121
- const snap = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
264
+ const snap = useSyncExternalStore2(controller.subscribe, controller.getSnapshot);
122
265
  const envelope = snap.envelope;
123
266
  const root = envelope.data.createSurface.components[0];
124
267
  const closed = !!card.status;
@@ -158,7 +301,7 @@ function GenuiCard({ card }) {
158
301
  import {
159
302
  createCardEngine
160
303
  } from "@hollis-labs/surface-cards";
161
- import { useSyncExternalStore as useSyncExternalStore2 } from "react";
304
+ import { useSyncExternalStore as useSyncExternalStore3 } from "react";
162
305
  var ANSWERABLE = ["confirm", "prompt", "choice", "form", "approval"];
163
306
  var answer = [{ id: "answer", label: "Answer" }];
164
307
  var rules = [
@@ -171,13 +314,13 @@ var rules = [
171
314
  var engine = createCardEngine({ rules, now: () => Date.now() });
172
315
  var cards = /* @__PURE__ */ new Map();
173
316
  var stale = /* @__PURE__ */ new Set();
174
- var subs = /* @__PURE__ */ new Set();
317
+ var subs2 = /* @__PURE__ */ new Set();
175
318
  var version = 0;
176
- var emit = () => {
319
+ var emit2 = () => {
177
320
  version++;
178
- for (const fn of subs) fn();
321
+ for (const fn of subs2) fn();
179
322
  };
180
- engine.subscribe(emit);
323
+ engine.subscribe(emit2);
181
324
  function take(c) {
182
325
  const have = cards.get(c.id);
183
326
  if (have && (have.revision ?? 0) > (c.revision ?? 0)) return;
@@ -194,7 +337,7 @@ function take(c) {
194
337
  expiresAt: Number.isFinite(expiresAt) ? expiresAt : void 0
195
338
  });
196
339
  if (c.status) engine.applyServerState(c.id, c.status, { supersededBy: c.superseded_by });
197
- emit();
340
+ emit2();
198
341
  }
199
342
  var started = false;
200
343
  function startCards() {
@@ -214,7 +357,7 @@ async function respond(id, outcome) {
214
357
  if (now) take(now);
215
358
  else {
216
359
  stale.add(id);
217
- emit();
360
+ emit2();
218
361
  }
219
362
  return;
220
363
  }
@@ -223,10 +366,10 @@ async function respond(id, outcome) {
223
366
  }
224
367
  var dismissToast = (id) => engine.dismissToast(id);
225
368
  var isStale = (id) => stale.has(id);
226
- var subscribe = (fn) => {
227
- subs.add(fn);
369
+ var subscribe2 = (fn) => {
370
+ subs2.add(fn);
228
371
  return () => {
229
- subs.delete(fn);
372
+ subs2.delete(fn);
230
373
  };
231
374
  };
232
375
  var cache = /* @__PURE__ */ new Map();
@@ -241,10 +384,10 @@ function shown(surface) {
241
384
  return list2;
242
385
  }
243
386
  function useCards(surface) {
244
- return useSyncExternalStore2(subscribe, () => shown(surface));
387
+ return useSyncExternalStore3(subscribe2, () => shown(surface));
245
388
  }
246
389
  function useCard(id) {
247
- return useSyncExternalStore2(subscribe, () => cards.get(id));
390
+ return useSyncExternalStore3(subscribe2, () => cards.get(id));
248
391
  }
249
392
 
250
393
  // ../../web/src/cards/renderers.tsx
@@ -273,14 +416,14 @@ function describeOutcome(card) {
273
416
  }
274
417
  var clock = new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit" });
275
418
  function answerable({ card, respond: send2 }) {
276
- const state2 = classifyPriorResponse(card.status);
419
+ const state3 = classifyPriorResponse(card.status);
277
420
  const at = card.expires_at ? Date.parse(card.expires_at) : Number.NaN;
278
421
  return {
279
422
  title: card.title,
280
- state: state2.kind,
423
+ state: state3.kind,
281
424
  stale: isStale(card.id),
282
425
  receipt: describeOutcome(card),
283
- expires: state2.kind === "open" && Number.isFinite(at) ? `at ${clock.format(at)}` : void 0,
426
+ expires: state3.kind === "open" && Number.isFinite(at) ? `at ${clock.format(at)}` : void 0,
284
427
  onRespond: send2
285
428
  };
286
429
  }
@@ -435,7 +578,12 @@ function CardDock() {
435
578
  }
436
579
  function CardHost() {
437
580
  useEffect2(startCards, []);
438
- const toasts = useCards("toast").filter((s) => isOpen(s.card) && !s.view.toastDismissed);
581
+ const desk2 = useDeskState();
582
+ const shown2 = desk2.wins.find((w) => w.id === desk2.focus);
583
+ const inFront = shown2?.key ? `${shown2.module}:${shown2.key}` : "";
584
+ const toasts = useCards("toast").filter(
585
+ (s) => isOpen(s.card) && !s.view.toastDismissed && (s.view.answerable || !inFront || s.card.subject !== inFront)
586
+ );
439
587
  const blocking = useCards("modal").filter((s) => isOpen(s.card));
440
588
  const [hidden, setHidden] = useState(null);
441
589
  const front = blocking.find((s) => s.card.id !== hidden);
@@ -498,162 +646,246 @@ function Sourced({ card }) {
498
646
  }
499
647
 
500
648
  // ../../web/src/desk/coreViews.tsx
649
+ import { useCallback as useCallback3, useEffect as useEffect4, useState as useState3 } from "react";
650
+ import { Badge as Badge2 } from "@/components/ui/badge";
651
+ import { Button as Button3 } from "@/components/ui/button";
652
+ import { Input } from "@/components/ui/input";
653
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
654
+ import { Switch as Switch2 } from "@/components/ui/switch";
655
+
656
+ // ../../web/src/desk/ContextInspector.tsx
501
657
  import { useCallback as useCallback2, useEffect as useEffect3, useState as useState2 } from "react";
502
658
  import { Badge } from "@/components/ui/badge";
503
659
  import { Button as Button2 } from "@/components/ui/button";
504
- import { Input } from "@/components/ui/input";
505
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
660
+ import { Empty as Empty2, EmptyDescription as EmptyDescription2, EmptyHeader as EmptyHeader2, EmptyTitle as EmptyTitle2 } from "@/components/ui/empty";
661
+ import { Item, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item";
506
662
  import { Switch } from "@/components/ui/switch";
507
-
508
- // ../../web/src/desk/store.ts
509
- import { useSyncExternalStore as useSyncExternalStore3 } from "react";
510
- var manifest = null;
511
- var state = { wins: [], focus: "", tree: { root: { type: "row" } }, layout: "tile", ratio: 0.56, rev: -1 };
512
- var subs2 = /* @__PURE__ */ new Set();
513
- var emit2 = () => {
514
- for (const fn of subs2) fn();
515
- };
516
- onEvent("desk.changed", (ev) => {
517
- const next = ev.data;
518
- if (next && next.rev >= state.rev) {
519
- state = next;
520
- emit2();
521
- }
522
- });
523
- async function loadManifest() {
524
- manifest = await call("GET", "/api/app");
525
- return manifest;
526
- }
527
- var app = () => {
528
- if (!manifest) throw new Error("the app manifest is not loaded yet");
529
- return manifest;
530
- };
531
- var viewById = (id) => manifest?.views.find((v) => v.id === id);
532
- function viewForFile(name) {
533
- const base2 = name.toLowerCase().split("/").pop() ?? "";
534
- const matches2 = (pattern) => {
535
- const p = pattern.toLowerCase();
536
- if (p.startsWith("*")) return base2.endsWith(p.slice(1));
537
- return base2 === p;
538
- };
539
- return manifest?.views.find((v) => v.opens?.some(matches2));
540
- }
541
- var deskState = () => state;
542
- var subscribe2 = (fn) => {
543
- subs2.add(fn);
544
- return () => {
545
- subs2.delete(fn);
546
- };
547
- };
548
- function useDeskState() {
549
- return useSyncExternalStore3(subscribe2, deskState);
550
- }
551
- async function act(action) {
552
- const res = await call("POST", "/api/desk/actions", action);
553
- return res.window;
554
- }
555
- var toWin = (w, focus) => ({
556
- id: w.id,
557
- view: w.view,
558
- module: w.module,
559
- title: w.title,
560
- key: w.key,
561
- args: w.args ?? {},
562
- state: w.state,
563
- focused: w.id === focus
564
- });
565
- var pendingReports = /* @__PURE__ */ new Map();
566
- var reportTimer;
567
- function flushReports() {
568
- reportTimer = void 0;
569
- for (const [id, st] of pendingReports) {
570
- void act({ type: "state", id, state: st }).catch(() => {
571
- });
572
- }
573
- pendingReports.clear();
574
- }
575
- var confirmImpl = async (q) => window.confirm(q.title);
576
- var setConfirm = (fn) => {
577
- confirmImpl = fn;
663
+ import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
664
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
665
+ var WHY = {
666
+ focus: "the window in front belongs to it",
667
+ kept: "it stayed from before: the window in front has no slot of its own",
668
+ pinned: "it was pinned",
669
+ mode: "your mode chose it",
670
+ default: "nothing else applied (the default)"
578
671
  };
579
- var clientRunner = () => void 0;
580
- var setClientRunner = (fn) => {
581
- clientRunner = fn;
672
+ var when = (iso) => {
673
+ const d = new Date(iso);
674
+ return Number.isNaN(d.getTime()) ? iso : d.toLocaleString([], { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit" });
582
675
  };
583
- async function runCommand(id, args) {
584
- const local = clientRunner(id, args);
585
- if (local !== void 0) return await local;
586
- const res = await call("POST", `/api/commands/${encodeURIComponent(id)}`, { args: args ?? {} });
587
- return res.result;
588
- }
589
- async function closeWindow(id) {
590
- const w = state.wins.find((x) => x.id === id);
591
- if (w?.dirty && getSetting("surface.confirm_close_dirty") === false) {
592
- await act({ type: "close", id, force: true });
593
- return;
594
- }
595
- if (w?.dirty) {
596
- const yes = await confirmImpl({
597
- title: `Close \u201C${w.title}\u201D?`,
598
- message: "It holds unsaved work.",
599
- confirmLabel: "Close anyway",
600
- danger: true
601
- });
602
- if (!yes) return;
603
- await act({ type: "close", id, force: true });
604
- return;
605
- }
606
- await act({ type: "close", id });
676
+ var byOwner = (s) => s.actor === "owner" || s.actor === "" || s.actor === void 0;
677
+ var correction = (s) => byOwner(s) && (s.kind === "pin" || s.kind === "unpin");
678
+ function Row({ label, children }) {
679
+ return /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[9rem_1fr] gap-3 py-1.5 text-sm", children: [
680
+ /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground text-xs", children: label }),
681
+ /* @__PURE__ */ jsx4("div", { className: "flex min-w-0 flex-wrap items-center gap-1", children })
682
+ ] });
607
683
  }
608
- function unlessGone(err) {
609
- if (err instanceof ApiError && /no window/.test(err.message)) return void 0;
610
- throw err;
684
+ var chips = (list2, empty = "none") => list2 && list2.length > 0 ? list2.map((x) => /* @__PURE__ */ jsx4(Badge, { variant: "outline", className: "font-mono", children: x }, x)) : /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground text-xs", children: empty });
685
+ function TurnDetail({ t }) {
686
+ const corrections = (t.signals ?? []).filter(correction);
687
+ return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-1 p-4", children: [
688
+ /* @__PURE__ */ jsx4("p", { className: "text-sm whitespace-pre-wrap", children: t.text }),
689
+ /* @__PURE__ */ jsxs2("span", { className: "mb-2 text-xs text-muted-foreground", children: [
690
+ when(t.at),
691
+ t.run_id ? ` \xB7 run ${t.run_id}` : ""
692
+ ] }),
693
+ /* @__PURE__ */ jsxs2(Row, { label: "In front", children: [
694
+ t.view ? /* @__PURE__ */ jsx4(Badge, { variant: "secondary", children: t.view }) : /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing" }),
695
+ t.mode && /* @__PURE__ */ jsxs2(Badge, { variant: "outline", children: [
696
+ "mode ",
697
+ t.mode
698
+ ] }),
699
+ t.layout && /* @__PURE__ */ jsx4(Badge, { variant: "outline", children: t.layout })
700
+ ] }),
701
+ /* @__PURE__ */ jsx4(Row, { label: "Open", children: chips(t.open_views) }),
702
+ /* @__PURE__ */ jsxs2(Row, { label: "Slot", children: [
703
+ /* @__PURE__ */ jsx4(Badge, { children: t.slot || "none" }),
704
+ /* @__PURE__ */ jsxs2("span", { className: "text-xs text-muted-foreground", children: [
705
+ "because ",
706
+ WHY[t.why ?? ""] ?? t.why ?? "?"
707
+ ] })
708
+ ] }),
709
+ /* @__PURE__ */ jsx4(Row, { label: "Slots offered", children: chips(t.slots) }),
710
+ /* @__PURE__ */ jsx4(Row, { label: "Tools to mind", children: chips(t.top_of_mind) }),
711
+ /* @__PURE__ */ jsx4(Row, { label: "Routed", children: t.routed ? /* @__PURE__ */ jsx4(Badge, { variant: "outline", children: t.routed }) : /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "no rule" }) }),
712
+ /* @__PURE__ */ jsxs2(Row, { label: "Reflexes", children: [
713
+ chips(t.fired),
714
+ t.halted && /* @__PURE__ */ jsx4(Badge, { variant: "destructive", children: "halted the turn" })
715
+ ] }),
716
+ /* @__PURE__ */ jsx4(Row, { label: "Context size", children: /* @__PURE__ */ jsxs2("span", { className: "font-mono text-xs", children: [
717
+ t.block_chars.toLocaleString(),
718
+ " characters"
719
+ ] }) }),
720
+ /* @__PURE__ */ jsx4(Row, { label: "Budget cut", children: chips(t.trimmed, "nothing cut") }),
721
+ /* @__PURE__ */ jsx4(Row, { label: "What followed", children: (t.signals ?? []).length === 0 ? /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing in the next 15 minutes" }) : /* @__PURE__ */ jsx4("ul", { className: "flex w-full flex-col gap-1", children: (t.signals ?? []).map((s) => /* @__PURE__ */ jsxs2(
722
+ "li",
723
+ {
724
+ className: "flex flex-wrap items-center gap-1.5 text-xs",
725
+ children: [
726
+ /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: when(s.at) }),
727
+ /* @__PURE__ */ jsx4(Badge, { variant: correction(s) ? "secondary" : "outline", children: s.kind }),
728
+ /* @__PURE__ */ jsxs2("span", { className: "text-muted-foreground", children: [
729
+ "by ",
730
+ s.actor || "owner"
731
+ ] }),
732
+ s.detail && /* @__PURE__ */ jsx4("code", { className: "font-mono text-muted-foreground", children: JSON.stringify(s.detail) })
733
+ ]
734
+ },
735
+ `${s.at}-${s.kind}-${s.actor ?? ""}-${JSON.stringify(s.detail ?? {})}`
736
+ )) }) }),
737
+ corrections.length > 0 && /* @__PURE__ */ jsxs2("p", { className: "mt-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs", children: [
738
+ "You re-pinned the context soon after this turn (",
739
+ corrections.map((c) => c.kind).join(", "),
740
+ "): the slot the agent chose was probably not the one you meant."
741
+ ] })
742
+ ] });
743
+ }
744
+ function Now() {
745
+ const [p, setP] = useState2(null);
746
+ const [error, setError] = useState2("");
747
+ const load = useCallback2(() => {
748
+ call("GET", "/api/agent/context").then((x) => {
749
+ setP(x);
750
+ setError("");
751
+ }).catch((e) => setError(e.message));
752
+ }, []);
753
+ useEffect3(load, [load]);
754
+ useEvent("desk.changed", load);
755
+ if (error) return /* @__PURE__ */ jsx4("p", { className: "p-4 text-xs text-destructive", children: error });
756
+ if (!p) return /* @__PURE__ */ jsx4("p", { className: "p-4 text-xs text-muted-foreground", children: "Reading\u2026" });
757
+ return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-1 p-4", children: [
758
+ /* @__PURE__ */ jsx4("p", { className: "text-xs text-muted-foreground", children: "What a message sent now would carry. It follows the window in front." }),
759
+ /* @__PURE__ */ jsx4(Row, { label: "In front", children: p.focused?.view ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
760
+ /* @__PURE__ */ jsx4(Badge, { variant: "secondary", children: p.focused.view }),
761
+ /* @__PURE__ */ jsx4("span", { className: "truncate text-xs", children: p.focused.title }),
762
+ p.focused.ref && /* @__PURE__ */ jsx4(Badge, { variant: "outline", className: "font-mono", children: p.focused.ref })
763
+ ] }) : /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing" }) }),
764
+ /* @__PURE__ */ jsxs2(Row, { label: "Slot", children: [
765
+ /* @__PURE__ */ jsx4(Badge, { children: p.slot || "none" }),
766
+ /* @__PURE__ */ jsxs2("span", { className: "text-xs text-muted-foreground", children: [
767
+ "because ",
768
+ WHY[p.why] ?? p.why
769
+ ] })
770
+ ] }),
771
+ /* @__PURE__ */ jsx4(Row, { label: "Slots offered", children: chips(p.slots.map((s) => s.name)) }),
772
+ /* @__PURE__ */ jsx4(Row, { label: "Tools to mind", children: chips(p.top_of_mind) }),
773
+ /* @__PURE__ */ jsx4(Row, { label: "The block", children: /* @__PURE__ */ jsxs2("span", { className: "font-mono text-xs", children: [
774
+ p.block.length.toLocaleString(),
775
+ " characters"
776
+ ] }) }),
777
+ /* @__PURE__ */ jsx4("pre", { className: "mt-2 max-h-[50vh] overflow-auto rounded-md border bg-muted/40 p-3 font-mono text-xs whitespace-pre-wrap", children: p.block })
778
+ ] });
779
+ }
780
+ function History() {
781
+ const [turns, setTurns] = useState2(null);
782
+ const [on, setOn] = useState2(true);
783
+ const [open, setOpen] = useState2(null);
784
+ const [error, setError] = useState2("");
785
+ const load = useCallback2(() => {
786
+ call("GET", "/api/agent/trace?limit=200").then((r) => {
787
+ setTurns(r.turns ?? []);
788
+ setOn(r.on);
789
+ setError("");
790
+ }).catch((e) => setError(e.message));
791
+ }, []);
792
+ useEffect3(load, [load]);
793
+ const shown2 = turns?.find((t) => t.id === open) ?? turns?.[0];
794
+ return /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 flex-1 flex-col", children: [
795
+ /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 flex-wrap items-center gap-3 border-b px-3 py-2 text-xs", children: [
796
+ /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-2", children: [
797
+ /* @__PURE__ */ jsx4(
798
+ Switch,
799
+ {
800
+ checked: on,
801
+ onCheckedChange: (v) => void setSetting("surface.agent_trace", v).then(() => setOn(v)).catch((e) => setError(e.message)),
802
+ "aria-label": "Keep the trace"
803
+ }
804
+ ),
805
+ "Keep the trace"
806
+ ] }),
807
+ /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: "On this machine only; the newest 50,000 turns." }),
808
+ /* @__PURE__ */ jsxs2("div", { className: "ml-auto flex items-center gap-1", children: [
809
+ /* @__PURE__ */ jsx4(Button2, { size: "sm", variant: "ghost", "aria-label": "Read the trace again", onClick: load, children: /* @__PURE__ */ jsx4(Icon, { name: "refresh-cw" }) }),
810
+ /* @__PURE__ */ jsxs2(
811
+ Button2,
812
+ {
813
+ size: "sm",
814
+ variant: "outline",
815
+ render: /* @__PURE__ */ jsx4("a", { href: "/api/agent/trace/export", download: "context-trace.jsonl" }),
816
+ children: [
817
+ /* @__PURE__ */ jsx4(Icon, { name: "download" }),
818
+ "Export"
819
+ ]
820
+ }
821
+ )
822
+ ] })
823
+ ] }),
824
+ error && /* @__PURE__ */ jsx4("p", { className: "border-b px-3 py-1 text-xs text-destructive", children: error }),
825
+ turns?.length === 0 ? /* @__PURE__ */ jsx4(Empty2, { className: "h-full", children: /* @__PURE__ */ jsxs2(EmptyHeader2, { children: [
826
+ /* @__PURE__ */ jsx4(EmptyTitle2, { children: "No turns yet" }),
827
+ /* @__PURE__ */ jsx4(EmptyDescription2, { children: "Each message to the agent leaves a record here." })
828
+ ] }) }) : /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 flex-1", children: [
829
+ /* @__PURE__ */ jsx4("div", { className: "flex w-80 shrink-0 flex-col gap-0.5 overflow-auto border-r p-1.5 @max-3xl:w-56", children: turns?.map((t) => {
830
+ const fixed = (t.signals ?? []).some(correction);
831
+ return /* @__PURE__ */ jsx4(
832
+ Item,
833
+ {
834
+ size: "sm",
835
+ variant: shown2?.id === t.id ? "muted" : "default",
836
+ render: /* @__PURE__ */ jsx4("a", { href: `#turn-${t.id}` }),
837
+ onClick: (e) => {
838
+ e.preventDefault();
839
+ setOpen(t.id);
840
+ },
841
+ children: /* @__PURE__ */ jsxs2(ItemContent, { children: [
842
+ /* @__PURE__ */ jsxs2(ItemTitle, { className: "w-full", children: [
843
+ /* @__PURE__ */ jsx4(Badge, { variant: "outline", className: "font-mono", children: t.slot || "none" }),
844
+ fixed && /* @__PURE__ */ jsx4("span", { title: "You re-pinned the context soon after this turn", children: /* @__PURE__ */ jsx4(Icon, { name: "corner-down-left", size: 12 }) }),
845
+ t.halted && /* @__PURE__ */ jsx4(Badge, { variant: "destructive", children: "halted" }),
846
+ /* @__PURE__ */ jsx4("span", { className: "ml-auto shrink-0 font-normal text-muted-foreground text-xs", children: when(t.at) })
847
+ ] }),
848
+ /* @__PURE__ */ jsx4(ItemDescription, { className: "truncate", children: t.text })
849
+ ] })
850
+ },
851
+ t.id
852
+ );
853
+ }) }),
854
+ /* @__PURE__ */ jsx4("div", { className: "min-w-0 flex-1 overflow-auto", children: shown2 && /* @__PURE__ */ jsx4(TurnDetail, { t: shown2 }) })
855
+ ] })
856
+ ] });
857
+ }
858
+ function ContextInspector(_) {
859
+ const [tab, setTab] = useState2("now");
860
+ return /* @__PURE__ */ jsxs2("div", { className: "@container flex h-full min-h-0 flex-col bg-background", children: [
861
+ /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2 border-b px-3 py-2", children: [
862
+ /* @__PURE__ */ jsx4("span", { className: "text-sm font-semibold", children: "Context" }),
863
+ /* @__PURE__ */ jsxs2(
864
+ ToggleGroup,
865
+ {
866
+ size: "sm",
867
+ spacing: 0,
868
+ value: [tab],
869
+ onValueChange: (v) => v[0] && setTab(v[0]),
870
+ children: [
871
+ /* @__PURE__ */ jsx4(ToggleGroupItem, { value: "now", children: "Now" }),
872
+ /* @__PURE__ */ jsx4(ToggleGroupItem, { value: "history", children: "History" })
873
+ ]
874
+ }
875
+ ),
876
+ /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "Why the agent gets the context it gets." })
877
+ ] }),
878
+ tab === "now" ? /* @__PURE__ */ jsx4("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ jsx4(Now, {}) }) : /* @__PURE__ */ jsx4(History, {})
879
+ ] });
611
880
  }
612
- var desk = {
613
- async open(view, opts) {
614
- const w = await act({ type: "open", view, ...opts });
615
- if (!w) throw new Error(`could not open ${view}`);
616
- return toWin(w, w.id);
617
- },
618
- async openFile(name, opts) {
619
- const view = viewForFile(name);
620
- return view ? desk.open(view.id, opts) : null;
621
- },
622
- close: closeWindow,
623
- async focus(id) {
624
- await act({ type: "focus", id }).catch(unlessGone);
625
- },
626
- async setTitle(id, title) {
627
- await act({ type: "title", id, title }).catch(unlessGone);
628
- },
629
- async setArgs(id, args) {
630
- await act({ type: "args", id, args }).catch(unlessGone);
631
- },
632
- report(id, st) {
633
- pendingReports.set(id, st);
634
- if (reportTimer === void 0) reportTimer = window.setTimeout(flushReports, 250);
635
- },
636
- setDirty(id, dirty) {
637
- const w = state.wins.find((x) => x.id === id);
638
- if (w && !!w.dirty !== dirty) void act({ type: "dirty", id, dirty }).catch(() => {
639
- });
640
- },
641
- run: runCommand,
642
- confirm: (q) => confirmImpl(q),
643
- windows: () => state.wins.map((w) => toWin(w, state.focus))
644
- };
645
- var listLayouts = () => call("GET", "/api/layouts");
646
- var saveLayout = (name, about) => call("POST", "/api/layouts", { name, about });
647
- var loadLayout = (name) => call("POST", `/api/layouts/${encodeURIComponent(name)}/load`);
648
- var deleteLayout = (name) => call("DELETE", `/api/layouts/${encodeURIComponent(name)}`);
649
881
 
650
882
  // ../../web/src/desk/coreViews.tsx
651
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
883
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
652
884
  function Settings(_) {
653
- const [entries, setEntries] = useState2(allSettings());
654
- const [error, setError] = useState2("");
655
- const refresh = useCallback2(() => void loadSettings().then(setEntries), []);
656
- useEffect3(refresh, [refresh]);
885
+ const [entries, setEntries] = useState3(allSettings());
886
+ const [error, setError] = useState3("");
887
+ const refresh = useCallback3(() => void loadSettings().then(setEntries), []);
888
+ useEffect4(refresh, [refresh]);
657
889
  useEvent("config.changed", refresh);
658
890
  const change = (e, value) => {
659
891
  setError("");
@@ -662,24 +894,24 @@ function Settings(_) {
662
894
  const reset = (e) => void call("DELETE", `/api/settings/${encodeURIComponent(e.full_key)}`).then(refresh);
663
895
  const scopes = [...new Set(entries.map((e) => e.scope))];
664
896
  const title = (scope) => scope === "surface" ? "Desk" : app().modules.find((m) => m.id === scope)?.title ?? scope;
665
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-3 p-4", children: [
666
- /* @__PURE__ */ jsx4("p", { className: "text-muted-foreground", children: "Settings are kept in the app's database and take effect as you change them. Nothing restarts." }),
667
- error && /* @__PURE__ */ jsx4("p", { className: "text-destructive", children: error }),
668
- scopes.map((scope) => /* @__PURE__ */ jsxs2("section", { className: "flex flex-col", children: [
669
- /* @__PURE__ */ jsx4("h3", { className: "pt-2 pb-1.5 font-medium text-muted-foreground text-xs uppercase tracking-wider", children: title(scope) }),
670
- entries.filter((e) => e.scope === scope).map((e) => /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-4 border-t py-2.5", children: [
671
- /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
672
- /* @__PURE__ */ jsx4("span", { className: "font-medium", children: e.title }),
673
- e.about && /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground text-xs", children: e.about }),
674
- /* @__PURE__ */ jsx4("code", { className: "font-mono text-muted-foreground text-xs", children: e.full_key })
897
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3 p-4", children: [
898
+ /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: "Settings are kept in the app's database and take effect as you change them. Nothing restarts." }),
899
+ error && /* @__PURE__ */ jsx5("p", { className: "text-destructive", children: error }),
900
+ scopes.map((scope) => /* @__PURE__ */ jsxs3("section", { className: "flex flex-col", children: [
901
+ /* @__PURE__ */ jsx5("h3", { className: "pt-2 pb-1.5 font-medium text-muted-foreground text-xs uppercase tracking-wider", children: title(scope) }),
902
+ entries.filter((e) => e.scope === scope).map((e) => /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-4 border-t py-2.5", children: [
903
+ /* @__PURE__ */ jsxs3("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
904
+ /* @__PURE__ */ jsx5("span", { className: "font-medium", children: e.title }),
905
+ e.about && /* @__PURE__ */ jsx5("span", { className: "text-muted-foreground text-xs", children: e.about }),
906
+ /* @__PURE__ */ jsx5("code", { className: "font-mono text-muted-foreground text-xs", children: e.full_key })
675
907
  ] }),
676
- /* @__PURE__ */ jsxs2("span", { className: "flex shrink-0 items-center gap-2", children: [
677
- e.type === "bool" && /* @__PURE__ */ jsx4(Switch, { checked: !!e.value, onCheckedChange: (on) => change(e, on), "aria-label": e.title }),
678
- e.type === "enum" && /* @__PURE__ */ jsxs2(Select, { value: String(e.value), onValueChange: (v) => change(e, v), children: [
679
- /* @__PURE__ */ jsx4(SelectTrigger, { size: "sm", "aria-label": e.title, children: /* @__PURE__ */ jsx4(SelectValue, {}) }),
680
- /* @__PURE__ */ jsx4(SelectContent, { children: e.options?.map((o) => /* @__PURE__ */ jsx4(SelectItem, { value: o, children: o }, o)) })
908
+ /* @__PURE__ */ jsxs3("span", { className: "flex shrink-0 items-center gap-2", children: [
909
+ e.type === "bool" && /* @__PURE__ */ jsx5(Switch2, { checked: !!e.value, onCheckedChange: (on) => change(e, on), "aria-label": e.title }),
910
+ e.type === "enum" && /* @__PURE__ */ jsxs3(Select, { value: String(e.value), onValueChange: (v) => change(e, v), children: [
911
+ /* @__PURE__ */ jsx5(SelectTrigger, { size: "sm", "aria-label": e.title, children: /* @__PURE__ */ jsx5(SelectValue, {}) }),
912
+ /* @__PURE__ */ jsx5(SelectContent, { children: e.options?.map((o) => /* @__PURE__ */ jsx5(SelectItem, { value: o, children: o }, o)) })
681
913
  ] }),
682
- e.type === "int" && /* @__PURE__ */ jsx4(
914
+ e.type === "int" && /* @__PURE__ */ jsx5(
683
915
  Input,
684
916
  {
685
917
  className: "w-24",
@@ -692,7 +924,7 @@ function Settings(_) {
692
924
  }
693
925
  }
694
926
  ),
695
- e.type === "string" && /* @__PURE__ */ jsx4(
927
+ e.type === "string" && /* @__PURE__ */ jsx5(
696
928
  Input,
697
929
  {
698
930
  className: "w-64",
@@ -704,27 +936,27 @@ function Settings(_) {
704
936
  },
705
937
  String(e.value)
706
938
  ),
707
- e.set && /* @__PURE__ */ jsx4(Button2, { variant: "link", size: "xs", title: "Back to the default", onClick: () => reset(e), children: "reset" })
939
+ e.set && /* @__PURE__ */ jsx5(Button3, { variant: "link", size: "xs", title: "Back to the default", onClick: () => reset(e), children: "reset" })
708
940
  ] })
709
941
  ] }, e.full_key))
710
942
  ] }, scope))
711
943
  ] });
712
944
  }
713
945
  function Layouts(_) {
714
- const [layouts, setLayouts] = useState2([]);
715
- const [name, setName] = useState2("");
716
- const [error, setError] = useState2("");
717
- const refresh = useCallback2(() => void listLayouts().then(setLayouts), []);
718
- useEffect3(refresh, [refresh]);
946
+ const [layouts, setLayouts] = useState3([]);
947
+ const [name, setName] = useState3("");
948
+ const [error, setError] = useState3("");
949
+ const refresh = useCallback3(() => void listLayouts().then(setLayouts), []);
950
+ useEffect4(refresh, [refresh]);
719
951
  useEvent("desk.layouts", refresh);
720
952
  const active = deskState().active;
721
953
  const save = (n) => {
722
954
  setError("");
723
955
  saveLayout(n).then(() => setName("")).catch((err) => setError(err.message));
724
956
  };
725
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-3 p-4", children: [
726
- /* @__PURE__ */ jsx4("p", { className: "text-muted-foreground", children: "A layout is an arrangement you can come back to: which windows are open, how they sit, and the setup that goes with them (your mode, the agent's standing instructions, the reflexes that are on)." }),
727
- /* @__PURE__ */ jsxs2(
957
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3 p-4", children: [
958
+ /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: "A layout is an arrangement you can come back to: which windows are open, how they sit, and the setup that goes with them (your mode, the agent's standing instructions, the reflexes that are on)." }),
959
+ /* @__PURE__ */ jsxs3(
728
960
  "form",
729
961
  {
730
962
  className: "flex items-center gap-2",
@@ -733,7 +965,7 @@ function Layouts(_) {
733
965
  if (name.trim()) save(name.trim());
734
966
  },
735
967
  children: [
736
- /* @__PURE__ */ jsx4(
968
+ /* @__PURE__ */ jsx5(
737
969
  Input,
738
970
  {
739
971
  className: "flex-1",
@@ -742,26 +974,26 @@ function Layouts(_) {
742
974
  onChange: (e) => setName(e.target.value)
743
975
  }
744
976
  ),
745
- /* @__PURE__ */ jsx4(Button2, { type: "submit", disabled: !name.trim(), children: "Save" })
977
+ /* @__PURE__ */ jsx5(Button3, { type: "submit", disabled: !name.trim(), children: "Save" })
746
978
  ]
747
979
  }
748
980
  ),
749
- error && /* @__PURE__ */ jsx4("p", { className: "text-destructive", children: error }),
750
- layouts.length === 0 && /* @__PURE__ */ jsx4("p", { className: "text-muted-foreground text-xs", children: "No saved layouts yet." }),
751
- layouts.map((l) => /* @__PURE__ */ jsxs2(
981
+ error && /* @__PURE__ */ jsx5("p", { className: "text-destructive", children: error }),
982
+ layouts.length === 0 && /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground text-xs", children: "No saved layouts yet." }),
983
+ layouts.map((l) => /* @__PURE__ */ jsxs3(
752
984
  "div",
753
985
  {
754
986
  className: "flex flex-col gap-2 rounded-lg border bg-card p-3 data-[on=true]:border-ring",
755
987
  "data-on": l.name === active,
756
988
  children: [
757
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
758
- /* @__PURE__ */ jsx4(Icon, { name: "layout-dashboard", size: 15 }),
759
- /* @__PURE__ */ jsx4("strong", { children: l.name }),
760
- l.name === active && /* @__PURE__ */ jsx4(Badge, { variant: "secondary", children: "in use" }),
761
- /* @__PURE__ */ jsx4("span", { className: "flex-1" }),
762
- /* @__PURE__ */ jsx4(Button2, { variant: "outline", size: "sm", onClick: () => void loadLayout(l.name), children: "Arrange" }),
763
- /* @__PURE__ */ jsx4(
764
- Button2,
989
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
990
+ /* @__PURE__ */ jsx5(Icon, { name: "layout-dashboard", size: 15 }),
991
+ /* @__PURE__ */ jsx5("strong", { children: l.name }),
992
+ l.name === active && /* @__PURE__ */ jsx5(Badge2, { variant: "secondary", children: "in use" }),
993
+ /* @__PURE__ */ jsx5("span", { className: "flex-1" }),
994
+ /* @__PURE__ */ jsx5(Button3, { variant: "outline", size: "sm", onClick: () => void loadLayout(l.name), children: "Arrange" }),
995
+ /* @__PURE__ */ jsx5(
996
+ Button3,
765
997
  {
766
998
  variant: "outline",
767
999
  size: "sm",
@@ -770,17 +1002,17 @@ function Layouts(_) {
770
1002
  children: "Update"
771
1003
  }
772
1004
  ),
773
- /* @__PURE__ */ jsx4(Button2, { variant: "destructive", size: "sm", onClick: () => void deleteLayout(l.name).then(refresh), children: "Delete" })
1005
+ /* @__PURE__ */ jsx5(Button3, { variant: "destructive", size: "sm", onClick: () => void deleteLayout(l.name).then(refresh), children: "Delete" })
774
1006
  ] }),
775
- l.about && /* @__PURE__ */ jsx4("p", { className: "text-muted-foreground", children: l.about }),
776
- /* @__PURE__ */ jsxs2("p", { className: "text-muted-foreground text-xs", children: [
1007
+ l.about && /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: l.about }),
1008
+ /* @__PURE__ */ jsxs3("p", { className: "text-muted-foreground text-xs", children: [
777
1009
  l.mode,
778
1010
  " \xB7 ",
779
1011
  l.windows.map((w) => w.title || w.view).join(", ") || "no windows"
780
1012
  ] }),
781
- l.setup && Object.keys(l.setup).length > 0 && /* @__PURE__ */ jsx4("dl", { className: "grid gap-1 text-xs [&_dd]:text-muted-foreground [&_div]:flex [&_div]:gap-2 [&_dt]:w-24 [&_dt]:shrink-0 [&_dt]:text-muted-foreground", children: Object.entries(l.setup).map(([k, v]) => /* @__PURE__ */ jsxs2("div", { children: [
782
- /* @__PURE__ */ jsx4("dt", { children: k }),
783
- /* @__PURE__ */ jsx4("dd", { children: typeof v === "string" ? v : JSON.stringify(v) })
1013
+ l.setup && Object.keys(l.setup).length > 0 && /* @__PURE__ */ jsx5("dl", { className: "grid gap-1 text-xs [&_dd]:text-muted-foreground [&_div]:flex [&_div]:gap-2 [&_dt]:w-24 [&_dt]:shrink-0 [&_dt]:text-muted-foreground", children: Object.entries(l.setup).map(([k, v]) => /* @__PURE__ */ jsxs3("div", { children: [
1014
+ /* @__PURE__ */ jsx5("dt", { children: k }),
1015
+ /* @__PURE__ */ jsx5("dd", { children: typeof v === "string" ? v : JSON.stringify(v) })
784
1016
  ] }, k)) })
785
1017
  ]
786
1018
  },
@@ -789,38 +1021,38 @@ function Layouts(_) {
789
1021
  ] });
790
1022
  }
791
1023
  function Marks(_) {
792
- const [marks, setMarks] = useState2([]);
793
- const refresh = useCallback2(() => void call("GET", "/api/marks").then(setMarks), []);
794
- useEffect3(refresh, [refresh]);
1024
+ const [marks, setMarks] = useState3([]);
1025
+ const refresh = useCallback3(() => void call("GET", "/api/marks").then(setMarks), []);
1026
+ useEffect4(refresh, [refresh]);
795
1027
  useEvent("marks.changed", refresh);
796
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-3 p-4", children: [
797
- /* @__PURE__ */ jsx4("p", { className: "text-muted-foreground", children: "Marks are notes pinned to a part of something, by you or the agent. These are the open ones, across every module." }),
798
- marks.length === 0 && /* @__PURE__ */ jsx4("p", { className: "text-muted-foreground text-xs", children: "No open marks." }),
799
- marks.map((m) => /* @__PURE__ */ jsx4(MarkCard, { mark: m }, m.id))
1028
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3 p-4", children: [
1029
+ /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: "Marks are notes pinned to a part of something, by you or the agent. These are the open ones, across every module." }),
1030
+ marks.length === 0 && /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground text-xs", children: "No open marks." }),
1031
+ marks.map((m) => /* @__PURE__ */ jsx5(MarkCard, { mark: m }, m.id))
800
1032
  ] });
801
1033
  }
802
1034
  function MarkCard({ mark }) {
803
- const [reply, setReply] = useState2("");
804
- return /* @__PURE__ */ jsxs2(
1035
+ const [reply, setReply] = useState3("");
1036
+ return /* @__PURE__ */ jsxs3(
805
1037
  "div",
806
1038
  {
807
1039
  className: "flex flex-col gap-2 rounded-lg border bg-card p-3 data-[author=agent]:border-l-2 data-[author=agent]:border-l-primary",
808
1040
  "data-author": mark.author,
809
1041
  children: [
810
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
811
- /* @__PURE__ */ jsx4(Icon, { name: mark.author === "agent" ? "bot" : "user", size: 14 }),
812
- /* @__PURE__ */ jsx4("code", { className: "truncate font-mono text-muted-foreground text-xs", title: mark.ref, children: mark.ref }),
813
- /* @__PURE__ */ jsx4("span", { className: "flex-1" }),
814
- /* @__PURE__ */ jsx4(Button2, { variant: "link", size: "xs", onClick: () => void resolveMark(mark.id), children: "resolve" })
1042
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
1043
+ /* @__PURE__ */ jsx5(Icon, { name: mark.author === "agent" ? "bot" : "user", size: 14 }),
1044
+ /* @__PURE__ */ jsx5("code", { className: "truncate font-mono text-muted-foreground text-xs", title: mark.ref, children: mark.ref }),
1045
+ /* @__PURE__ */ jsx5("span", { className: "flex-1" }),
1046
+ /* @__PURE__ */ jsx5(Button3, { variant: "link", size: "xs", onClick: () => void resolveMark(mark.id), children: "resolve" })
815
1047
  ] }),
816
- mark.quote && /* @__PURE__ */ jsx4("blockquote", { className: "border-l-2 pl-2.5 text-muted-foreground italic", children: mark.quote }),
817
- /* @__PURE__ */ jsx4("p", { children: mark.body }),
818
- mark.replies?.map((r) => /* @__PURE__ */ jsxs2("p", { className: "flex items-center gap-1.5 pl-2 text-muted-foreground", children: [
819
- /* @__PURE__ */ jsx4(Icon, { name: r.author === "agent" ? "bot" : "user", size: 12 }),
1048
+ mark.quote && /* @__PURE__ */ jsx5("blockquote", { className: "border-l-2 pl-2.5 text-muted-foreground italic", children: mark.quote }),
1049
+ /* @__PURE__ */ jsx5("p", { children: mark.body }),
1050
+ mark.replies?.map((r) => /* @__PURE__ */ jsxs3("p", { className: "flex items-center gap-1.5 pl-2 text-muted-foreground", children: [
1051
+ /* @__PURE__ */ jsx5(Icon, { name: r.author === "agent" ? "bot" : "user", size: 12 }),
820
1052
  " ",
821
1053
  r.body
822
1054
  ] }, r.created + r.body)),
823
- /* @__PURE__ */ jsx4(
1055
+ /* @__PURE__ */ jsx5(
824
1056
  "form",
825
1057
  {
826
1058
  className: "flex items-center gap-2",
@@ -828,7 +1060,7 @@ function MarkCard({ mark }) {
828
1060
  e.preventDefault();
829
1061
  if (reply.trim()) void replyMark(mark.id, reply.trim()).then(() => setReply(""));
830
1062
  },
831
- children: /* @__PURE__ */ jsx4(Input, { className: "flex-1", placeholder: "Reply\u2026", value: reply, onChange: (e) => setReply(e.target.value) })
1063
+ children: /* @__PURE__ */ jsx5(Input, { className: "flex-1", placeholder: "Reply\u2026", value: reply, onChange: (e) => setReply(e.target.value) })
832
1064
  }
833
1065
  )
834
1066
  ]
@@ -840,28 +1072,30 @@ var coreWeb = {
840
1072
  "surface/settings": Settings,
841
1073
  "surface/layouts": Layouts,
842
1074
  "surface/marks": Marks,
843
- "surface/cards": CardsWindow
1075
+ "surface/cards": CardsWindow,
1076
+ "surface/context": ContextInspector
844
1077
  }
845
1078
  };
846
1079
 
847
1080
  // ../../web/src/desk/Desktop.tsx
848
- import { Component as Component2, useCallback as useCallback4, useEffect as useEffect8, useMemo as useMemo4, useState as useState7 } from "react";
1081
+ import { applyPalette, DEFAULT_PALETTE as DEFAULT_PALETTE2, paletteById as paletteById2 } from "@hollis-labs/surface-theme";
1082
+ import { Component as Component2, useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo4, useRef, useState as useState10 } from "react";
849
1083
  import { AppFrame } from "@/components/ui/app-frame";
850
- import { Badge as Badge3 } from "@/components/ui/badge";
851
- import { Button as Button4 } from "@/components/ui/button";
1084
+ import { Badge as Badge4 } from "@/components/ui/badge";
1085
+ import { Button as Button7 } from "@/components/ui/button";
852
1086
  import {
853
- DropdownMenu,
854
- DropdownMenuContent,
1087
+ DropdownMenu as DropdownMenu2,
1088
+ DropdownMenuContent as DropdownMenuContent2,
855
1089
  DropdownMenuItem,
856
1090
  DropdownMenuShortcut,
857
- DropdownMenuTrigger
1091
+ DropdownMenuTrigger as DropdownMenuTrigger2
858
1092
  } from "@/components/ui/dropdown-menu";
859
- import { Empty as Empty2, EmptyDescription as EmptyDescription2, EmptyHeader as EmptyHeader2, EmptyTitle as EmptyTitle2 } from "@/components/ui/empty";
1093
+ import { Empty as Empty3, EmptyDescription as EmptyDescription3, EmptyHeader as EmptyHeader3, EmptyTitle as EmptyTitle3 } from "@/components/ui/empty";
860
1094
  import { Kbd } from "@/components/ui/kbd";
861
1095
  import { WindowManager } from "@/components/ui/window-manager";
862
1096
 
863
1097
  // ../../web/src/ade/Overlay.tsx
864
- import { useEffect as useEffect4, useState as useState3, useSyncExternalStore as useSyncExternalStore4 } from "react";
1098
+ import { useEffect as useEffect5, useState as useState4, useSyncExternalStore as useSyncExternalStore4 } from "react";
865
1099
  import { AttentionLayer } from "@/components/ui/attention-layer";
866
1100
  import { GuideBar } from "@/components/ui/guide-bar";
867
1101
 
@@ -882,8 +1116,8 @@ function windowRect(id) {
882
1116
  const body = document.querySelector(`[data-window="${CSS.escape(id)}"]`);
883
1117
  if (!rectOf(body)) return null;
884
1118
  const path = body?.closest(".flexlayout__tab")?.getAttribute("data-layout-path");
885
- const set = path ? document.querySelector(`.flexlayout__tabset[data-layout-path="${CSS.escape(path.replace(/\/t\d+$/, ""))}"]`) : null;
886
- return rectOf(set) ?? rectOf(body);
1119
+ const set2 = path ? document.querySelector(`.flexlayout__tabset[data-layout-path="${CSS.escape(path.replace(/\/t\d+$/, ""))}"]`) : null;
1120
+ return rectOf(set2) ?? rectOf(body);
887
1121
  }
888
1122
  var viewTitle = (view) => viewById(view)?.title ?? view;
889
1123
  function toGuide(g) {
@@ -934,8 +1168,8 @@ function applyGuide(g, report) {
934
1168
  }
935
1169
  const guide = toGuide(g);
936
1170
  if (report && report.guide === g.id && report.index > 0 && (report.status === "running" || report.status === "paused")) {
937
- const state2 = { guide, index: report.index, status: report.status, controller: "agent", history: [] };
938
- if (hub.restoreGuide(state2)) return;
1171
+ const state3 = { guide, index: report.index, status: report.status, controller: "agent", history: [] };
1172
+ if (hub.restoreGuide(state3)) return;
939
1173
  }
940
1174
  try {
941
1175
  hub.startGuide(guide, "agent");
@@ -1014,14 +1248,14 @@ var dismissAttention = () => {
1014
1248
  };
1015
1249
 
1016
1250
  // ../../web/src/ade/Overlay.tsx
1017
- import { jsx as jsx5 } from "react/jsx-runtime";
1251
+ import { jsx as jsx6 } from "react/jsx-runtime";
1018
1252
  var version2 = () => hub.getVersion();
1019
1253
  var subscribe3 = (fn) => hub.subscribe(fn);
1020
1254
  function useTick(on) {
1021
- const [, set] = useState3(0);
1022
- useEffect4(() => {
1255
+ const [, set2] = useState4(0);
1256
+ useEffect5(() => {
1023
1257
  if (!on) return;
1024
- const again = () => set((t) => t + 1);
1258
+ const again = () => set2((t) => t + 1);
1025
1259
  const timer = window.setInterval(again, 200);
1026
1260
  window.addEventListener("resize", again);
1027
1261
  window.addEventListener("scroll", again, true);
@@ -1044,13 +1278,13 @@ function marksOf(list2) {
1044
1278
  }));
1045
1279
  }
1046
1280
  function AdeAttention() {
1047
- useEffect4(startAde, []);
1281
+ useEffect5(startAde, []);
1048
1282
  useSyncExternalStore4(subscribe3, version2);
1049
1283
  const list2 = hub.attentionNow();
1050
1284
  useTick(list2.length > 0);
1051
1285
  const spot = list2.find((a) => a.style === "spotlight");
1052
1286
  const area = spot ? hub.bounds(spot.anchors[0]?.surface ?? "") : null;
1053
- return /* @__PURE__ */ jsx5(
1287
+ return /* @__PURE__ */ jsx6(
1054
1288
  AttentionLayer,
1055
1289
  {
1056
1290
  marks: marksOf(list2),
@@ -1067,7 +1301,7 @@ function AdeGuide() {
1067
1301
  if (!step) return null;
1068
1302
  const a = step.await;
1069
1303
  const wait = g.status === "done" || !a || a.kind === "ack" ? void 0 : a.kind === "state" && typeof a.args?.text === "string" ? a.args.text : "Do what the step asks.";
1070
- return /* @__PURE__ */ jsx5("div", { className: "pointer-events-none absolute inset-x-0 bottom-4 z-40 flex justify-center px-4", children: /* @__PURE__ */ jsx5(
1304
+ return /* @__PURE__ */ jsx6("div", { className: "pointer-events-none absolute inset-x-0 bottom-4 z-40 flex justify-center px-4", children: /* @__PURE__ */ jsx6(
1071
1305
  GuideBar,
1072
1306
  {
1073
1307
  className: "pointer-events-auto",
@@ -1088,18 +1322,11 @@ function AdeGuide() {
1088
1322
  }
1089
1323
 
1090
1324
  // ../../web/src/agent/AgentPanel.tsx
1091
- import {
1092
- createChatStore,
1093
- useChat,
1094
- useChatBusy,
1095
- useChatIds,
1096
- useChatItem,
1097
- useStickToBottom
1098
- } from "@hollis-labs/surface-chat";
1325
+ import { useChat, useChatBusy, useChatIds, useChatItem, useStickToBottom } from "@hollis-labs/surface-chat";
1099
1326
  import { Bot, Check, ChevronDown, ChevronUp, Copy } from "lucide-react";
1100
- import { memo, useCallback as useCallback3, useEffect as useEffect5, useLayoutEffect, useMemo as useMemo3, useState as useState4 } from "react";
1101
- import { Badge as Badge2 } from "@/components/ui/badge";
1102
- import { Button as Button3 } from "@/components/ui/button";
1327
+ import { memo, useCallback as useCallback4, useEffect as useEffect6, useLayoutEffect, useMemo as useMemo3, useState as useState5 } from "react";
1328
+ import { Badge as Badge3 } from "@/components/ui/badge";
1329
+ import { Button as Button4 } from "@/components/ui/button";
1103
1330
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
1104
1331
  import {
1105
1332
  Conversation,
@@ -1108,7 +1335,7 @@ import {
1108
1335
  ConversationScrollButton,
1109
1336
  ConversationViewport
1110
1337
  } from "@/components/ui/conversation";
1111
- import { Item, ItemContent, ItemDescription, ItemFooter, ItemTitle } from "@/components/ui/item";
1338
+ import { Item as Item2, ItemContent as ItemContent2, ItemDescription as ItemDescription2, ItemFooter, ItemTitle as ItemTitle2 } from "@/components/ui/item";
1112
1339
  import { Label } from "@/components/ui/label";
1113
1340
  import { MessageNotice as MessageNotice2 } from "@/components/ui/message";
1114
1341
  import { PromptInput, PromptInputFooter, PromptInputSubmit, PromptInputTextarea } from "@/components/ui/prompt-input";
@@ -1146,7 +1373,7 @@ import { Markdown } from "@/components/ui/markdown";
1146
1373
  import { Message, MessageContent, MessageNotice } from "@/components/ui/message";
1147
1374
  import { Spinner } from "@/components/ui/spinner";
1148
1375
  import { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput } from "@/components/ui/tool";
1149
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1376
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1150
1377
  function AskedCard({ item }) {
1151
1378
  const input = item.input ?? {};
1152
1379
  let result = {};
@@ -1155,10 +1382,10 @@ function AskedCard({ item }) {
1155
1382
  } catch {
1156
1383
  }
1157
1384
  const live = useCard(result.id ?? "");
1158
- if (item.status === "error") return /* @__PURE__ */ jsx6(ToolRow, { item });
1385
+ if (item.status === "error") return /* @__PURE__ */ jsx7(ToolRow, { item });
1159
1386
  if (item.status === "running" || !input.kind) {
1160
- return /* @__PURE__ */ jsxs3(MessageNotice, { className: "flex items-center gap-1.5", children: [
1161
- /* @__PURE__ */ jsx6(Spinner, { className: "size-3" }),
1387
+ return /* @__PURE__ */ jsxs4(MessageNotice, { className: "flex items-center gap-1.5", children: [
1388
+ /* @__PURE__ */ jsx7(Spinner, { className: "size-3" }),
1162
1389
  " Waiting on your answer",
1163
1390
  input.title ? `: ${input.title}` : ""
1164
1391
  ] });
@@ -1172,13 +1399,13 @@ function AskedCard({ item }) {
1172
1399
  status: result.status || "submitted",
1173
1400
  outcome: result.status === "submitted" ? { status: "submitted", data: result.data, answers: result.answers, decisions: result.decisions } : void 0
1174
1401
  };
1175
- return /* @__PURE__ */ jsx6(CardView, { card });
1402
+ return /* @__PURE__ */ jsx7(CardView, { card });
1176
1403
  }
1177
1404
  function ShownCard({ item }) {
1178
1405
  const input = item.input ?? {};
1179
- if (item.status === "error") return /* @__PURE__ */ jsx6(ToolRow, { item });
1406
+ if (item.status === "error") return /* @__PURE__ */ jsx7(ToolRow, { item });
1180
1407
  const what = item.name === "card_update" ? input.end ? "Closed a card" : "Updated a card" : `Showed a ${input.kind ?? ""} card`;
1181
- return /* @__PURE__ */ jsxs3(MessageNotice, { children: [
1408
+ return /* @__PURE__ */ jsxs4(MessageNotice, { children: [
1182
1409
  what,
1183
1410
  input.title ? `: ${input.title}` : ""
1184
1411
  ] });
@@ -1191,17 +1418,17 @@ function GeneratedSurface({ item }) {
1191
1418
  } catch {
1192
1419
  }
1193
1420
  const live = useCard(result.id ?? "");
1194
- if (item.status === "error") return /* @__PURE__ */ jsx6(ToolRow, { item });
1421
+ if (item.status === "error") return /* @__PURE__ */ jsx7(ToolRow, { item });
1195
1422
  const title = input.params?.title;
1196
1423
  if (item.status === "running") {
1197
- return /* @__PURE__ */ jsxs3(MessageNotice, { className: "flex items-center gap-1.5", children: [
1198
- /* @__PURE__ */ jsx6(Spinner, { className: "size-3" }),
1424
+ return /* @__PURE__ */ jsxs4(MessageNotice, { className: "flex items-center gap-1.5", children: [
1425
+ /* @__PURE__ */ jsx7(Spinner, { className: "size-3" }),
1199
1426
  " Showing you",
1200
1427
  title ? `: ${title}` : " something"
1201
1428
  ] });
1202
1429
  }
1203
- if (live) return /* @__PURE__ */ jsx6(CardView, { card: live });
1204
- return /* @__PURE__ */ jsxs3(MessageNotice, { children: [
1430
+ if (live) return /* @__PURE__ */ jsx7(CardView, { card: live });
1431
+ return /* @__PURE__ */ jsxs4(MessageNotice, { children: [
1205
1432
  "Showed you",
1206
1433
  title ? `: ${title}` : " a generated surface",
1207
1434
  result.status ? ` (${result.status})` : ""
@@ -1214,37 +1441,116 @@ var toolCards = {
1214
1441
  genui_show: GeneratedSurface
1215
1442
  };
1216
1443
  function ToolRow({ item }) {
1217
- return /* @__PURE__ */ jsxs3(Tool, { children: [
1218
- /* @__PURE__ */ jsx6(ToolHeader, { title: item.name, status: item.status }),
1219
- /* @__PURE__ */ jsxs3(ToolContent, { children: [
1220
- /* @__PURE__ */ jsx6(ToolInput, { input: item.input }),
1221
- /* @__PURE__ */ jsx6(ToolOutput, { output: item.result, error: item.status === "error" })
1444
+ return /* @__PURE__ */ jsxs4(Tool, { children: [
1445
+ /* @__PURE__ */ jsx7(ToolHeader, { title: item.name, status: item.status }),
1446
+ /* @__PURE__ */ jsxs4(ToolContent, { children: [
1447
+ /* @__PURE__ */ jsx7(ToolInput, { input: item.input }),
1448
+ /* @__PURE__ */ jsx7(ToolOutput, { output: item.result, error: item.status === "error" })
1222
1449
  ] })
1223
1450
  ] });
1224
1451
  }
1225
1452
  var renderers = {
1226
- user: ({ item }) => item.auto ? /* @__PURE__ */ jsx6(MessageNotice, { children: item.auto }) : /* @__PURE__ */ jsx6(Message, { from: "user", children: /* @__PURE__ */ jsx6(MessageContent, { children: item.text }) }),
1227
- text: ({ item }) => item.text ? /* @__PURE__ */ jsx6(Message, { from: "assistant", children: /* @__PURE__ */ jsx6(MessageContent, { children: /* @__PURE__ */ jsx6(Markdown, { streaming: item.streaming, children: item.text }) }) }) : item.streaming ? /* @__PURE__ */ jsxs3(MessageNotice, { className: "flex items-center gap-1.5", children: [
1228
- /* @__PURE__ */ jsx6(Spinner, { className: "size-3" }),
1453
+ user: ({ item }) => item.auto ? /* @__PURE__ */ jsx7(MessageNotice, { children: item.auto }) : /* @__PURE__ */ jsx7(Message, { from: "user", children: /* @__PURE__ */ jsx7(MessageContent, { children: item.text }) }),
1454
+ text: ({ item }) => item.text ? /* @__PURE__ */ jsx7(Message, { from: "assistant", children: /* @__PURE__ */ jsx7(MessageContent, { children: /* @__PURE__ */ jsx7(Markdown, { streaming: item.streaming, children: item.text }) }) }) : item.streaming ? /* @__PURE__ */ jsxs4(MessageNotice, { className: "flex items-center gap-1.5", children: [
1455
+ /* @__PURE__ */ jsx7(Spinner, { className: "size-3" }),
1229
1456
  " Writing\u2026"
1230
1457
  ] }) : null,
1231
1458
  tool: ({ item }) => {
1232
1459
  const Card2 = toolCards[item.name] ?? ToolRow;
1233
- return /* @__PURE__ */ jsx6(Card2, { item });
1460
+ return /* @__PURE__ */ jsx7(Card2, { item });
1234
1461
  },
1235
- notice: ({ item }) => /* @__PURE__ */ jsx6(MessageNotice, { tone: item.tone, children: item.text })
1462
+ notice: ({ item }) => /* @__PURE__ */ jsx7(MessageNotice, { tone: item.tone, children: item.text })
1236
1463
  };
1237
1464
  function ItemView({ item }) {
1238
1465
  const Draw = renderers[item.kind];
1239
- return /* @__PURE__ */ jsx6(Draw, { item });
1466
+ return /* @__PURE__ */ jsx7(Draw, { item });
1467
+ }
1468
+
1469
+ // ../../web/src/agent/session.ts
1470
+ import {
1471
+ createChatStore,
1472
+ createConversationStore,
1473
+ initialState
1474
+ } from "@hollis-labs/surface-chat";
1475
+ var BASE = "/api/agent";
1476
+ function mode() {
1477
+ const want = typeof location === "undefined" ? "" : new URLSearchParams(location.search).get("chat") ?? "";
1478
+ return { role: want === "viewer" ? "viewer" : "controller", stream: want === "committed" ? "committed" : "deltas" };
1479
+ }
1480
+ function createAgentSession() {
1481
+ let run = null;
1482
+ let conv = null;
1483
+ const inner = () => conv ?? run;
1484
+ const listeners = /* @__PURE__ */ new Set();
1485
+ const ends = /* @__PURE__ */ new Set();
1486
+ const tell = () => {
1487
+ for (const fn of [...listeners]) fn();
1488
+ };
1489
+ const { role, stream } = mode();
1490
+ const boot = agentApi.setup().catch(() => null).then((setup) => {
1491
+ if (setup?.wire === "conversation" && setup.agent) {
1492
+ conv = createConversationStore({
1493
+ base: BASE,
1494
+ agent: setup.agent,
1495
+ role,
1496
+ stream,
1497
+ hostState: async () => ({ available: true, ready: setup.ready, model: setup.model })
1498
+ });
1499
+ } else {
1500
+ run = createChatStore({ base: BASE });
1501
+ }
1502
+ if (conv) {
1503
+ const leaving = conv;
1504
+ window.addEventListener("pagehide", () => leaving.dispose(), { once: true });
1505
+ }
1506
+ const store = inner();
1507
+ store.subscribe(tell);
1508
+ store.onRunEnd((id, how) => {
1509
+ for (const fn of [...ends]) fn(id, how);
1510
+ });
1511
+ tell();
1512
+ return store.start();
1513
+ });
1514
+ return {
1515
+ get: () => inner()?.get() ?? initialState,
1516
+ subscribe: (fn) => {
1517
+ listeners.add(fn);
1518
+ return () => {
1519
+ listeners.delete(fn);
1520
+ };
1521
+ },
1522
+ start: () => boot,
1523
+ send: async (text, how) => {
1524
+ await boot;
1525
+ return inner().send(text, how);
1526
+ },
1527
+ stop: () => inner()?.stop(),
1528
+ answer: async (decision) => {
1529
+ await inner()?.answer(decision);
1530
+ },
1531
+ newThread: async () => {
1532
+ await inner()?.newThread();
1533
+ },
1534
+ turnElsewhere: (id) => inner()?.turnElsewhere(id),
1535
+ onRunEnd: (fn) => {
1536
+ ends.add(fn);
1537
+ return () => {
1538
+ ends.delete(fn);
1539
+ };
1540
+ },
1541
+ durable: () => conv !== null,
1542
+ attachment: () => conv?.attachment() ?? "",
1543
+ role: () => conv ? conv.role() : "controller",
1544
+ takeover: async () => conv ? conv.takeover() : false
1545
+ };
1240
1546
  }
1241
1547
 
1242
1548
  // ../../web/src/agent/AgentPanel.tsx
1243
- import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1549
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1244
1550
  var shared = null;
1245
1551
  function agentSession() {
1246
1552
  if (!shared) {
1247
- shared = createChatStore({ base: "/api/agent" });
1553
+ shared = createAgentSession();
1248
1554
  void shared.start();
1249
1555
  }
1250
1556
  return shared;
@@ -1263,27 +1569,28 @@ function AgentPanel({ title = "Agent" }) {
1263
1569
  "agent.turn",
1264
1570
  (ev) => store.turnElsewhere(String(ev.data?.run_id ?? ""))
1265
1571
  );
1266
- return /* @__PURE__ */ jsxs4("div", { className: "flex h-full min-h-0 flex-col bg-background text-foreground", children: [
1267
- /* @__PURE__ */ jsx7(ContextStrip, { store }),
1268
- /* @__PURE__ */ jsx7(ChatHeader, { store, title }),
1269
- /* @__PURE__ */ jsx7(Thread, { store }),
1270
- /* @__PURE__ */ jsx7(CardDock, {}),
1271
- /* @__PURE__ */ jsx7(ApprovalBar, { store }),
1272
- /* @__PURE__ */ jsx7(Composer, { store })
1572
+ return /* @__PURE__ */ jsxs5("div", { className: "flex h-full min-h-0 flex-col bg-background text-foreground", children: [
1573
+ /* @__PURE__ */ jsx8(ContextStrip, { store }),
1574
+ /* @__PURE__ */ jsx8(ChatHeader, { store, title }),
1575
+ /* @__PURE__ */ jsx8(Thread, { store }),
1576
+ /* @__PURE__ */ jsx8(CardDock, {}),
1577
+ /* @__PURE__ */ jsx8(ApprovalBar, { store }),
1578
+ /* @__PURE__ */ jsx8(InputHolder, { store }),
1579
+ /* @__PURE__ */ jsx8(Composer, { store })
1273
1580
  ] });
1274
1581
  }
1275
1582
  function ContextStrip({ store }) {
1276
- const [asm, setAsm] = useState4(null);
1277
- const [setup, setSetup] = useState4(null);
1278
- const [slots, setSlots] = useState4([]);
1279
- const [open, setOpen] = useState4(false);
1280
- const [err, setErr] = useState4("");
1281
- const refresh = useCallback3(() => {
1583
+ const [asm, setAsm] = useState5(null);
1584
+ const [setup, setSetup] = useState5(null);
1585
+ const [slots, setSlots] = useState5([]);
1586
+ const [open, setOpen] = useState5(false);
1587
+ const [err, setErr] = useState5("");
1588
+ const refresh = useCallback4(() => {
1282
1589
  agentApi.context().then(setAsm, (e) => setErr(e.message));
1283
1590
  agentApi.slots().then(setSlots, () => {
1284
1591
  });
1285
1592
  }, []);
1286
- useEffect5(() => {
1593
+ useEffect6(() => {
1287
1594
  refresh();
1288
1595
  agentApi.setup().then(setSetup, () => {
1289
1596
  });
@@ -1291,46 +1598,46 @@ function ContextStrip({ store }) {
1291
1598
  useEvent("agent.context", (ev) => setAsm(ev.data));
1292
1599
  useEvent("agent.note", refresh);
1293
1600
  useEvent("agent.turn", refresh);
1294
- useEffect5(() => store.onRunEnd(() => refresh()), [store, refresh]);
1601
+ useEffect6(() => store.onRunEnd(() => refresh()), [store, refresh]);
1295
1602
  const pin = (name) => agentApi.pin(name).then(setAsm, (e) => setErr(e.message));
1296
1603
  const top = asm?.top_of_mind ?? [];
1297
1604
  const why = asm?.why === "pinned" ? "pinned" : asm?.focused ? `from ${asm.focused.title}` : "";
1298
- return /* @__PURE__ */ jsxs4(
1605
+ return /* @__PURE__ */ jsxs5(
1299
1606
  "section",
1300
1607
  {
1301
1608
  className: "flex flex-col gap-1.5 border-b border-border px-2.5 py-2 text-xs",
1302
1609
  "aria-label": "What the agent has in mind",
1303
1610
  children: [
1304
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-2", children: [
1305
- /* @__PURE__ */ jsx7(Label, { htmlFor: "agent-slot", children: "Slot" }),
1306
- /* @__PURE__ */ jsxs4(
1611
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-2", children: [
1612
+ /* @__PURE__ */ jsx8(Label, { htmlFor: "agent-slot", children: "Slot" }),
1613
+ /* @__PURE__ */ jsxs5(
1307
1614
  Select2,
1308
1615
  {
1309
1616
  value: asm?.slot ?? null,
1310
1617
  onValueChange: (v) => void pin(String(v ?? "")),
1311
1618
  items: slots.map((s) => ({ value: s.name, label: s.name })),
1312
1619
  children: [
1313
- /* @__PURE__ */ jsx7(SelectTrigger2, { id: "agent-slot", size: "sm", title: asm ? `${asm.slots[0]?.about ?? ""} (${asm.why})` : "", children: /* @__PURE__ */ jsx7(SelectValue2, {}) }),
1314
- /* @__PURE__ */ jsx7(SelectContent2, { children: slots.map((s) => /* @__PURE__ */ jsx7(SelectItem2, { value: s.name, children: s.name }, s.name)) })
1620
+ /* @__PURE__ */ jsx8(SelectTrigger2, { id: "agent-slot", size: "sm", title: asm ? `${asm.slots[0]?.about ?? ""} (${asm.why})` : "", children: /* @__PURE__ */ jsx8(SelectValue2, {}) }),
1621
+ /* @__PURE__ */ jsx8(SelectContent2, { children: slots.map((s) => /* @__PURE__ */ jsx8(SelectItem2, { value: s.name, children: s.name }, s.name)) })
1315
1622
  ]
1316
1623
  }
1317
1624
  ),
1318
- /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate text-muted-foreground", children: why }),
1319
- asm?.why === "pinned" && /* @__PURE__ */ jsx7(Button3, { variant: "link", size: "xs", onClick: () => void pin(""), children: "unpin" }),
1320
- /* @__PURE__ */ jsxs4(Button3, { variant: "ghost", size: "xs", "aria-expanded": open, onClick: () => setOpen(!open), children: [
1321
- open ? /* @__PURE__ */ jsx7(ChevronUp, {}) : /* @__PURE__ */ jsx7(ChevronDown, {}),
1625
+ /* @__PURE__ */ jsx8("span", { className: "min-w-0 flex-1 truncate text-muted-foreground", children: why }),
1626
+ asm?.why === "pinned" && /* @__PURE__ */ jsx8(Button4, { variant: "link", size: "xs", onClick: () => void pin(""), children: "unpin" }),
1627
+ /* @__PURE__ */ jsxs5(Button4, { variant: "ghost", size: "xs", "aria-expanded": open, onClick: () => setOpen(!open), children: [
1628
+ open ? /* @__PURE__ */ jsx8(ChevronUp, {}) : /* @__PURE__ */ jsx8(ChevronDown, {}),
1322
1629
  "context"
1323
1630
  ] })
1324
1631
  ] }),
1325
- asm && asm.slots.length > 1 && /* @__PURE__ */ jsxs4("div", { className: "text-muted-foreground", children: [
1632
+ asm && asm.slots.length > 1 && /* @__PURE__ */ jsxs5("div", { className: "text-muted-foreground", children: [
1326
1633
  "also:",
1327
1634
  " ",
1328
1635
  asm.slots.slice(1).map((s) => s.name).join(", ")
1329
1636
  ] }),
1330
- top.length > 0 && /* @__PURE__ */ jsx7("div", { className: "flex flex-wrap gap-1", title: "Top of mind", children: top.map((t) => /* @__PURE__ */ jsx7(Badge2, { variant: "secondary", className: "font-mono", children: t }, t)) }),
1331
- open && asm && /* @__PURE__ */ jsx7("pre", { className: "m-0 max-h-[40vh] overflow-auto rounded-md bg-muted p-2 font-mono break-words whitespace-pre-wrap", children: asm.block }),
1332
- setup && !setup.ready && /* @__PURE__ */ jsx7(SetupCard, { path: setup.config_path, reason: setup.reason }),
1333
- err && /* @__PURE__ */ jsx7("div", { className: "text-destructive", children: err })
1637
+ top.length > 0 && /* @__PURE__ */ jsx8("div", { className: "flex flex-wrap gap-1", title: "Top of mind", children: top.map((t) => /* @__PURE__ */ jsx8(Badge3, { variant: "secondary", className: "font-mono", children: t }, t)) }),
1638
+ open && asm && /* @__PURE__ */ jsx8("pre", { className: "m-0 max-h-[40vh] overflow-auto rounded-md bg-muted p-2 font-mono break-words whitespace-pre-wrap", children: asm.block }),
1639
+ setup && !setup.ready && /* @__PURE__ */ jsx8(SetupCard, { path: setup.config_path, reason: setup.reason }),
1640
+ err && /* @__PURE__ */ jsx8("div", { className: "text-destructive", children: err })
1334
1641
  ]
1335
1642
  }
1336
1643
  );
@@ -1339,10 +1646,10 @@ function ChatHeader({ store, title }) {
1339
1646
  const busy = useChatBusy(store);
1340
1647
  const model = useChat(store, (s) => s.host?.model ?? "");
1341
1648
  const empty = useChat(store, (s) => s.ids.length === 0);
1342
- return /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 border-b border-border px-2.5 py-1.5", children: [
1343
- /* @__PURE__ */ jsx7("span", { className: "text-sm font-semibold", children: title }),
1344
- /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: busy ? "working\u2026" : model }),
1345
- /* @__PURE__ */ jsx7(Button3, { variant: "ghost", size: "xs", disabled: busy || empty, onClick: () => void store.newThread(), children: "New" })
1649
+ return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 border-b border-border px-2.5 py-1.5", children: [
1650
+ /* @__PURE__ */ jsx8("span", { className: "text-sm font-semibold", children: title }),
1651
+ /* @__PURE__ */ jsx8("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: busy ? "working\u2026" : model }),
1652
+ /* @__PURE__ */ jsx8(Button4, { variant: "ghost", size: "xs", disabled: busy || empty, onClick: () => void store.newThread(), children: "New" })
1346
1653
  ] });
1347
1654
  }
1348
1655
  var Thread = memo(function Thread2({ store }) {
@@ -1351,49 +1658,66 @@ var Thread = memo(function Thread2({ store }) {
1351
1658
  const error = useChat(store, (s) => s.error);
1352
1659
  const { viewportRef, contentRef, atBottom, scrollToBottom } = useStickToBottom();
1353
1660
  useCommits("thread");
1354
- return /* @__PURE__ */ jsxs4(Conversation, { children: [
1355
- /* @__PURE__ */ jsx7(ConversationViewport, { ref: viewportRef, children: /* @__PURE__ */ jsxs4(ConversationContent, { ref: contentRef, children: [
1356
- off && /* @__PURE__ */ jsx7(MessageNotice2, { children: "No model is connected. The desk still works by hand." }),
1357
- !off && ids.length === 0 && /* @__PURE__ */ jsx7(
1661
+ return /* @__PURE__ */ jsxs5(Conversation, { children: [
1662
+ /* @__PURE__ */ jsx8(ConversationViewport, { ref: viewportRef, children: /* @__PURE__ */ jsxs5(ConversationContent, { ref: contentRef, children: [
1663
+ off && /* @__PURE__ */ jsx8(MessageNotice2, { children: "No model is connected. The desk still works by hand." }),
1664
+ !off && ids.length === 0 && /* @__PURE__ */ jsx8(
1358
1665
  ConversationEmptyState,
1359
1666
  {
1360
- icon: /* @__PURE__ */ jsx7(Bot, {}),
1667
+ icon: /* @__PURE__ */ jsx8(Bot, {}),
1361
1668
  title: "Ask the agent",
1362
1669
  description: "It sees the window in front and can work the desk for you."
1363
1670
  }
1364
1671
  ),
1365
- ids.map((id) => /* @__PURE__ */ jsx7(Row, { store, id }, id)),
1366
- error && /* @__PURE__ */ jsx7(MessageNotice2, { tone: "error", children: error })
1672
+ ids.map((id) => /* @__PURE__ */ jsx8(Row2, { store, id }, id)),
1673
+ error && /* @__PURE__ */ jsx8(MessageNotice2, { tone: "error", children: error })
1367
1674
  ] }) }),
1368
- !atBottom && /* @__PURE__ */ jsx7(ConversationScrollButton, { onClick: scrollToBottom })
1675
+ !atBottom && /* @__PURE__ */ jsx8(ConversationScrollButton, { onClick: scrollToBottom })
1369
1676
  ] });
1370
1677
  });
1371
- var Row = memo(function Row2({ store, id }) {
1678
+ var Row2 = memo(function Row3({ store, id }) {
1372
1679
  const item = useChatItem(store, id);
1373
1680
  useCommits(`row:${id}`);
1374
- return item ? /* @__PURE__ */ jsx7(ItemView, { item }) : null;
1681
+ return item ? /* @__PURE__ */ jsx8(ItemView, { item }) : null;
1375
1682
  });
1683
+ function InputHolder({ store }) {
1684
+ const holder = useChat(store, (s) => s.holder ?? null);
1685
+ useChat(store, (s) => s.error);
1686
+ useChat(store, (s) => s.loaded);
1687
+ if (!store.durable()) return null;
1688
+ const mine = store.attachment();
1689
+ const watching = store.role() === "viewer";
1690
+ const elsewhere = holder !== null && holder !== mine;
1691
+ if (!watching && !elsewhere) return null;
1692
+ return /* @__PURE__ */ jsx8("div", { role: "status", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs5(Item2, { variant: "muted", size: "sm", children: [
1693
+ /* @__PURE__ */ jsxs5(ItemContent2, { className: "min-w-0", children: [
1694
+ /* @__PURE__ */ jsx8(ItemTitle2, { children: elsewhere ? "Another window has the input" : "This window is watching" }),
1695
+ /* @__PURE__ */ jsx8(ItemDescription2, { className: "text-xs", children: watching ? "It shows the conversation. Take over to type here." : "What you send here is refused until you take over." })
1696
+ ] }),
1697
+ /* @__PURE__ */ jsx8(ItemFooter, { className: "justify-start", children: /* @__PURE__ */ jsx8(Button4, { variant: "outline", size: "xs", onClick: () => void store.takeover(), children: "Take over" }) })
1698
+ ] }) });
1699
+ }
1376
1700
  function ApprovalBar({ store }) {
1377
1701
  const q = useChat(store, (s) => s.approval);
1378
1702
  if (!q) return null;
1379
1703
  const input = q.input === void 0 ? "" : JSON.stringify(q.input);
1380
- return /* @__PURE__ */ jsx7("div", { role: "alertdialog", "aria-label": "Permission", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs4(Item, { variant: "outline", size: "sm", children: [
1381
- /* @__PURE__ */ jsxs4(ItemContent, { className: "min-w-0", children: [
1382
- /* @__PURE__ */ jsx7(ItemTitle, { children: q.description || `Allow ${q.tool}?` }),
1383
- !q.description && input && /* @__PURE__ */ jsx7(ItemDescription, { className: "font-mono text-xs", children: input })
1704
+ return /* @__PURE__ */ jsx8("div", { role: "alertdialog", "aria-label": "Permission", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs5(Item2, { variant: "outline", size: "sm", children: [
1705
+ /* @__PURE__ */ jsxs5(ItemContent2, { className: "min-w-0", children: [
1706
+ /* @__PURE__ */ jsx8(ItemTitle2, { children: q.description || `Allow ${q.tool}?` }),
1707
+ !q.description && input && /* @__PURE__ */ jsx8(ItemDescription2, { className: "font-mono text-xs", children: input })
1384
1708
  ] }),
1385
- /* @__PURE__ */ jsxs4(ItemFooter, { className: "flex-wrap justify-start", children: [
1386
- /* @__PURE__ */ jsx7(Button3, { size: "xs", onClick: () => void store.answer("once"), children: "Allow" }),
1387
- q.standing && /* @__PURE__ */ jsxs4(Fragment2, { children: [
1388
- /* @__PURE__ */ jsx7(Button3, { variant: "outline", size: "xs", onClick: () => void store.answer("session"), children: "This session" }),
1389
- /* @__PURE__ */ jsx7(Button3, { variant: "outline", size: "xs", onClick: () => void store.answer("always"), children: "Always" })
1709
+ /* @__PURE__ */ jsxs5(ItemFooter, { className: "flex-wrap justify-start", children: [
1710
+ /* @__PURE__ */ jsx8(Button4, { size: "xs", onClick: () => void store.answer("once"), children: "Allow" }),
1711
+ q.standing && /* @__PURE__ */ jsxs5(Fragment3, { children: [
1712
+ /* @__PURE__ */ jsx8(Button4, { variant: "outline", size: "xs", onClick: () => void store.answer("session"), children: store.durable() ? "This conversation" : "This session" }),
1713
+ /* @__PURE__ */ jsx8(Button4, { variant: "outline", size: "xs", onClick: () => void store.answer("always"), children: "Always" })
1390
1714
  ] }),
1391
- /* @__PURE__ */ jsx7(Button3, { variant: "ghost", size: "xs", onClick: () => void store.answer("deny"), children: "Don't" })
1715
+ /* @__PURE__ */ jsx8(Button4, { variant: "ghost", size: "xs", onClick: () => void store.answer("deny"), children: "Don't" })
1392
1716
  ] })
1393
1717
  ] }) });
1394
1718
  }
1395
1719
  var Composer = memo(function Composer2({ store }) {
1396
- const [draft, setDraft] = useState4("");
1720
+ const [draft, setDraft] = useState5("");
1397
1721
  const busy = useChatBusy(store);
1398
1722
  useCommits("composer");
1399
1723
  const submit = (e) => {
@@ -1405,8 +1729,8 @@ var Composer = memo(function Composer2({ store }) {
1405
1729
  if (!ok) setDraft(text);
1406
1730
  });
1407
1731
  };
1408
- return /* @__PURE__ */ jsx7("div", { className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs4(PromptInput, { onSubmit: submit, children: [
1409
- /* @__PURE__ */ jsx7(
1732
+ return /* @__PURE__ */ jsx8("div", { className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs5(PromptInput, { onSubmit: submit, children: [
1733
+ /* @__PURE__ */ jsx8(
1410
1734
  PromptInputTextarea,
1411
1735
  {
1412
1736
  value: draft,
@@ -1415,9 +1739,9 @@ var Composer = memo(function Composer2({ store }) {
1415
1739
  onChange: (e) => setDraft(e.target.value)
1416
1740
  }
1417
1741
  ),
1418
- /* @__PURE__ */ jsxs4(PromptInputFooter, { children: [
1419
- /* @__PURE__ */ jsx7("span", { className: "text-xs text-muted-foreground", children: "Enter sends, Shift+Enter breaks the line" }),
1420
- /* @__PURE__ */ jsx7(
1742
+ /* @__PURE__ */ jsxs5(PromptInputFooter, { children: [
1743
+ /* @__PURE__ */ jsx8("span", { className: "text-xs text-muted-foreground", children: "Enter sends, Shift+Enter breaks the line" }),
1744
+ /* @__PURE__ */ jsx8(
1421
1745
  PromptInputSubmit,
1422
1746
  {
1423
1747
  status: busy ? "streaming" : "ready",
@@ -1434,7 +1758,7 @@ var example = (path) => `{
1434
1758
  "key_file": "${path.replace(/[^/]*$/, "") || "./"}agent-key"
1435
1759
  }`;
1436
1760
  function SetupCard({ path, reason }) {
1437
- const [copied, setCopied] = useState4(false);
1761
+ const [copied, setCopied] = useState5(false);
1438
1762
  const text = example(path);
1439
1763
  const copy = () => {
1440
1764
  void navigator.clipboard?.writeText(text).then(() => {
@@ -1442,69 +1766,57 @@ function SetupCard({ path, reason }) {
1442
1766
  setTimeout(() => setCopied(false), 1500);
1443
1767
  });
1444
1768
  };
1445
- return /* @__PURE__ */ jsxs4(Card, { size: "sm", children: [
1446
- /* @__PURE__ */ jsxs4(CardHeader, { children: [
1447
- /* @__PURE__ */ jsx7(CardTitle, { children: "The agent is not set up yet" }),
1448
- reason && /* @__PURE__ */ jsx7("p", { className: "text-sm text-destructive", children: reason }),
1449
- /* @__PURE__ */ jsxs4(CardDescription, { children: [
1769
+ return /* @__PURE__ */ jsxs5(Card, { size: "sm", children: [
1770
+ /* @__PURE__ */ jsxs5(CardHeader, { children: [
1771
+ /* @__PURE__ */ jsx8(CardTitle, { children: "The agent is not set up yet" }),
1772
+ reason && /* @__PURE__ */ jsx8("p", { className: "text-sm text-destructive", children: reason }),
1773
+ /* @__PURE__ */ jsxs5(CardDescription, { children: [
1450
1774
  "Everything else works by hand. To talk to the agent, write ",
1451
- /* @__PURE__ */ jsx7("code", { className: "break-all", children: path }),
1775
+ /* @__PURE__ */ jsx8("code", { className: "break-all", children: path }),
1452
1776
  ":"
1453
1777
  ] })
1454
1778
  ] }),
1455
- /* @__PURE__ */ jsxs4(CardContent, { className: "flex flex-col gap-2 text-muted-foreground", children: [
1456
- /* @__PURE__ */ jsx7("pre", { className: "m-0 overflow-x-auto rounded-md bg-muted p-2 font-mono text-xs text-foreground", children: text }),
1457
- /* @__PURE__ */ jsx7("p", { children: "The gateway is any Anthropic-compatible endpoint; the key file holds its key. Restart the app after writing it." })
1779
+ /* @__PURE__ */ jsxs5(CardContent, { className: "flex flex-col gap-2 text-muted-foreground", children: [
1780
+ /* @__PURE__ */ jsx8("pre", { className: "m-0 overflow-x-auto rounded-md bg-muted p-2 font-mono text-xs text-foreground", children: text }),
1781
+ /* @__PURE__ */ jsx8("p", { children: "The gateway is any Anthropic-compatible endpoint; the key file holds its key. Restart the app after writing it." })
1458
1782
  ] }),
1459
- /* @__PURE__ */ jsx7(CardFooter, { children: /* @__PURE__ */ jsxs4(Button3, { variant: "outline", size: "xs", onClick: copy, children: [
1460
- copied ? /* @__PURE__ */ jsx7(Check, {}) : /* @__PURE__ */ jsx7(Copy, {}),
1783
+ /* @__PURE__ */ jsx8(CardFooter, { children: /* @__PURE__ */ jsxs5(Button4, { variant: "outline", size: "xs", onClick: copy, children: [
1784
+ copied ? /* @__PURE__ */ jsx8(Check, {}) : /* @__PURE__ */ jsx8(Copy, {}),
1461
1785
  copied ? "Copied" : "Copy the example"
1462
1786
  ] }) })
1463
1787
  ] });
1464
1788
  }
1465
1789
 
1466
- // ../../web/src/desk/Confirm.tsx
1467
- import { useEffect as useEffect6, useState as useState5 } from "react";
1468
- import {
1469
- AlertDialog,
1470
- AlertDialogAction,
1471
- AlertDialogCancel,
1472
- AlertDialogContent,
1473
- AlertDialogDescription,
1474
- AlertDialogFooter,
1475
- AlertDialogHeader,
1476
- AlertDialogTitle
1477
- } from "@/components/ui/alert-dialog";
1478
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1479
- function ConfirmHost() {
1480
- const [q, setQ] = useState5(null);
1481
- useEffect6(() => {
1482
- setConfirm((question) => new Promise((resolve) => setQ({ ...question, resolve })));
1483
- }, []);
1484
- const answer2 = (yes) => {
1485
- q?.resolve(yes);
1486
- setQ(null);
1487
- };
1488
- return /* @__PURE__ */ jsx8(
1489
- AlertDialog,
1490
- {
1491
- open: !!q,
1492
- onOpenChange: (open) => {
1493
- if (!open) answer2(false);
1494
- },
1495
- children: /* @__PURE__ */ jsxs5(AlertDialogContent, { size: "sm", children: [
1496
- /* @__PURE__ */ jsxs5(AlertDialogHeader, { children: [
1497
- /* @__PURE__ */ jsx8(AlertDialogTitle, { children: q?.title }),
1498
- q?.message && /* @__PURE__ */ jsx8(AlertDialogDescription, { children: q.message })
1499
- ] }),
1500
- /* @__PURE__ */ jsxs5(AlertDialogFooter, { children: [
1501
- /* @__PURE__ */ jsx8(AlertDialogCancel, { children: "Cancel" }),
1502
- /* @__PURE__ */ jsx8(AlertDialogAction, { variant: q?.danger ? "destructive" : "default", onClick: () => answer2(true), children: q?.confirmLabel ?? "OK" })
1503
- ] })
1504
- ] })
1505
- }
1790
+ // ../../web/src/desk/AttentionBadge.tsx
1791
+ import { Button as Button5 } from "@/components/ui/button";
1792
+
1793
+ // ../../web/src/desk/attention.ts
1794
+ import { useSyncExternalStore as useSyncExternalStore5 } from "react";
1795
+ var state2 = { items: [], counts: {} };
1796
+ var subs3 = /* @__PURE__ */ new Set();
1797
+ var set = (a) => {
1798
+ state2 = { items: a?.items ?? [], counts: a?.counts ?? {} };
1799
+ for (const fn of subs3) fn();
1800
+ };
1801
+ var started3 = false;
1802
+ function start() {
1803
+ if (started3) return;
1804
+ started3 = true;
1805
+ void call("GET", "/api/attend").then(set).catch(() => {
1806
+ });
1807
+ onEvent("attend.changed", (ev) => set(ev.data));
1808
+ }
1809
+ function useAttention() {
1810
+ start();
1811
+ return useSyncExternalStore5(
1812
+ (fn) => {
1813
+ subs3.add(fn);
1814
+ return () => subs3.delete(fn);
1815
+ },
1816
+ () => state2
1506
1817
  );
1507
1818
  }
1819
+ var firstItem = (a) => a.items[0];
1508
1820
 
1509
1821
  // ../../web/src/desk/commands.ts
1510
1822
  var clientCommands = [
@@ -1527,8 +1839,30 @@ var clientCommands = [
1527
1839
  server: false
1528
1840
  },
1529
1841
  { id: "agent.ask", title: "Ask the agent", section: "Agent", hidden: true, module: "surface", server: false },
1530
- { id: "menu.toggle", title: "Apps menu", section: "System", hidden: true, module: "surface", server: false }
1842
+ { id: "menu.toggle", title: "Apps menu", section: "System", hidden: true, module: "surface", server: false },
1843
+ {
1844
+ id: "attention.jump",
1845
+ title: "Jump to what needs me",
1846
+ section: "System",
1847
+ keys: "cmd+.",
1848
+ keywords: "attention waiting unseen needs answer next",
1849
+ module: "surface",
1850
+ server: false
1851
+ }
1531
1852
  ];
1853
+ async function jumpTo(item, ui) {
1854
+ if (!item) return false;
1855
+ if (item.window) {
1856
+ await act({ type: "focus", id: item.window });
1857
+ return true;
1858
+ }
1859
+ if (item.card) {
1860
+ if (item.by === "agent") ui.toggleAgent(true);
1861
+ else await call("POST", "/api/desk/actions", { type: "open", view: "surface.cards" });
1862
+ return true;
1863
+ }
1864
+ return false;
1865
+ }
1532
1866
  function runClient(id, ui, args) {
1533
1867
  switch (id) {
1534
1868
  case "palette.toggle":
@@ -1546,10 +1880,201 @@ function runClient(id, ui, args) {
1546
1880
  case "menu.toggle":
1547
1881
  ui.toggleMenu();
1548
1882
  return Promise.resolve(null);
1883
+ case "attention.jump":
1884
+ return call("GET", "/api/attend").then(
1885
+ (a) => jumpTo(firstItem({ items: a.items ?? [], counts: {} }), ui)
1886
+ );
1549
1887
  }
1550
1888
  return void 0;
1551
1889
  }
1552
1890
 
1891
+ // ../../web/src/desk/AttentionBadge.tsx
1892
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1893
+ var words = { needs_you: "need you", failed: "failed", unseen: "not seen yet" };
1894
+ function AttentionBadge({ ui }) {
1895
+ const a = useAttention();
1896
+ const total = a.items.length;
1897
+ if (total === 0) return null;
1898
+ const needs = a.counts.needs_you ?? a.items.filter((i) => i.state === "needs_you").length;
1899
+ const byState = {};
1900
+ for (const i of a.items) byState[i.state] = (byState[i.state] ?? 0) + 1;
1901
+ const summary = Object.entries(byState).map(([state3, n]) => `${n} ${words[state3] ?? state3}`).join(" \xB7 ");
1902
+ const first = a.items[0];
1903
+ return /* @__PURE__ */ jsxs6(
1904
+ Button5,
1905
+ {
1906
+ variant: needs > 0 ? "secondary" : "ghost",
1907
+ size: "sm",
1908
+ "aria-pressed": needs > 0,
1909
+ "aria-label": `${total} waiting: ${summary}. Jump to the first.`,
1910
+ title: `${summary}
1911
+ Next: ${first?.title ?? first?.subject ?? ""} (\u2318.)`,
1912
+ onClick: () => void jumpTo(first, ui),
1913
+ children: [
1914
+ /* @__PURE__ */ jsx9(Icon, { name: needs > 0 ? "bell-ring" : "bell" }),
1915
+ /* @__PURE__ */ jsx9("span", { className: "tabular-nums", children: total })
1916
+ ]
1917
+ }
1918
+ );
1919
+ }
1920
+
1921
+ // ../../web/src/desk/Confirm.tsx
1922
+ import { useEffect as useEffect7, useState as useState6 } from "react";
1923
+ import {
1924
+ AlertDialog,
1925
+ AlertDialogAction,
1926
+ AlertDialogCancel,
1927
+ AlertDialogContent,
1928
+ AlertDialogDescription,
1929
+ AlertDialogFooter,
1930
+ AlertDialogHeader,
1931
+ AlertDialogTitle
1932
+ } from "@/components/ui/alert-dialog";
1933
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1934
+ function ConfirmHost() {
1935
+ const [q, setQ] = useState6(null);
1936
+ useEffect7(() => {
1937
+ setConfirm((question) => new Promise((resolve) => setQ({ ...question, resolve })));
1938
+ }, []);
1939
+ const answer2 = (yes) => {
1940
+ q?.resolve(yes);
1941
+ setQ(null);
1942
+ };
1943
+ return /* @__PURE__ */ jsx10(
1944
+ AlertDialog,
1945
+ {
1946
+ open: !!q,
1947
+ onOpenChange: (open) => {
1948
+ if (!open) answer2(false);
1949
+ },
1950
+ children: /* @__PURE__ */ jsxs7(AlertDialogContent, { size: "sm", children: [
1951
+ /* @__PURE__ */ jsxs7(AlertDialogHeader, { children: [
1952
+ /* @__PURE__ */ jsx10(AlertDialogTitle, { children: q?.title }),
1953
+ q?.message && /* @__PURE__ */ jsx10(AlertDialogDescription, { children: q.message })
1954
+ ] }),
1955
+ /* @__PURE__ */ jsxs7(AlertDialogFooter, { children: [
1956
+ /* @__PURE__ */ jsx10(AlertDialogCancel, { children: "Cancel" }),
1957
+ /* @__PURE__ */ jsx10(AlertDialogAction, { variant: q?.danger ? "destructive" : "default", onClick: () => answer2(true), children: q?.confirmLabel ?? "OK" })
1958
+ ] })
1959
+ ] })
1960
+ }
1961
+ );
1962
+ }
1963
+
1964
+ // ../../web/src/desk/composing.ts
1965
+ import { useEffect as useEffect8 } from "react";
1966
+ var fields = 'textarea, input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="url"], [contenteditable="true"]';
1967
+ function hasText(root) {
1968
+ for (const el of root.querySelectorAll(fields)) {
1969
+ const v = el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement ? el.value : el.textContent;
1970
+ if (v && v.trim() !== "") return true;
1971
+ }
1972
+ return false;
1973
+ }
1974
+ function useComposing(ref, id) {
1975
+ useEffect8(() => {
1976
+ const root = ref.current;
1977
+ if (!root) return;
1978
+ let last = false;
1979
+ let timer = 0;
1980
+ let poll = 0;
1981
+ const report = (now) => {
1982
+ if (now === last) return;
1983
+ last = now;
1984
+ void act({ type: "composing", ...id ? { id } : {}, composing: now }).catch(() => {
1985
+ });
1986
+ window.clearInterval(poll);
1987
+ if (now) poll = window.setInterval(() => report(hasText(root)), 3e3);
1988
+ };
1989
+ const check = () => {
1990
+ window.clearTimeout(timer);
1991
+ timer = window.setTimeout(() => report(hasText(root)), 250);
1992
+ };
1993
+ const events = ["input", "keyup", "submit", "focusout", "click"];
1994
+ for (const e of events) root.addEventListener(e, check, true);
1995
+ return () => {
1996
+ for (const e of events) root.removeEventListener(e, check, true);
1997
+ window.clearTimeout(timer);
1998
+ window.clearInterval(poll);
1999
+ if (last) void act({ type: "composing", ...id ? { id } : {}, composing: false }).catch(() => {
2000
+ });
2001
+ };
2002
+ }, [ref, id]);
2003
+ }
2004
+
2005
+ // ../../web/src/desk/GhostCursor.tsx
2006
+ import { useEffect as useEffect9, useState as useState7 } from "react";
2007
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2008
+ function elementOf(p) {
2009
+ const win = p.window ?? deskState().wins.find((w) => w.view === p.view)?.id;
2010
+ if (!win) return null;
2011
+ if (p.anchor) {
2012
+ const a = anchorElement(win, p.anchor);
2013
+ if (a) return a;
2014
+ }
2015
+ return document.querySelector(`[data-window="${CSS.escape(win)}"]`);
2016
+ }
2017
+ function GhostCursor() {
2018
+ const [at, setAt] = useState7(null);
2019
+ useEffect9(() => {
2020
+ const desk2 = () => document.querySelector("[data-slot=app-frame-content]");
2021
+ let unzoom = 0;
2022
+ const reset = () => {
2023
+ const d = desk2();
2024
+ if (d) {
2025
+ d.style.transform = "";
2026
+ d.style.transformOrigin = "";
2027
+ }
2028
+ };
2029
+ const offStep = onEvent("script.step", (ev) => {
2030
+ const s = ev.data ?? {};
2031
+ const p = s.point?.[0];
2032
+ const el = p ? elementOf(p) : null;
2033
+ const r = el?.getBoundingClientRect();
2034
+ if (!r?.width) {
2035
+ setAt((cur) => cur ? { ...cur, say: s.say ?? "" } : null);
2036
+ return;
2037
+ }
2038
+ const x = r.x + r.width / 2;
2039
+ const y = r.y + Math.min(r.height / 2, 120);
2040
+ setAt({ x, y, label: p?.label ?? "agent", say: s.say ?? "" });
2041
+ window.clearTimeout(unzoom);
2042
+ const d = desk2();
2043
+ if (d && s.zoom) {
2044
+ d.style.transition = "transform 600ms ease";
2045
+ d.style.transformOrigin = `${x}px ${y}px`;
2046
+ d.style.transform = "scale(1.25)";
2047
+ unzoom = window.setTimeout(reset, Math.max(1500, (s.hold_ms ?? 4e3) - 400));
2048
+ } else reset();
2049
+ });
2050
+ const offDone = onEvent("script.done", () => {
2051
+ window.clearTimeout(unzoom);
2052
+ reset();
2053
+ setAt(null);
2054
+ });
2055
+ return () => {
2056
+ offStep();
2057
+ offDone();
2058
+ window.clearTimeout(unzoom);
2059
+ reset();
2060
+ };
2061
+ }, []);
2062
+ if (!at) return null;
2063
+ return /* @__PURE__ */ jsxs8(
2064
+ "div",
2065
+ {
2066
+ "data-slot": "ghost-cursor",
2067
+ "aria-hidden": true,
2068
+ className: "pointer-events-none fixed z-50 transition-[left,top] duration-700 ease-out",
2069
+ style: { left: at.x, top: at.y },
2070
+ children: [
2071
+ /* @__PURE__ */ jsx11("span", { className: "block text-primary drop-shadow-[0_0_6px_var(--p-accent)]", children: /* @__PURE__ */ jsx11(Icon, { name: "mouse-pointer-2", size: 22 }) }),
2072
+ /* @__PURE__ */ jsx11("span", { className: "ml-4 inline-block rounded-md bg-primary px-1.5 py-0.5 font-mono text-[11px] text-primary-foreground", children: at.label })
2073
+ ]
2074
+ }
2075
+ );
2076
+ }
2077
+
1553
2078
  // ../../web/src/desk/keys.ts
1554
2079
  var ALIASES = {
1555
2080
  return: "enter",
@@ -1624,7 +2149,7 @@ function moduleApi(id) {
1624
2149
  }
1625
2150
 
1626
2151
  // ../../web/src/desk/Palette.tsx
1627
- import { useEffect as useEffect7, useState as useState6 } from "react";
2152
+ import { useEffect as useEffect10, useState as useState8 } from "react";
1628
2153
  import {
1629
2154
  Command,
1630
2155
  CommandDialog,
@@ -1635,10 +2160,10 @@ import {
1635
2160
  CommandList,
1636
2161
  CommandShortcut
1637
2162
  } from "@/components/ui/command";
1638
- import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2163
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
1639
2164
  function Palette({ open, onOpenChange, commands }) {
1640
- const [layouts, setLayouts] = useState6([]);
1641
- useEffect7(() => {
2165
+ const [layouts, setLayouts] = useState8([]);
2166
+ useEffect10(() => {
1642
2167
  if (!open) return;
1643
2168
  void listLayouts().then(setLayouts).catch(() => {
1644
2169
  });
@@ -1672,21 +2197,21 @@ function Palette({ open, onOpenChange, commands }) {
1672
2197
  onOpenChange(false);
1673
2198
  void Promise.resolve(row.run()).catch((err) => console.warn("palette: failed", row.id, err));
1674
2199
  };
1675
- return /* @__PURE__ */ jsx9(
2200
+ return /* @__PURE__ */ jsx12(
1676
2201
  CommandDialog,
1677
2202
  {
1678
2203
  open,
1679
2204
  onOpenChange,
1680
2205
  title: "Command palette",
1681
2206
  description: "Run a command, open a window or load a layout.",
1682
- children: /* @__PURE__ */ jsxs6(Command, { children: [
1683
- /* @__PURE__ */ jsx9(CommandInput, { placeholder: "Run a command, open a window, load a layout\u2026" }),
1684
- /* @__PURE__ */ jsxs6(CommandList, { children: [
1685
- /* @__PURE__ */ jsx9(CommandEmpty, { children: "Nothing matches." }),
1686
- sections.map((section) => /* @__PURE__ */ jsx9(CommandGroup, { heading: section, children: rows.filter((r) => r.section === section).map((r) => /* @__PURE__ */ jsxs6(CommandItem, { value: r.title, keywords: r.keywords, onSelect: () => pick(r), children: [
1687
- /* @__PURE__ */ jsx9(Icon, { name: r.icon ?? "chevron-right" }),
1688
- /* @__PURE__ */ jsx9("span", { children: r.title }),
1689
- r.hint && /* @__PURE__ */ jsx9(CommandShortcut, { children: r.hint })
2207
+ children: /* @__PURE__ */ jsxs9(Command, { children: [
2208
+ /* @__PURE__ */ jsx12(CommandInput, { placeholder: "Run a command, open a window, load a layout\u2026" }),
2209
+ /* @__PURE__ */ jsxs9(CommandList, { children: [
2210
+ /* @__PURE__ */ jsx12(CommandEmpty, { children: "Nothing matches." }),
2211
+ sections.map((section) => /* @__PURE__ */ jsx12(CommandGroup, { heading: section, children: rows.filter((r) => r.section === section).map((r) => /* @__PURE__ */ jsxs9(CommandItem, { value: r.title, keywords: r.keywords, onSelect: () => pick(r), children: [
2212
+ /* @__PURE__ */ jsx12(Icon, { name: r.icon ?? "chevron-right" }),
2213
+ /* @__PURE__ */ jsx12("span", { children: r.title }),
2214
+ r.hint && /* @__PURE__ */ jsx12(CommandShortcut, { children: r.hint })
1690
2215
  ] }, r.id)) }, section))
1691
2216
  ] })
1692
2217
  ] })
@@ -1694,30 +2219,114 @@ function Palette({ open, onOpenChange, commands }) {
1694
2219
  );
1695
2220
  }
1696
2221
 
2222
+ // ../../web/src/desk/ThemePicker.tsx
2223
+ import { DEFAULT_PALETTE, PALETTES, paletteById } from "@hollis-labs/surface-theme";
2224
+ import { useEffect as useEffect11, useState as useState9 } from "react";
2225
+ import { Button as Button6 } from "@/components/ui/button";
2226
+ import {
2227
+ DropdownMenu,
2228
+ DropdownMenuContent,
2229
+ DropdownMenuGroup,
2230
+ DropdownMenuLabel,
2231
+ DropdownMenuRadioGroup,
2232
+ DropdownMenuRadioItem,
2233
+ DropdownMenuSeparator,
2234
+ DropdownMenuTrigger
2235
+ } from "@/components/ui/dropdown-menu";
2236
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2237
+ function Dots({ colors }) {
2238
+ return /* @__PURE__ */ jsx13("span", { className: "flex shrink-0 items-center gap-0.5", "aria-hidden": true, children: Object.entries(colors).map(([role, c]) => /* @__PURE__ */ jsx13("span", { className: "size-2 rounded-full", style: { background: c } }, role)) });
2239
+ }
2240
+ function ThemePicker() {
2241
+ const id = useSetting("surface.palette") ?? DEFAULT_PALETTE.id;
2242
+ const type = (useSetting("surface.type") ?? "mixed") === "mono" ? "mono" : "mixed";
2243
+ const palette = paletteById(id) ?? DEFAULT_PALETTE;
2244
+ const set2 = (key, value) => void setSetting(key, value).catch(() => {
2245
+ });
2246
+ return /* @__PURE__ */ jsxs10(DropdownMenu, { children: [
2247
+ /* @__PURE__ */ jsx13(
2248
+ DropdownMenuTrigger,
2249
+ {
2250
+ render: /* @__PURE__ */ jsxs10(Button6, { variant: "ghost", size: "sm", title: "Theme", "aria-label": `Theme: ${palette.name}`, children: [
2251
+ /* @__PURE__ */ jsx13(
2252
+ Dots,
2253
+ {
2254
+ colors: {
2255
+ accent: palette.accent,
2256
+ accent2: palette.accent2 ?? palette.cyan,
2257
+ red: palette.red,
2258
+ green: palette.green
2259
+ }
2260
+ }
2261
+ ),
2262
+ /* @__PURE__ */ jsx13("span", { children: palette.name })
2263
+ ] })
2264
+ }
2265
+ ),
2266
+ /* @__PURE__ */ jsxs10(DropdownMenuContent, { align: "end", className: "min-w-60", children: [
2267
+ /* @__PURE__ */ jsxs10(DropdownMenuGroup, { children: [
2268
+ /* @__PURE__ */ jsx13(DropdownMenuLabel, { children: "Palette" }),
2269
+ /* @__PURE__ */ jsx13(DropdownMenuRadioGroup, { value: palette.id, onValueChange: (v) => set2("surface.palette", String(v)), children: PALETTES.map((p) => /* @__PURE__ */ jsxs10(DropdownMenuRadioItem, { value: p.id, children: [
2270
+ /* @__PURE__ */ jsx13(
2271
+ Dots,
2272
+ {
2273
+ colors: { background: p.background, accent: p.accent, accent2: p.accent2 ?? p.cyan, red: p.red }
2274
+ }
2275
+ ),
2276
+ /* @__PURE__ */ jsx13("span", { children: p.name })
2277
+ ] }, p.id)) })
2278
+ ] }),
2279
+ /* @__PURE__ */ jsx13(DropdownMenuSeparator, {}),
2280
+ /* @__PURE__ */ jsxs10(DropdownMenuGroup, { children: [
2281
+ /* @__PURE__ */ jsx13(DropdownMenuLabel, { children: "Type" }),
2282
+ /* @__PURE__ */ jsxs10(DropdownMenuRadioGroup, { value: type, onValueChange: (v) => set2("surface.type", String(v)), children: [
2283
+ /* @__PURE__ */ jsx13(DropdownMenuRadioItem, { value: "mixed", children: "Mixed (mono chrome)" }),
2284
+ /* @__PURE__ */ jsx13(DropdownMenuRadioItem, { value: "mono", children: "Mono everywhere" })
2285
+ ] })
2286
+ ] })
2287
+ ] })
2288
+ ] });
2289
+ }
2290
+ function Clock() {
2291
+ const [now, setNow] = useState9(() => /* @__PURE__ */ new Date());
2292
+ useEffect11(() => {
2293
+ const t = setInterval(() => setNow(/* @__PURE__ */ new Date()), 15e3);
2294
+ return () => clearInterval(t);
2295
+ }, []);
2296
+ return /* @__PURE__ */ jsx13("span", { className: "px-1.5 tabular-nums text-muted-foreground", title: now.toLocaleString(), children: now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) });
2297
+ }
2298
+
1697
2299
  // ../../web/src/desk/Desktop.tsx
1698
- import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
2300
+ import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
1699
2301
  function Desktop({ modules }) {
1700
- const state2 = useDeskState();
2302
+ const state3 = useDeskState();
1701
2303
  const manifest2 = app();
1702
- const [palette, setPalette] = useState7(false);
1703
- const [menu, setMenu] = useState7(false);
1704
- const [agentOpen, setAgentOpen] = useState7(() => localStorage.getItem("surface.agent.open") !== "0");
1705
- const [up, setUp] = useState7(isConnected());
2304
+ const [palette, setPalette] = useState10(false);
2305
+ const [menu, setMenu] = useState10(false);
2306
+ const [agentOpen, setAgentOpen] = useState10(() => {
2307
+ try {
2308
+ return localStorage.getItem("surface.agent.open") === "1";
2309
+ } catch {
2310
+ return false;
2311
+ }
2312
+ });
2313
+ const [up, setUp] = useState10(isConnected());
1706
2314
  const gap = useSetting("surface.gap") ?? 10;
1707
- const theme = useSetting("surface.theme") ?? "dark";
2315
+ useAnswerSeen(agentOpen);
2316
+ const paletteId = useSetting("surface.palette") ?? DEFAULT_PALETTE2.id;
2317
+ const typeStyle = (useSetting("surface.type") ?? "mixed") === "mono" ? "mono" : "mixed";
1708
2318
  const panelWidth = useSetting("surface.agent_panel_width") ?? 420;
1709
- useEffect8(() => {
2319
+ useEffect12(() => {
1710
2320
  setUp(isConnected());
1711
2321
  return onConnection(setUp);
1712
2322
  }, []);
1713
- useEffect8(() => {
1714
- const root = document.documentElement;
1715
- root.classList.toggle("dark", theme !== "light");
1716
- }, [theme]);
1717
- useEffect8(() => {
2323
+ useEffect12(() => {
2324
+ applyPalette(paletteById2(paletteId) ?? DEFAULT_PALETTE2, document.documentElement, typeStyle);
2325
+ }, [paletteId, typeStyle]);
2326
+ useEffect12(() => {
1718
2327
  document.title = manifest2.title;
1719
2328
  }, [manifest2.title]);
1720
- const toggleAgent = useCallback4((open) => {
2329
+ const toggleAgent = useCallback5((open) => {
1721
2330
  setAgentOpen((was) => {
1722
2331
  const next = open ?? !was;
1723
2332
  localStorage.setItem("surface.agent.open", next ? "1" : "0");
@@ -1732,11 +2341,11 @@ function Desktop({ modules }) {
1732
2341
  }),
1733
2342
  [toggleAgent]
1734
2343
  );
1735
- useEffect8(() => {
2344
+ useEffect12(() => {
1736
2345
  setClientRunner((id, args) => runClient(id, ui, args));
1737
2346
  }, [ui]);
1738
2347
  const commands = useMemo4(() => [...clientCommands, ...manifest2.commands], [manifest2.commands]);
1739
- useEffect8(() => {
2348
+ useEffect12(() => {
1740
2349
  const chords = commands.flatMap((c) => {
1741
2350
  const chord = c.keys ? parseKeys(c.keys) : null;
1742
2351
  return chord ? [{ chord, id: c.id }] : [];
@@ -1755,98 +2364,167 @@ function Desktop({ modules }) {
1755
2364
  return () => window.removeEventListener("keydown", onKey, true);
1756
2365
  }, [commands]);
1757
2366
  const windows = useMemo4(
1758
- () => state2.wins.map((w) => ({
2367
+ () => state3.wins.map((w) => ({
1759
2368
  id: w.id,
1760
2369
  title: w.title,
1761
2370
  dirty: w.dirty,
1762
- icon: /* @__PURE__ */ jsx10(Icon, { name: viewById(w.view)?.icon, size: 13 })
2371
+ icon: /* @__PURE__ */ jsx14(Icon, { name: viewById(w.view)?.icon, size: 13 }),
2372
+ // A delegate's window the owner has not made theirs: who opened it, and Keep (rule 4).
2373
+ badge: notYetKept(w) ? /* @__PURE__ */ jsx14(
2374
+ "span",
2375
+ {
2376
+ className: "text-muted-foreground",
2377
+ title: `Opened by the ${w.opened_by}${w.reason ? `: ${w.reason}` : ""}`,
2378
+ children: /* @__PURE__ */ jsx14(Icon, { name: "bot", size: 11 })
2379
+ }
2380
+ ) : void 0,
2381
+ actions: notYetKept(w) || w.held ? /* @__PURE__ */ jsxs11(Fragment4, { children: [
2382
+ w.held && /* @__PURE__ */ jsxs11(Fragment4, { children: [
2383
+ /* @__PURE__ */ jsx14(
2384
+ "span",
2385
+ {
2386
+ className: "text-warning",
2387
+ title: `The ${w.held.by} wants to change what this shows${w.held.title ? ` (${w.held.title})` : ""}. It waits until you are done here.`,
2388
+ children: /* @__PURE__ */ jsx14(Icon, { name: "git-pull-request-arrow", size: 12 })
2389
+ }
2390
+ ),
2391
+ /* @__PURE__ */ jsx14(
2392
+ Button7,
2393
+ {
2394
+ variant: "ghost",
2395
+ size: "xs",
2396
+ title: "Apply the waiting change now",
2397
+ onPointerDown: (e) => e.stopPropagation(),
2398
+ onClick: (e) => {
2399
+ e.stopPropagation();
2400
+ void act({ type: "held", id: w.id, do: "apply" });
2401
+ },
2402
+ children: "Apply"
2403
+ }
2404
+ ),
2405
+ /* @__PURE__ */ jsx14(
2406
+ Button7,
2407
+ {
2408
+ variant: "ghost",
2409
+ size: "xs",
2410
+ title: "Drop the waiting change",
2411
+ onPointerDown: (e) => e.stopPropagation(),
2412
+ onClick: (e) => {
2413
+ e.stopPropagation();
2414
+ void act({ type: "held", id: w.id, do: "drop" });
2415
+ },
2416
+ children: "Drop"
2417
+ }
2418
+ )
2419
+ ] }),
2420
+ notYetKept(w) && /* @__PURE__ */ jsx14(
2421
+ Button7,
2422
+ {
2423
+ variant: "ghost",
2424
+ size: "xs",
2425
+ title: "Keep this window: it is yours, and the agent will not close it",
2426
+ onPointerDown: (e) => e.stopPropagation(),
2427
+ onClick: (e) => {
2428
+ e.stopPropagation();
2429
+ void act({ type: "keep", id: w.id });
2430
+ },
2431
+ children: "Keep"
2432
+ }
2433
+ )
2434
+ ] }) : void 0
1763
2435
  })),
1764
- [state2.wins]
2436
+ [state3.wins]
2437
+ );
2438
+ const arrange = useCallback5(
2439
+ (tree, focus, grabbed) => act({ type: "tree", tree, focus, id: grabbed }),
2440
+ []
1765
2441
  );
1766
- const arrange = useCallback4((tree, focus) => act({ type: "tree", tree, focus }), []);
1767
2442
  const menuViews = manifest2.views.filter((v) => v.menu);
1768
- const bar = /* @__PURE__ */ jsxs7(Fragment3, { children: [
1769
- /* @__PURE__ */ jsxs7("div", { className: "flex h-full min-w-0 flex-1 items-center gap-1", children: [
1770
- /* @__PURE__ */ jsxs7(DropdownMenu, { open: menu, onOpenChange: setMenu, children: [
1771
- /* @__PURE__ */ jsx10(
1772
- DropdownMenuTrigger,
2443
+ const bar = /* @__PURE__ */ jsxs11(Fragment4, { children: [
2444
+ /* @__PURE__ */ jsxs11("div", { className: "flex h-full min-w-0 flex-1 items-center gap-1", children: [
2445
+ /* @__PURE__ */ jsxs11(DropdownMenu2, { open: menu, onOpenChange: setMenu, children: [
2446
+ /* @__PURE__ */ jsx14(
2447
+ DropdownMenuTrigger2,
1773
2448
  {
1774
- render: /* @__PURE__ */ jsxs7(Button4, { variant: "ghost", size: "sm", title: "Apps", children: [
1775
- /* @__PURE__ */ jsx10(Icon, { name: "layout-grid" }),
1776
- /* @__PURE__ */ jsx10("span", { className: "font-semibold", children: manifest2.title })
2449
+ render: /* @__PURE__ */ jsxs11(Button7, { variant: "ghost", size: "sm", title: "Apps", children: [
2450
+ /* @__PURE__ */ jsx14(Icon, { name: "layout-grid" }),
2451
+ /* @__PURE__ */ jsx14("span", { className: "font-semibold", children: manifest2.title })
1777
2452
  ] })
1778
2453
  }
1779
2454
  ),
1780
- /* @__PURE__ */ jsx10(DropdownMenuContent, { className: "min-w-56", children: menuViews.map((v) => /* @__PURE__ */ jsxs7(DropdownMenuItem, { onClick: () => void desk.open(v.id), children: [
1781
- /* @__PURE__ */ jsx10(Icon, { name: v.icon }),
1782
- /* @__PURE__ */ jsx10("span", { children: v.title }),
1783
- v.module !== "surface" && /* @__PURE__ */ jsx10(DropdownMenuShortcut, { children: v.module })
2455
+ /* @__PURE__ */ jsx14(DropdownMenuContent2, { className: "min-w-56", children: menuViews.map((v) => /* @__PURE__ */ jsxs11(DropdownMenuItem, { onClick: () => void desk.open(v.id), children: [
2456
+ /* @__PURE__ */ jsx14(Icon, { name: v.icon }),
2457
+ /* @__PURE__ */ jsx14("span", { children: v.title }),
2458
+ v.module !== "surface" && /* @__PURE__ */ jsx14(DropdownMenuShortcut, { children: v.module })
1784
2459
  ] }, v.id)) })
1785
2460
  ] }),
1786
- /* @__PURE__ */ jsx10("div", { className: "ml-1 flex min-w-0 gap-0.5 overflow-hidden", children: state2.wins.map((w) => /* @__PURE__ */ jsxs7(
1787
- Button4,
2461
+ /* @__PURE__ */ jsx14("div", { className: "ml-1 flex min-w-0 gap-0.5 overflow-hidden", children: state3.wins.map((w) => /* @__PURE__ */ jsxs11(
2462
+ Button7,
1788
2463
  {
1789
- variant: w.id === state2.focus ? "secondary" : "ghost",
2464
+ variant: w.id === state3.focus ? "secondary" : "ghost",
1790
2465
  size: "sm",
1791
2466
  className: "min-w-0 max-w-44 shrink",
1792
2467
  title: w.title,
1793
- "aria-pressed": w.id === state2.focus,
2468
+ "aria-pressed": w.id === state3.focus,
1794
2469
  onClick: () => void act({ type: "focus", id: w.id }),
1795
2470
  onAuxClick: (e) => {
1796
2471
  if (e.button === 1) void closeWindow(w.id);
1797
2472
  },
1798
2473
  children: [
1799
- /* @__PURE__ */ jsx10(Icon, { name: viewById(w.view)?.icon }),
1800
- /* @__PURE__ */ jsx10("span", { className: "truncate", children: w.dirty ? `\u25CF ${w.title}` : w.title })
2474
+ /* @__PURE__ */ jsx14(Icon, { name: viewById(w.view)?.icon }),
2475
+ /* @__PURE__ */ jsx14("span", { className: "truncate", children: w.dirty ? `\u25CF ${w.title}` : w.title })
1801
2476
  ]
1802
2477
  },
1803
2478
  w.id
1804
2479
  )) })
1805
2480
  ] }),
1806
- /* @__PURE__ */ jsxs7("div", { className: "flex h-full shrink-0 items-center gap-1", children: [
1807
- state2.active && /* @__PURE__ */ jsxs7(
1808
- Button4,
2481
+ /* @__PURE__ */ jsxs11("div", { className: "flex h-full shrink-0 items-center gap-1", children: [
2482
+ state3.active && /* @__PURE__ */ jsxs11(
2483
+ Button7,
1809
2484
  {
1810
2485
  variant: "ghost",
1811
2486
  size: "sm",
1812
2487
  title: "The saved layout in use",
1813
2488
  onClick: () => void desk.open("surface.layouts"),
1814
2489
  children: [
1815
- /* @__PURE__ */ jsx10(Icon, { name: "layout-dashboard" }),
1816
- /* @__PURE__ */ jsx10("span", { children: state2.active })
2490
+ /* @__PURE__ */ jsx14(Icon, { name: "layout-dashboard" }),
2491
+ /* @__PURE__ */ jsx14("span", { children: state3.active })
1817
2492
  ]
1818
2493
  }
1819
2494
  ),
1820
- state2.mode && /* @__PURE__ */ jsx10(Badge3, { variant: "secondary", title: "Your mode", children: state2.mode }),
1821
- /* @__PURE__ */ jsxs7(
1822
- Button4,
2495
+ state3.mode && /* @__PURE__ */ jsx14(Badge4, { variant: "secondary", title: "Your mode", children: state3.mode }),
2496
+ /* @__PURE__ */ jsxs11(
2497
+ Button7,
1823
2498
  {
1824
2499
  variant: "ghost",
1825
2500
  size: "sm",
1826
2501
  title: "Tile every window, or float them all",
1827
2502
  onClick: () => void runCommand("layout.toggle"),
1828
2503
  children: [
1829
- /* @__PURE__ */ jsx10(Icon, { name: state2.layout === "tile" ? "columns-2" : "picture-in-picture-2" }),
1830
- /* @__PURE__ */ jsx10("span", { children: state2.layout })
2504
+ /* @__PURE__ */ jsx14(Icon, { name: state3.layout === "tile" ? "columns-2" : "picture-in-picture-2" }),
2505
+ /* @__PURE__ */ jsx14("span", { children: state3.layout })
1831
2506
  ]
1832
2507
  }
1833
2508
  ),
1834
- /* @__PURE__ */ jsxs7(Button4, { variant: "ghost", size: "sm", title: "Command palette", onClick: () => setPalette(true), children: [
1835
- /* @__PURE__ */ jsx10(Icon, { name: "search" }),
1836
- /* @__PURE__ */ jsx10(Kbd, { children: showKeys("cmd+k") })
2509
+ /* @__PURE__ */ jsx14(AttentionBadge, { ui }),
2510
+ /* @__PURE__ */ jsx14(ThemePicker, {}),
2511
+ /* @__PURE__ */ jsxs11(Button7, { variant: "ghost", size: "sm", title: "Command palette", onClick: () => setPalette(true), children: [
2512
+ /* @__PURE__ */ jsx14(Icon, { name: "search" }),
2513
+ /* @__PURE__ */ jsx14(Kbd, { children: showKeys("cmd+k") })
1837
2514
  ] }),
1838
- /* @__PURE__ */ jsx10(
1839
- Button4,
2515
+ /* @__PURE__ */ jsx14(
2516
+ Button7,
1840
2517
  {
1841
2518
  variant: agentOpen ? "secondary" : "ghost",
1842
2519
  size: "icon-sm",
1843
2520
  title: `Agent ${showKeys("cmd+j")}`,
1844
2521
  "aria-pressed": agentOpen,
1845
2522
  onClick: () => toggleAgent(),
1846
- children: /* @__PURE__ */ jsx10(Icon, { name: "bot" })
2523
+ children: /* @__PURE__ */ jsx14(Icon, { name: "bot" })
1847
2524
  }
1848
2525
  ),
1849
- /* @__PURE__ */ jsx10(
2526
+ /* @__PURE__ */ jsx14(Clock, {}),
2527
+ /* @__PURE__ */ jsx14(
1850
2528
  "span",
1851
2529
  {
1852
2530
  className: `mx-1.5 size-2 rounded-full ${up ? "bg-success" : "bg-warning"}`,
@@ -1855,53 +2533,78 @@ function Desktop({ modules }) {
1855
2533
  )
1856
2534
  ] })
1857
2535
  ] });
1858
- return /* @__PURE__ */ jsxs7(Fragment3, { children: [
1859
- /* @__PURE__ */ jsxs7(
2536
+ return /* @__PURE__ */ jsxs11(Fragment4, { children: [
2537
+ /* @__PURE__ */ jsxs11(
1860
2538
  AppFrame,
1861
2539
  {
1862
2540
  className: "fixed inset-0 text-sm",
1863
- "data-layout": state2.layout,
2541
+ "data-layout": state3.layout,
1864
2542
  bar,
1865
- side: /* @__PURE__ */ jsx10(AgentPanel, { desk, title: "Agent" }),
2543
+ side: /* @__PURE__ */ jsx14(PanelComposer, {}),
1866
2544
  showSide: agentOpen,
1867
2545
  sideSize: panelWidth,
1868
2546
  onSideResize: keepPanelWidth,
1869
2547
  children: [
1870
- /* @__PURE__ */ jsx10(
2548
+ /* @__PURE__ */ jsx14(
1871
2549
  "div",
1872
2550
  {
1873
- className: "relative isolate size-full overflow-hidden bg-muted/40",
2551
+ className: "relative isolate size-full overflow-hidden bg-desk",
1874
2552
  style: { "--window-gap": `${gap}px` },
1875
- children: /* @__PURE__ */ jsx10(
2553
+ children: /* @__PURE__ */ jsx14(
1876
2554
  WindowManager,
1877
2555
  {
1878
- tree: state2.tree,
2556
+ tree: state3.tree,
1879
2557
  windows,
1880
- focus: state2.focus,
2558
+ focus: state3.focus,
1881
2559
  onArrange: arrange,
1882
2560
  onClose: (id) => void closeWindow(id),
1883
- empty: /* @__PURE__ */ jsx10(Empty2, { className: "size-full", children: /* @__PURE__ */ jsxs7(EmptyHeader2, { children: [
1884
- /* @__PURE__ */ jsx10(EmptyTitle2, { children: manifest2.title }),
1885
- /* @__PURE__ */ jsxs7(EmptyDescription2, { children: [
2561
+ empty: /* @__PURE__ */ jsx14(Empty3, { className: "size-full", children: /* @__PURE__ */ jsxs11(EmptyHeader3, { children: [
2562
+ /* @__PURE__ */ jsx14(EmptyTitle3, { children: manifest2.title }),
2563
+ /* @__PURE__ */ jsxs11(EmptyDescription3, { children: [
1886
2564
  "Open something from the menu, press ",
1887
- /* @__PURE__ */ jsx10(Kbd, { children: showKeys("cmd+k") }),
2565
+ /* @__PURE__ */ jsx14(Kbd, { children: showKeys("cmd+k") }),
1888
2566
  " for the palette, or ask the agent."
1889
2567
  ] })
1890
2568
  ] }) }),
1891
- children: (id) => /* @__PURE__ */ jsx10(WindowBody, { id, modules })
2569
+ children: (id) => /* @__PURE__ */ jsx14(WindowBody, { id, modules })
1892
2570
  }
1893
2571
  )
1894
2572
  }
1895
2573
  ),
1896
- /* @__PURE__ */ jsx10(AdeGuide, {})
2574
+ /* @__PURE__ */ jsx14(AdeGuide, {}),
2575
+ /* @__PURE__ */ jsx14(GhostCursor, {})
1897
2576
  ]
1898
2577
  }
1899
2578
  ),
1900
- /* @__PURE__ */ jsx10(AdeAttention, {}),
1901
- /* @__PURE__ */ jsx10(Palette, { open: palette, onOpenChange: setPalette, commands }),
1902
- /* @__PURE__ */ jsx10(ConfirmHost, {})
2579
+ /* @__PURE__ */ jsx14(AdeAttention, {}),
2580
+ /* @__PURE__ */ jsx14(Palette, { open: palette, onOpenChange: setPalette, commands }),
2581
+ /* @__PURE__ */ jsx14(ConfirmHost, {})
1903
2582
  ] });
1904
2583
  }
2584
+ function PanelComposer() {
2585
+ const ref = useRef(null);
2586
+ useComposing(ref, "");
2587
+ return /* @__PURE__ */ jsx14("div", { ref, className: "contents", children: /* @__PURE__ */ jsx14(AgentPanel, { desk, title: "Agent" }) });
2588
+ }
2589
+ function useAnswerSeen(panelOpen) {
2590
+ const a = useAttention();
2591
+ const [focused, setFocused] = useState10(() => document.hasFocus());
2592
+ useEffect12(() => {
2593
+ const on = () => setFocused(true);
2594
+ const off = () => setFocused(false);
2595
+ window.addEventListener("focus", on);
2596
+ window.addEventListener("blur", off);
2597
+ return () => {
2598
+ window.removeEventListener("focus", on);
2599
+ window.removeEventListener("blur", off);
2600
+ };
2601
+ }, []);
2602
+ const waiting = a.items.find((i) => i.subject === "agent" && i.state === "unseen");
2603
+ useEffect12(() => {
2604
+ if (waiting && panelOpen && focused) void call("POST", "/api/attend/seen", { subject: "agent" }).catch(() => {
2605
+ });
2606
+ }, [waiting, panelOpen, focused]);
2607
+ }
1905
2608
  var widthTimer;
1906
2609
  function keepPanelWidth(px) {
1907
2610
  clearTimeout(widthTimer);
@@ -1912,22 +2615,25 @@ function keepPanelWidth(px) {
1912
2615
  }, 400);
1913
2616
  }
1914
2617
  function WindowBody({ id, modules }) {
1915
- const state2 = useDeskState();
1916
- const win = state2.wins.find((w) => w.id === id);
1917
- const focused = state2.focus === id;
2618
+ const state3 = useDeskState();
2619
+ const win = state3.wins.find((w) => w.id === id);
2620
+ const focused = state3.focus === id;
1918
2621
  const module = win?.module ?? "";
1919
2622
  const api = useMemo4(() => moduleApi(module), [module]);
1920
2623
  const pub = useMemo4(() => win ? toWin(win, focused ? win.id : "") : null, [win, focused]);
2624
+ const body = useRef(null);
2625
+ useComposing(body, id);
1921
2626
  if (!win || !pub) return null;
1922
2627
  const view = viewById(win.view);
1923
2628
  const Cmp = view ? modules[view.module]?.views[view.render.entry] : void 0;
1924
- return /* @__PURE__ */ jsx10(
2629
+ return /* @__PURE__ */ jsx14(
1925
2630
  "div",
1926
2631
  {
1927
2632
  className: "relative size-full min-h-0 overflow-auto data-[bare=true]:flex data-[bare=true]:flex-col data-[bare=true]:overflow-hidden",
2633
+ ref: body,
1928
2634
  "data-bare": !!view?.bare,
1929
2635
  "data-window": win.id,
1930
- children: /* @__PURE__ */ jsx10(Boundary2, { children: Cmp ? /* @__PURE__ */ jsx10(Cmp, { win: pub, desk, api }) : /* @__PURE__ */ jsxs7("p", { className: "p-4 text-muted-foreground", children: [
2636
+ children: /* @__PURE__ */ jsx14(Boundary2, { children: Cmp ? /* @__PURE__ */ jsx14(Cmp, { win: pub, desk, api }) : /* @__PURE__ */ jsxs11("p", { className: "p-4 text-muted-foreground", children: [
1931
2637
  "This app's page was built without the view \u201C",
1932
2638
  win.view,
1933
2639
  "\u201D. Rebuild the page with the module's web entry."
@@ -1942,10 +2648,10 @@ var Boundary2 = class extends Component2 {
1942
2648
  }
1943
2649
  render() {
1944
2650
  if (this.state.error) {
1945
- return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col items-start gap-3 p-4", children: [
1946
- /* @__PURE__ */ jsx10("p", { children: "This window failed to draw." }),
1947
- /* @__PURE__ */ jsx10("pre", { className: "whitespace-pre-wrap text-destructive text-xs", children: this.state.error.message }),
1948
- /* @__PURE__ */ jsx10(Button4, { variant: "outline", size: "sm", onClick: () => this.setState({ error: null }), children: "Try again" })
2651
+ return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-start gap-3 p-4", children: [
2652
+ /* @__PURE__ */ jsx14("p", { children: "This window failed to draw." }),
2653
+ /* @__PURE__ */ jsx14("pre", { className: "whitespace-pre-wrap text-destructive text-xs", children: this.state.error.message }),
2654
+ /* @__PURE__ */ jsx14(Button7, { variant: "outline", size: "sm", onClick: () => this.setState({ error: null }), children: "Try again" })
1949
2655
  ] });
1950
2656
  }
1951
2657
  return this.props.children;
@@ -1953,11 +2659,11 @@ var Boundary2 = class extends Component2 {
1953
2659
  };
1954
2660
 
1955
2661
  // ../../web/src/boot.tsx
1956
- import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2662
+ import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
1957
2663
  function Page({ modules, core }) {
1958
- const [ready, setReady] = useState8(false);
1959
- const [error, setError] = useState8("");
1960
- useEffect9(() => {
2664
+ const [ready, setReady] = useState11(false);
2665
+ const [error, setError] = useState11("");
2666
+ useEffect13(() => {
1961
2667
  let live = true;
1962
2668
  Promise.all([loadManifest(), loadSettings()]).then(() => {
1963
2669
  if (!live) return;
@@ -1971,21 +2677,21 @@ function Page({ modules, core }) {
1971
2677
  };
1972
2678
  }, []);
1973
2679
  if (error)
1974
- return /* @__PURE__ */ jsxs8("div", { className: "grid h-full place-items-center text-muted-foreground", children: [
2680
+ return /* @__PURE__ */ jsxs12("div", { className: "grid h-full place-items-center text-muted-foreground", children: [
1975
2681
  "The app's server did not answer: ",
1976
2682
  error
1977
2683
  ] });
1978
- if (!ready) return /* @__PURE__ */ jsx11("div", { className: "grid h-full place-items-center text-muted-foreground", children: "\u2026" });
1979
- return /* @__PURE__ */ jsxs8(Fragment4, { children: [
1980
- /* @__PURE__ */ jsx11(Desktop, { modules: { ...modules, surface: { ...coreWeb, views: { ...coreWeb.views, ...core } } } }),
1981
- /* @__PURE__ */ jsx11(CardHost, {})
2684
+ if (!ready) return /* @__PURE__ */ jsx15("div", { className: "grid h-full place-items-center text-muted-foreground", children: "\u2026" });
2685
+ return /* @__PURE__ */ jsxs12(Fragment5, { children: [
2686
+ /* @__PURE__ */ jsx15(Desktop, { modules: { ...modules, surface: { ...coreWeb, views: { ...coreWeb.views, ...core } } } }),
2687
+ /* @__PURE__ */ jsx15(CardHost, {})
1982
2688
  ] });
1983
2689
  }
1984
2690
  function mountPage(props, element = document.getElementById("root")) {
1985
2691
  if (!element) throw new Error("mountPage: no element to draw into (#root not found)");
1986
2692
  const root = createRoot(element);
1987
2693
  root.render(
1988
- /* @__PURE__ */ jsx11(StrictMode, { children: /* @__PURE__ */ jsx11(Page, { ...props }) })
2694
+ /* @__PURE__ */ jsx15(StrictMode, { children: /* @__PURE__ */ jsx15(Page, { ...props }) })
1989
2695
  );
1990
2696
  return root;
1991
2697
  }