@hachej/boring-workspace 0.1.58 → 0.1.60

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/app-front.js CHANGED
@@ -1,129 +1,1042 @@
1
- import { jsx as d, jsxs as Ae, Fragment as fe } from "react/jsx-runtime";
2
- import { useEffect as A, useSyncExternalStore as xr, useMemo as L, useState as M, useCallback as E, useRef as $, useLayoutEffect as Mr } from "react";
3
- import { PiChatPanel as Cr, usePiSessions as Wr } from "@hachej/boring-agent/front";
4
- import { at as Fr, aG as ze, aH as _n, aI as On, aJ as Ln, aK as xn, aL as ke, aM as St, aN as vt, aO as Mn, aP as Ir, aQ as Ve, O as Gr, q as $r, aR as bn, aS as Ur, U as yn, aT as Kr, w as Hr, u as Cn, aU as Jr, aq as qr, aV as jr } from "./WorkspaceProvider-Bp1Sm40K.js";
5
- import { T as Br, C as Vr, r as Pn, w as zr, W as En } from "./WorkspaceLoadingState-BYTO4wdt.js";
6
- import { Sun as kr, Moon as Yr } from "lucide-react";
7
- import { IconButton as Qr, ErrorState as Xr } from "@hachej/boring-ui-kit";
8
- function Zr() {
9
- const { theme: e, toggleTheme: n } = Fr(), r = e === "dark";
10
- return A(() => {
11
- typeof document > "u" || document.documentElement.classList.toggle("dark", r);
12
- }, [r]), /* @__PURE__ */ d(
13
- Qr,
1
+ import { jsx as i, jsxs as b, Fragment as oe } from "react/jsx-runtime";
2
+ import { useEffect as _, useState as O, useCallback as k, useMemo as D, useRef as J, useSyncExternalStore as cn, useLayoutEffect as Gi } from "react";
3
+ import { Sun as zi, Moon as Ki, FileText as Hi, RefreshCw as _r, X as Dr, Sparkles as Lr, Plug as Or, Clock3 as Ji, Pin as Wr, MessageSquarePlus as Mr, ChevronRight as Bi, Plus as dn, MoreHorizontal as qi, PinOff as Vi, Settings as Yi, ExternalLink as Xi, Search as ji, PanelLeftOpen as Qi, PanelLeftClose as Zi } from "lucide-react";
4
+ import { searchPiSessions as es, PiChatPanel as ts, usePiSessions as ns } from "@hachej/boring-agent/front";
5
+ import { ax as rs, aE as Ir, p as is, aM as un, aN as ss, aO as os, aP as Dt, aQ as Fr, aR as $r, aS as Ur, aT as Gr, aU as Lt, aV as fn, aW as gn, aX as zr, aY as as, aZ as _t, u as Kr, aw as ls, a_ as cs, az as ds, Y as us, q as fs, a$ as xr, b0 as gs, U as yr, x as ms, b1 as ps, au as hs, b2 as bs } from "./WorkspaceProvider-Dxvh_Faj.js";
6
+ import { IconButton as st, DropdownMenu as vs, DropdownMenuTrigger as xs, DropdownMenuContent as ys, DropdownMenuItem as Rt, DropdownMenuSeparator as Ss, ErrorState as Ns } from "@hachej/boring-ui-kit";
7
+ import { c as V } from "./utils-B6yFEsav.js";
8
+ import { C as ws, r as Sr, w as Ps, a as Nr, c as Es, T as ks, W as wr } from "./WorkspaceLoadingState-D9v0oLDq.js";
9
+ function As() {
10
+ const { theme: e, toggleTheme: t } = rs(), n = e === "dark";
11
+ return _(() => {
12
+ typeof document > "u" || document.documentElement.classList.toggle("dark", n);
13
+ }, [n]), /* @__PURE__ */ i(
14
+ st,
14
15
  {
15
16
  type: "button",
16
17
  variant: "ghost",
17
18
  size: "icon-sm",
18
- onClick: n,
19
+ onClick: t,
19
20
  "aria-label": "Toggle theme",
20
- title: r ? "Switch to light theme" : "Switch to dark theme",
21
- children: r ? /* @__PURE__ */ d(kr, { className: "h-4 w-4" }) : /* @__PURE__ */ d(Yr, { className: "h-4 w-4" })
21
+ title: n ? "Switch to light theme" : "Switch to dark theme",
22
+ children: n ? /* @__PURE__ */ i(zi, { className: "h-4 w-4" }) : /* @__PURE__ */ i(Ki, { className: "h-4 w-4" })
23
+ }
24
+ );
25
+ }
26
+ function Hr({
27
+ part: e,
28
+ icon: t,
29
+ title: n,
30
+ description: s,
31
+ actions: o,
32
+ headerInsetStart: a = !1,
33
+ headerInsetEnd: l = !1,
34
+ children: g
35
+ }) {
36
+ return /* @__PURE__ */ b("div", { "data-boring-workspace-part": e, className: "flex h-full min-h-0 flex-col bg-background", children: [
37
+ /* @__PURE__ */ b("header", { className: V(
38
+ "flex h-12 shrink-0 items-center justify-between border-b border-border/60",
39
+ a ? "pl-12" : "pl-4",
40
+ l ? "pr-16" : "pr-4"
41
+ ), children: [
42
+ /* @__PURE__ */ b("div", { className: "flex min-w-0 items-center gap-2", children: [
43
+ t,
44
+ /* @__PURE__ */ b("div", { className: "min-w-0", children: [
45
+ /* @__PURE__ */ i("h2", { className: "truncate text-sm font-semibold tracking-tight text-foreground", children: n }),
46
+ /* @__PURE__ */ i("p", { className: "truncate text-xs text-muted-foreground", children: s })
47
+ ] })
48
+ ] }),
49
+ o ? /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center gap-0.5", children: o }) : null
50
+ ] }),
51
+ g
52
+ ] });
53
+ }
54
+ function Rs({ onClose: e, headerInsetStart: t = !1, headerInsetEnd: n = !1 }) {
55
+ const s = Ir(), [o, a] = O({ status: "loading", skills: [] }), l = k((d) => {
56
+ d.filePath && is({ kind: "openFile", params: { path: d.filePath, mode: "view" } });
57
+ }, []), g = k(async (d = !1) => {
58
+ a((m) => ({ status: "loading", skills: m.skills }));
59
+ try {
60
+ const m = await s.getJson(`/api/v1/agent/skills${d ? "?refresh=1" : ""}`, {
61
+ missingMessage: "Failed to load workspace skills."
62
+ }), A = Array.isArray(m.skills) ? m.skills.filter((R) => typeof (R == null ? void 0 : R.name) == "string" && R.name.length > 0) : [];
63
+ a({ status: "ready", skills: A });
64
+ } catch (m) {
65
+ a((A) => ({
66
+ status: "error",
67
+ skills: A.skills,
68
+ error: m instanceof Error ? m.message : "Failed to load workspace skills."
69
+ }));
70
+ }
71
+ }, [s]);
72
+ _(() => {
73
+ g(!1);
74
+ }, [g]);
75
+ const f = D(
76
+ () => [...o.skills].sort((d, m) => d.name.localeCompare(m.name)),
77
+ [o.skills]
78
+ );
79
+ return /* @__PURE__ */ i(
80
+ Hr,
81
+ {
82
+ part: "skills-page",
83
+ title: "Skills",
84
+ description: "Workspace skills available to slash commands",
85
+ headerInsetStart: t,
86
+ headerInsetEnd: n,
87
+ icon: /* @__PURE__ */ i("span", { className: "grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.12)] text-[color:var(--accent)]", children: /* @__PURE__ */ i(Lr, { className: "h-4 w-4", strokeWidth: 1.75, "aria-hidden": "true" }) }),
88
+ actions: /* @__PURE__ */ b(oe, { children: [
89
+ /* @__PURE__ */ i(
90
+ st,
91
+ {
92
+ type: "button",
93
+ variant: "ghost",
94
+ size: "icon-xs",
95
+ onClick: () => void g(!0),
96
+ disabled: o.status === "loading",
97
+ "aria-label": "Refresh skills",
98
+ title: "Refresh skills",
99
+ className: "text-muted-foreground hover:text-foreground",
100
+ children: /* @__PURE__ */ i(_r, { className: V("size-3", o.status === "loading" && "animate-spin"), strokeWidth: 1.75 })
101
+ }
102
+ ),
103
+ e ? /* @__PURE__ */ i(
104
+ st,
105
+ {
106
+ type: "button",
107
+ variant: "ghost",
108
+ size: "icon-xs",
109
+ onClick: e,
110
+ "aria-label": "Close skills",
111
+ title: "Close",
112
+ className: "text-muted-foreground hover:text-foreground",
113
+ children: /* @__PURE__ */ i(Dr, { className: "size-3", strokeWidth: 1.75 })
114
+ }
115
+ ) : null
116
+ ] }),
117
+ children: /* @__PURE__ */ b("div", { className: "boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto p-4", "aria-live": "polite", children: [
118
+ o.status === "error" ? /* @__PURE__ */ i("div", { className: "mb-4 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive", children: o.error }) : null,
119
+ o.status === "loading" && f.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full min-h-[180px] items-center justify-center text-sm text-muted-foreground", children: "Loading skills…" }) : f.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full min-h-[180px] items-center justify-center text-center text-sm text-muted-foreground", children: /* @__PURE__ */ b("div", { children: [
120
+ /* @__PURE__ */ i("div", { className: "font-medium text-foreground/80", children: "No skills found" }),
121
+ /* @__PURE__ */ i("p", { className: "mt-1 max-w-xs", children: "Reload plugins or add workspace skills to make them available in chat." })
122
+ ] }) }) : /* @__PURE__ */ i("ul", { role: "list", className: "grid gap-2", children: f.map((d) => /* @__PURE__ */ i(
123
+ "li",
124
+ {
125
+ className: "rounded-xl border border-border/60 bg-card/70 px-3 py-2.5 cursor-pointer transition-colors hover:border-border hover:bg-muted/60",
126
+ children: /* @__PURE__ */ i(
127
+ "button",
128
+ {
129
+ type: "button",
130
+ onClick: () => l(d),
131
+ title: "Open skill",
132
+ "aria-label": `Open skill ${d.name} in workspace`,
133
+ className: "block w-full text-left",
134
+ children: /* @__PURE__ */ b("div", { className: "flex items-start justify-between gap-3", children: [
135
+ /* @__PURE__ */ b("div", { className: "min-w-0", children: [
136
+ /* @__PURE__ */ b("div", { className: "truncate text-sm font-medium text-foreground", children: [
137
+ "/",
138
+ d.name
139
+ ] }),
140
+ d.description ? /* @__PURE__ */ i("p", { className: "mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground", children: d.description }) : null
141
+ ] }),
142
+ /* @__PURE__ */ i(Hi, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground", strokeWidth: 1.75, "aria-hidden": "true" })
143
+ ] })
144
+ }
145
+ )
146
+ },
147
+ d.name
148
+ )) })
149
+ ] })
22
150
  }
23
151
  );
24
152
  }
25
- function es() {
153
+ function Pe(e) {
154
+ var t, n;
155
+ return ((t = e.boring) == null ? void 0 : t.label) || ((n = e.boring) == null ? void 0 : n.id) || e.id;
156
+ }
157
+ function Cs(e, t) {
158
+ const n = e.filter((s) => s.id !== t.id);
159
+ return n.push(t), n.sort((s, o) => Pe(s).localeCompare(Pe(o)));
160
+ }
161
+ function Ts({ onClose: e, onReloadExternalPlugins: t, headerInsetStart: n = !1, headerInsetEnd: s = !1 }) {
162
+ const o = Ir(), [a, l] = O({ status: "loading", plugins: [] }), [g, f] = O(() => /* @__PURE__ */ new Set()), [d, m] = O(!1), [A, R] = O(null), W = k(async () => {
163
+ l((p) => ({ status: "loading", plugins: p.plugins }));
164
+ try {
165
+ const p = await o.getJson("/api/v1/agent-plugins?external=1", {
166
+ missingMessage: "Failed to load external plugins."
167
+ }), h = Array.isArray(p) ? [...p].sort((x, L) => Pe(x).localeCompare(Pe(L))) : [];
168
+ l({ status: "ready", plugins: h });
169
+ } catch (p) {
170
+ const h = p instanceof Error ? p.message : "Failed to load external plugins.";
171
+ if (/\(404\)/.test(h)) {
172
+ l({ status: "ready", plugins: [] });
173
+ return;
174
+ }
175
+ l((x) => ({
176
+ status: "error",
177
+ plugins: x.plugins,
178
+ error: h
179
+ }));
180
+ }
181
+ }, [o]);
182
+ _(() => {
183
+ W();
184
+ }, [W]), _(() => {
185
+ const p = (h) => {
186
+ const x = h.detail;
187
+ if (!(!x || typeof x != "object"))
188
+ switch (x.type) {
189
+ case "boring.plugin.load":
190
+ l((L) => ({ ...L, plugins: Cs(L.plugins, x) })), f((L) => {
191
+ const F = new Set(L);
192
+ return F.delete(x.id), F;
193
+ });
194
+ break;
195
+ case "boring.plugin.unload":
196
+ l((L) => ({ ...L, plugins: L.plugins.filter((F) => F.id !== x.id) })), f((L) => {
197
+ const F = new Set(L);
198
+ return F.delete(x.id), F;
199
+ });
200
+ break;
201
+ case "boring.plugin.front-pending":
202
+ f((L) => new Set(L).add(x.id));
203
+ break;
204
+ case "boring.plugin.front-settled":
205
+ f((L) => {
206
+ const F = new Set(L);
207
+ return F.delete(x.id), F;
208
+ });
209
+ break;
210
+ case "boring.plugin.error":
211
+ case "boring.plugin.front-error":
212
+ R(x.message ? `${x.id}: ${x.message}` : `${x.id} failed to reload`), f((L) => {
213
+ const F = new Set(L);
214
+ return F.delete(x.id), F;
215
+ });
216
+ break;
217
+ case "boring.plugin.replay-complete":
218
+ W();
219
+ break;
220
+ }
221
+ };
222
+ return window.addEventListener(un, p), () => window.removeEventListener(un, p);
223
+ }, [W]);
224
+ const E = D(() => [...a.plugins].sort((p, h) => Pe(p).localeCompare(Pe(h))), [a.plugins]), v = k(async () => {
225
+ m(!0), R(null);
226
+ try {
227
+ const p = t ? await t() : void 0;
228
+ R(p || "External plugins reloaded."), await W();
229
+ } catch (p) {
230
+ R(p instanceof Error ? p.message : "External plugin reload failed.");
231
+ } finally {
232
+ m(!1);
233
+ }
234
+ }, [W, t]);
235
+ return /* @__PURE__ */ i(
236
+ Hr,
237
+ {
238
+ part: "plugins-overlay",
239
+ title: "Plugins",
240
+ description: "External plugins loaded for this workspace",
241
+ headerInsetStart: n,
242
+ headerInsetEnd: s,
243
+ icon: /* @__PURE__ */ i("span", { className: "grid size-7 place-items-center rounded-lg bg-foreground/[0.06] text-muted-foreground", children: /* @__PURE__ */ i(Or, { className: "h-4 w-4", strokeWidth: 1.75, "aria-hidden": "true" }) }),
244
+ actions: /* @__PURE__ */ b(oe, { children: [
245
+ /* @__PURE__ */ i(
246
+ st,
247
+ {
248
+ type: "button",
249
+ variant: "ghost",
250
+ size: "icon-xs",
251
+ onClick: () => void v(),
252
+ disabled: d || a.status === "loading",
253
+ "aria-label": "Reload plugins",
254
+ title: "Reload plugins",
255
+ className: "text-muted-foreground hover:text-foreground",
256
+ children: /* @__PURE__ */ i(_r, { className: V("size-3", (d || a.status === "loading") && "animate-spin"), strokeWidth: 1.75 })
257
+ }
258
+ ),
259
+ /* @__PURE__ */ i(
260
+ st,
261
+ {
262
+ type: "button",
263
+ variant: "ghost",
264
+ size: "icon-xs",
265
+ onClick: e,
266
+ "aria-label": "Close plugins",
267
+ title: "Close",
268
+ className: "text-muted-foreground hover:text-foreground",
269
+ children: /* @__PURE__ */ i(Dr, { className: "size-3", strokeWidth: 1.75 })
270
+ }
271
+ )
272
+ ] }),
273
+ children: /* @__PURE__ */ b("div", { className: "boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto p-4", "aria-live": "polite", children: [
274
+ a.status === "error" ? /* @__PURE__ */ i("div", { className: "mb-4 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive", children: a.error }) : null,
275
+ A ? /* @__PURE__ */ i("div", { className: "mb-4 rounded-lg border border-border/70 bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: A }) : null,
276
+ a.status === "loading" && E.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full min-h-[180px] items-center justify-center text-sm text-muted-foreground", children: "Loading external plugins…" }) : E.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full min-h-[180px] items-center justify-center text-center text-sm text-muted-foreground", children: /* @__PURE__ */ b("div", { children: [
277
+ /* @__PURE__ */ i("div", { className: "font-medium text-foreground/80", children: "No external plugins loaded" }),
278
+ /* @__PURE__ */ i("p", { className: "mt-1 max-w-xs", children: "Create or install an external plugin, then reload external plugins." })
279
+ ] }) }) : /* @__PURE__ */ i("ul", { role: "list", className: "grid gap-2", children: E.map((p) => {
280
+ const h = g.has(p.id);
281
+ return /* @__PURE__ */ b(
282
+ "li",
283
+ {
284
+ className: "rounded-xl border border-border/60 bg-card/70 px-3 py-2.5",
285
+ children: [
286
+ /* @__PURE__ */ b("div", { className: "flex items-start justify-between gap-3", children: [
287
+ /* @__PURE__ */ b("div", { className: "min-w-0", children: [
288
+ /* @__PURE__ */ i("div", { className: "truncate text-sm font-medium text-foreground", children: Pe(p) }),
289
+ /* @__PURE__ */ i("div", { className: "mt-0.5 truncate text-[11px] text-muted-foreground/80", children: p.id })
290
+ ] }),
291
+ /* @__PURE__ */ b("div", { className: "flex shrink-0 items-center gap-1", children: [
292
+ h ? /* @__PURE__ */ i("span", { className: "rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground", children: "loading" }) : null,
293
+ p.frontTarget ? /* @__PURE__ */ i("span", { className: "rounded bg-foreground/[0.06] px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground", children: "front" }) : null,
294
+ typeof p.revision == "number" ? /* @__PURE__ */ b("span", { className: "rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground", children: [
295
+ "r",
296
+ p.revision
297
+ ] }) : null
298
+ ] })
299
+ ] }),
300
+ p.version ? /* @__PURE__ */ b("div", { className: "mt-2 text-xs text-muted-foreground", children: [
301
+ "Version ",
302
+ p.version
303
+ ] }) : null
304
+ ]
305
+ },
306
+ p.id
307
+ );
308
+ }) })
309
+ ] })
310
+ }
311
+ );
312
+ }
313
+ function _s({
314
+ appTitle: e,
315
+ workspaceLabel: t,
316
+ topSlot: n,
317
+ showBrand: s = !0
318
+ }) {
319
+ const o = e || "Boring UI";
320
+ return /* @__PURE__ */ b("div", { className: "shrink-0 px-2 pb-2 pt-2", children: [
321
+ s ? /* @__PURE__ */ b("div", { className: "flex h-8 min-w-0 items-center gap-2 pr-1", style: { paddingLeft: "2.5rem" }, children: [
322
+ /* @__PURE__ */ i(
323
+ "span",
324
+ {
325
+ "aria-hidden": "true",
326
+ className: "grid size-7 shrink-0 place-items-center rounded-lg bg-foreground text-[12px] font-semibold text-background",
327
+ children: (o[0] ?? "B").toUpperCase()
328
+ }
329
+ ),
330
+ /* @__PURE__ */ i("span", { className: "truncate text-[15px] font-semibold tracking-tight text-foreground", "data-boring-workspace-part": "app-left-pane-brand", children: o })
331
+ ] }) : null,
332
+ n ? /* @__PURE__ */ i(
333
+ "div",
334
+ {
335
+ className: s ? "mt-1 min-w-0" : "min-w-0 pr-1",
336
+ style: s ? void 0 : { paddingLeft: "2.5rem" },
337
+ "data-boring-workspace-part": "app-left-pane-workspace",
338
+ children: n
339
+ }
340
+ ) : t ? /* @__PURE__ */ i(
341
+ "div",
342
+ {
343
+ className: "mt-0.5 flex min-h-8 items-center gap-2 rounded-md px-2 text-[13px] text-foreground/72",
344
+ "data-boring-workspace-part": "app-left-pane-workspace",
345
+ children: /* @__PURE__ */ i("span", { className: "truncate", children: t })
346
+ }
347
+ ) : null
348
+ ] });
349
+ }
350
+ function rn({
351
+ icon: e,
352
+ label: t,
353
+ onClick: n,
354
+ emphasis: s = !1,
355
+ trailing: o
356
+ }) {
357
+ return /* @__PURE__ */ b(
358
+ "button",
359
+ {
360
+ type: "button",
361
+ onClick: n,
362
+ className: V(
363
+ "flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
364
+ s ? "bg-foreground/[0.06] text-foreground hover:bg-foreground/[0.1]" : "text-foreground/82 hover:bg-foreground/[0.055] hover:text-foreground"
365
+ ),
366
+ children: [
367
+ /* @__PURE__ */ i("span", { className: V("grid size-5 shrink-0 place-items-center", s ? "text-foreground/90" : "text-muted-foreground"), "aria-hidden": "true", children: e }),
368
+ /* @__PURE__ */ i("span", { className: "min-w-0 flex-1 truncate", children: t }),
369
+ o ? /* @__PURE__ */ i("span", { className: "shrink-0", children: o }) : null
370
+ ]
371
+ }
372
+ );
373
+ }
374
+ function Ds({ keys: e }) {
375
+ return /* @__PURE__ */ i("kbd", { "aria-hidden": "true", className: "rounded border border-border/60 bg-foreground/[0.08] px-1.5 py-px text-[10px] font-medium leading-[1.4] tracking-wide text-muted-foreground", children: e });
376
+ }
377
+ function Jr({
378
+ session: e,
379
+ state: t,
380
+ pinned: n,
381
+ canSplit: s = !0,
382
+ canPin: o = !0,
383
+ onSwitch: a,
384
+ onOpenAsPane: l,
385
+ onTogglePinned: g
386
+ }) {
387
+ const f = e.title || "Untitled", d = () => {
388
+ t !== "active" && a(e.id);
389
+ };
390
+ return /* @__PURE__ */ b(
391
+ "div",
392
+ {
393
+ "data-boring-workspace-part": "app-session-row",
394
+ "data-boring-session-state": t,
395
+ draggable: s,
396
+ onDragStart: s ? (m) => {
397
+ m.dataTransfer.setData(ss, e.id), m.dataTransfer.setData("text/plain", f), m.dataTransfer.effectAllowed = "copyMove";
398
+ } : void 0,
399
+ className: V(
400
+ "group flex min-h-8 w-full items-center gap-2 rounded-md border px-2.5 py-1 text-left transition-colors",
401
+ t === "active" ? "border-transparent bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-foreground" : t === "open" ? "border-transparent bg-foreground/[0.05] text-foreground/90 hover:bg-foreground/[0.07]" : "border-transparent text-foreground/78 hover:bg-foreground/[0.055] hover:text-foreground"
402
+ ),
403
+ children: [
404
+ /* @__PURE__ */ i(
405
+ Ji,
406
+ {
407
+ className: V(
408
+ "h-3.5 w-3.5 shrink-0",
409
+ t === "active" ? "text-[color:var(--accent)]" : "text-muted-foreground/65"
410
+ ),
411
+ strokeWidth: 1.75,
412
+ "aria-hidden": "true"
413
+ }
414
+ ),
415
+ /* @__PURE__ */ i(
416
+ "button",
417
+ {
418
+ type: "button",
419
+ onClick: d,
420
+ disabled: t === "active",
421
+ className: "min-w-0 flex-1 truncate rounded text-left text-[13px] font-medium leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default",
422
+ title: f,
423
+ children: f
424
+ }
425
+ ),
426
+ /* @__PURE__ */ b("span", { className: "flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100", children: [
427
+ o ? /* @__PURE__ */ i(
428
+ "button",
429
+ {
430
+ type: "button",
431
+ "aria-label": n ? `Unpin ${f}` : `Pin ${f}`,
432
+ title: n ? "Unpin" : "Pin",
433
+ "aria-pressed": n,
434
+ onClick: () => g(e.id),
435
+ className: V(
436
+ "grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
437
+ n && "text-[color:var(--accent)]"
438
+ ),
439
+ children: /* @__PURE__ */ i(Wr, { className: V("h-3.5 w-3.5", n && "fill-current"), strokeWidth: 1.75 })
440
+ }
441
+ ) : null,
442
+ t === "normal" && s ? /* @__PURE__ */ i(
443
+ "button",
444
+ {
445
+ type: "button",
446
+ "aria-label": `Open ${f} in new chat pane`,
447
+ title: "Open in new chat pane",
448
+ onClick: () => l(e.id),
449
+ className: "grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
450
+ children: /* @__PURE__ */ i(Mr, { className: "h-3.5 w-3.5", strokeWidth: 1.75 })
451
+ }
452
+ ) : null
453
+ ] })
454
+ ]
455
+ }
456
+ );
457
+ }
458
+ const Br = "boring-workspace:pinned-projects";
459
+ function Ls() {
460
+ var e;
461
+ try {
462
+ const t = (e = globalThis.localStorage) == null ? void 0 : e.getItem(Br);
463
+ if (!t) return [];
464
+ const n = JSON.parse(t);
465
+ return Array.isArray(n == null ? void 0 : n.ids) ? n.ids.filter((s) => typeof s == "string") : [];
466
+ } catch {
467
+ return [];
468
+ }
469
+ }
470
+ function Os(e) {
471
+ var t;
472
+ try {
473
+ (t = globalThis.localStorage) == null || t.setItem(Br, JSON.stringify({ ids: e }));
474
+ } catch {
475
+ }
476
+ }
477
+ function Ws() {
478
+ const [e, t] = O(() => Ls());
479
+ return [e, (s) => t((o) => {
480
+ const a = o.includes(s) ? o.filter((l) => l !== s) : [...o, s];
481
+ return Os(a), a;
482
+ })];
483
+ }
484
+ function Ms({
485
+ projects: e,
486
+ activeProjectId: t,
487
+ fallbackName: n,
488
+ expandedIds: s,
489
+ onToggleExpanded: o,
490
+ pinnedProjectIds: a,
491
+ onTogglePinnedProject: l,
492
+ onOpenProjectSession: g,
493
+ onShowMoreProjectSessions: f,
494
+ onCreateProjectSession: d,
495
+ onOpenProjectSettings: m,
496
+ onOpenProjectInNewTab: A,
497
+ renderProjectSession: R
498
+ }) {
499
+ var E;
500
+ const W = t ?? ((E = e[0]) == null ? void 0 : E.id) ?? null;
501
+ return /* @__PURE__ */ i("div", { className: "space-y-0.5", children: e.map((v) => /* @__PURE__ */ i(
502
+ Is,
503
+ {
504
+ project: v,
505
+ fallbackName: n,
506
+ active: v.id === W,
507
+ expanded: s.has(v.id),
508
+ pinned: a.has(v.id),
509
+ onTogglePinned: () => l(v.id),
510
+ onToggleExpanded: () => o(v.id),
511
+ onActivate: () => o(v.id),
512
+ onOpenSession: g,
513
+ onShowMore: f,
514
+ onCreateSession: d,
515
+ onOpenSettings: m,
516
+ onOpenInNewTab: A,
517
+ renderProjectSession: R
518
+ },
519
+ v.id
520
+ )) });
521
+ }
522
+ function Is({
523
+ project: e,
524
+ fallbackName: t,
525
+ active: n,
526
+ expanded: s,
527
+ pinned: o,
528
+ onTogglePinned: a,
529
+ onToggleExpanded: l,
530
+ onActivate: g,
531
+ onOpenSession: f,
532
+ onShowMore: d,
533
+ onCreateSession: m,
534
+ onOpenSettings: A,
535
+ onOpenInNewTab: R,
536
+ renderProjectSession: W
537
+ }) {
538
+ const [E, v] = O(!1), p = e.sessions ?? [], h = e.blockedCount ?? 0, x = e.available === !1, L = e.name || t, he = !!(m || !0);
539
+ return /* @__PURE__ */ b("div", { className: "space-y-0.5", children: [
540
+ /* @__PURE__ */ b(
541
+ "div",
542
+ {
543
+ className: V(
544
+ "group relative flex min-h-8 w-full items-center gap-2 rounded-md py-1 pl-2 pr-2 transition-colors",
545
+ n ? "bg-foreground/[0.07] text-foreground" : x ? "text-muted-foreground/45" : "text-foreground/82 hover:bg-foreground/[0.05] hover:text-foreground"
546
+ ),
547
+ children: [
548
+ /* @__PURE__ */ i(
549
+ "button",
550
+ {
551
+ type: "button",
552
+ "aria-label": s ? `Collapse ${L}` : `Expand ${L}`,
553
+ "aria-expanded": s,
554
+ onClick: l,
555
+ className: "grid size-5 shrink-0 place-items-center rounded text-muted-foreground/55 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
556
+ children: /* @__PURE__ */ i(Bi, { className: V("h-3.5 w-3.5 transition-transform duration-150", s && "rotate-90"), strokeWidth: 2, "aria-hidden": "true" })
557
+ }
558
+ ),
559
+ /* @__PURE__ */ i(
560
+ "button",
561
+ {
562
+ type: "button",
563
+ "aria-current": n ? "page" : void 0,
564
+ disabled: x,
565
+ onClick: () => {
566
+ x || g();
567
+ },
568
+ className: "min-w-0 flex-1 truncate rounded text-left text-[13px] font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default",
569
+ children: L
570
+ }
571
+ ),
572
+ /* @__PURE__ */ b("span", { className: "relative flex h-6 w-[3.25rem] shrink-0 items-center justify-end", children: [
573
+ h > 0 ? /* @__PURE__ */ i("span", { className: V(
574
+ "pointer-events-none absolute inset-0 flex items-center justify-end transition-opacity",
575
+ he && "group-hover:opacity-0 group-focus-within:opacity-0",
576
+ E && "opacity-0"
577
+ ), children: /* @__PURE__ */ i(
578
+ "span",
579
+ {
580
+ title: `${h} session${h === 1 ? "" : "s"} waiting`,
581
+ className: "grid min-w-5 place-items-center rounded-full bg-[color:oklch(from_var(--accent)_l_c_h/0.18)] px-1.5 py-0.5 text-[11px] font-semibold text-[color:var(--accent)]",
582
+ children: h > 99 ? "99+" : h
583
+ }
584
+ ) }) : null,
585
+ he ? /* @__PURE__ */ b("span", { className: V(
586
+ "flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",
587
+ E && "opacity-100"
588
+ ), children: [
589
+ m ? /* @__PURE__ */ i(
590
+ "button",
591
+ {
592
+ type: "button",
593
+ "aria-label": `New chat in ${L}`,
594
+ title: "New chat",
595
+ onClick: (H) => {
596
+ H.stopPropagation(), m(e.id);
597
+ },
598
+ className: "grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-foreground/[0.08] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
599
+ children: /* @__PURE__ */ i(dn, { className: "h-3.5 w-3.5", strokeWidth: 2 })
600
+ }
601
+ ) : null,
602
+ /* @__PURE__ */ b(vs, { open: E, onOpenChange: v, children: [
603
+ /* @__PURE__ */ i(xs, { asChild: !0, children: /* @__PURE__ */ i(
604
+ "button",
605
+ {
606
+ type: "button",
607
+ "aria-label": `${L} options`,
608
+ title: "More",
609
+ onClick: (H) => H.stopPropagation(),
610
+ className: "grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-foreground/[0.08] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
611
+ children: /* @__PURE__ */ i(qi, { className: "h-3.5 w-3.5", strokeWidth: 2 })
612
+ }
613
+ ) }),
614
+ /* @__PURE__ */ b(ys, { align: "end", sideOffset: 6, className: "w-48 border-border/50 shadow-[0_12px_28px_-6px_rgba(0,0,0,0.55)]", children: [
615
+ /* @__PURE__ */ b(Rt, { onSelect: a, className: "gap-2 text-[13px]", children: [
616
+ o ? /* @__PURE__ */ i(Vi, { className: "h-3.5 w-3.5", "aria-hidden": "true" }) : /* @__PURE__ */ i(Wr, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
617
+ o ? "Unpin project" : "Pin project"
618
+ ] }),
619
+ m ? /* @__PURE__ */ b(Rt, { onSelect: () => m(e.id), className: "gap-2 text-[13px]", children: [
620
+ /* @__PURE__ */ i(Mr, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
621
+ "New chat"
622
+ ] }) : null,
623
+ A ? /* @__PURE__ */ b(Rt, { onSelect: () => A(e.id), className: "gap-2 text-[13px]", children: [
624
+ /* @__PURE__ */ i(Yi, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
625
+ "Workspace settings"
626
+ ] }) : null,
627
+ R ? /* @__PURE__ */ b(oe, { children: [
628
+ /* @__PURE__ */ i(Ss, {}),
629
+ /* @__PURE__ */ b(Rt, { onSelect: () => R(e.id), className: "gap-2 text-[13px]", children: [
630
+ /* @__PURE__ */ i(Xi, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
631
+ "Open in new tab"
632
+ ] })
633
+ ] }) : null
634
+ ] })
635
+ ] })
636
+ ] }) : null
637
+ ] })
638
+ ]
639
+ }
640
+ ),
641
+ s ? /* @__PURE__ */ b("div", { className: "space-y-0.5 pl-6", children: [
642
+ e.loadingSessions && p.length === 0 ? /* @__PURE__ */ i("div", { className: "px-1 py-1.5 text-xs text-muted-foreground", children: "Loading chats…" }) : p.length === 0 ? /* @__PURE__ */ i("div", { className: "px-1 py-1.5 text-xs text-muted-foreground", children: "No chats yet." }) : p.map((H) => /* @__PURE__ */ i("div", { children: W ? W(e, H) : /* @__PURE__ */ i(
643
+ Jr,
644
+ {
645
+ session: H,
646
+ state: "normal",
647
+ pinned: !1,
648
+ onSwitch: () => f == null ? void 0 : f(e.id, H.id),
649
+ onOpenAsPane: () => f == null ? void 0 : f(e.id, H.id),
650
+ onTogglePinned: () => {
651
+ }
652
+ }
653
+ ) }, H.id)),
654
+ e.hasMoreSessions ? /* @__PURE__ */ i(
655
+ "button",
656
+ {
657
+ type: "button",
658
+ onClick: () => d == null ? void 0 : d(e.id),
659
+ className: "rounded-md px-1 py-1 text-left text-[13px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
660
+ children: "Show more"
661
+ }
662
+ ) : null
663
+ ] }) : null
664
+ ] });
665
+ }
666
+ function sn({ title: e, empty: t, children: n }) {
667
+ const s = Array.isArray(n) ? n.length > 0 : !!n;
668
+ return !s && !t ? null : /* @__PURE__ */ b("div", { className: "space-y-1", children: [
669
+ /* @__PURE__ */ i("div", { className: "px-2 pb-0.5 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/65", children: e }),
670
+ /* @__PURE__ */ i("div", { className: "space-y-0.5", children: s ? n : /* @__PURE__ */ i("div", { className: "px-2 py-1.5 text-xs text-muted-foreground/60", children: t }) })
671
+ ] });
672
+ }
673
+ function Fs({
674
+ width: e = 268,
675
+ appTitle: t,
676
+ workspaceLabel: n,
677
+ workspaceSectionTitle: s = "Workspaces",
678
+ projects: o,
679
+ activeProjectId: a,
680
+ onOpenProjectSession: l,
681
+ onShowMoreProjectSessions: g,
682
+ onCreateProject: f,
683
+ onCreateProjectSession: d,
684
+ onOpenProjectSettings: m,
685
+ onOpenProjectInNewTab: A,
686
+ topSlot: R,
687
+ bottomSlot: W,
688
+ headerMode: E = "full",
689
+ sessions: v,
690
+ activeSessionId: p,
691
+ openSessionIds: h,
692
+ pinnedSessionIds: x,
693
+ onCreateSession: L,
694
+ onOpenCommandPalette: F,
695
+ onSwitchSession: he,
696
+ onOpenSessionAsPane: H,
697
+ onToggleSessionPinned: Ot,
698
+ actions: Wt = [],
699
+ layoutMode: ge = "single-project"
700
+ }) {
701
+ const ot = D(() => new Set(h), [h]), Ee = D(() => new Set(x), [x]), me = D(
702
+ () => x.map((y) => v.find((T) => T.id === y)).filter((y) => !!y),
703
+ [x, v]
704
+ ), be = D(
705
+ () => v.filter((y) => !Ee.has(y.id)),
706
+ [Ee, v]
707
+ ), ae = D(() => {
708
+ const y = o ?? [];
709
+ return ge !== "multi-project" ? y : y.map((T) => T.id !== a ? T : {
710
+ ...T,
711
+ sessions: T.sessions ?? be.map((M) => ({
712
+ id: M.id,
713
+ title: M.title,
714
+ updatedAt: M.updatedAt
715
+ })),
716
+ sessionCount: T.sessionCount ?? be.length
717
+ });
718
+ }, [a, ge, o, be]), [$e, at] = O(() => {
719
+ var T;
720
+ const y = a ?? ((T = o == null ? void 0 : o[0]) == null ? void 0 : T.id);
721
+ return new Set(y ? [y] : []);
722
+ }), Mt = (y) => at((T) => {
723
+ const M = new Set(T);
724
+ return M.has(y) ? M.delete(y) : M.add(y), M;
725
+ }), [ke, It] = Ws(), Ue = D(() => new Set(ke), [ke]), Ae = D(
726
+ () => ke.map((y) => ae.find((T) => T.id === y)).filter((y) => !!y),
727
+ [ke, ae]
728
+ ), Ge = D(
729
+ () => ae.filter((y) => !Ue.has(y.id)),
730
+ [ae, Ue]
731
+ ), Ft = E !== "hidden" && (ge !== "multi-project" || E === "workspace"), $t = E === "full" && ge !== "multi-project", Re = (y, T, M = a ?? void 0) => {
732
+ const le = !M || M === a, Ut = le && y.id === p ? "active" : le && ot.has(y.id) ? "open" : "normal";
733
+ return /* @__PURE__ */ i(
734
+ Jr,
735
+ {
736
+ session: y,
737
+ state: Ut,
738
+ pinned: T,
739
+ canSplit: le,
740
+ canPin: le,
741
+ onSwitch: le ? he : () => l == null ? void 0 : l(M, y.id),
742
+ onOpenAsPane: le ? H : () => l == null ? void 0 : l(M, y.id),
743
+ onTogglePinned: Ot
744
+ },
745
+ y.id
746
+ );
747
+ }, lt = (y) => /* @__PURE__ */ i(
748
+ Ms,
749
+ {
750
+ projects: y,
751
+ activeProjectId: a,
752
+ fallbackName: n || t || "Boring UI",
753
+ expandedIds: $e,
754
+ onToggleExpanded: Mt,
755
+ pinnedProjectIds: Ue,
756
+ onTogglePinnedProject: It,
757
+ onOpenProjectSession: (T, M) => {
758
+ T === a ? he(M) : l == null || l(T, M);
759
+ },
760
+ onShowMoreProjectSessions: g,
761
+ onCreateProjectSession: d,
762
+ onOpenProjectSettings: m,
763
+ onOpenProjectInNewTab: A,
764
+ renderProjectSession: (T, M) => Re({
765
+ id: M.id,
766
+ title: M.title,
767
+ updatedAt: M.updatedAt
768
+ }, Ee.has(M.id), T.id)
769
+ }
770
+ );
771
+ return /* @__PURE__ */ b(
772
+ "aside",
773
+ {
774
+ "data-boring-workspace-part": "app-left-pane",
775
+ className: "flex h-full min-h-0 shrink-0 flex-col border-r border-border bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)] text-sm",
776
+ style: { width: e, minWidth: e, maxWidth: e },
777
+ "aria-label": "App navigation",
778
+ children: [
779
+ Ft ? /* @__PURE__ */ i(
780
+ _s,
781
+ {
782
+ appTitle: t,
783
+ workspaceLabel: n,
784
+ topSlot: R,
785
+ showBrand: $t
786
+ }
787
+ ) : /* @__PURE__ */ i("div", { className: "h-12 shrink-0", "aria-hidden": "true" }),
788
+ /* @__PURE__ */ b("nav", { className: "shrink-0 space-y-0.5 px-2 pb-1 pt-1", "aria-label": "Primary workspace actions", children: [
789
+ /* @__PURE__ */ i(rn, { icon: /* @__PURE__ */ i(dn, { className: "h-4 w-4", strokeWidth: 2 }), label: "New chat", onClick: L, emphasis: !0 }),
790
+ /* @__PURE__ */ i(rn, { icon: /* @__PURE__ */ i(ji, { className: "h-4 w-4", strokeWidth: 1.75 }), label: "Search", onClick: F, trailing: /* @__PURE__ */ i(Ds, { keys: "⌘K" }) }),
791
+ Wt.map((y) => /* @__PURE__ */ i(
792
+ rn,
793
+ {
794
+ icon: y.icon,
795
+ label: y.label,
796
+ onClick: y.onClick,
797
+ trailing: y.trailing,
798
+ emphasis: y.emphasis
799
+ },
800
+ y.id
801
+ ))
802
+ ] }),
803
+ /* @__PURE__ */ i("div", { className: "boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto px-2 py-2", children: ge === "multi-project" ? /* @__PURE__ */ b("div", { className: "space-y-3 py-1", children: [
804
+ me.length > 0 || Ae.length > 0 ? /* @__PURE__ */ b(sn, { title: "Pinned", children: [
805
+ me.map((y) => Re(y, !0)),
806
+ Ae.length > 0 ? lt(Ae) : null
807
+ ] }) : null,
808
+ /* @__PURE__ */ b("section", { "data-boring-workspace-part": "app-left-pane-section", className: "space-y-1", children: [
809
+ /* @__PURE__ */ b("div", { className: "flex items-center justify-between gap-1 px-2 pb-0.5", children: [
810
+ /* @__PURE__ */ i("span", { className: "text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/65", children: s }),
811
+ f ? /* @__PURE__ */ i(
812
+ "button",
813
+ {
814
+ type: "button",
815
+ "aria-label": "New project",
816
+ title: "New project",
817
+ onClick: f,
818
+ className: "grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-foreground/[0.055] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
819
+ children: /* @__PURE__ */ i(dn, { className: "h-3.5 w-3.5", strokeWidth: 2, "aria-hidden": "true" })
820
+ }
821
+ ) : null
822
+ ] }),
823
+ lt(Ge)
824
+ ] })
825
+ ] }) : (
826
+ /* Single-project: no "Chats" wrapper — the session list is the whole
827
+ point of the body, so show Pinned + Sessions directly. */
828
+ /* @__PURE__ */ b("div", { className: "space-y-4 py-1", children: [
829
+ me.length > 0 ? /* @__PURE__ */ i(sn, { title: "Pinned", children: me.map((y) => Re(y, !0)) }) : null,
830
+ /* @__PURE__ */ i(sn, { title: "Chats", empty: "No chats yet.", children: be.map((y) => Re(y, !1)) })
831
+ ] })
832
+ ) }),
833
+ W ? /* @__PURE__ */ i("footer", { className: "shrink-0 border-t border-border/40 p-2", children: W }) : null
834
+ ]
835
+ }
836
+ );
837
+ }
838
+ function $s({
839
+ width: e,
840
+ minWidth: t,
841
+ maxWidth: n,
842
+ onResize: s
843
+ }) {
844
+ const o = J(null), a = k((d) => {
845
+ if (o.current == null) return;
846
+ const m = d.clientX - o.current;
847
+ o.current = d.clientX, m !== 0 && s(m);
848
+ }, [s]), l = k(() => {
849
+ o.current = null, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", l);
850
+ }, [a]), g = k((d) => {
851
+ var m, A;
852
+ d.preventDefault(), (A = (m = d.currentTarget).setPointerCapture) == null || A.call(m, d.pointerId), o.current = d.clientX, document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", window.addEventListener("pointermove", a), window.addEventListener("pointerup", l);
853
+ }, [a, l]), f = k((d) => {
854
+ d.key === "ArrowLeft" ? (d.preventDefault(), s(d.shiftKey ? -48 : -16)) : d.key === "ArrowRight" ? (d.preventDefault(), s(d.shiftKey ? 48 : 16)) : d.key === "Home" ? (d.preventDefault(), s(t - e)) : d.key === "End" && (d.preventDefault(), s(n - e));
855
+ }, [n, t, s, e]);
856
+ return /* @__PURE__ */ i(
857
+ "div",
858
+ {
859
+ role: "separator",
860
+ "aria-label": "Resize app navigation",
861
+ "aria-orientation": "vertical",
862
+ "aria-valuemin": t,
863
+ "aria-valuemax": n,
864
+ "aria-valuenow": e,
865
+ tabIndex: 0,
866
+ onKeyDown: f,
867
+ onPointerDown: g,
868
+ className: "group relative z-20 -ml-px w-1 shrink-0 cursor-col-resize touch-none bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
869
+ children: /* @__PURE__ */ i("span", { className: "absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-colors group-hover:bg-foreground/30 group-active:bg-foreground/45" })
870
+ }
871
+ );
872
+ }
873
+ function Us({
874
+ collapsed: e,
875
+ leftPane: t,
876
+ children: n,
877
+ onExpand: s,
878
+ onCollapse: o,
879
+ onResizeLeftPane: a,
880
+ leftPaneWidth: l,
881
+ minLeftPaneWidth: g = 220,
882
+ maxLeftPaneWidth: f = 420,
883
+ className: d
884
+ }) {
885
+ const [m, A] = O(!1);
886
+ return /* @__PURE__ */ b(
887
+ "div",
888
+ {
889
+ "data-boring-workspace-part": "plugin-tabs-shell",
890
+ "data-boring-state": e ? "collapsed" : "expanded",
891
+ className: V("relative flex h-full min-h-0 w-full overflow-hidden bg-background", d),
892
+ children: [
893
+ e ? null : t,
894
+ !e && a && l != null ? /* @__PURE__ */ i(
895
+ $s,
896
+ {
897
+ width: l,
898
+ minWidth: g,
899
+ maxWidth: f,
900
+ onResize: a
901
+ }
902
+ ) : null,
903
+ /* @__PURE__ */ i("div", { className: "relative min-w-0 flex-1", children: n }),
904
+ e ? /* @__PURE__ */ b(oe, { children: [
905
+ /* @__PURE__ */ i(
906
+ "div",
907
+ {
908
+ "data-boring-workspace-part": "app-left-peek-trigger",
909
+ className: "absolute inset-y-0 left-0 z-[60] w-3",
910
+ onMouseEnter: () => A(!0),
911
+ "aria-hidden": "true"
912
+ }
913
+ ),
914
+ m ? /* @__PURE__ */ i(
915
+ "div",
916
+ {
917
+ "data-boring-workspace-part": "app-left-peek",
918
+ "data-boring-state": "open",
919
+ onMouseLeave: () => A(!1),
920
+ className: "absolute inset-y-0 left-0 z-[65] flex shadow-2xl",
921
+ children: t
922
+ }
923
+ ) : null
924
+ ] }) : null,
925
+ /* @__PURE__ */ i("div", { className: "pointer-events-none absolute left-1.5 top-2 z-[70]", children: /* @__PURE__ */ i(
926
+ os,
927
+ {
928
+ label: e ? "Open app navigation" : "Hide app navigation",
929
+ side: "right",
930
+ onClick: e ? s : o,
931
+ children: e ? /* @__PURE__ */ i(Qi, { className: "h-4 w-4", strokeWidth: 1.75 }) : /* @__PURE__ */ i(Zi, { className: "h-4 w-4", strokeWidth: 1.75 })
932
+ }
933
+ ) })
934
+ ]
935
+ }
936
+ );
937
+ }
938
+ function Gs() {
26
939
  const e = `s${Date.now()}`;
27
940
  return {
28
941
  sessions: [{ id: e, title: "New session", updatedAt: Date.now() }],
29
942
  activeId: e
30
943
  };
31
944
  }
32
- function ts(e, n) {
33
- var r;
34
- if (typeof localStorage > "u") return n();
945
+ function zs(e, t) {
946
+ var n;
947
+ if (typeof localStorage > "u") return t();
35
948
  try {
36
949
  const s = localStorage.getItem(e);
37
950
  if (s) {
38
- const i = JSON.parse(s), o = Array.isArray(i.sessions) ? i.sessions : Array.isArray(i.items) ? i.items : null;
39
- if (o)
40
- return { sessions: o, activeId: i.activeId ?? ((r = o[0]) == null ? void 0 : r.id) ?? "" };
951
+ const o = JSON.parse(s), a = Array.isArray(o.sessions) ? o.sessions : Array.isArray(o.items) ? o.items : null;
952
+ if (a)
953
+ return { sessions: a, activeId: o.activeId ?? ((n = a[0]) == null ? void 0 : n.id) ?? "" };
41
954
  }
42
955
  } catch {
43
956
  }
44
- return n();
957
+ return t();
45
958
  }
46
- function ns(e, n) {
959
+ function Ks(e, t) {
47
960
  if (!(typeof localStorage > "u"))
48
961
  try {
49
- localStorage.setItem(e, JSON.stringify(n));
962
+ localStorage.setItem(e, JSON.stringify(t));
50
963
  } catch {
51
964
  }
52
965
  }
53
- function rs(e = {}) {
54
- const n = e.storageKey ?? "workspace:sessions", r = e.initial ?? es;
55
- let s = ts(n, r);
56
- const i = /* @__PURE__ */ new Set(), o = (c) => {
57
- s = c, ns(n, s), i.forEach((u) => u());
966
+ function Hs(e = {}) {
967
+ const t = e.storageKey ?? "workspace:sessions", n = e.initial ?? Gs;
968
+ let s = zs(t, n);
969
+ const o = /* @__PURE__ */ new Set(), a = (l) => {
970
+ s = l, Ks(t, s), o.forEach((g) => g());
58
971
  };
59
972
  return {
60
973
  getState: () => s,
61
- subscribe(c) {
62
- return i.add(c), () => {
63
- i.delete(c);
974
+ subscribe(l) {
975
+ return o.add(l), () => {
976
+ o.delete(l);
64
977
  };
65
978
  },
66
- switchTo(c) {
67
- o({ ...s, activeId: c });
979
+ switchTo(l) {
980
+ a({ ...s, activeId: l });
68
981
  },
69
982
  create() {
70
- const c = `s${Date.now()}`, u = {
71
- id: c,
983
+ const l = `s${Date.now()}`, g = {
984
+ id: l,
72
985
  title: "New session",
73
986
  updatedAt: Date.now()
74
987
  };
75
- o({ sessions: [u, ...s.sessions], activeId: c });
988
+ a({ sessions: [g, ...s.sessions], activeId: l });
76
989
  },
77
- remove(c) {
78
- var y;
79
- const u = s.sessions.filter((b) => b.id !== c), v = s.activeId === c ? ((y = u[0]) == null ? void 0 : y.id) ?? "" : s.activeId;
80
- o({ sessions: u, activeId: v });
990
+ remove(l) {
991
+ var d;
992
+ const g = s.sessions.filter((m) => m.id !== l), f = s.activeId === l ? ((d = g[0]) == null ? void 0 : d.id) ?? "" : s.activeId;
993
+ a({ sessions: g, activeId: f });
81
994
  }
82
995
  };
83
996
  }
84
- function ss(e) {
85
- return xr(e.subscribe, e.getState, e.getState);
997
+ function Js(e) {
998
+ return cn(e.subscribe, e.getState, e.getState);
86
999
  }
87
- const is = 500, os = 1e4;
88
- function An(e) {
89
- return new Promise((n, r) => {
1000
+ const Bs = 500, qs = 1e4;
1001
+ function Pr(e) {
1002
+ return new Promise((t, n) => {
90
1003
  let s;
91
- const i = () => {
92
- s && globalThis.clearTimeout(s), e.removeEventListener("abort", o);
93
- }, o = () => {
94
- i(), r(new DOMException("Warmup aborted", "AbortError"));
1004
+ const o = () => {
1005
+ s && globalThis.clearTimeout(s), e.removeEventListener("abort", a);
1006
+ }, a = () => {
1007
+ o(), n(new DOMException("Warmup aborted", "AbortError"));
95
1008
  };
96
1009
  if (e.aborted) {
97
- o();
1010
+ a();
98
1011
  return;
99
1012
  }
100
1013
  s = globalThis.setTimeout(() => {
101
- i(), n();
102
- }, is), e.addEventListener("abort", o, { once: !0 });
1014
+ o(), t();
1015
+ }, Bs), e.addEventListener("abort", a, { once: !0 });
103
1016
  });
104
1017
  }
105
- async function as(e) {
106
- const n = e.body;
107
- if (!n) return Ve(await ke(e));
108
- const r = n.getReader(), s = new TextDecoder();
109
- let i = "";
1018
+ async function Vs(e) {
1019
+ const t = e.body;
1020
+ if (!t) return _t(await Lt(e));
1021
+ const n = t.getReader(), s = new TextDecoder();
1022
+ let o = "";
110
1023
  try {
111
1024
  for (; ; ) {
112
- const { done: o, value: c } = await r.read();
113
- if (c) {
114
- i += s.decode(c, { stream: !o });
115
- const u = Ve(i);
116
- if (u) return u;
1025
+ const { done: a, value: l } = await n.read();
1026
+ if (l) {
1027
+ o += s.decode(l, { stream: !a });
1028
+ const g = _t(o);
1029
+ if (g) return g;
117
1030
  }
118
- if (o)
119
- return i += s.decode(), Ve(i);
1031
+ if (a)
1032
+ return o += s.decode(), _t(o);
120
1033
  }
121
1034
  } finally {
122
- await r.cancel().catch(() => {
1035
+ await n.cancel().catch(() => {
123
1036
  });
124
1037
  }
125
1038
  }
126
- function ls(e) {
1039
+ function Ys(e) {
127
1040
  if (!((e == null ? void 0 : e.runtimeDependenciesState) !== "preparing" && (e == null ? void 0 : e.runtimeDependenciesState) !== "ready" && (e == null ? void 0 : e.runtimeDependenciesState) !== "failed"))
128
1041
  return {
129
1042
  state: e.runtimeDependenciesState,
@@ -131,946 +1044,1158 @@ function ls(e) {
131
1044
  ...e.runtimeDependenciesRequirement ? { requirement: e.runtimeDependenciesRequirement } : {}
132
1045
  };
133
1046
  }
134
- async function cs(e) {
1047
+ async function Xs(e) {
135
1048
  if (!e.ok) {
136
- const i = await ke(e);
137
- if (St(i)) return { status: "preparing" };
138
- throw new Error(vt(i) ?? `/api/v1/ready-status failed with ${e.status}`);
1049
+ const o = await Lt(e);
1050
+ if (fn(o)) return { status: "preparing" };
1051
+ throw new Error(gn(o) ?? `/api/v1/ready-status failed with ${e.status}`);
139
1052
  }
140
- const n = await as(e), r = ls(n), s = Ir(n);
141
- if ((n == null ? void 0 : n.state) === "degraded" || (n == null ? void 0 : n.state) === "failed") {
142
- if (s && (r == null ? void 0 : r.state) === "failed")
143
- return { status: "ready", runtimeDependencies: r };
144
- throw new Error(n.message ?? "Workspace failed to prepare");
1053
+ const t = await Vs(e), n = Ys(t), s = as(t);
1054
+ if ((t == null ? void 0 : t.state) === "degraded" || (t == null ? void 0 : t.state) === "failed") {
1055
+ if (s && (n == null ? void 0 : n.state) === "failed")
1056
+ return { status: "ready", runtimeDependencies: n };
1057
+ throw new Error(t.message ?? "Workspace failed to prepare");
145
1058
  }
146
- return s ? { status: "ready", ...r ? { runtimeDependencies: r } : {} } : { status: "preparing", ...r ? { runtimeDependencies: r } : {} };
1059
+ return s ? { status: "ready", ...n ? { runtimeDependencies: n } : {} } : { status: "preparing", ...n ? { runtimeDependencies: n } : {} };
147
1060
  }
148
- async function us({
1061
+ async function js({
149
1062
  apiBaseUrl: e,
150
- path: n,
151
- headers: r,
1063
+ path: t,
1064
+ headers: n,
152
1065
  signal: s,
153
- workspaceId: i
1066
+ workspaceId: o
154
1067
  }) {
155
- const o = new AbortController(), c = globalThis.setTimeout(() => o.abort(new DOMException("Warmup attempt timed out", "TimeoutError")), os), u = () => o.abort(s.reason);
156
- s.aborted && u(), s.addEventListener("abort", u, { once: !0 });
1068
+ const a = new AbortController(), l = globalThis.setTimeout(() => a.abort(new DOMException("Warmup attempt timed out", "TimeoutError")), qs), g = () => a.abort(s.reason);
1069
+ s.aborted && g(), s.addEventListener("abort", g, { once: !0 });
157
1070
  try {
158
- const v = await fetch(Ln(e, n), { headers: r, signal: o.signal });
159
- if (xn(n)) return await cs(v);
160
- const y = await ke(v);
161
- if (!v.ok) {
162
- const b = St(y);
163
- if (b) return { status: "preparing", ...b };
164
- throw new Error(vt(y) ?? `${n} failed with ${v.status}`);
1071
+ const f = await fetch(Ur(e, t), { headers: n, signal: a.signal });
1072
+ if (Gr(t)) return await Xs(f);
1073
+ const d = await Lt(f);
1074
+ if (!f.ok) {
1075
+ const m = fn(d);
1076
+ if (m) return { status: "preparing", ...m };
1077
+ throw new Error(gn(d) ?? `${t} failed with ${f.status}`);
165
1078
  }
166
- return y && typeof y == "object" && Mn(e, r["x-boring-workspace-id"] ?? i, n, y), { status: "ready" };
167
- } catch (v) {
168
- if (s.aborted) throw v;
169
- if (o.signal.aborted || v instanceof TypeError) return { status: "preparing" };
170
- throw v;
1079
+ return d && typeof d == "object" && zr(e, n["x-boring-workspace-id"] ?? o, t, d), { status: "ready" };
1080
+ } catch (f) {
1081
+ if (s.aborted) throw f;
1082
+ if (a.signal.aborted || f instanceof TypeError) return { status: "preparing" };
1083
+ throw f;
171
1084
  } finally {
172
- globalThis.clearTimeout(c), s.removeEventListener("abort", u);
1085
+ globalThis.clearTimeout(l), s.removeEventListener("abort", g);
173
1086
  }
174
1087
  }
175
- function ds({
1088
+ function Qs({
176
1089
  workspaceId: e,
177
- requestHeaders: n,
178
- apiBaseUrl: r,
179
- preloadPaths: s = _n,
180
- provisionWorkspace: i = !0,
181
- onStatusChange: o
1090
+ requestHeaders: t,
1091
+ apiBaseUrl: n,
1092
+ preloadPaths: s = Fr,
1093
+ provisionWorkspace: o = !0,
1094
+ onStatusChange: a
182
1095
  }) {
183
- return A(() => {
184
- let c = !1;
185
- const u = new AbortController(), v = ze(e, n);
186
- async function y() {
187
- var b, q;
188
- o == null || o({ status: "preparing" });
1096
+ return _(() => {
1097
+ let l = !1;
1098
+ const g = new AbortController(), f = Dt(e, t);
1099
+ async function d() {
1100
+ var m, A;
1101
+ a == null || a({ status: "preparing" });
189
1102
  try {
190
- const F = On(s, i), z = (p) => us({
191
- apiBaseUrl: r,
192
- path: p,
193
- headers: v,
194
- signal: u.signal,
1103
+ const R = $r(s, o), W = (h) => js({
1104
+ apiBaseUrl: n,
1105
+ path: h,
1106
+ headers: f,
1107
+ signal: g.signal,
195
1108
  workspaceId: e
196
1109
  });
197
- let T = await Promise.all(F.map(async (p) => ({ path: p, result: await z(p) })));
198
- if (c || u.signal.aborted) return;
199
- let h = (b = T.find((p) => p.result.runtimeDependencies)) == null ? void 0 : b.result.runtimeDependencies, w = T.filter((p) => p.result.status === "preparing");
200
- for (; w.length > 0; ) {
201
- let p;
202
- for (const N of w)
203
- if (N.result.status === "preparing" && N.result.requirement) {
204
- p = N.result.requirement;
1110
+ let E = await Promise.all(R.map(async (h) => ({ path: h, result: await W(h) })));
1111
+ if (l || g.signal.aborted) return;
1112
+ let v = (m = E.find((h) => h.result.runtimeDependencies)) == null ? void 0 : m.result.runtimeDependencies, p = E.filter((h) => h.result.status === "preparing");
1113
+ for (; p.length > 0; ) {
1114
+ let h;
1115
+ for (const x of p)
1116
+ if (x.result.status === "preparing" && x.result.requirement) {
1117
+ h = x.result.requirement;
205
1118
  break;
206
1119
  }
207
- if (o == null || o({ status: "preparing", message: "Workspace is still preparing", ...p ? { requirement: p } : {} }), await An(u.signal), c || u.signal.aborted || (T = await Promise.all(w.map(async (N) => ({ path: N.path, result: await z(N.path) }))), c || u.signal.aborted)) return;
208
- h = ((q = T.find((N) => N.result.runtimeDependencies)) == null ? void 0 : q.result.runtimeDependencies) ?? h, w = T.filter((N) => N.result.status === "preparing");
1120
+ if (a == null || a({ status: "preparing", message: "Workspace is still preparing", ...h ? { requirement: h } : {} }), await Pr(g.signal), l || g.signal.aborted || (E = await Promise.all(p.map(async (x) => ({ path: x.path, result: await W(x.path) }))), l || g.signal.aborted)) return;
1121
+ v = ((A = E.find((x) => x.result.runtimeDependencies)) == null ? void 0 : A.result.runtimeDependencies) ?? v, p = E.filter((x) => x.result.status === "preparing");
209
1122
  }
210
- for (o == null || o({ status: "ready", ...h ? { runtimeDependencies: h } : {} }); (h == null ? void 0 : h.state) === "preparing"; ) {
211
- if (await An(u.signal), c || u.signal.aborted) return;
212
- const p = await z("/api/v1/ready-status");
213
- if (c || u.signal.aborted) return;
214
- h = p.runtimeDependencies, h && (o == null || o({ status: "ready", runtimeDependencies: h }));
1123
+ for (a == null || a({ status: "ready", ...v ? { runtimeDependencies: v } : {} }); (v == null ? void 0 : v.state) === "preparing"; ) {
1124
+ if (await Pr(g.signal), l || g.signal.aborted) return;
1125
+ const h = await W("/api/v1/ready-status");
1126
+ if (l || g.signal.aborted) return;
1127
+ v = h.runtimeDependencies, v && (a == null || a({ status: "ready", runtimeDependencies: v }));
215
1128
  }
216
- } catch (F) {
217
- if (c || u.signal.aborted) return;
218
- o == null || o({
1129
+ } catch (R) {
1130
+ if (l || g.signal.aborted) return;
1131
+ a == null || a({
219
1132
  status: "failed",
220
- message: F instanceof Error ? F.message : "Workspace failed to prepare"
1133
+ message: R instanceof Error ? R.message : "Workspace failed to prepare"
221
1134
  });
222
1135
  }
223
1136
  }
224
- return y(), () => {
225
- c = !0, u.abort();
1137
+ return d(), () => {
1138
+ l = !0, g.abort();
226
1139
  };
227
- }, [r, o, s, i, n, e]), null;
1140
+ }, [n, a, s, o, t, e]), null;
228
1141
  }
229
- function fs(e) {
1142
+ function Zs({ status: e }) {
1143
+ const t = e.status === "ready" ? void 0 : e.requirement, n = e.status !== "failed", s = n ? t === "workspace-fs" ? "Preparing files…" : t === "sandbox-exec" ? "Preparing secure runtime…" : t === "ui-bridge" ? "Connecting workspace…" : "Preparing workspace…" : "Workspace workbench failed", o = e.status === "failed" ? e.message : "Chat is ready while files, tools, and workspace panels finish warming up.";
1144
+ return /* @__PURE__ */ i("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ b("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
1145
+ n ? /* @__PURE__ */ i("div", { className: "mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin", "aria-hidden": "true" }) : null,
1146
+ /* @__PURE__ */ i("div", { className: "text-sm font-semibold text-foreground", children: s }),
1147
+ /* @__PURE__ */ i("p", { className: "mt-2 text-sm text-muted-foreground", children: o }),
1148
+ e.status === "failed" ? /* @__PURE__ */ i("p", { className: "mt-3 text-xs text-muted-foreground", children: "Reload the workspace to retry." }) : null
1149
+ ] }) });
1150
+ }
1151
+ function eo() {
1152
+ return /* @__PURE__ */ i("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ b("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
1153
+ /* @__PURE__ */ i("div", { className: "mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin", "aria-hidden": "true" }),
1154
+ /* @__PURE__ */ i("div", { className: "text-sm font-semibold text-foreground", children: "Loading sessions…" }),
1155
+ /* @__PURE__ */ i("p", { className: "mt-2 text-sm text-muted-foreground", children: "Finding this workspace’s saved chats." })
1156
+ ] }) });
1157
+ }
1158
+ function to(e) {
1159
+ if (!e) return "/api/v1/ui";
1160
+ const t = e.replace(/\/$/, ""), n = "/api/v1/ui";
1161
+ return t.endsWith(n) ? t : `${t}${n}`;
1162
+ }
1163
+ function no(e) {
1164
+ return `${to(e)}/state`;
1165
+ }
1166
+ function ro(e) {
1167
+ var s;
1168
+ const t = e.openTabs.find((o) => o.id === e.activeTab), n = (s = t == null ? void 0 : t.params) == null ? void 0 : s.path;
1169
+ return typeof n == "string" ? n : null;
1170
+ }
1171
+ function io({
1172
+ bridgeEndpoint: e,
1173
+ requestHeaders: t,
1174
+ navOpen: n,
1175
+ surfaceOpen: s,
1176
+ surfaceReady: o,
1177
+ snapshot: a
1178
+ }) {
1179
+ const l = Kr(), g = ls(), f = cn(
1180
+ l.subscribe,
1181
+ l.getSnapshot,
1182
+ l.getSnapshot
1183
+ ), d = cn(
1184
+ g.subscribe,
1185
+ g.getSnapshot,
1186
+ g.getSnapshot
1187
+ ), m = J(null);
1188
+ return _(() => {
1189
+ var W;
1190
+ if (e === null || s && !o) return;
1191
+ (W = m.current) == null || W.abort();
1192
+ const A = new AbortController();
1193
+ m.current = A;
1194
+ const R = {
1195
+ v: 1,
1196
+ drawerOpen: n,
1197
+ workbenchOpen: s,
1198
+ openTabs: a.openTabs,
1199
+ activeTab: a.activeTab,
1200
+ activeFile: ro(a),
1201
+ availablePanels: f.map((E) => E.id),
1202
+ availableSurfaces: d.flatMap((E) => {
1203
+ const v = cs(E);
1204
+ return v ? [v] : [];
1205
+ })
1206
+ };
1207
+ return fetch(no(e), {
1208
+ method: "PUT",
1209
+ headers: { ...t, "Content-Type": "application/json" },
1210
+ body: JSON.stringify({ state: R, causedBy: "user" }),
1211
+ signal: A.signal
1212
+ }).catch(() => {
1213
+ }), () => {
1214
+ A.abort();
1215
+ };
1216
+ }, [e, n, f, t, a, s, o, d]), null;
1217
+ }
1218
+ function so({ onQuestionOpen: e }) {
1219
+ const { blockers: t } = ds(), n = t.some((o) => o.reason === "waiting_for_user_input"), s = J(!1);
1220
+ return _(() => {
1221
+ n && !s.current && e(), s.current = n;
1222
+ }, [n, e]), null;
1223
+ }
1224
+ function Er(e) {
230
1225
  return typeof (e == null ? void 0 : e.id) == "string" ? e.id : null;
231
1226
  }
232
- function Be(e, n, r) {
233
- if (e.includes(r)) return e;
234
- const s = n ? e.indexOf(n) : -1, i = s >= 0 ? s + 1 : e.length;
235
- return [...e.slice(0, i), r, ...e.slice(i)];
1227
+ function Ct(e, t, n) {
1228
+ if (e.includes(n)) return e;
1229
+ const s = t ? e.indexOf(t) : -1, o = s >= 0 ? s + 1 : e.length;
1230
+ return [...e.slice(0, o), n, ...e.slice(o)];
1231
+ }
1232
+ function on(e, t, n) {
1233
+ if (e.includes(n)) return e;
1234
+ if (e.length === 0) return [n];
1235
+ const s = t ? e.indexOf(t) : -1, o = s >= 0 ? s : 0;
1236
+ return e.map((a, l) => l === o ? n : a);
236
1237
  }
237
- function Rn(e, n, r) {
238
- if (e.includes(r)) return e;
239
- if (e.length === 0) return [r];
240
- const s = n ? e.indexOf(n) : -1, i = s >= 0 ? s : 0;
241
- return e.map((o, c) => c === i ? r : o);
1238
+ function oo(e, t) {
1239
+ return e.endsWith(":surface") ? e.slice(0, -8) : t;
242
1240
  }
243
- function gs(e, n) {
244
- return e.endsWith(":surface") ? e.slice(0, -8) : n;
1241
+ function ao(e, t, n) {
1242
+ const [s, o] = O(() => Nr(e, t, n));
1243
+ _(() => {
1244
+ o(Nr(e, t, n));
1245
+ }, [e, t, n]);
1246
+ const a = k(
1247
+ (l) => {
1248
+ o((g) => {
1249
+ const f = typeof l == "function" ? l(g) : l;
1250
+ return Es(e, f, n), f;
1251
+ });
1252
+ },
1253
+ [n, e]
1254
+ );
1255
+ return [s, a];
245
1256
  }
246
- function mt(e, n, r) {
247
- const [s, i] = M(() => Pn(e, n, r));
248
- A(() => {
249
- i(Pn(e, n, r));
250
- }, [e, n, r]);
251
- const o = E(
252
- (c) => {
253
- i(c), zr(e, c, r);
1257
+ function Tt(e, t, n) {
1258
+ const [s, o] = O(() => Sr(e, t, n));
1259
+ _(() => {
1260
+ o(Sr(e, t, n));
1261
+ }, [e, t, n]);
1262
+ const a = k(
1263
+ (l) => {
1264
+ o(l), Ps(e, l, n);
254
1265
  },
255
- [r, e]
1266
+ [n, e]
256
1267
  );
257
- return [s, o];
1268
+ return [s, a];
1269
+ }
1270
+ const an = {}, lo = [], kr = { status: "preparing" };
1271
+ function Ar(e, t, n) {
1272
+ return Math.min(n, Math.max(t, e));
258
1273
  }
259
- const pt = {}, ms = [], Tn = { status: "preparing" }, wn = {
1274
+ const Rr = {
260
1275
  openTabs: [],
261
1276
  activeTab: null
262
1277
  };
263
- function ps({ status: e }) {
264
- const n = e.status === "ready" ? void 0 : e.requirement, r = e.status !== "failed", s = r ? n === "workspace-fs" ? "Preparing files…" : n === "sandbox-exec" ? "Preparing secure runtime…" : n === "ui-bridge" ? "Connecting workspace…" : "Preparing workspace…" : "Workspace workbench failed", i = e.status === "failed" ? e.message : "Chat is ready while files, tools, and workspace panels finish warming up.";
265
- return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Ae("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
266
- r ? /* @__PURE__ */ d("div", { className: "mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin", "aria-hidden": "true" }) : null,
267
- /* @__PURE__ */ d("div", { className: "text-sm font-semibold text-foreground", children: s }),
268
- /* @__PURE__ */ d("p", { className: "mt-2 text-sm text-muted-foreground", children: i }),
269
- e.status === "failed" ? /* @__PURE__ */ d("p", { className: "mt-3 text-xs text-muted-foreground", children: "Reload the workspace to retry." }) : null
270
- ] }) });
271
- }
272
- function hs(e) {
273
- const n = e.workspaceId ?? Ss(e.requestHeaders) ?? e.storageKey, r = Wr({
1278
+ function co(e) {
1279
+ const t = e.workspaceId ?? uo(e.requestHeaders) ?? e.storageKey, n = ns({
274
1280
  apiBaseUrl: e.apiBaseUrl,
275
- workspaceId: n,
276
- storageScope: n,
1281
+ workspaceId: t,
1282
+ storageScope: t,
277
1283
  requestHeaders: e.requestHeaders,
278
1284
  enabled: e.enabled,
279
1285
  connectActiveSession: !1,
280
1286
  refreshKey: e.refreshKey
281
1287
  });
282
- return { ...r, workspaceId: r.dataStorageScope };
1288
+ return { ...n, workspaceId: n.dataStorageScope };
283
1289
  }
284
- function Ss(e) {
1290
+ function uo(e) {
285
1291
  return (e == null ? void 0 : e["x-boring-workspace-id"]) ?? (e == null ? void 0 : e["X-Boring-Workspace-Id"]) ?? null;
286
1292
  }
287
- function vs(e) {
288
- const n = e.reloaded ? "Extensions reloaded." : "Extensions will reload on the next message.", r = Array.isArray(e.diagnostics) ? e.diagnostics.map((s) => s.message).filter((s) => !!s) : [];
289
- return r.length > 0 ? `${n}
1293
+ function fo(e) {
1294
+ const t = e.reloaded ? "Extensions reloaded." : "Extensions will reload on the next message.", n = Array.isArray(e.diagnostics) ? e.diagnostics.map((s) => s.message).filter((s) => !!s) : [];
1295
+ return n.length > 0 ? `${t}
290
1296
 
291
1297
  Warnings:
292
- ${r.join(`
293
- `)}` : n;
1298
+ ${n.join(`
1299
+ `)}` : t;
294
1300
  }
295
- function bs(e) {
296
- var n;
1301
+ function go(e) {
1302
+ var t;
297
1303
  try {
298
- return ((n = globalThis.localStorage) == null ? void 0 : n.getItem(e)) ?? null;
1304
+ return ((t = globalThis.localStorage) == null ? void 0 : t.getItem(e)) ?? null;
299
1305
  } catch {
300
1306
  return null;
301
1307
  }
302
1308
  }
303
- function Nn(e, n) {
304
- var r;
1309
+ function Cr(e, t) {
1310
+ var n;
305
1311
  try {
306
- const s = (r = globalThis.localStorage) == null ? void 0 : r.getItem(e);
1312
+ const s = (n = globalThis.localStorage) == null ? void 0 : n.getItem(e);
307
1313
  if (!s) return null;
308
- const i = JSON.parse(s), o = Array.isArray(i.ids) ? i.ids.filter((u) => typeof u == "string" && u.length > 0) : [];
309
- if (o.length === 0) return null;
310
- const c = typeof i.activeId == "string" && o.includes(i.activeId) ? i.activeId : o[0];
311
- return { workspaceId: n, ids: o, activeId: c };
1314
+ const o = JSON.parse(s), a = Array.isArray(o.ids) ? o.ids.filter((g) => typeof g == "string" && g.length > 0) : [];
1315
+ if (a.length === 0) return null;
1316
+ const l = typeof o.activeId == "string" && a.includes(o.activeId) ? o.activeId : a[0];
1317
+ return { workspaceId: t, ids: a, activeId: l };
312
1318
  } catch {
313
1319
  return null;
314
1320
  }
315
1321
  }
316
- function ys(e, n) {
317
- var r, s;
1322
+ function mo(e, t) {
1323
+ var n, s;
318
1324
  try {
319
- if (n.ids.length === 0) {
320
- (r = globalThis.localStorage) == null || r.removeItem(e);
1325
+ if (t.ids.length === 0) {
1326
+ (n = globalThis.localStorage) == null || n.removeItem(e);
321
1327
  return;
322
1328
  }
323
1329
  (s = globalThis.localStorage) == null || s.setItem(
324
1330
  e,
325
- JSON.stringify({ ids: n.ids, activeId: n.activeId })
1331
+ JSON.stringify({ ids: t.ids, activeId: t.activeId })
326
1332
  );
327
1333
  } catch {
328
1334
  }
329
1335
  }
330
- function Dn(e, n) {
331
- var r;
1336
+ function Tr(e, t) {
1337
+ var n;
332
1338
  try {
333
- const s = (r = globalThis.localStorage) == null ? void 0 : r.getItem(e);
1339
+ const s = (n = globalThis.localStorage) == null ? void 0 : n.getItem(e);
334
1340
  if (!s) return null;
335
- const i = JSON.parse(s), o = Array.isArray(i.ids) ? i.ids.filter((c) => typeof c == "string" && c.length > 0) : [];
336
- return { workspaceId: n, ids: o };
1341
+ const o = JSON.parse(s), a = Array.isArray(o.ids) ? o.ids.filter((l) => typeof l == "string" && l.length > 0) : [];
1342
+ return { workspaceId: t, ids: a };
337
1343
  } catch {
338
1344
  return null;
339
1345
  }
340
1346
  }
341
- function Ps(e, n) {
342
- var r, s;
1347
+ function po(e, t) {
1348
+ var n, s;
343
1349
  try {
344
- if (n.length === 0) {
345
- (r = globalThis.localStorage) == null || r.removeItem(e);
1350
+ if (t.length === 0) {
1351
+ (n = globalThis.localStorage) == null || n.removeItem(e);
346
1352
  return;
347
1353
  }
348
- (s = globalThis.localStorage) == null || s.setItem(e, JSON.stringify({ ids: n }));
1354
+ (s = globalThis.localStorage) == null || s.setItem(e, JSON.stringify({ ids: t }));
349
1355
  } catch {
350
1356
  }
351
1357
  }
352
- function Es() {
353
- return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Ae("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
354
- /* @__PURE__ */ d("div", { className: "mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin", "aria-hidden": "true" }),
355
- /* @__PURE__ */ d("div", { className: "text-sm font-semibold text-foreground", children: "Loading sessions…" }),
356
- /* @__PURE__ */ d("p", { className: "mt-2 text-sm text-muted-foreground", children: "Finding this workspace’s saved chats." })
357
- ] }) });
358
- }
359
- function As(e) {
360
- if (!e) return "/api/v1/ui";
361
- const n = e.replace(/\/$/, ""), r = "/api/v1/ui";
362
- return n.endsWith(r) ? n : `${n}${r}`;
363
- }
364
- function Rs(e) {
365
- return `${As(e)}/state`;
366
- }
367
- function Ts(e) {
368
- var s;
369
- const n = e.openTabs.find((i) => i.id === e.activeTab), r = (s = n == null ? void 0 : n.params) == null ? void 0 : s.path;
370
- return typeof r == "string" ? r : null;
371
- }
372
- function ws({
373
- bridgeEndpoint: e,
374
- requestHeaders: n,
375
- navOpen: r,
376
- surfaceOpen: s,
377
- surfaceReady: i,
378
- snapshot: o
379
- }) {
380
- const c = Cn(), u = $(null);
381
- return A(() => {
382
- var b;
383
- if (e === null || s && !i) return;
384
- (b = u.current) == null || b.abort();
385
- const v = new AbortController();
386
- u.current = v;
387
- const y = {
388
- v: 1,
389
- drawerOpen: r,
390
- workbenchOpen: s,
391
- openTabs: o.openTabs,
392
- activeTab: o.activeTab,
393
- activeFile: Ts(o),
394
- availablePanels: c.list().map((q) => q.id)
395
- };
396
- return fetch(Rs(e), {
397
- method: "PUT",
398
- headers: { ...n, "Content-Type": "application/json" },
399
- body: JSON.stringify({ state: y, causedBy: "user" }),
400
- signal: v.signal
401
- }).catch(() => {
402
- }), () => {
403
- v.abort();
404
- };
405
- }, [e, r, c, n, o, s, i]), null;
406
- }
407
- function zs({
1358
+ function Fo({
408
1359
  workspaceId: e,
409
- chatPanel: n,
410
- useSessions: r,
1360
+ chatPanel: t,
1361
+ useSessions: n,
411
1362
  requestHeaders: s,
412
- sessionStorageKey: i,
413
- providerStorageKey: o,
414
- surfaceStorageKey: c,
415
- beforeShell: u,
416
- afterShell: v,
417
- panels: y,
418
- commands: b,
419
- catalogs: q,
420
- plugins: F,
421
- excludeDefaults: z,
422
- capabilities: T,
423
- apiBaseUrl: h,
424
- authHeaders: w,
425
- apiTimeout: p,
426
- defaultTheme: N,
427
- onThemeChange: Wn,
428
- persistenceEnabled: bt,
429
- debug: Fn,
430
- bridgeEndpoint: Ye,
431
- fullPageBasePath: In,
432
- onAuthError: Gn,
433
- sessions: yt,
434
- activeSessionId: Pt,
435
- onSwitchSession: Et,
436
- onCreateSession: Qe,
437
- onDeleteSession: At,
438
- onActiveSessionIdChange: Re,
439
- appTitle: Rt = "Boring UI",
440
- workspaceLabel: $n,
441
- defaultSessionTitle: k = "New session",
442
- navEnabled: Tt = !0,
443
- defaultNavOpen: Un = !1,
444
- defaultSurfaceOpen: Kn,
445
- defaultWorkbenchLeftTab: Te,
446
- defaultWorkbenchLeftOpen: Xe,
447
- surfaceInitialPanels: wt,
448
- topBarLeft: Hn,
449
- topBarRight: Jn,
450
- showThemeToggle: qn = !0,
451
- chatParams: O,
452
- externalPlugins: jn,
453
- hotReloadEnabled: Bn,
454
- frontPluginHotReload: Vn,
455
- extraPanels: Nt,
456
- extraCommands: Dt,
457
- provisionWorkspace: Ze,
458
- bootPreloadPaths: zn,
459
- onWorkspaceWarmupStatusChange: we,
460
- onOpenNav: et,
461
- onOpenSurface: tt,
462
- surfaceButtonBottomOffset: kn,
463
- className: Yn
1363
+ sessionStorageKey: o,
1364
+ providerStorageKey: a,
1365
+ surfaceStorageKey: l,
1366
+ beforeShell: g,
1367
+ afterShell: f,
1368
+ panels: d,
1369
+ commands: m,
1370
+ catalogs: A,
1371
+ plugins: R,
1372
+ excludeDefaults: W,
1373
+ capabilities: E,
1374
+ apiBaseUrl: v,
1375
+ authHeaders: p,
1376
+ apiTimeout: h,
1377
+ defaultTheme: x,
1378
+ onThemeChange: L,
1379
+ persistenceEnabled: F,
1380
+ debug: he,
1381
+ bridgeEndpoint: H,
1382
+ fullPageBasePath: Ot,
1383
+ onAuthError: Wt,
1384
+ sessions: ge,
1385
+ activeSessionId: ot,
1386
+ onSwitchSession: Ee,
1387
+ onCreateSession: me,
1388
+ onDeleteSession: be,
1389
+ onActiveSessionIdChange: ae,
1390
+ appTitle: $e = "Boring UI",
1391
+ workspaceLabel: at,
1392
+ workspaceSectionTitle: Mt = "Workspaces",
1393
+ appLeftLayoutMode: ke = "single-project",
1394
+ appLeftHeaderMode: It = "full",
1395
+ appLeftProjects: Ue,
1396
+ appLeftActiveProjectId: Ae,
1397
+ onSwitchAppLeftProject: Ge,
1398
+ onOpenAppLeftProjectSession: Ft,
1399
+ onShowMoreAppLeftProjectSessions: $t,
1400
+ onCreateAppLeftProject: Re,
1401
+ onOpenAppLeftProjectSettings: lt,
1402
+ onOpenAppLeftProjectInNewTab: y,
1403
+ defaultSessionTitle: T = "New session",
1404
+ workspaceLayout: M = "classic",
1405
+ navEnabled: le = !0,
1406
+ defaultNavOpen: Ut = !1,
1407
+ defaultSurfaceOpen: qr,
1408
+ defaultWorkbenchLeftTab: ct,
1409
+ defaultWorkbenchLeftOpen: Gt,
1410
+ surfaceInitialPanels: mn,
1411
+ topBarLeft: pn,
1412
+ topBarRight: hn,
1413
+ showThemeToggle: bn = !0,
1414
+ showSkills: Vr = !0,
1415
+ showPlugins: Yr = !0,
1416
+ appLeftActions: vn,
1417
+ chatParams: $,
1418
+ externalPlugins: Xr,
1419
+ hotReloadEnabled: jr,
1420
+ frontPluginHotReload: Qr,
1421
+ extraPanels: xn,
1422
+ extraCommands: yn,
1423
+ provisionWorkspace: zt,
1424
+ bootPreloadPaths: Zr,
1425
+ onWorkspaceWarmupStatusChange: dt,
1426
+ onOpenNav: Kt,
1427
+ onOpenSurface: ve,
1428
+ surfaceButtonBottomOffset: ei,
1429
+ className: ti
464
1430
  }) {
465
- var fn, gn;
466
- const _t = jn !== !1, Qn = _t ? Vn : !1, nt = _t ? Bn : !1, rt = o ?? `boring-ui-v2:layout:${e}`, I = c ?? `${rt}:surface`, Ne = gs(
467
- I,
468
- rt
469
- ), C = bt !== !1, De = i ?? `boring-workspace:sessions:${e}`, Y = L(
470
- () => ze(e, s ?? pt),
1431
+ var gr, mr;
1432
+ const Sn = Xr !== !1, ni = Sn ? Qr : !1, Ht = Sn ? jr : !1, Jt = a ?? `boring-ui-v2:layout:${e}`, Y = l ?? `${Jt}:surface`, Ce = oo(
1433
+ Y,
1434
+ Jt
1435
+ ), z = F !== !1, re = M === "plugin-tabs", ze = Vr !== !1, Ke = Yr !== !1, ri = d, ut = o ?? `boring-workspace:sessions:${e}`, xe = D(
1436
+ () => Dt(e, s ?? an),
471
1437
  [s, e]
472
- ), Xn = L(
473
- () => ze(e, { ...s ?? pt, ...w ?? pt }),
474
- [w, s, e]
475
- ), _e = L(
476
- () => rs({ storageKey: De }),
477
- [De]
478
- ), Ot = ss(_e), [Lt, Zn] = M(() => ({
1438
+ ), ii = D(
1439
+ () => Dt(e, { ...s ?? an, ...p ?? an }),
1440
+ [p, s, e]
1441
+ ), ft = D(
1442
+ () => Hs({ storageKey: ut }),
1443
+ [ut]
1444
+ ), Nn = Js(ft), [wn, si] = O(() => ({
479
1445
  workspaceId: e,
480
- status: Tn
481
- })), [Oe, st] = M(() => ({
1446
+ status: kr
1447
+ })), [gt, Bt] = O(() => ({
482
1448
  workspaceId: e,
483
1449
  expired: !1
484
- })), [xt, Le] = M(() => ({
1450
+ })), [Pn, mt] = O(() => ({
485
1451
  workspaceId: e,
486
1452
  creating: !1
487
- })), [Mt, xe] = M(() => ({
1453
+ })), [En, pt] = O(() => ({
488
1454
  workspaceId: e,
489
1455
  failed: !1
490
- })), ge = `boring-workspace:chat-panes:${e}`, [D, B] = M(
491
- () => (C ? Nn(ge, e) : null) ?? { workspaceId: e, ids: [], activeId: null }
492
- ), [ie, Ct] = M(null);
493
- A(() => {
494
- if (!ie) return;
495
- const t = setTimeout(() => Ct(null), 700);
496
- return () => clearTimeout(t);
497
- }, [ie]);
498
- const me = `boring-workspace:pinned-sessions:${e}`, [Wt, Ft] = M(
499
- () => (C ? Dn(me, e) : null) ?? { workspaceId: e, ids: [] }
500
- ), er = Wt.workspaceId === e ? Wt.ids : ms;
501
- A(() => {
502
- Ft((t) => t.workspaceId === e ? t : (C ? Dn(me, e) : null) ?? { workspaceId: e, ids: [] });
503
- }, [me, C, e]);
504
- const tr = E((t) => {
505
- Ft((a) => {
506
- const l = a.workspaceId === e ? a.ids : [], g = l.includes(t) ? l.filter((S) => S !== t) : [t, ...l];
507
- return C && Ps(me, g), { workspaceId: e, ids: g };
1456
+ })), He = `boring-workspace:chat-panes:${e}`, [U, ce] = O(
1457
+ () => (z ? Cr(He, e) : null) ?? { workspaceId: e, ids: [], activeId: null }
1458
+ ), [Te, kn] = O(null);
1459
+ _(() => {
1460
+ if (!Te) return;
1461
+ const r = setTimeout(() => kn(null), 700);
1462
+ return () => clearTimeout(r);
1463
+ }, [Te]);
1464
+ const Je = `boring-workspace:pinned-sessions:${e}`, [An, Rn] = O(
1465
+ () => (z ? Tr(Je, e) : null) ?? { workspaceId: e, ids: [] }
1466
+ ), Cn = An.workspaceId === e ? An.ids : lo;
1467
+ _(() => {
1468
+ Rn((r) => r.workspaceId === e ? r : (z ? Tr(Je, e) : null) ?? { workspaceId: e, ids: [] });
1469
+ }, [Je, z, e]);
1470
+ const Tn = k((r) => {
1471
+ Rn((c) => {
1472
+ const u = c.workspaceId === e ? c.ids : [], N = u.includes(r) ? u.filter((S) => S !== r) : [r, ...u];
1473
+ return z && po(Je, N), { workspaceId: e, ids: N };
508
1474
  });
509
- }, [me, C, e]);
510
- A(() => {
511
- C && D.workspaceId === e && ys(ge, D);
512
- }, [D, ge, C, e]), A(() => {
513
- B((t) => t.workspaceId === e ? t : (C ? Nn(ge, e) : null) ?? { workspaceId: e, ids: [], activeId: null });
514
- }, [ge, C, e]);
515
- const Me = Lt.workspaceId === e ? Lt.status : Tn, nr = n ?? Cr, rr = r ?? hs, Q = !n || !!r, Ce = Q && Ze !== !1, it = () => {
516
- }, _ = rr({
517
- requestHeaders: Y,
518
- storageKey: De,
1475
+ }, [Je, z, e]);
1476
+ _(() => {
1477
+ z && U.workspaceId === e && mo(He, U);
1478
+ }, [U, He, z, e]), _(() => {
1479
+ ce((r) => r.workspaceId === e ? r : (z ? Cr(He, e) : null) ?? { workspaceId: e, ids: [], activeId: null });
1480
+ }, [He, z, e]);
1481
+ const ht = wn.workspaceId === e ? wn.status : kr, oi = t ?? ts, ai = n ?? co, ye = !t || !!n, bt = ye && zt !== !1, qt = () => {
1482
+ }, G = ai({
1483
+ requestHeaders: xe,
1484
+ storageKey: ut,
519
1485
  workspaceId: e,
520
- apiBaseUrl: h,
521
- enabled: Ce
522
- }), [pe, sr] = M(() => ({ workspaceId: e, sessions: [], activeSessionId: null })), It = Ce && _.workspaceId != null && _.workspaceId !== e, V = Ce && !_.loading && !_.error && !It, W = Ce && !V;
523
- A(() => {
524
- V && sr((t) => {
525
- const a = t.workspaceId === e, l = t.activeSessionId === _.activeSessionId, g = t.sessions.length === _.sessions.length && t.sessions.every((S, R) => {
526
- var re;
527
- return S.id === ((re = _.sessions[R]) == null ? void 0 : re.id);
1486
+ apiBaseUrl: v,
1487
+ enabled: bt
1488
+ }), [Be, li] = O(() => ({ workspaceId: e, sessions: [], activeSessionId: null })), _n = bt && G.workspaceId != null && G.workspaceId !== e, ie = bt && !G.loading && !G.error && !_n, B = bt && !ie;
1489
+ _(() => {
1490
+ ie && li((r) => {
1491
+ const c = r.workspaceId === e, u = r.activeSessionId === G.activeSessionId, N = r.sessions.length === G.sessions.length && r.sessions.every((S, C) => {
1492
+ var j;
1493
+ return S.id === ((j = G.sessions[C]) == null ? void 0 : j.id);
528
1494
  });
529
- return a && l && g ? t : {
1495
+ return c && u && N ? r : {
530
1496
  workspaceId: e,
531
- sessions: _.sessions,
532
- activeSessionId: _.activeSessionId
1497
+ sessions: G.sessions,
1498
+ activeSessionId: G.activeSessionId
533
1499
  };
534
1500
  });
535
- }, [_.activeSessionId, _.sessions, V, e]);
536
- const We = W && pe.workspaceId === e && pe.sessions.length > 0, Fe = W ? bs(De) : null, Gt = W && !It ? _.activeSessionId ?? null : null, X = V ? _.sessions : We ? pe.sessions : [], ir = V ? _.activeSessionId : We ? pe.activeSessionId : null, f = Q && (V || We) ? _ : void 0, oe = yt !== void 0 || Pt !== void 0 || Et !== void 0 || Qe !== void 0 || At !== void 0, $t = Oe.workspaceId === e && Oe.expired, he = $(!1), Se = !!(V && f && !oe && X.length === 0 && !$t), or = xt.workspaceId === e && xt.creating, ar = Mt.workspaceId === e && Mt.failed, lr = !!(V && f && !oe && X.length === 0 && $t && !he.current && !ar), Ie = !!(W && _.loading && !_.error && Q && !oe && !We && !Fe && !Gt) || Se || or || lr;
537
- A(() => {
538
- if (!Se) {
539
- Oe.workspaceId !== e && st({ workspaceId: e, expired: !1 });
1501
+ }, [G.activeSessionId, G.sessions, ie, e]);
1502
+ const vt = B && Be.workspaceId === e && Be.sessions.length > 0, xt = B ? go(ut) : null, Dn = B && !_n ? G.activeSessionId ?? null : null, de = ie ? G.sessions : vt ? Be.sessions : [], ci = ie ? G.activeSessionId : vt ? Be.activeSessionId : null, w = ye && (ie || vt) ? G : void 0, _e = ge !== void 0 || ot !== void 0 || Ee !== void 0 || me !== void 0 || be !== void 0, Ln = gt.workspaceId === e && gt.expired, qe = J(!1), Ve = !!(ie && w && !_e && de.length === 0 && !Ln), di = Pn.workspaceId === e && Pn.creating, ui = En.workspaceId === e && En.failed, fi = !!(ie && w && !_e && de.length === 0 && Ln && !qe.current && !ui), Ye = !!(B && G.loading && !G.error && ye && !_e && !vt && !xt && !Dn) || Ve || di || fi;
1503
+ _(() => {
1504
+ if (!Ve) {
1505
+ gt.workspaceId !== e && Bt({ workspaceId: e, expired: !1 });
540
1506
  return;
541
1507
  }
542
- st({ workspaceId: e, expired: !1 });
543
- const t = globalThis.setTimeout(() => {
544
- st({ workspaceId: e, expired: !0 });
1508
+ Bt({ workspaceId: e, expired: !1 });
1509
+ const r = globalThis.setTimeout(() => {
1510
+ Bt({ workspaceId: e, expired: !0 });
545
1511
  }, 2e3);
546
- return () => globalThis.clearTimeout(t);
547
- }, [Oe.workspaceId, Se, e]);
548
- const cr = f ? X.map((t) => ({
549
- ...t,
550
- title: t.title ?? "New session"
551
- })) : void 0, ur = Fe ? [{
552
- id: Fe,
1512
+ return () => globalThis.clearTimeout(r);
1513
+ }, [gt.workspaceId, Ve, e]);
1514
+ const gi = w ? de.map((r) => ({
1515
+ ...r,
1516
+ title: r.title ?? "New session"
1517
+ })) : void 0, mi = xt ? [{
1518
+ id: xt,
553
1519
  title: "Loading sessions…",
554
1520
  createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
555
1521
  updatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
556
1522
  turnCount: 0
557
- }] : [], U = f ? cr ?? [] : W ? ur : oe ? yt ?? [] : Ot.sessions, dr = f ? ir ?? null : W ? Fe ?? Gt : oe ? Pt ?? null : Ot.activeId, ae = (O == null ? void 0 : O.autoSubmitInitialDraft) === !0, Ge = ae && Q && !oe, [K, ve] = M(() => Ge ? null : void 0), Ut = $(e), le = $(!1);
558
- A(() => {
559
- if (Ut.current !== e) {
560
- Ut.current = e, le.current = !1, ve(Ge ? null : void 0);
1523
+ }] : [], q = w ? gi ?? [] : B ? mi : _e ? ge ?? [] : Nn.sessions, pi = w ? ci ?? null : B ? xt ?? Dn : _e ? ot ?? null : Nn.activeId, De = ($ == null ? void 0 : $.autoSubmitInitialDraft) === !0, yt = De && ye && !_e, [ee, Xe] = O(() => yt ? null : void 0), On = J(e), Le = J(!1);
1524
+ _(() => {
1525
+ if (On.current !== e) {
1526
+ On.current = e, Le.current = !1, Xe(yt ? null : void 0);
561
1527
  return;
562
1528
  }
563
- Ge && K === void 0 && (le.current = !1, ve(null));
564
- }, [K, Ge, e]), A(() => {
565
- !f || K !== null || le.current || (le.current = !0, Promise.resolve(f.create({ title: k })).then((t) => {
566
- if (typeof (t == null ? void 0 : t.id) != "string")
1529
+ yt && ee === void 0 && (Le.current = !1, Xe(null));
1530
+ }, [ee, yt, e]), _(() => {
1531
+ !w || ee !== null || Le.current || (Le.current = !0, Promise.resolve(w.create({ title: T })).then((r) => {
1532
+ if (typeof (r == null ? void 0 : r.id) != "string")
567
1533
  throw new Error("auto_submit_session_create_failed");
568
- ve(t.id);
1534
+ Xe(r.id);
569
1535
  }).catch(() => {
570
- le.current = !1, ve(void 0);
1536
+ Le.current = !1, Xe(void 0);
571
1537
  }));
572
- }, [K, k, f]);
573
- const G = K !== void 0 ? K ?? null : dr, J = W ? it : (f == null ? void 0 : f.switch) ?? Et ?? _e.switchTo, $e = E((t) => (G && t !== G && Gr({ sessionId: G, reason: $r.sessionSwitch }), J(t)), [G, J]), ot = W ? it : f ? () => f.create() : Qe ? () => Qe() : () => _e.create(), Kt = W ? it : (f == null ? void 0 : f.delete) ?? At ?? _e.remove, Ht = E((t) => (f && X.length <= 1 && (he.current = !0), Kt(t)), [X.length, Kt, f]), fr = ((fn = U.find((t) => t.id === G)) == null ? void 0 : fn.title) ?? void 0, [gr, Jt] = mt(
574
- `${Ne}:drawer`,
575
- Un,
576
- C
577
- ), qt = Tt && gr, [Z, j] = mt(
1538
+ }, [ee, T, w]);
1539
+ const X = ee !== void 0 ? ee ?? null : pi, Q = B ? qt : (w == null ? void 0 : w.switch) ?? Ee ?? ft.switchTo, St = k((r) => (X && r !== X && us({ sessionId: X, reason: fs.sessionSwitch }), Q(r)), [X, Q]), je = B ? qt : w ? () => w.create() : me ? () => me() : () => ft.create(), Wn = B ? qt : (w == null ? void 0 : w.delete) ?? be ?? ft.remove, Mn = k((r) => (w && de.length <= 1 && (qe.current = !0), Wn(r)), [de.length, Wn, w]), In = ((gr = q.find((r) => r.id === X)) == null ? void 0 : gr.title) ?? void 0, [hi, Fn] = Tt(
1540
+ `${Ce}:drawer`,
1541
+ Ut,
1542
+ z
1543
+ ), [Nt, $n] = Tt(
1544
+ `${Ce}:appLeftPaneCollapsed`,
1545
+ !1,
1546
+ z
1547
+ ), [bi, vi] = ao(
1548
+ `${Ce}:appLeftPaneWidth`,
1549
+ 268,
1550
+ z
1551
+ ), Un = Ar(bi, 220, 420), [Qe, ue] = O(null);
1552
+ _(() => {
1553
+ (Qe === "skills" && !ze || Qe === "plugins" && !Ke) && ue(null);
1554
+ }, [Qe, Ke, ze]);
1555
+ const Gn = le && hi, [fe, te] = Tt(
578
1556
  // Key must NOT match resolvedSurfaceStorageKey (which stores the dockview
579
1557
  // layout JSON at the same ":surface" suffix). Writing "1"/"0" to the same
580
1558
  // key corrupts the JSON and drops the persisted workbench layout on reload.
581
- `${Ne}:workbenchOpen`,
582
- Kn ?? !1,
583
- C
584
- ), [mr, at] = M(!1), [pr, be] = mt(
585
- `${Ne}:workbenchLeftOpen`,
586
- Xe ?? !1,
587
- C
588
- ), [hr, Ue] = M(() => Xe ?? !1), Sr = Xe === !1 ? hr : pr, ye = $(!1), ee = $(null), te = $(Z), jt = $(I), lt = $(null), ct = $([]);
589
- jt.current = I;
590
- const [Bt, Vt] = M(() => ({
591
- key: I,
592
- snapshot: wn
593
- })), vr = Bt.key === I ? Bt.snapshot : wn;
594
- A(() => {
595
- ye.current = !1, he.current = !1, Le({ workspaceId: e, creating: !1 }), xe({ workspaceId: e, failed: !1 });
596
- }, [e]), A(() => {
597
- at(!1), ct.current = [];
598
- }, [I]), A(() => {
599
- if (!(!f || f.loading) && !Se && K === void 0) {
600
- if (X.length > 0) {
601
- ye.current = !1, he.current = !1, Le((t) => t.workspaceId === e && t.creating ? { workspaceId: e, creating: !1 } : t), xe((t) => t.workspaceId === e && t.failed ? { workspaceId: e, failed: !1 } : t);
1559
+ `${Ce}:workbenchOpen`,
1560
+ qr ?? !1,
1561
+ z
1562
+ ), [xi, Vt] = O(!1), [yi, Se] = Tt(
1563
+ `${Ce}:workbenchLeftOpen`,
1564
+ Gt ?? !1,
1565
+ z
1566
+ ), [Si, Ze] = O(() => Gt ?? !1), Ni = Gt === !1 ? Si : yi, wi = k(() => {
1567
+ Se(!1), Ze(!1), ue(null);
1568
+ }, [Se]), et = J(!1), Ne = J(null), pe = J(fe), zn = J(Y), Yt = J(null), Xt = J([]);
1569
+ zn.current = Y;
1570
+ const [Kn, Hn] = O(() => ({
1571
+ key: Y,
1572
+ snapshot: Rr
1573
+ })), Pi = Kn.key === Y ? Kn.snapshot : Rr;
1574
+ _(() => {
1575
+ et.current = !1, qe.current = !1, mt({ workspaceId: e, creating: !1 }), pt({ workspaceId: e, failed: !1 });
1576
+ }, [e]), _(() => {
1577
+ Vt(!1), Xt.current = [];
1578
+ }, [Y]), _(() => {
1579
+ if (!(!w || w.loading) && !Ve && ee === void 0) {
1580
+ if (de.length > 0) {
1581
+ et.current = !1, qe.current = !1, mt((r) => r.workspaceId === e && r.creating ? { workspaceId: e, creating: !1 } : r), pt((r) => r.workspaceId === e && r.failed ? { workspaceId: e, failed: !1 } : r);
602
1582
  return;
603
1583
  }
604
- he.current || ye.current || (ye.current = !0, Le({ workspaceId: e, creating: !0 }), xe({ workspaceId: e, failed: !1 }), Promise.resolve(f.create({ title: k })).catch(() => {
605
- ye.current = !1, Le({ workspaceId: e, creating: !1 }), xe({ workspaceId: e, failed: !0 });
1584
+ qe.current || et.current || (et.current = !0, mt({ workspaceId: e, creating: !0 }), pt({ workspaceId: e, failed: !1 }), Promise.resolve(w.create({ title: T })).catch(() => {
1585
+ et.current = !1, mt({ workspaceId: e, creating: !1 }), pt({ workspaceId: e, failed: !0 });
606
1586
  }));
607
1587
  }
608
- }, [X.length, K, k, Se, f, e]), A(() => {
609
- te.current = Z;
610
- }, [Z]);
611
- const zt = E((t) => {
612
- lt.current = { key: I, api: t }, at(!0), Vt({
613
- key: I,
614
- snapshot: t.getSnapshot()
1588
+ }, [de.length, ee, T, Ve, w, e]), _(() => {
1589
+ pe.current = fe;
1590
+ }, [fe]);
1591
+ const Jn = k((r) => {
1592
+ Yt.current = { key: Y, api: r }, Vt(!0), Hn({
1593
+ key: Y,
1594
+ snapshot: r.getSnapshot()
615
1595
  });
616
- const a = ct.current.splice(0);
617
- for (const l of a) l(t);
618
- }, [I]), kt = E((t) => {
619
- ct.current.push(t);
620
- }, []), Yt = E((t) => {
621
- Vt({
622
- key: I,
623
- snapshot: t
1596
+ const c = Xt.current.splice(0);
1597
+ for (const u of c) u(r);
1598
+ }, [Y]), wt = k((r) => {
1599
+ Xt.current.push(r);
1600
+ }, []), Bn = k((r) => {
1601
+ Hn({
1602
+ key: Y,
1603
+ snapshot: r
624
1604
  });
625
- }, [I]), Ke = E(() => {
626
- const t = lt.current;
627
- return (t == null ? void 0 : t.key) === jt.current ? t.api : null;
628
- }, []), Qt = E(() => te.current, []), Xt = E(() => {
629
- te.current = !0, j(!0);
630
- }, [j]), Zt = E(() => {
631
- te.current = !0, j(!0), be(!0), Ue(!0);
632
- }, [j, be]), He = E(() => {
633
- te.current = !1, lt.current = null, at(!1), j(!1);
634
- }, [j]), en = $(/* @__PURE__ */ new Set()), tn = E((t) => {
635
- const a = t.meta;
636
- if (!a || a.openOnlyWhenSessionOpen !== !0) return !0;
637
- const l = typeof a.sessionId == "string" ? a.sessionId : null;
638
- return l ? en.current.has(l) : !1;
639
- }, []), ce = L(() => ({
640
- surface: Ke,
641
- isWorkbenchOpen: Qt,
642
- openWorkbench: Xt,
643
- openWorkbenchSources: Zt,
644
- closeWorkbench: He,
645
- enqueue: kt,
646
- shouldOpenSurface: tn
647
- }), [Ke, Qt, Xt, Zt, He, kt, tn]), br = L(() => ({
648
- openFile: async (t) => (bn({ kind: "openFile", params: { path: t } }, ce), { seq: 0, status: "ok" }),
1605
+ }, [Y]), Oe = k(() => {
1606
+ const r = Yt.current;
1607
+ return (r == null ? void 0 : r.key) === zn.current ? r.api : null;
1608
+ }, []), qn = k(() => pe.current, []), Vn = k(() => {
1609
+ pe.current = !0, te(!0);
1610
+ }, [te]), Yn = k(() => {
1611
+ pe.current = !0, te(!0), Se(!0), Ze(!0);
1612
+ }, [te, Se]), Pt = k(() => {
1613
+ pe.current = !1, Yt.current = null, Vt(!1), te(!1);
1614
+ }, [te]), Xn = J(/* @__PURE__ */ new Set()), jn = k((r) => {
1615
+ const c = r.meta;
1616
+ if (!c || c.openOnlyWhenSessionOpen !== !0) return !0;
1617
+ const u = typeof c.sessionId == "string" ? c.sessionId : null;
1618
+ return u ? Xn.current.has(u) : !1;
1619
+ }, []), We = D(() => ({
1620
+ surface: Oe,
1621
+ isWorkbenchOpen: qn,
1622
+ openWorkbench: Vn,
1623
+ openWorkbenchSources: Yn,
1624
+ closeWorkbench: Pt,
1625
+ enqueue: wt,
1626
+ shouldOpenSurface: jn
1627
+ }), [Oe, qn, Vn, Yn, Pt, wt, jn]);
1628
+ k((r) => {
1629
+ if (pe.current = !0, te(!0), ve == null || ve(), !r) return;
1630
+ const c = (N) => N.openPanel(r), u = Oe();
1631
+ u ? c(u) : wt(c);
1632
+ }, [wt, Oe, ve, te]);
1633
+ const Ei = D(() => ({
1634
+ openFile: async (r) => (xr({ kind: "openFile", params: { path: r } }, We), { seq: 0, status: "ok" }),
649
1635
  getActiveFile: () => {
650
- var t;
651
- return ((t = Ke()) == null ? void 0 : t.getSnapshot().activeTab) ?? null;
1636
+ var r;
1637
+ return ((r = Oe()) == null ? void 0 : r.getSnapshot().activeTab) ?? null;
652
1638
  },
653
1639
  select: () => () => {
654
1640
  }
655
- }), [Ke, ce]), ue = L(
656
- () => (F == null ? void 0 : F.map(Ur)) ?? [],
657
- [F]
658
- ), ut = L(
659
- () => ue.some((t) => t.registrations.leftTabs.length > 0),
660
- [ue]
661
- ), nn = L(
662
- () => ue.flatMap((t) => t.registrations.panels.map((a) => a.id)),
663
- [ue]
664
- ), rn = L(() => {
665
- const t = {};
666
- for (const a of ue)
667
- for (const l of a.registrations.toolRenderers)
668
- t[l.id] = l.render;
669
- return t;
670
- }, [ue]), sn = L(
671
- () => [...Nt ?? [], ...nn],
672
- [Nt, nn]
673
- ), m = Q && !r && pe.workspaceId !== e ? "default" : G ?? (K !== void 0 ? "default" : ((gn = U[0]) == null ? void 0 : gn.id) ?? "default"), on = !(f != null && f.hasMore) && !W;
674
- A(() => {
675
- var re, mn;
676
- if (Ie) return;
677
- const t = ee.current, a = new Set(U.map((H) => H.id)), l = t ? t.createdId ?? (a.has(m) && !t.knownIds.has(m) ? m : ((re = U.find((H) => !t.knownIds.has(H.id))) == null ? void 0 : re.id) ?? null) : null;
678
- l && a.has(l) && (ee.current = null);
679
- const g = m === "default" && K !== void 0, S = on && a.size > 0 && !g, R = l ?? (S && !a.has(m) ? ((mn = U[0]) == null ? void 0 : mn.id) ?? m : m);
680
- B((H) => {
681
- const se = H.workspaceId === e ? H : { workspaceId: e, ids: [], activeId: null };
682
- if (W && se.ids.length > 0 && !l) return se;
683
- const pn = se.ids.length > 0 ? se.ids : [R], hn = S ? pn.filter((je) => a.has(je) || je === l) : pn, de = hn.length > 0 ? hn : [R], Sn = se.activeId && de.includes(se.activeId) ? se.activeId : de[0] ?? R, Ee = l ? Be(de, t == null ? void 0 : t.afterId, l) : R === Sn || de.includes(R) ? de : Rn(de, Sn, R), vn = Ee.includes(R) ? R : Ee[0] ?? R;
684
- return H.workspaceId === e && H.activeId === vn && H.ids.length === Ee.length && H.ids.every((je, Lr) => je === Ee[Lr]) ? H : { workspaceId: e, ids: Ee, activeId: vn };
1641
+ }), [Oe, We]), Me = D(
1642
+ () => (R == null ? void 0 : R.map(gs)) ?? [],
1643
+ [R]
1644
+ ), jt = D(
1645
+ () => !re && Me.some((r) => r.registrations.workspaceSources.length > 0),
1646
+ [Me, re]
1647
+ ), Qn = D(
1648
+ () => Me.flatMap((r) => r.registrations.panels.map((c) => c.id)),
1649
+ [Me]
1650
+ ), Zn = D(() => {
1651
+ const r = {};
1652
+ for (const c of Me)
1653
+ for (const u of c.registrations.toolRenderers)
1654
+ r[u.id] = u.render;
1655
+ return r;
1656
+ }, [Me]), er = D(
1657
+ () => [...xn ?? [], ...Qn],
1658
+ [xn, Qn]
1659
+ ), P = ye && !n && Be.workspaceId !== e ? "default" : X ?? (ee !== void 0 ? "default" : ((mr = q[0]) == null ? void 0 : mr.id) ?? "default"), tr = !(w != null && w.hasMore) && !B;
1660
+ _(() => {
1661
+ var j, rt;
1662
+ if (Ye) return;
1663
+ const r = Ne.current, c = new Set(q.map((ne) => ne.id)), u = r ? r.createdId ?? (c.has(P) && !r.knownIds.has(P) ? P : ((j = q.find((ne) => !r.knownIds.has(ne.id))) == null ? void 0 : j.id) ?? null) : null;
1664
+ u && c.has(u) && (Ne.current = null);
1665
+ const N = P === "default" && ee !== void 0, S = tr && c.size > 0 && !N, C = u ?? (S && !c.has(P) ? ((rt = q[0]) == null ? void 0 : rt.id) ?? P : P);
1666
+ ce((ne) => {
1667
+ const we = ne.workspaceId === e ? ne : { workspaceId: e, ids: [], activeId: null };
1668
+ if (B && we.ids.length > 0 && !u) return we;
1669
+ const pr = we.ids.length > 0 ? we.ids : [C], hr = S ? pr.filter((At) => c.has(At) || At === u) : pr, Fe = hr.length > 0 ? hr : [C], br = we.activeId && Fe.includes(we.activeId) ? we.activeId : Fe[0] ?? C, it = u ? Ct(Fe, r == null ? void 0 : r.afterId, u) : C === br || Fe.includes(C) ? Fe : on(Fe, br, C), vr = it.includes(C) ? C : it[0] ?? C;
1670
+ return ne.workspaceId === e && ne.activeId === vr && ne.ids.length === it.length && ne.ids.every((At, Ui) => At === it[Ui]) ? ne : { workspaceId: e, ids: it, activeId: vr };
685
1671
  });
686
- }, [K, m, W, Ie, U, on, e]);
687
- const an = L(() => {
688
- const t = /* @__PURE__ */ new Map();
689
- for (const a of U) t.set(a.id, a.title);
690
- return t;
691
- }, [U]), dt = D.workspaceId === e ? D : { ids: [], activeId: null }, ne = dt.ids.length > 0 ? dt.ids : [m];
692
- A(() => {
693
- en.current = new Set(ne);
694
- }, [ne]);
695
- const Pe = dt.activeId ?? ne[0] ?? m, yr = E((t) => {
696
- const l = (D.workspaceId === e ? D : { ids: [m] }).ids.includes(t);
697
- return B((g) => {
698
- const S = g.workspaceId === e ? g : { ids: [m], activeId: m }, R = S.ids.includes(t) ? S.ids : Rn(S.ids, S.activeId, t);
699
- return { workspaceId: e, ids: R, activeId: t };
700
- }), l ? J(t) : $e(t);
701
- }, [D, m, J, $e, e]), Pr = E((t) => (B((a) => {
702
- const l = a.workspaceId === e ? a : { ids: [m], activeId: m };
1672
+ }, [ee, P, B, Ye, q, tr, e]);
1673
+ const nr = D(() => {
1674
+ const r = /* @__PURE__ */ new Map();
1675
+ for (const c of q) r.set(c.id, c.title);
1676
+ return r;
1677
+ }, [q]), [Qt, rr] = O(() => ({
1678
+ workspaceId: e,
1679
+ ids: /* @__PURE__ */ new Set()
1680
+ })), ir = D(() => {
1681
+ const r = /* @__PURE__ */ new Set();
1682
+ if (!ie) return r;
1683
+ const c = Qt.workspaceId === e ? Qt.ids : /* @__PURE__ */ new Set();
1684
+ for (const u of de)
1685
+ u.turnCount === 0 && !c.has(u.id) && r.add(u.id);
1686
+ return r;
1687
+ }, [de, Qt, ie, e]);
1688
+ _(() => {
1689
+ rr((r) => r.workspaceId === e ? r : { workspaceId: e, ids: /* @__PURE__ */ new Set() });
1690
+ }, [e]);
1691
+ const Zt = U.workspaceId === e ? U : { ids: [], activeId: null }, Z = Zt.ids.length > 0 ? Zt.ids : [P];
1692
+ _(() => {
1693
+ Xn.current = new Set(Z);
1694
+ }, [Z]);
1695
+ const se = Zt.activeId ?? Z[0] ?? P, Et = k((r) => {
1696
+ const u = (U.workspaceId === e ? U : { ids: [P] }).ids.includes(r);
1697
+ return ce((N) => {
1698
+ const S = N.workspaceId === e ? N : { ids: [P], activeId: P }, C = S.ids.includes(r) ? S.ids : on(S.ids, S.activeId, r);
1699
+ return { workspaceId: e, ids: C, activeId: r };
1700
+ }), u ? Q(r) : St(r);
1701
+ }, [U, P, Q, St, e]), ki = k((r) => (ce((c) => {
1702
+ const u = c.workspaceId === e ? c : { ids: [P], activeId: P };
703
1703
  return {
704
1704
  workspaceId: e,
705
- ids: l.ids.includes(t) ? l.ids : Be(l.ids, l.activeId, t),
706
- activeId: t
1705
+ ids: u.ids.includes(r) ? u.ids : Ct(u.ids, u.activeId, r),
1706
+ activeId: r
707
1707
  };
708
- }), J(t)), [m, J, e]), ln = E((t) => ((D.workspaceId === e ? D : { ids: [m] }).ids.includes(t) && Ct({ workspaceId: e, id: t }), B((l) => {
709
- const g = l.workspaceId === e ? l : { ids: [m], activeId: m };
1708
+ }), Q(r)), [P, Q, e]), tt = k((r) => ((U.workspaceId === e ? U : { ids: [P] }).ids.includes(r) && kn({ workspaceId: e, id: r }), ce((u) => {
1709
+ const N = u.workspaceId === e ? u : { ids: [P], activeId: P };
710
1710
  return {
711
1711
  workspaceId: e,
712
- ids: Be(g.ids, g.activeId, t),
713
- activeId: t
1712
+ ids: Ct(N.ids, N.activeId, r),
1713
+ activeId: r
714
1714
  };
715
- }), J(t)), [D, m, J, e]), Er = E((t) => {
716
- const a = D.workspaceId === e ? D : { ids: [m], activeId: m };
717
- if (a.ids.length <= 1) return;
718
- const l = a.ids.indexOf(t);
719
- if (l < 0) return;
720
- const g = a.ids.filter((R) => R !== t), S = a.activeId === t ? g[Math.max(0, l - 1)] ?? g[0] ?? null : a.activeId;
721
- B({ workspaceId: e, ids: g, activeId: S }), S && a.activeId === t && J(S);
722
- }, [D, m, J, e]), Ar = E((t) => {
723
- const a = {
724
- afterId: t,
725
- knownIds: new Set(U.map((g) => g.id))
1715
+ }), Q(r)), [U, P, Q, e]), Ai = k((r) => {
1716
+ const c = U.workspaceId === e ? U : { ids: [P], activeId: P };
1717
+ if (c.ids.length <= 1) return;
1718
+ const u = c.ids.indexOf(r);
1719
+ if (u < 0) return;
1720
+ const N = c.ids.filter((C) => C !== r), S = c.activeId === r ? N[Math.max(0, u - 1)] ?? N[0] ?? null : c.activeId;
1721
+ ce({ workspaceId: e, ids: N, activeId: S }), S && c.activeId === r && Q(S);
1722
+ }, [U, P, Q, e]), sr = k(() => {
1723
+ const r = je();
1724
+ return Promise.resolve(r).then((c) => {
1725
+ const u = Er(c);
1726
+ u && (ce((N) => {
1727
+ const S = N.workspaceId === e ? N : { ids: [P], activeId: P }, C = S.ids.length > 0 ? S.ids : [P], j = S.activeId ?? C[0] ?? P;
1728
+ return {
1729
+ workspaceId: e,
1730
+ ids: on(C, j, u),
1731
+ activeId: u
1732
+ };
1733
+ }), Q(u));
1734
+ }).catch(() => {
1735
+ }), r;
1736
+ }, [P, Q, je, e]), en = k((r) => {
1737
+ const c = {
1738
+ afterId: r,
1739
+ knownIds: new Set(q.map((N) => N.id))
726
1740
  };
727
- ee.current = a;
728
- const l = ot();
729
- return Promise.resolve(l).then((g) => {
730
- const S = fs(g);
731
- S && (ee.current === a && (ee.current = { ...a, createdId: S }), B((R) => {
732
- const re = R.workspaceId === e ? R : { ids: [m] };
1741
+ Ne.current = c;
1742
+ const u = je();
1743
+ return Promise.resolve(u).then((N) => {
1744
+ const S = Er(N);
1745
+ S && (Ne.current === c && (Ne.current = { ...c, createdId: S }), ce((C) => {
1746
+ const j = C.workspaceId === e ? C : { ids: [P] };
733
1747
  return {
734
1748
  workspaceId: e,
735
- ids: Be(re.ids, t, S),
1749
+ ids: Ct(j.ids, r, S),
736
1750
  activeId: S
737
1751
  };
738
1752
  }));
739
1753
  }).catch(() => {
740
- ee.current === a && (ee.current = null);
741
- }), l;
742
- }, [m, ot, U, e]), Rr = E((t) => {
743
- const a = D.workspaceId === e ? D : { ids: [m], activeId: m }, l = a.ids.indexOf(t);
744
- let g = a.activeId;
745
- if (l >= 0) {
746
- const S = a.ids.filter((R) => R !== t);
747
- g = a.activeId === t ? S[Math.max(0, l - 1)] ?? S[0] ?? null : a.activeId, B({ workspaceId: e, ids: S, activeId: g }), g && a.activeId === t && $e(g);
1754
+ Ne.current === c && (Ne.current = null);
1755
+ }), u;
1756
+ }, [P, je, q, e]), Ri = k((r) => {
1757
+ const c = U.workspaceId === e ? U : { ids: [P], activeId: P }, u = c.ids.indexOf(r);
1758
+ let N = c.activeId;
1759
+ if (u >= 0) {
1760
+ const S = c.ids.filter((C) => C !== r);
1761
+ N = c.activeId === r ? S[Math.max(0, u - 1)] ?? S[0] ?? null : c.activeId, ce({ workspaceId: e, ids: S, activeId: N }), N && c.activeId === r && St(N);
748
1762
  }
749
- return Ht(t);
750
- }, [D, m, Ht, $e, e]), [Tr, ft] = M(ae), cn = $(e);
751
- A(() => {
752
- if (cn.current !== e) {
753
- cn.current = e, ft(ae);
1763
+ return Mn(r);
1764
+ }, [U, P, Mn, St, e]), or = k(() => Z.length >= 2 ? en(se) : sr(), [se, Z.length, en, sr]), [Ci, tn] = O(De), ar = J(e);
1765
+ _(() => {
1766
+ if (ar.current !== e) {
1767
+ ar.current = e, tn(De);
754
1768
  return;
755
1769
  }
756
- ae && ft(!0);
757
- }, [ae, e]);
758
- const un = ae && Q && !G, dn = !Tr && Ze !== !1 && (Q ? !!G : !0), wr = E((t) => {
759
- Zn({ workspaceId: e, status: t }), we == null || we(t);
760
- }, [we, e]);
761
- A(() => {
762
- var a;
763
- const t = (l) => {
764
- const g = l.detail;
765
- !g || typeof g != "object" || bn(g, ce);
1770
+ De && tn(!0);
1771
+ }, [De, e]);
1772
+ const lr = De && ye && !X, cr = !Ci && zt !== !1 && (ye ? !!X : !0), Ti = k((r) => {
1773
+ si({ workspaceId: e, status: r }), dt == null || dt(r);
1774
+ }, [dt, e]);
1775
+ _(() => {
1776
+ var c;
1777
+ const r = (u) => {
1778
+ const N = u.detail;
1779
+ !N || typeof N != "object" || xr(N, We);
766
1780
  };
767
- return (a = globalThis.addEventListener) == null || a.call(globalThis, yn, t), () => {
768
- var l;
769
- return (l = globalThis.removeEventListener) == null ? void 0 : l.call(globalThis, yn, t);
1781
+ return (c = globalThis.addEventListener) == null || c.call(globalThis, yr, r), () => {
1782
+ var u;
1783
+ return (u = globalThis.removeEventListener) == null ? void 0 : u.call(globalThis, yr, r);
770
1784
  };
771
- }, [ce]), A(() => {
772
- W || Re == null || Re(G ?? null);
773
- }, [G, Re, W]);
774
- const gt = Me.status !== "ready", Nr = gt ? /* @__PURE__ */ d(ps, { status: Me }) : void 0, Je = E(async (t) => {
775
- const a = `${(h == null ? void 0 : h.replace(/\/$/, "")) ?? ""}/api/v1/agent/reload`;
1785
+ }, [We]), _(() => {
1786
+ B || ae == null || ae(X ?? null);
1787
+ }, [X, ae, B]);
1788
+ const nn = ht.status !== "ready", _i = nn ? /* @__PURE__ */ i(Zs, { status: ht }) : void 0, nt = k(async (r) => {
1789
+ const c = `${(v == null ? void 0 : v.replace(/\/$/, "")) ?? ""}/api/v1/agent/reload`;
776
1790
  try {
777
- const l = await fetch(a, {
1791
+ const u = await fetch(c, {
778
1792
  method: "POST",
779
- headers: { ...Y, "content-type": "application/json" },
780
- body: JSON.stringify({ sessionId: t })
1793
+ headers: { ...xe, "content-type": "application/json" },
1794
+ body: JSON.stringify({ sessionId: r })
781
1795
  });
782
- if (!l.ok)
783
- return (await l.json().catch(() => ({}))).error || `reload failed (${l.status})`;
784
- const g = await l.json().catch(() => ({}));
785
- return window.dispatchEvent(new CustomEvent(Kr, { detail: g })), vs(g);
786
- } catch (l) {
787
- return l instanceof Error ? l.message : "Agent plugin reload failed.";
1796
+ if (!u.ok)
1797
+ return (await u.json().catch(() => ({}))).error || `reload failed (${u.status})`;
1798
+ const N = await u.json().catch(() => ({}));
1799
+ return window.dispatchEvent(new CustomEvent(un, { detail: N })), fo(N);
1800
+ } catch (u) {
1801
+ return u instanceof Error ? u.message : "Agent plugin reload failed.";
788
1802
  }
789
- }, [h, Y]), qe = E(
790
- (t, a = {}) => {
791
- const l = a.bridgeEnabled ?? !0, g = O != null && O.toolRenderers && typeof O.toolRenderers == "object" ? O.toolRenderers : void 0;
1803
+ }, [v, xe]), Ie = k(
1804
+ (r, c = {}) => {
1805
+ const u = c.bridgeEnabled ?? !0, N = $ != null && $.toolRenderers && typeof $.toolRenderers == "object" ? $.toolRenderers : void 0;
792
1806
  return {
793
- ...O,
794
- ...un ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
795
- sessionId: t,
796
- apiBaseUrl: h,
1807
+ ...$,
1808
+ ...lr ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
1809
+ sessionId: r,
1810
+ apiBaseUrl: v,
797
1811
  workspaceId: e,
798
1812
  storageScope: e,
799
- requestHeaders: Y,
1813
+ requestHeaders: xe,
800
1814
  showSessions: !1,
801
- onReloadAgentPlugins: (O == null ? void 0 : O.onReloadAgentPlugins) ?? (() => Je(t)),
802
- toolRenderers: { ...rn, ...g ?? {} },
803
- bridgeEndpoint: l ? Ye : null,
804
- surfaceDispatch: ce,
805
- extraCommands: Dt,
806
- workspaceWarmupStatus: Me,
807
- hydrateMessages: dn,
1815
+ onReloadAgentPlugins: ($ == null ? void 0 : $.onReloadAgentPlugins) ?? (() => nt(r)),
1816
+ toolRenderers: { ...Zn, ...N ?? {} },
1817
+ bridgeEndpoint: u ? H : null,
1818
+ surfaceDispatch: We,
1819
+ extraCommands: yn,
1820
+ workspaceWarmupStatus: ht,
1821
+ hydrateMessages: cr,
1822
+ allowPromptDuringInitialHydration: ir.has(r),
1823
+ onPromptSubmitStarted: ({ sessionId: S }) => {
1824
+ rr((C) => {
1825
+ const j = C.workspaceId === e ? C.ids : /* @__PURE__ */ new Set();
1826
+ if (j.has(S)) return C.workspaceId === e ? C : { workspaceId: e, ids: j };
1827
+ const rt = new Set(j);
1828
+ return rt.add(S), { workspaceId: e, ids: rt };
1829
+ });
1830
+ },
1831
+ onTurnComplete: () => {
1832
+ var C;
1833
+ (C = w == null ? void 0 : w.refresh) == null || C.call(w, { background: !0 });
1834
+ const S = $ == null ? void 0 : $.onTurnComplete;
1835
+ typeof S == "function" && S();
1836
+ },
808
1837
  onAutoSubmitInitialDraftSettled: () => {
809
- le.current = !1, ft(!1), ve(void 0);
810
- const S = O == null ? void 0 : O.onAutoSubmitInitialDraftSettled;
1838
+ Le.current = !1, tn(!1), Xe(void 0);
1839
+ const S = $ == null ? void 0 : $.onAutoSubmitInitialDraftSettled;
811
1840
  typeof S == "function" && S();
812
1841
  },
813
1842
  // Forward the explicit prop when set. Omitting the key (when undefined)
814
1843
  // lets ChatPanel apply its own default (true) and avoids overriding a
815
1844
  // value passed through chatParams.
816
- ...nt !== void 0 ? { hotReloadEnabled: nt } : {}
1845
+ ...Ht !== void 0 ? { hotReloadEnabled: Ht } : {}
817
1846
  };
818
1847
  },
819
- [h, O, un, Y, Ye, ce, Dt, Me, dn, nt, rn, Je, e]
820
- ), Dr = L(
821
- () => qe(m),
822
- [m, qe]
823
- ), _r = L(() => ne.map((t) => ({
824
- id: t,
825
- title: an.get(t) ?? (t === "default" ? k : t),
826
- panel: "chat",
827
- params: qe(t, { bridgeEnabled: t === Pe })
828
- })), [Pe, ne, k, qe, an]), Or = L(() => ({
829
- storageKey: I,
830
- defaultLeftTab: Te,
831
- initialPanels: wt,
832
- extraPanels: sn,
833
- onReloadAgentPlugins: () => Je(G ?? m),
834
- onReady: zt,
835
- onChange: Yt,
836
- onClose: He
1848
+ [v, $, lr, xe, H, We, yn, ht, cr, ir, Ht, Zn, nt, w, e]
1849
+ ), Di = D(
1850
+ () => Ie(P),
1851
+ [P, Ie]
1852
+ ), kt = J(null), Li = D(() => {
1853
+ (!kt.current || kt.current.make !== Ie) && (kt.current = { make: Ie, cache: /* @__PURE__ */ new Map() });
1854
+ const { cache: r } = kt.current;
1855
+ return Z.map((c) => {
1856
+ const u = c === se, N = `${c}:${u}`;
1857
+ let S = r.get(N);
1858
+ return S || (S = Ie(c, { bridgeEnabled: u }), r.set(N, S)), {
1859
+ id: c,
1860
+ title: nr.get(c) ?? (c === "default" ? T : c),
1861
+ panel: "chat",
1862
+ params: S
1863
+ };
1864
+ });
1865
+ }, [se, Z, T, Ie, nr]), Oi = D(() => ({
1866
+ storageKey: Y,
1867
+ defaultLeftTab: ct,
1868
+ initialPanels: mn,
1869
+ extraPanels: er,
1870
+ onReloadAgentPlugins: () => nt(X ?? P),
1871
+ onReady: Jn,
1872
+ onChange: Bn,
1873
+ onClose: Pt,
1874
+ showCloseAction: !1
837
1875
  }), [
838
- He,
839
- Te,
840
- wt,
841
- Je,
842
- G,
843
- m,
844
- Yt,
845
- zt,
846
- I,
847
- sn,
848
- j
849
- ]);
850
- return /* @__PURE__ */ d("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ Ae(
851
- Hr,
1876
+ Pt,
1877
+ ct,
1878
+ mn,
1879
+ nt,
1880
+ X,
1881
+ P,
1882
+ Bn,
1883
+ Jn,
1884
+ Y,
1885
+ er,
1886
+ te
1887
+ ]), dr = () => {
1888
+ document.dispatchEvent(new KeyboardEvent("keydown", {
1889
+ key: "k",
1890
+ metaKey: !0,
1891
+ ctrlKey: !0,
1892
+ bubbles: !0,
1893
+ cancelable: !0
1894
+ }));
1895
+ }, ur = /* @__PURE__ */ b(oe, { children: [
1896
+ bn ? /* @__PURE__ */ i(As, {}) : null,
1897
+ hn
1898
+ ] }), Wi = {
1899
+ sessions: q,
1900
+ activeId: se,
1901
+ openIds: Z,
1902
+ pinnedIds: Cn,
1903
+ onTogglePin: Tn,
1904
+ onSwitch: Et,
1905
+ onOpenAsTab: tt,
1906
+ onCreate: je,
1907
+ onDelete: Ri,
1908
+ onLoadMore: w == null ? void 0 : w.loadMore,
1909
+ hasMore: w == null ? void 0 : w.hasMore,
1910
+ loadingMore: w == null ? void 0 : w.loadingMore,
1911
+ onClose: () => Fn(!1)
1912
+ }, Mi = D(() => re ? {
1913
+ sessions: q,
1914
+ activeId: se,
1915
+ openIds: Z,
1916
+ search: (r, c) => es(r, c, { limit: 8 }),
1917
+ onSwitch: Et,
1918
+ onOpenAsTab: tt
1919
+ } : void 0, [se, Z, re, tt, q, Et]), Ii = D(() => {
1920
+ const r = [...vn ?? []];
1921
+ return Ke && r.push({
1922
+ id: "plugins",
1923
+ label: "Plugins",
1924
+ icon: /* @__PURE__ */ i(Or, { className: "h-4 w-4", strokeWidth: 1.75 }),
1925
+ onClick: () => ue((c) => c === "plugins" ? null : "plugins")
1926
+ }), ze && r.push({
1927
+ id: "skills",
1928
+ label: "Skills",
1929
+ icon: /* @__PURE__ */ i(Lr, { className: "h-4 w-4", strokeWidth: 1.75 }),
1930
+ onClick: () => ue((c) => c === "skills" ? null : "skills")
1931
+ }), r;
1932
+ }, [vn, Ke, ze]), Fi = Qe === "skills" && ze ? /* @__PURE__ */ i(
1933
+ Rs,
1934
+ {
1935
+ onClose: () => ue(null),
1936
+ headerInsetStart: Nt,
1937
+ headerInsetEnd: !fe
1938
+ }
1939
+ ) : Qe === "plugins" && Ke ? /* @__PURE__ */ i(
1940
+ Ts,
852
1941
  {
853
- chatPanel: nr,
854
- panels: y,
855
- commands: b,
856
- catalogs: q,
857
- plugins: F,
858
- excludeDefaults: z,
859
- capabilities: T,
860
- apiBaseUrl: h,
861
- authHeaders: Xn,
862
- apiTimeout: p,
863
- activeSessionId: Pe,
864
- openSessionIds: ne,
865
- defaultTheme: N,
866
- onThemeChange: Wn,
1942
+ onClose: () => ue(null),
1943
+ onReloadExternalPlugins: () => nt(X ?? P),
1944
+ headerInsetStart: Nt,
1945
+ headerInsetEnd: !fe
1946
+ }
1947
+ ) : null, fr = Ye ? /* @__PURE__ */ i(eo, {}) : /* @__PURE__ */ i(
1948
+ ws,
1949
+ {
1950
+ className: ti,
1951
+ nav: re ? null : Gn ? "session-list" : null,
1952
+ navParams: Wi,
1953
+ center: "chat",
1954
+ centerParams: Di,
1955
+ chatPanes: Li,
1956
+ activeChatPaneId: se,
1957
+ onActiveChatPaneChange: ki,
1958
+ onCloseChatPane: Ai,
1959
+ onCreateChatPaneAfter: re ? void 0 : en,
1960
+ onDropChatSession: tt,
1961
+ flashChatPaneId: (Te == null ? void 0 : Te.workspaceId) === e ? Te.id : null,
1962
+ surface: fe ? "artifact-surface" : null,
1963
+ surfaceParams: Oi,
1964
+ chatOverlay: re ? Fi : null,
1965
+ onCloseChatOverlay: () => ue(null),
1966
+ surfaceOverlay: _i,
1967
+ sidebar: fe && !nn && jt && Ni ? "workbench-left" : null,
1968
+ sidebarParams: fe && !nn && jt ? {
1969
+ ...ct ? { defaultTab: ct } : {},
1970
+ bridge: Ei,
1971
+ onClose: () => {
1972
+ Se(!1), Ze(!1);
1973
+ },
1974
+ onCollapse: () => {
1975
+ Se(!1), Ze(!1);
1976
+ }
1977
+ } : void 0,
1978
+ storageKey: z ? Ce : void 0,
1979
+ onOpenNav: !re && le ? () => {
1980
+ Fn(!0), Kt == null || Kt();
1981
+ } : void 0,
1982
+ onOpenSurface: () => {
1983
+ pe.current = !0, te(!0), ve == null || ve();
1984
+ },
1985
+ surfaceButtonBottomOffset: ei,
1986
+ onOpenSidebar: jt ? () => {
1987
+ pe.current = !0, te(!0), Se(!0), Ze(!0);
1988
+ } : void 0
1989
+ }
1990
+ ), $i = re ? /* @__PURE__ */ i(
1991
+ Us,
1992
+ {
1993
+ collapsed: Nt,
1994
+ onExpand: () => $n(!1),
1995
+ onCollapse: () => $n(!0),
1996
+ onResizeLeftPane: (r) => vi((c) => Ar(c + r, 220, 420)),
1997
+ leftPaneWidth: Un,
1998
+ minLeftPaneWidth: 220,
1999
+ maxLeftPaneWidth: 420,
2000
+ leftPane: /* @__PURE__ */ i(
2001
+ Fs,
2002
+ {
2003
+ width: Un,
2004
+ appTitle: $e,
2005
+ workspaceLabel: at,
2006
+ workspaceSectionTitle: Mt,
2007
+ layoutMode: ke,
2008
+ headerMode: It,
2009
+ projects: Ue,
2010
+ activeProjectId: Ae ?? e,
2011
+ onOpenProjectSession: Ft,
2012
+ onShowMoreProjectSessions: $t,
2013
+ onCreateProject: Re,
2014
+ onCreateProjectSession: (r) => {
2015
+ r === (Ae ?? e) ? (ue(null), or()) : Ge == null || Ge(r);
2016
+ },
2017
+ onOpenProjectSettings: lt,
2018
+ onOpenProjectInNewTab: y,
2019
+ sessionTitle: Ye ? "Loading sessions…" : In ?? T,
2020
+ topSlot: pn,
2021
+ bottomSlot: bn || hn != null ? /* @__PURE__ */ i("div", { className: "flex w-full min-w-0 items-center gap-2", children: ur }) : void 0,
2022
+ sessions: q,
2023
+ activeSessionId: se,
2024
+ openSessionIds: Z,
2025
+ pinnedSessionIds: Cn,
2026
+ onCreateSession: () => {
2027
+ ue(null), or();
2028
+ },
2029
+ onOpenCommandPalette: dr,
2030
+ onSwitchSession: Et,
2031
+ onOpenSessionAsPane: tt,
2032
+ onToggleSessionPinned: Tn,
2033
+ actions: Ii
2034
+ }
2035
+ ),
2036
+ children: fr
2037
+ }
2038
+ ) : /* @__PURE__ */ b("div", { className: "flex h-full min-h-0 flex-col", children: [
2039
+ /* @__PURE__ */ i(
2040
+ ks,
2041
+ {
2042
+ appTitle: $e,
2043
+ sessionTitle: Ye ? "Loading sessions…" : In ?? T,
2044
+ onCommandPalette: dr,
2045
+ topBarLeft: pn,
2046
+ topBarRight: ur
2047
+ }
2048
+ ),
2049
+ fr
2050
+ ] });
2051
+ return /* @__PURE__ */ i("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ b(
2052
+ ms,
2053
+ {
2054
+ chatPanel: oi,
2055
+ panels: ri,
2056
+ commands: m,
2057
+ catalogs: A,
2058
+ plugins: R,
2059
+ excludeDefaults: W,
2060
+ capabilities: E,
2061
+ apiBaseUrl: v,
2062
+ authHeaders: ii,
2063
+ apiTimeout: h,
2064
+ activeSessionId: se,
2065
+ openSessionIds: Z,
2066
+ defaultTheme: x,
2067
+ onThemeChange: L,
867
2068
  workspaceId: e,
868
- workspaceLabel: $n,
869
- appTitle: Rt,
870
- storageKey: rt,
871
- persistenceEnabled: bt,
872
- debug: Fn,
2069
+ workspaceLabel: at,
2070
+ appTitle: $e,
2071
+ storageKey: Jt,
2072
+ persistenceEnabled: F,
2073
+ debug: he,
873
2074
  bridgeEndpoint: null,
874
- onAuthError: Gn,
875
- frontPluginHotReload: Qn,
876
- fullPageBasePath: In,
2075
+ onAuthError: Wt,
2076
+ frontPluginHotReload: ni,
2077
+ fullPageBasePath: Ot,
2078
+ commandPaletteSessionSearch: Mi,
877
2079
  children: [
878
- u,
879
- /* @__PURE__ */ d(
880
- ds,
2080
+ g,
2081
+ /* @__PURE__ */ i(
2082
+ Qs,
881
2083
  {
882
2084
  workspaceId: e,
883
- requestHeaders: Y,
884
- apiBaseUrl: h,
885
- preloadPaths: zn,
886
- provisionWorkspace: Ze,
887
- onStatusChange: wr
2085
+ requestHeaders: xe,
2086
+ apiBaseUrl: v,
2087
+ preloadPaths: Zr,
2088
+ provisionWorkspace: zt,
2089
+ onStatusChange: Ti
888
2090
  }
889
2091
  ),
890
- /* @__PURE__ */ d(
891
- ws,
2092
+ /* @__PURE__ */ i(
2093
+ io,
892
2094
  {
893
- bridgeEndpoint: Ye,
894
- requestHeaders: Y,
895
- navOpen: qt,
896
- surfaceOpen: Z,
897
- surfaceReady: mr,
898
- snapshot: vr
2095
+ bridgeEndpoint: H,
2096
+ requestHeaders: xe,
2097
+ navOpen: re ? !Nt : Gn,
2098
+ surfaceOpen: fe,
2099
+ surfaceReady: xi,
2100
+ snapshot: Pi
899
2101
  }
900
2102
  ),
901
- /* @__PURE__ */ Ae("div", { className: "flex h-full min-h-0 flex-col", children: [
902
- /* @__PURE__ */ d(
903
- Br,
904
- {
905
- appTitle: Rt,
906
- sessionTitle: Ie ? "Loading sessions…" : fr ?? k,
907
- onCommandPalette: () => {
908
- document.dispatchEvent(new KeyboardEvent("keydown", {
909
- key: "k",
910
- metaKey: !0,
911
- ctrlKey: !0,
912
- bubbles: !0,
913
- cancelable: !0
914
- }));
915
- },
916
- topBarLeft: Hn,
917
- topBarRight: /* @__PURE__ */ Ae(fe, { children: [
918
- qn ? /* @__PURE__ */ d(Zr, {}) : null,
919
- Jn
920
- ] })
921
- }
922
- ),
923
- Ie ? /* @__PURE__ */ d(Es, {}) : /* @__PURE__ */ d(
924
- Vr,
925
- {
926
- className: Yn,
927
- nav: qt ? "session-list" : null,
928
- navParams: {
929
- sessions: U,
930
- activeId: Pe,
931
- openIds: ne,
932
- pinnedIds: er,
933
- onTogglePin: tr,
934
- onSwitch: yr,
935
- onOpenAsTab: ln,
936
- onCreate: ot,
937
- onDelete: Rr,
938
- onLoadMore: f == null ? void 0 : f.loadMore,
939
- hasMore: f == null ? void 0 : f.hasMore,
940
- loadingMore: f == null ? void 0 : f.loadingMore,
941
- onClose: () => Jt(!1)
942
- },
943
- center: "chat",
944
- centerParams: Dr,
945
- chatPanes: _r,
946
- activeChatPaneId: Pe,
947
- onActiveChatPaneChange: Pr,
948
- onCloseChatPane: Er,
949
- onCreateChatPaneAfter: Ar,
950
- onDropChatSession: ln,
951
- flashChatPaneId: (ie == null ? void 0 : ie.workspaceId) === e ? ie.id : null,
952
- surface: Z ? "artifact-surface" : null,
953
- surfaceParams: Or,
954
- surfaceOverlay: Nr,
955
- sidebar: Z && !gt && ut && Sr ? "workbench-left" : null,
956
- sidebarParams: Z && !gt && ut ? {
957
- ...Te ? { defaultTab: Te } : {},
958
- bridge: br,
959
- onClose: () => {
960
- be(!1), Ue(!1);
961
- },
962
- onCollapse: () => {
963
- be(!1), Ue(!1);
964
- }
965
- } : void 0,
966
- storageKey: C ? Ne : void 0,
967
- onOpenNav: Tt ? () => {
968
- Jt(!0), et == null || et();
969
- } : void 0,
970
- onOpenSurface: () => {
971
- te.current = !0, j(!0), tt == null || tt();
972
- },
973
- surfaceButtonBottomOffset: kn,
974
- onOpenSidebar: ut ? () => {
975
- te.current = !0, j(!0), be(!0), Ue(!0);
976
- } : void 0
977
- }
978
- )
979
- ] }),
980
- v
2103
+ /* @__PURE__ */ i(so, { onQuestionOpen: wi }),
2104
+ $i,
2105
+ f
981
2106
  ]
982
2107
  }
983
2108
  ) });
984
2109
  }
985
- const Ns = 500;
986
- function Ds(e) {
987
- return new Promise((n, r) => {
2110
+ const ho = 500;
2111
+ function bo(e) {
2112
+ return new Promise((t, n) => {
988
2113
  let s;
989
- const i = () => {
990
- s && globalThis.clearTimeout(s), e.removeEventListener("abort", o);
991
- }, o = () => {
992
- i(), r(new DOMException("Workspace boot aborted", "AbortError"));
2114
+ const o = () => {
2115
+ s && globalThis.clearTimeout(s), e.removeEventListener("abort", a);
2116
+ }, a = () => {
2117
+ o(), n(new DOMException("Workspace boot aborted", "AbortError"));
993
2118
  };
994
2119
  if (e.aborted) {
995
- o();
2120
+ a();
996
2121
  return;
997
2122
  }
998
2123
  s = globalThis.setTimeout(() => {
999
- i(), n();
1000
- }, Ns), e.addEventListener("abort", o, { once: !0 });
2124
+ o(), t();
2125
+ }, ho), e.addEventListener("abort", a, { once: !0 });
1001
2126
  });
1002
2127
  }
1003
- function ks({
2128
+ function $o({
1004
2129
  workspaceId: e,
1005
- requestHeaders: n,
1006
- apiBaseUrl: r,
1007
- preloadPaths: s = _n,
1008
- provisionWorkspace: i = !0,
1009
- loadingFallback: o,
1010
- errorFallback: c,
1011
- children: u
2130
+ requestHeaders: t,
2131
+ apiBaseUrl: n,
2132
+ preloadPaths: s = Fr,
2133
+ provisionWorkspace: o = !0,
2134
+ loadingFallback: a,
2135
+ errorFallback: l,
2136
+ children: g
1012
2137
  }) {
1013
- const [v, y] = M({
2138
+ const [f, d] = O({
1014
2139
  status: "loading",
1015
2140
  label: "Waking workspace runtime"
1016
2141
  });
1017
- return A(() => {
1018
- const b = new AbortController(), q = ze(e, n);
1019
- async function F(T) {
1020
- const h = await fetch(Ln(r, T), {
1021
- headers: q,
1022
- signal: b.signal
1023
- }), w = await ke(h);
1024
- if (!h.ok) {
1025
- if (St(w)) return "preparing";
1026
- throw new Error(vt(w) ?? `${T} failed with ${h.status}`);
2142
+ return _(() => {
2143
+ const m = new AbortController(), A = Dt(e, t);
2144
+ async function R(E) {
2145
+ const v = await fetch(Ur(n, E), {
2146
+ headers: A,
2147
+ signal: m.signal
2148
+ }), p = await Lt(v);
2149
+ if (!v.ok) {
2150
+ if (fn(p)) return "preparing";
2151
+ throw new Error(gn(p) ?? `${E} failed with ${v.status}`);
1027
2152
  }
1028
- if (xn(T)) {
1029
- const N = Ve(w);
1030
- if ((N == null ? void 0 : N.state) === "degraded") throw new Error(N.message ?? "Workspace failed to prepare");
2153
+ if (Gr(E)) {
2154
+ const x = _t(p);
2155
+ if ((x == null ? void 0 : x.state) === "degraded") throw new Error(x.message ?? "Workspace failed to prepare");
1031
2156
  }
1032
- return Jr(T) !== null && w && typeof w == "object" && Mn(r, q["x-boring-workspace-id"] ?? e, T, w), "ready";
2157
+ return ps(E) !== null && p && typeof p == "object" && zr(n, A["x-boring-workspace-id"] ?? e, E, p), "ready";
1033
2158
  }
1034
- async function z() {
1035
- y({ status: "loading", label: "Waking workspace runtime" });
2159
+ async function W() {
2160
+ d({ status: "loading", label: "Waking workspace runtime" });
1036
2161
  try {
1037
- const T = On(s, i);
1038
- let h = await Promise.all(T.map(async (p) => ({ path: p, status: await F(p) }))), w = h.filter((p) => p.status === "preparing").map((p) => p.path);
1039
- for (; w.length > 0; ) {
1040
- if (y({ status: "loading", label: "Workspace is still preparing" }), await Ds(b.signal), b.signal.aborted) return;
1041
- h = await Promise.all(w.map(async (p) => ({ path: p, status: await F(p) }))), w = h.filter((p) => p.status === "preparing").map((p) => p.path);
2162
+ const E = $r(s, o);
2163
+ let v = await Promise.all(E.map(async (h) => ({ path: h, status: await R(h) }))), p = v.filter((h) => h.status === "preparing").map((h) => h.path);
2164
+ for (; p.length > 0; ) {
2165
+ if (d({ status: "loading", label: "Workspace is still preparing" }), await bo(m.signal), m.signal.aborted) return;
2166
+ v = await Promise.all(p.map(async (h) => ({ path: h, status: await R(h) }))), p = v.filter((h) => h.status === "preparing").map((h) => h.path);
1042
2167
  }
1043
- b.signal.aborted || y({ status: "ready" });
1044
- } catch (T) {
1045
- if (b.signal.aborted) return;
1046
- y({
2168
+ m.signal.aborted || d({ status: "ready" });
2169
+ } catch (E) {
2170
+ if (m.signal.aborted) return;
2171
+ d({
1047
2172
  status: "error",
1048
- message: T instanceof Error ? T.message : "Unknown workspace boot error"
2173
+ message: E instanceof Error ? E.message : "Unknown workspace boot error"
1049
2174
  });
1050
2175
  }
1051
2176
  }
1052
- return z(), () => b.abort();
1053
- }, [r, s, i, n, e]), v.status === "ready" ? /* @__PURE__ */ d(fe, { children: u }) : v.status === "error" ? typeof c == "function" ? /* @__PURE__ */ d(fe, { children: c(v.message) }) : c ? /* @__PURE__ */ d(fe, { children: c }) : /* @__PURE__ */ d(
1054
- En,
2177
+ return W(), () => m.abort();
2178
+ }, [n, s, o, t, e]), f.status === "ready" ? /* @__PURE__ */ i(oe, { children: g }) : f.status === "error" ? typeof l == "function" ? /* @__PURE__ */ i(oe, { children: l(f.message) }) : l ? /* @__PURE__ */ i(oe, { children: l }) : /* @__PURE__ */ i(
2179
+ wr,
1055
2180
  {
1056
2181
  title: "Workspace failed to open",
1057
- description: v.message,
2182
+ description: f.message,
1058
2183
  status: "Retry by reloading the page"
1059
2184
  }
1060
- ) : typeof o == "function" ? /* @__PURE__ */ d(fe, { children: o(v.label) }) : o ? /* @__PURE__ */ d(fe, { children: o }) : /* @__PURE__ */ d(
1061
- En,
2185
+ ) : typeof a == "function" ? /* @__PURE__ */ i(oe, { children: a(f.label) }) : a ? /* @__PURE__ */ i(oe, { children: a }) : /* @__PURE__ */ i(
2186
+ wr,
1062
2187
  {
1063
2188
  title: "Opening workspace",
1064
2189
  description: "Preparing secure runtime, files, sessions, and layout.",
1065
- status: v.label
2190
+ status: f.label
1066
2191
  }
1067
2192
  );
1068
2193
  }
1069
- const _s = "FULL_PAGE_PANEL_MISSING_COMPONENT", Os = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", Ls = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", xs = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", Ms = "FULL_PAGE_PANEL_NOT_SUPPORTED", Cs = "FULL_PAGE_PANEL_RENDER_FAILED";
1070
- function x() {
2194
+ const vo = "FULL_PAGE_PANEL_MISSING_COMPONENT", xo = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", yo = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", So = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", No = "FULL_PAGE_PANEL_NOT_SUPPORTED", wo = "FULL_PAGE_PANEL_RENDER_FAILED";
2195
+ function K() {
1071
2196
  }
1072
- const Ws = { dispose: x }, P = () => Ws;
1073
- function Fs(e) {
2197
+ const Po = { dispose: K }, I = () => Po;
2198
+ function Eo(e) {
1074
2199
  return {
1075
2200
  id: `full-page:${e}`,
1076
2201
  title: e,
@@ -1080,31 +2205,31 @@ function Fs(e) {
1080
2205
  width: 0,
1081
2206
  height: 0,
1082
2207
  location: { type: "grid", referenceGroup: void 0 },
1083
- setActive: x,
1084
- setTitle: (n) => {
1085
- document.title = n;
2208
+ setActive: K,
2209
+ setTitle: (t) => {
2210
+ document.title = t;
1086
2211
  },
1087
- setSize: x,
2212
+ setSize: K,
1088
2213
  close: () => {
1089
2214
  window.close();
1090
2215
  },
1091
- moveTo: x,
1092
- maximize: x,
1093
- exitMaximized: x,
2216
+ moveTo: K,
2217
+ maximize: K,
2218
+ exitMaximized: K,
1094
2219
  isMaximized: () => !1,
1095
- minimize: x,
1096
- onDidActiveChange: P,
1097
- onDidVisibilityChange: P,
1098
- onDidDimensionsChange: P,
1099
- onDidFocusChange: P,
1100
- onDidLocationChange: P,
1101
- onDidParametersChange: P,
1102
- onDidTitleChange: P,
1103
- onDidRenamed: P,
1104
- onWillFocus: P
2220
+ minimize: K,
2221
+ onDidActiveChange: I,
2222
+ onDidVisibilityChange: I,
2223
+ onDidDimensionsChange: I,
2224
+ onDidFocusChange: I,
2225
+ onDidLocationChange: I,
2226
+ onDidParametersChange: I,
2227
+ onDidTitleChange: I,
2228
+ onDidRenamed: I,
2229
+ onWillFocus: I
1105
2230
  };
1106
2231
  }
1107
- function Is() {
2232
+ function ko() {
1108
2233
  return {
1109
2234
  width: window.innerWidth,
1110
2235
  height: window.innerHeight,
@@ -1116,139 +2241,139 @@ function Is() {
1116
2241
  panels: [],
1117
2242
  groups: [],
1118
2243
  activeGroup: void 0,
1119
- addPanel: x,
1120
- addGroup: x,
1121
- removePanel: x,
1122
- removeGroup: x,
2244
+ addPanel: K,
2245
+ addGroup: K,
2246
+ removePanel: K,
2247
+ removeGroup: K,
1123
2248
  getPanel: () => {
1124
2249
  },
1125
2250
  getGroup: () => {
1126
2251
  },
1127
- moveGroupOrPanel: x,
1128
- fromJSON: x,
2252
+ moveGroupOrPanel: K,
2253
+ fromJSON: K,
1129
2254
  toJSON: () => ({}),
1130
- clear: x,
1131
- focus: x,
1132
- layout: x,
1133
- onDidLayoutChange: P,
1134
- onDidLayoutFromJSON: P,
1135
- onDidAddPanel: P,
1136
- onDidRemovePanel: P,
1137
- onDidActivePanelChange: P,
1138
- onDidAddGroup: P,
1139
- onDidRemoveGroup: P,
1140
- onDidActiveGroupChange: P,
1141
- onUnhandledDragOverEvent: P,
1142
- onDidDrop: P,
1143
- onWillDrop: P,
1144
- onWillDragGroup: P,
1145
- onWillDragPanel: P,
1146
- onDidActivePanelChange_: P
2255
+ clear: K,
2256
+ focus: K,
2257
+ layout: K,
2258
+ onDidLayoutChange: I,
2259
+ onDidLayoutFromJSON: I,
2260
+ onDidAddPanel: I,
2261
+ onDidRemovePanel: I,
2262
+ onDidActivePanelChange: I,
2263
+ onDidAddGroup: I,
2264
+ onDidRemoveGroup: I,
2265
+ onDidActiveGroupChange: I,
2266
+ onUnhandledDragOverEvent: I,
2267
+ onDidDrop: I,
2268
+ onWillDrop: I,
2269
+ onWillDragGroup: I,
2270
+ onWillDragPanel: I,
2271
+ onDidActivePanelChange_: I
1147
2272
  };
1148
2273
  }
1149
- function ht({ code: e, title: n, description: r }) {
1150
- return /* @__PURE__ */ d(
2274
+ function ln({ code: e, title: t, description: n }) {
2275
+ return /* @__PURE__ */ i(
1151
2276
  "div",
1152
2277
  {
1153
2278
  className: "flex min-h-screen items-center justify-center bg-background p-6 text-foreground",
1154
2279
  "data-testid": "full-page-error-state",
1155
2280
  "data-full-page-error-code": e,
1156
- children: /* @__PURE__ */ d(Xr, { className: "w-full max-w-lg", title: n, description: r })
2281
+ children: /* @__PURE__ */ i(Ns, { className: "w-full max-w-lg", title: t, description: n })
1157
2282
  }
1158
2283
  );
1159
2284
  }
1160
- function Ys({ componentId: e, params: n = {} }) {
1161
- const r = Cn(), { errors: s } = qr(), i = r.get(e), o = r.getComponents()[e];
1162
- Mr(() => {
1163
- document.title = (i == null ? void 0 : i.title) ?? e;
1164
- }, [e, i == null ? void 0 : i.title]);
1165
- const c = L(() => ({
1166
- params: n,
1167
- api: Fs(e),
1168
- containerApi: Is(),
2285
+ function Uo({ componentId: e, params: t = {} }) {
2286
+ const n = Kr(), { errors: s } = hs(), o = n.get(e), a = n.getComponents()[e];
2287
+ Gi(() => {
2288
+ document.title = (o == null ? void 0 : o.title) ?? e;
2289
+ }, [e, o == null ? void 0 : o.title]);
2290
+ const l = D(() => ({
2291
+ params: t,
2292
+ api: Eo(e),
2293
+ containerApi: ko(),
1169
2294
  className: "h-full"
1170
- }), [e, n]), u = L(() => {
1171
- if (!i) return null;
1172
- const v = i.pluginId ?? i.id;
1173
- for (let y = s.length - 1; y >= 0; y -= 1) {
1174
- const b = s[y];
1175
- if (b.contributionKind === "panel" && b.contributionId === e && b.pluginId === v)
1176
- return b;
2295
+ }), [e, t]), g = D(() => {
2296
+ if (!o) return null;
2297
+ const f = o.pluginId ?? o.id;
2298
+ for (let d = s.length - 1; d >= 0; d -= 1) {
2299
+ const m = s[d];
2300
+ if (m.contributionKind === "panel" && m.contributionId === e && m.pluginId === f)
2301
+ return m;
1177
2302
  }
1178
2303
  return null;
1179
- }, [e, s, i]);
1180
- return i ? !i.supportsFullPage || !o ? /* @__PURE__ */ d(
1181
- ht,
2304
+ }, [e, s, o]);
2305
+ return o ? !o.supportsFullPage || !a ? /* @__PURE__ */ i(
2306
+ ln,
1182
2307
  {
1183
- code: Ms,
2308
+ code: No,
1184
2309
  title: "Panel does not support full-page mode",
1185
2310
  description: `Panel "${e}" can render in the workspace, but it has not opted into the dedicated full-page pane route.`
1186
2311
  }
1187
- ) : u ? /* @__PURE__ */ d(
1188
- ht,
2312
+ ) : g ? /* @__PURE__ */ i(
2313
+ ln,
1189
2314
  {
1190
- code: Cs,
2315
+ code: wo,
1191
2316
  title: "Panel failed to render",
1192
- description: `Panel "${e}" crashed while rendering in full-page mode: ${u.error.message}`
2317
+ description: `Panel "${e}" crashed while rendering in full-page mode: ${g.error.message}`
1193
2318
  }
1194
- ) : /* @__PURE__ */ d("div", { className: "min-h-screen bg-background text-foreground", children: /* @__PURE__ */ d(jr, { mode: "full-page", children: /* @__PURE__ */ d(o, { ...c }) }) }) : /* @__PURE__ */ d(
1195
- ht,
2319
+ ) : /* @__PURE__ */ i("div", { className: "min-h-screen bg-background text-foreground", children: /* @__PURE__ */ i(bs, { mode: "full-page", children: /* @__PURE__ */ i(a, { ...l }) }) }) : /* @__PURE__ */ i(
2320
+ ln,
1196
2321
  {
1197
- code: xs,
2322
+ code: So,
1198
2323
  title: "Unknown panel",
1199
2324
  description: `No full-page panel component is registered as "${e}".`
1200
2325
  }
1201
2326
  );
1202
2327
  }
1203
- function Qs(e) {
1204
- var o;
1205
- const n = new URLSearchParams(e), r = ((o = n.get("component")) == null ? void 0 : o.trim()) ?? "";
1206
- if (!r)
2328
+ function Go(e) {
2329
+ var a;
2330
+ const t = new URLSearchParams(e), n = ((a = t.get("component")) == null ? void 0 : a.trim()) ?? "";
2331
+ if (!n)
1207
2332
  return {
1208
2333
  componentId: null,
1209
2334
  params: {},
1210
2335
  error: {
1211
- code: _s,
2336
+ code: vo,
1212
2337
  message: "Missing full-page panel component id."
1213
2338
  }
1214
2339
  };
1215
- const s = n.get("params");
2340
+ const s = t.get("params");
1216
2341
  if (!s)
1217
- return { componentId: r, params: {} };
1218
- let i;
2342
+ return { componentId: n, params: {} };
2343
+ let o;
1219
2344
  try {
1220
- i = JSON.parse(s);
2345
+ o = JSON.parse(s);
1221
2346
  } catch {
1222
2347
  return {
1223
2348
  componentId: null,
1224
2349
  params: {},
1225
2350
  error: {
1226
- code: Os,
2351
+ code: xo,
1227
2352
  message: "Invalid full-page panel params JSON."
1228
2353
  }
1229
2354
  };
1230
2355
  }
1231
- return i === null || Array.isArray(i) || typeof i != "object" ? {
2356
+ return o === null || Array.isArray(o) || typeof o != "object" ? {
1232
2357
  componentId: null,
1233
2358
  params: {},
1234
2359
  error: {
1235
- code: Ls,
2360
+ code: yo,
1236
2361
  message: "Full-page panel params must be a JSON object."
1237
2362
  }
1238
- } : { componentId: r, params: i };
2363
+ } : { componentId: n, params: o };
1239
2364
  }
1240
2365
  export {
1241
- Os as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
1242
- _s as FULL_PAGE_PANEL_MISSING_COMPONENT,
1243
- Ms as FULL_PAGE_PANEL_NOT_SUPPORTED,
1244
- Ls as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
1245
- Cs as FULL_PAGE_PANEL_RENDER_FAILED,
1246
- xs as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
1247
- zs as WorkspaceAgentFront,
1248
- ds as WorkspaceBackgroundBoot,
1249
- ks as WorkspaceBootGate,
1250
- Ys as WorkspaceFullPagePanel,
1251
- rs as createLocalStorageSessions,
1252
- Qs as parseFullPagePanelLocation,
1253
- ss as useLocalStorageSessions
2366
+ xo as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
2367
+ vo as FULL_PAGE_PANEL_MISSING_COMPONENT,
2368
+ No as FULL_PAGE_PANEL_NOT_SUPPORTED,
2369
+ yo as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
2370
+ wo as FULL_PAGE_PANEL_RENDER_FAILED,
2371
+ So as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
2372
+ Fo as WorkspaceAgentFront,
2373
+ Qs as WorkspaceBackgroundBoot,
2374
+ $o as WorkspaceBootGate,
2375
+ Uo as WorkspaceFullPagePanel,
2376
+ Hs as createLocalStorageSessions,
2377
+ Go as parseFullPagePanelLocation,
2378
+ Js as useLocalStorageSessions
1254
2379
  };