@hachej/boring-workspace 0.1.47 → 0.1.49

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,16 +1,16 @@
1
- import { jsx as d, jsxs as ye, Fragment as ue } from "react/jsx-runtime";
2
- import { useEffect as E, useSyncExternalStore as Nr, useMemo as F, useState as O, useCallback as w, useRef as J, useLayoutEffect as Dr } from "react";
3
- import { PiChatPanel as _r, usePiSessions as Lr } from "@hachej/boring-agent/front";
4
- import { aj as Or, at as ke, au as wn, av as Rn, aw as Tn, ax as Nn, ay as Xe, az as St, aA as yt, aB as Dn, aC as xr, aD as Ye, aE as Mr, U as pn, aF as Cr, q as Fr, aG as Wr, u as _n, aH as Gr, ag as Ir, aI as $r } from "./WorkspaceProvider-CSwoKjTp.js";
5
- import { T as Ur, C as Kr, r as hn, w as Hr, W as vn } from "./WorkspaceLoadingState-BoFzsDji.js";
6
- import { Sun as Jr, Moon as jr } from "lucide-react";
7
- import { IconButton as Br, ErrorState as qr } from "@hachej/boring-ui-kit";
8
- function zr() {
9
- const { theme: e, toggleTheme: n } = Or(), r = e === "dark";
10
- return E(() => {
1
+ import { jsx as d, jsxs as Pe, Fragment as de } from "react/jsx-runtime";
2
+ import { useEffect as A, useSyncExternalStore as xr, useMemo as O, useState as x, useCallback as E, useRef as H, useLayoutEffect as Mr } from "react";
3
+ import { PiChatPanel as Fr, usePiSessions as Cr } from "@hachej/boring-agent/front";
4
+ import { aj as Wr, at as Ve, au as _n, av as Ln, aw as On, ax as xn, ay as ke, az as bt, aA as St, aB as Mn, aC as Ir, aD as ze, aE as Sn, aF as Gr, U as yn, aG as $r, q as Ur, u as Fn, aH as Kr, ag as Hr, aI as Jr } from "./WorkspaceProvider-CbvaXxgT.js";
5
+ import { T as jr, C as qr, r as Pn, w as Br, W as En } from "./WorkspaceLoadingState-Bi_qd29T.js";
6
+ import { Sun as zr, Moon as Vr } from "lucide-react";
7
+ import { IconButton as kr, ErrorState as Yr } from "@hachej/boring-ui-kit";
8
+ function Xr() {
9
+ const { theme: e, toggleTheme: n } = Wr(), r = e === "dark";
10
+ return A(() => {
11
11
  typeof document > "u" || document.documentElement.classList.toggle("dark", r);
12
12
  }, [r]), /* @__PURE__ */ d(
13
- Br,
13
+ kr,
14
14
  {
15
15
  type: "button",
16
16
  variant: "ghost",
@@ -18,18 +18,18 @@ function zr() {
18
18
  onClick: n,
19
19
  "aria-label": "Toggle theme",
20
20
  title: r ? "Switch to light theme" : "Switch to dark theme",
21
- children: r ? /* @__PURE__ */ d(Jr, { className: "h-4 w-4" }) : /* @__PURE__ */ d(jr, { className: "h-4 w-4" })
21
+ children: r ? /* @__PURE__ */ d(zr, { className: "h-4 w-4" }) : /* @__PURE__ */ d(Vr, { className: "h-4 w-4" })
22
22
  }
23
23
  );
24
24
  }
25
- function Vr() {
25
+ function Qr() {
26
26
  const e = `s${Date.now()}`;
27
27
  return {
28
28
  sessions: [{ id: e, title: "New session", updatedAt: Date.now() }],
29
29
  activeId: e
30
30
  };
31
31
  }
32
- function Yr(e, n) {
32
+ function Zr(e, n) {
33
33
  var r;
34
34
  if (typeof localStorage > "u") return n();
35
35
  try {
@@ -43,18 +43,18 @@ function Yr(e, n) {
43
43
  }
44
44
  return n();
45
45
  }
46
- function kr(e, n) {
46
+ function ei(e, n) {
47
47
  if (!(typeof localStorage > "u"))
48
48
  try {
49
49
  localStorage.setItem(e, JSON.stringify(n));
50
50
  } catch {
51
51
  }
52
52
  }
53
- function Xr(e = {}) {
54
- const n = e.storageKey ?? "workspace:sessions", r = e.initial ?? Vr;
55
- let i = Yr(n, r);
53
+ function ti(e = {}) {
54
+ const n = e.storageKey ?? "workspace:sessions", r = e.initial ?? Qr;
55
+ let i = Zr(n, r);
56
56
  const s = /* @__PURE__ */ new Set(), o = (c) => {
57
- i = c, kr(n, i), s.forEach((u) => u());
57
+ i = c, ei(n, i), s.forEach((u) => u());
58
58
  };
59
59
  return {
60
60
  getState: () => i,
@@ -81,11 +81,11 @@ function Xr(e = {}) {
81
81
  }
82
82
  };
83
83
  }
84
- function Qr(e) {
85
- return Nr(e.subscribe, e.getState, e.getState);
84
+ function ni(e) {
85
+ return xr(e.subscribe, e.getState, e.getState);
86
86
  }
87
- const Zr = 500, ei = 1e4;
88
- function bn(e) {
87
+ const ri = 500, ii = 1e4;
88
+ function An(e) {
89
89
  return new Promise((n, r) => {
90
90
  let i;
91
91
  const s = () => {
@@ -99,12 +99,12 @@ function bn(e) {
99
99
  }
100
100
  i = globalThis.setTimeout(() => {
101
101
  s(), n();
102
- }, Zr), e.addEventListener("abort", o, { once: !0 });
102
+ }, ri), e.addEventListener("abort", o, { once: !0 });
103
103
  });
104
104
  }
105
- async function ti(e) {
105
+ async function si(e) {
106
106
  const n = e.body;
107
- if (!n) return Ye(await Xe(e));
107
+ if (!n) return ze(await ke(e));
108
108
  const r = n.getReader(), i = new TextDecoder();
109
109
  let s = "";
110
110
  try {
@@ -112,18 +112,18 @@ async function ti(e) {
112
112
  const { done: o, value: c } = await r.read();
113
113
  if (c) {
114
114
  s += i.decode(c, { stream: !o });
115
- const u = Ye(s);
115
+ const u = ze(s);
116
116
  if (u) return u;
117
117
  }
118
118
  if (o)
119
- return s += i.decode(), Ye(s);
119
+ return s += i.decode(), ze(s);
120
120
  }
121
121
  } finally {
122
122
  await r.cancel().catch(() => {
123
123
  });
124
124
  }
125
125
  }
126
- function ni(e) {
126
+ function oi(e) {
127
127
  if (!((e == null ? void 0 : e.runtimeDependenciesState) !== "preparing" && (e == null ? void 0 : e.runtimeDependenciesState) !== "ready" && (e == null ? void 0 : e.runtimeDependenciesState) !== "failed"))
128
128
  return {
129
129
  state: e.runtimeDependenciesState,
@@ -131,13 +131,13 @@ function ni(e) {
131
131
  ...e.runtimeDependenciesRequirement ? { requirement: e.runtimeDependenciesRequirement } : {}
132
132
  };
133
133
  }
134
- async function ri(e) {
134
+ async function ai(e) {
135
135
  if (!e.ok) {
136
- const s = await Xe(e);
137
- if (St(s)) return { status: "preparing" };
138
- throw new Error(yt(s) ?? `/api/v1/ready-status failed with ${e.status}`);
136
+ const s = await ke(e);
137
+ if (bt(s)) return { status: "preparing" };
138
+ throw new Error(St(s) ?? `/api/v1/ready-status failed with ${e.status}`);
139
139
  }
140
- const n = await ti(e), r = ni(n), i = xr(n);
140
+ const n = await si(e), r = oi(n), i = Ir(n);
141
141
  if ((n == null ? void 0 : n.state) === "degraded" || (n == null ? void 0 : n.state) === "failed") {
142
142
  if (i && (r == null ? void 0 : r.state) === "failed")
143
143
  return { status: "ready", runtimeDependencies: r };
@@ -145,25 +145,25 @@ async function ri(e) {
145
145
  }
146
146
  return i ? { status: "ready", ...r ? { runtimeDependencies: r } : {} } : { status: "preparing", ...r ? { runtimeDependencies: r } : {} };
147
147
  }
148
- async function ii({
148
+ async function li({
149
149
  apiBaseUrl: e,
150
150
  path: n,
151
151
  headers: r,
152
152
  signal: i,
153
153
  workspaceId: s
154
154
  }) {
155
- const o = new AbortController(), c = globalThis.setTimeout(() => o.abort(new DOMException("Warmup attempt timed out", "TimeoutError")), ei), u = () => o.abort(i.reason);
155
+ const o = new AbortController(), c = globalThis.setTimeout(() => o.abort(new DOMException("Warmup attempt timed out", "TimeoutError")), ii), u = () => o.abort(i.reason);
156
156
  i.aborted && u(), i.addEventListener("abort", u, { once: !0 });
157
157
  try {
158
- const b = await fetch(Tn(e, n), { headers: r, signal: o.signal });
159
- if (Nn(n)) return await ri(b);
160
- const y = await Xe(b);
158
+ const b = await fetch(On(e, n), { headers: r, signal: o.signal });
159
+ if (xn(n)) return await ai(b);
160
+ const y = await ke(b);
161
161
  if (!b.ok) {
162
- const S = St(y);
162
+ const S = bt(y);
163
163
  if (S) return { status: "preparing", ...S };
164
- throw new Error(yt(y) ?? `${n} failed with ${b.status}`);
164
+ throw new Error(St(y) ?? `${n} failed with ${b.status}`);
165
165
  }
166
- return y && typeof y == "object" && Dn(e, r["x-boring-workspace-id"] ?? s, n, y), { status: "ready" };
166
+ return y && typeof y == "object" && Mn(e, r["x-boring-workspace-id"] ?? s, n, y), { status: "ready" };
167
167
  } catch (b) {
168
168
  if (i.aborted) throw b;
169
169
  if (o.signal.aborted || b instanceof TypeError) return { status: "preparing" };
@@ -172,31 +172,31 @@ async function ii({
172
172
  globalThis.clearTimeout(c), i.removeEventListener("abort", u);
173
173
  }
174
174
  }
175
- function si({
175
+ function ci({
176
176
  workspaceId: e,
177
177
  requestHeaders: n,
178
178
  apiBaseUrl: r,
179
- preloadPaths: i = wn,
179
+ preloadPaths: i = _n,
180
180
  provisionWorkspace: s = !0,
181
181
  onStatusChange: o
182
182
  }) {
183
- return E(() => {
183
+ return A(() => {
184
184
  let c = !1;
185
- const u = new AbortController(), b = ke(e, n);
185
+ const u = new AbortController(), b = Ve(e, n);
186
186
  async function y() {
187
187
  var S, j;
188
188
  o == null || o({ status: "preparing" });
189
189
  try {
190
- const W = Rn(i, s), V = (p) => ii({
190
+ const W = Ln(i, s), V = (p) => li({
191
191
  apiBaseUrl: r,
192
192
  path: p,
193
193
  headers: b,
194
194
  signal: u.signal,
195
195
  workspaceId: e
196
196
  });
197
- let R = await Promise.all(W.map(async (p) => ({ path: p, result: await V(p) })));
197
+ let w = await Promise.all(W.map(async (p) => ({ path: p, result: await V(p) })));
198
198
  if (c || u.signal.aborted) return;
199
- let h = (S = R.find((p) => p.result.runtimeDependencies)) == null ? void 0 : S.result.runtimeDependencies, T = R.filter((p) => p.result.status === "preparing");
199
+ let h = (S = w.find((p) => p.result.runtimeDependencies)) == null ? void 0 : S.result.runtimeDependencies, T = w.filter((p) => p.result.status === "preparing");
200
200
  for (; T.length > 0; ) {
201
201
  let p;
202
202
  for (const N of T)
@@ -204,11 +204,11 @@ function si({
204
204
  p = N.result.requirement;
205
205
  break;
206
206
  }
207
- if (o == null || o({ status: "preparing", message: "Workspace is still preparing", ...p ? { requirement: p } : {} }), await bn(u.signal), c || u.signal.aborted || (R = await Promise.all(T.map(async (N) => ({ path: N.path, result: await V(N.path) }))), c || u.signal.aborted)) return;
208
- h = ((j = R.find((N) => N.result.runtimeDependencies)) == null ? void 0 : j.result.runtimeDependencies) ?? h, T = R.filter((N) => N.result.status === "preparing");
207
+ if (o == null || o({ status: "preparing", message: "Workspace is still preparing", ...p ? { requirement: p } : {} }), await An(u.signal), c || u.signal.aborted || (w = await Promise.all(T.map(async (N) => ({ path: N.path, result: await V(N.path) }))), c || u.signal.aborted)) return;
208
+ h = ((j = w.find((N) => N.result.runtimeDependencies)) == null ? void 0 : j.result.runtimeDependencies) ?? h, T = w.filter((N) => N.result.status === "preparing");
209
209
  }
210
210
  for (o == null || o({ status: "ready", ...h ? { runtimeDependencies: h } : {} }); (h == null ? void 0 : h.state) === "preparing"; ) {
211
- if (await bn(u.signal), c || u.signal.aborted) return;
211
+ if (await An(u.signal), c || u.signal.aborted) return;
212
212
  const p = await V("/api/v1/ready-status");
213
213
  if (c || u.signal.aborted) return;
214
214
  h = p.runtimeDependencies, h && (o == null || o({ status: "ready", runtimeDependencies: h }));
@@ -226,51 +226,51 @@ function si({
226
226
  };
227
227
  }, [r, o, i, s, n, e]), null;
228
228
  }
229
- function oi(e) {
229
+ function ui(e) {
230
230
  return typeof (e == null ? void 0 : e.id) == "string" ? e.id : null;
231
231
  }
232
- function Ve(e, n, r) {
232
+ function Be(e, n, r) {
233
233
  if (e.includes(r)) return e;
234
234
  const i = n ? e.indexOf(n) : -1, s = i >= 0 ? i + 1 : e.length;
235
235
  return [...e.slice(0, s), r, ...e.slice(s)];
236
236
  }
237
- function Sn(e, n, r) {
237
+ function Rn(e, n, r) {
238
238
  if (e.includes(r)) return e;
239
239
  if (e.length === 0) return [r];
240
240
  const i = n ? e.indexOf(n) : -1, s = i >= 0 ? i : 0;
241
241
  return e.map((o, c) => c === s ? r : o);
242
242
  }
243
- function ai(e, n) {
243
+ function di(e, n) {
244
244
  return e.endsWith(":surface") ? e.slice(0, -8) : n;
245
245
  }
246
- function ht(e, n, r) {
247
- const [i, s] = O(() => hn(e, n, r));
248
- E(() => {
249
- s(hn(e, n, r));
246
+ function pt(e, n, r) {
247
+ const [i, s] = x(() => Pn(e, n, r));
248
+ A(() => {
249
+ s(Pn(e, n, r));
250
250
  }, [e, n, r]);
251
- const o = w(
251
+ const o = E(
252
252
  (c) => {
253
- s(c), Hr(e, c, r);
253
+ s(c), Br(e, c, r);
254
254
  },
255
255
  [r, e]
256
256
  );
257
257
  return [i, o];
258
258
  }
259
- const vt = {}, li = [], yn = { status: "preparing" }, Pn = {
259
+ const ht = {}, fi = [], wn = { status: "preparing" }, Tn = {
260
260
  openTabs: [],
261
261
  activeTab: null
262
262
  };
263
- function ci({ status: e }) {
263
+ function gi({ status: e }) {
264
264
  const n = e.status === "ready" ? void 0 : e.requirement, r = e.status !== "failed", i = r ? n === "workspace-fs" ? "Preparing files…" : n === "sandbox-exec" ? "Preparing secure runtime…" : n === "ui-bridge" ? "Connecting workspace…" : "Preparing workspace…" : "Workspace workbench failed", s = 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__ */ ye("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
265
+ return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Pe("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
266
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
267
  /* @__PURE__ */ d("div", { className: "text-sm font-semibold text-foreground", children: i }),
268
268
  /* @__PURE__ */ d("p", { className: "mt-2 text-sm text-muted-foreground", children: s }),
269
269
  e.status === "failed" ? /* @__PURE__ */ d("p", { className: "mt-3 text-xs text-muted-foreground", children: "Reload the workspace to retry." }) : null
270
270
  ] }) });
271
271
  }
272
- function ui(e) {
273
- const n = e.workspaceId ?? di(e.requestHeaders) ?? e.storageKey, r = Lr({
272
+ function mi(e) {
273
+ const n = e.workspaceId ?? pi(e.requestHeaders) ?? e.storageKey, r = Cr({
274
274
  apiBaseUrl: e.apiBaseUrl,
275
275
  workspaceId: n,
276
276
  storageScope: n,
@@ -281,10 +281,10 @@ function ui(e) {
281
281
  });
282
282
  return { ...r, workspaceId: r.dataStorageScope };
283
283
  }
284
- function di(e) {
284
+ function pi(e) {
285
285
  return (e == null ? void 0 : e["x-boring-workspace-id"]) ?? (e == null ? void 0 : e["X-Boring-Workspace-Id"]) ?? null;
286
286
  }
287
- function fi(e) {
287
+ function hi(e) {
288
288
  const n = e.reloaded ? "Extensions reloaded." : "Extensions will reload on the next message.", r = Array.isArray(e.diagnostics) ? e.diagnostics.map((i) => i.message).filter((i) => !!i) : [];
289
289
  return r.length > 0 ? `${n}
290
290
 
@@ -292,7 +292,7 @@ Warnings:
292
292
  ${r.join(`
293
293
  `)}` : n;
294
294
  }
295
- function gi(e) {
295
+ function vi(e) {
296
296
  var n;
297
297
  try {
298
298
  return ((n = globalThis.localStorage) == null ? void 0 : n.getItem(e)) ?? null;
@@ -300,7 +300,7 @@ function gi(e) {
300
300
  return null;
301
301
  }
302
302
  }
303
- function En(e, n) {
303
+ function Nn(e, n) {
304
304
  var r;
305
305
  try {
306
306
  const i = (r = globalThis.localStorage) == null ? void 0 : r.getItem(e);
@@ -313,7 +313,7 @@ function En(e, n) {
313
313
  return null;
314
314
  }
315
315
  }
316
- function mi(e, n) {
316
+ function bi(e, n) {
317
317
  var r, i;
318
318
  try {
319
319
  if (n.ids.length === 0) {
@@ -327,7 +327,7 @@ function mi(e, n) {
327
327
  } catch {
328
328
  }
329
329
  }
330
- function An(e, n) {
330
+ function Dn(e, n) {
331
331
  var r;
332
332
  try {
333
333
  const i = (r = globalThis.localStorage) == null ? void 0 : r.getItem(e);
@@ -338,7 +338,7 @@ function An(e, n) {
338
338
  return null;
339
339
  }
340
340
  }
341
- function pi(e, n) {
341
+ function Si(e, n) {
342
342
  var r, i;
343
343
  try {
344
344
  if (n.length === 0) {
@@ -349,27 +349,27 @@ function pi(e, n) {
349
349
  } catch {
350
350
  }
351
351
  }
352
- function hi() {
353
- return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ ye("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
352
+ function yi() {
353
+ return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Pe("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
354
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
355
  /* @__PURE__ */ d("div", { className: "text-sm font-semibold text-foreground", children: "Loading sessions…" }),
356
356
  /* @__PURE__ */ d("p", { className: "mt-2 text-sm text-muted-foreground", children: "Finding this workspace’s saved chats." })
357
357
  ] }) });
358
358
  }
359
- function vi(e) {
359
+ function Pi(e) {
360
360
  if (!e) return "/api/v1/ui";
361
361
  const n = e.replace(/\/$/, ""), r = "/api/v1/ui";
362
362
  return n.endsWith(r) ? n : `${n}${r}`;
363
363
  }
364
- function bi(e) {
365
- return `${vi(e)}/state`;
364
+ function Ei(e) {
365
+ return `${Pi(e)}/state`;
366
366
  }
367
- function Si(e) {
367
+ function Ai(e) {
368
368
  var i;
369
369
  const n = e.openTabs.find((s) => s.id === e.activeTab), r = (i = n == null ? void 0 : n.params) == null ? void 0 : i.path;
370
370
  return typeof r == "string" ? r : null;
371
371
  }
372
- function yi({
372
+ function Ri({
373
373
  bridgeEndpoint: e,
374
374
  requestHeaders: n,
375
375
  navOpen: r,
@@ -377,8 +377,8 @@ function yi({
377
377
  surfaceReady: s,
378
378
  snapshot: o
379
379
  }) {
380
- const c = _n(), u = J(null);
381
- return E(() => {
380
+ const c = Fn(), u = H(null);
381
+ return A(() => {
382
382
  var S;
383
383
  if (e === null || i && !s) return;
384
384
  (S = u.current) == null || S.abort();
@@ -390,10 +390,10 @@ function yi({
390
390
  workbenchOpen: i,
391
391
  openTabs: o.openTabs,
392
392
  activeTab: o.activeTab,
393
- activeFile: Si(o),
393
+ activeFile: Ai(o),
394
394
  availablePanels: c.list().map((j) => j.id)
395
395
  };
396
- return fetch(bi(e), {
396
+ return fetch(Ei(e), {
397
397
  method: "PUT",
398
398
  headers: { ...n, "Content-Type": "application/json" },
399
399
  body: JSON.stringify({ state: y, causedBy: "user" }),
@@ -404,7 +404,7 @@ function yi({
404
404
  };
405
405
  }, [e, r, c, n, o, i, s]), null;
406
406
  }
407
- function Ji({
407
+ function zi({
408
408
  workspaceId: e,
409
409
  chatPanel: n,
410
410
  useSessions: r,
@@ -419,112 +419,112 @@ function Ji({
419
419
  catalogs: j,
420
420
  plugins: W,
421
421
  excludeDefaults: V,
422
- capabilities: R,
422
+ capabilities: w,
423
423
  apiBaseUrl: h,
424
424
  authHeaders: T,
425
425
  apiTimeout: p,
426
426
  defaultTheme: N,
427
- onThemeChange: Ln,
428
- persistenceEnabled: Pt,
429
- debug: On,
430
- bridgeEndpoint: Qe,
431
- fullPageBasePath: xn,
432
- onAuthError: Mn,
433
- sessions: Et,
434
- activeSessionId: At,
435
- onSwitchSession: wt,
436
- onCreateSession: Ze,
427
+ onThemeChange: Cn,
428
+ persistenceEnabled: yt,
429
+ debug: Wn,
430
+ bridgeEndpoint: Ye,
431
+ fullPageBasePath: In,
432
+ onAuthError: Gn,
433
+ sessions: Pt,
434
+ activeSessionId: Et,
435
+ onSwitchSession: At,
436
+ onCreateSession: Xe,
437
437
  onDeleteSession: Rt,
438
- onActiveSessionIdChange: Pe,
439
- appTitle: Cn = "Sovereign Workspace",
440
- workspaceLabel: Fn,
441
- defaultSessionTitle: Y = "New session",
438
+ onActiveSessionIdChange: Ee,
439
+ appTitle: wt = "Boring UI",
440
+ workspaceLabel: $n,
441
+ defaultSessionTitle: k = "New session",
442
442
  navEnabled: Tt = !0,
443
- defaultNavOpen: Wn = !1,
444
- defaultSurfaceOpen: Gn,
445
- defaultWorkbenchLeftTab: Ee,
446
- defaultWorkbenchLeftOpen: et,
443
+ defaultNavOpen: Un = !1,
444
+ defaultSurfaceOpen: Kn,
445
+ defaultWorkbenchLeftTab: Ae,
446
+ defaultWorkbenchLeftOpen: Qe,
447
447
  surfaceInitialPanels: Nt,
448
- topBarLeft: In,
449
- topBarRight: $n,
450
- showThemeToggle: Un = !0,
448
+ topBarLeft: Hn,
449
+ topBarRight: Jn,
450
+ showThemeToggle: jn = !0,
451
451
  chatParams: L,
452
- externalPlugins: Kn,
453
- hotReloadEnabled: Hn,
454
- frontPluginHotReload: Jn,
452
+ externalPlugins: qn,
453
+ hotReloadEnabled: Bn,
454
+ frontPluginHotReload: zn,
455
455
  extraPanels: Dt,
456
456
  extraCommands: _t,
457
- provisionWorkspace: tt,
458
- bootPreloadPaths: jn,
459
- onWorkspaceWarmupStatusChange: Ae,
460
- onOpenNav: nt,
461
- onOpenSurface: rt,
462
- surfaceButtonBottomOffset: Bn,
463
- className: qn
457
+ provisionWorkspace: Ze,
458
+ bootPreloadPaths: Vn,
459
+ onWorkspaceWarmupStatusChange: Re,
460
+ onOpenNav: et,
461
+ onOpenSurface: tt,
462
+ surfaceButtonBottomOffset: kn,
463
+ className: Yn
464
464
  }) {
465
- var ln, cn;
466
- const Lt = Kn !== !1, zn = Lt ? Jn : !1, it = Lt ? Hn : !1, st = o ?? `boring-ui-v2:layout:${e}`, G = c ?? `${st}:surface`, we = ai(
467
- G,
468
- st
469
- ), M = Pt !== !1, Re = s ?? `boring-workspace:sessions:${e}`, k = F(
470
- () => ke(e, i ?? vt),
465
+ var fn, gn;
466
+ const Lt = qn !== !1, Xn = Lt ? zn : !1, nt = Lt ? Bn : !1, rt = o ?? `boring-ui-v2:layout:${e}`, I = c ?? `${rt}:surface`, we = di(
467
+ I,
468
+ rt
469
+ ), F = yt !== !1, Te = s ?? `boring-workspace:sessions:${e}`, Y = O(
470
+ () => Ve(e, i ?? ht),
471
471
  [i, e]
472
- ), Vn = F(
473
- () => ke(e, { ...i ?? vt, ...T ?? vt }),
472
+ ), Qn = O(
473
+ () => Ve(e, { ...i ?? ht, ...T ?? ht }),
474
474
  [T, i, e]
475
- ), Te = F(
476
- () => Xr({ storageKey: Re }),
477
- [Re]
478
- ), Ot = Qr(Te), [xt, Yn] = O(() => ({
475
+ ), Ne = O(
476
+ () => ti({ storageKey: Te }),
477
+ [Te]
478
+ ), Ot = ni(Ne), [xt, Zn] = x(() => ({
479
479
  workspaceId: e,
480
- status: yn
481
- })), [Ne, ot] = O(() => ({
480
+ status: wn
481
+ })), [De, it] = x(() => ({
482
482
  workspaceId: e,
483
483
  expired: !1
484
- })), [Mt, De] = O(() => ({
484
+ })), [Mt, _e] = x(() => ({
485
485
  workspaceId: e,
486
486
  creating: !1
487
- })), [Ct, _e] = O(() => ({
487
+ })), [Ft, Le] = x(() => ({
488
488
  workspaceId: e,
489
489
  failed: !1
490
- })), [at, Ft] = O(null), de = `boring-workspace:chat-panes:${e}`, [D, q] = O(
491
- () => (M ? En(de, e) : null) ?? { workspaceId: e, ids: [], activeId: null }
492
- ), [ie, Wt] = O(null);
493
- E(() => {
490
+ })), [st, Ct] = x(null), fe = `boring-workspace:chat-panes:${e}`, [D, B] = x(
491
+ () => (F ? Nn(fe, e) : null) ?? { workspaceId: e, ids: [], activeId: null }
492
+ ), [ie, Wt] = x(null);
493
+ A(() => {
494
494
  if (!ie) return;
495
495
  const t = setTimeout(() => Wt(null), 700);
496
496
  return () => clearTimeout(t);
497
497
  }, [ie]);
498
- const fe = `boring-workspace:pinned-sessions:${e}`, [Gt, It] = O(
499
- () => (M ? An(fe, e) : null) ?? { workspaceId: e, ids: [] }
500
- ), kn = Gt.workspaceId === e ? Gt.ids : li;
501
- E(() => {
502
- It((t) => t.workspaceId === e ? t : (M ? An(fe, e) : null) ?? { workspaceId: e, ids: [] });
503
- }, [fe, M, e]);
504
- const Xn = w((t) => {
505
- It((a) => {
498
+ const ge = `boring-workspace:pinned-sessions:${e}`, [It, Gt] = x(
499
+ () => (F ? Dn(ge, e) : null) ?? { workspaceId: e, ids: [] }
500
+ ), er = It.workspaceId === e ? It.ids : fi;
501
+ A(() => {
502
+ Gt((t) => t.workspaceId === e ? t : (F ? Dn(ge, e) : null) ?? { workspaceId: e, ids: [] });
503
+ }, [ge, F, e]);
504
+ const tr = E((t) => {
505
+ Gt((a) => {
506
506
  const l = a.workspaceId === e ? a.ids : [], g = l.includes(t) ? l.filter((v) => v !== t) : [t, ...l];
507
- return M && pi(fe, g), { workspaceId: e, ids: g };
507
+ return F && Si(ge, g), { workspaceId: e, ids: g };
508
508
  });
509
- }, [fe, M, e]);
510
- E(() => {
511
- M && D.workspaceId === e && mi(de, D);
512
- }, [D, de, M, e]), E(() => {
513
- q((t) => t.workspaceId === e ? t : (M ? En(de, e) : null) ?? { workspaceId: e, ids: [], activeId: null });
514
- }, [de, M, e]);
515
- const Le = xt.workspaceId === e ? xt.status : yn, Qn = n ?? _r, Zn = r ?? ui, X = !n || !!r, Oe = X && tt !== !1, lt = () => {
516
- }, _ = Zn({
517
- requestHeaders: k,
518
- storageKey: Re,
509
+ }, [ge, F, e]);
510
+ A(() => {
511
+ F && D.workspaceId === e && bi(fe, D);
512
+ }, [D, fe, F, e]), A(() => {
513
+ B((t) => t.workspaceId === e ? t : (F ? Nn(fe, e) : null) ?? { workspaceId: e, ids: [], activeId: null });
514
+ }, [fe, F, e]);
515
+ const Oe = xt.workspaceId === e ? xt.status : wn, nr = n ?? Fr, rr = r ?? mi, X = !n || !!r, xe = X && Ze !== !1, ot = () => {
516
+ }, _ = rr({
517
+ requestHeaders: Y,
518
+ storageKey: Te,
519
519
  workspaceId: e,
520
520
  apiBaseUrl: h,
521
- enabled: Oe
522
- }), [ge, er] = O(() => ({ workspaceId: e, sessions: [], activeSessionId: null })), $t = Oe && _.workspaceId != null && _.workspaceId !== e, z = Oe && !_.loading && !_.error && !$t, C = Oe && !z;
523
- E(() => {
524
- z && er((t) => {
525
- const a = t.workspaceId === e, l = t.activeSessionId === _.activeSessionId, g = t.sessions.length === _.sessions.length && t.sessions.every((v, A) => {
521
+ enabled: xe
522
+ }), [me, ir] = x(() => ({ workspaceId: e, sessions: [], activeSessionId: null })), $t = xe && _.workspaceId != null && _.workspaceId !== e, z = xe && !_.loading && !_.error && !$t, C = xe && !z;
523
+ A(() => {
524
+ z && ir((t) => {
525
+ const a = t.workspaceId === e, l = t.activeSessionId === _.activeSessionId, g = t.sessions.length === _.sessions.length && t.sessions.every((v, R) => {
526
526
  var ne;
527
- return v.id === ((ne = _.sessions[A]) == null ? void 0 : ne.id);
527
+ return v.id === ((ne = _.sessions[R]) == null ? void 0 : ne.id);
528
528
  });
529
529
  return a && l && g ? t : {
530
530
  workspaceId: e,
@@ -533,357 +533,368 @@ function Ji({
533
533
  };
534
534
  });
535
535
  }, [_.activeSessionId, _.sessions, z, e]);
536
- const xe = C && ge.workspaceId === e && ge.sessions.length > 0, Me = C ? gi(Re) : null, Ut = C && !$t ? _.activeSessionId ?? null : null, Q = z ? _.sessions : xe ? ge.sessions : [], tr = z ? _.activeSessionId : xe ? ge.activeSessionId : null, f = X && (z || xe) ? _ : void 0, se = Et !== void 0 || At !== void 0 || wt !== void 0 || Ze !== void 0 || Rt !== void 0, Kt = Ne.workspaceId === e && Ne.expired, me = J(!1), pe = !!(z && f && !se && Q.length === 0 && !Kt), nr = Mt.workspaceId === e && Mt.creating, rr = Ct.workspaceId === e && Ct.failed, ir = !!(z && f && !se && Q.length === 0 && Kt && !me.current && !rr), Ce = !!(C && _.loading && !_.error && X && !se && !xe && !Me && !Ut) || pe || nr || ir;
537
- E(() => {
538
- if (!pe) {
539
- Ne.workspaceId !== e && ot({ workspaceId: e, expired: !1 });
536
+ const Me = C && me.workspaceId === e && me.sessions.length > 0, Fe = C ? vi(Te) : null, Ut = C && !$t ? _.activeSessionId ?? null : null, Q = z ? _.sessions : Me ? me.sessions : [], sr = z ? _.activeSessionId : Me ? me.activeSessionId : null, f = X && (z || Me) ? _ : void 0, se = Pt !== void 0 || Et !== void 0 || At !== void 0 || Xe !== void 0 || Rt !== void 0, Kt = De.workspaceId === e && De.expired, pe = H(!1), he = !!(z && f && !se && Q.length === 0 && !Kt), or = Mt.workspaceId === e && Mt.creating, ar = Ft.workspaceId === e && Ft.failed, lr = !!(z && f && !se && Q.length === 0 && Kt && !pe.current && !ar), Ce = !!(C && _.loading && !_.error && X && !se && !Me && !Fe && !Ut) || he || or || lr;
537
+ A(() => {
538
+ if (!he) {
539
+ De.workspaceId !== e && it({ workspaceId: e, expired: !1 });
540
540
  return;
541
541
  }
542
- ot({ workspaceId: e, expired: !1 });
542
+ it({ workspaceId: e, expired: !1 });
543
543
  const t = globalThis.setTimeout(() => {
544
- ot({ workspaceId: e, expired: !0 });
544
+ it({ workspaceId: e, expired: !0 });
545
545
  }, 2e3);
546
546
  return () => globalThis.clearTimeout(t);
547
- }, [Ne.workspaceId, pe, e]);
548
- const sr = f ? Q.map((t) => ({
547
+ }, [De.workspaceId, he, e]);
548
+ const cr = f ? Q.map((t) => ({
549
549
  ...t,
550
550
  title: t.title ?? "New session"
551
- })) : void 0, or = Me ? [{
552
- id: Me,
551
+ })) : void 0, ur = Fe ? [{
552
+ id: Fe,
553
553
  title: "Loading sessions…",
554
554
  createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
555
555
  updatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
556
556
  turnCount: 0
557
- }] : [], $ = f ? sr ?? [] : C ? or : se ? Et ?? [] : Ot.sessions, ar = f ? tr ?? null : C ? Me ?? Ut : se ? At ?? null : Ot.activeId, oe = (L == null ? void 0 : L.autoSubmitInitialDraft) === !0, Fe = oe && X && !se, [U, he] = O(() => Fe ? null : void 0), Ht = J(e), ae = J(!1);
558
- E(() => {
557
+ }] : [], $ = f ? cr ?? [] : C ? ur : se ? Pt ?? [] : Ot.sessions, dr = f ? sr ?? null : C ? Fe ?? Ut : se ? Et ?? null : Ot.activeId, oe = (L == null ? void 0 : L.autoSubmitInitialDraft) === !0, We = oe && X && !se, [U, ve] = x(() => We ? null : void 0), Ht = H(e), ae = H(!1);
558
+ A(() => {
559
559
  if (Ht.current !== e) {
560
- Ht.current = e, ae.current = !1, he(Fe ? null : void 0);
560
+ Ht.current = e, ae.current = !1, ve(We ? null : void 0);
561
561
  return;
562
562
  }
563
- Fe && U === void 0 && (ae.current = !1, he(null));
564
- }, [U, Fe, e]), E(() => {
565
- !f || U !== null || ae.current || (ae.current = !0, Promise.resolve(f.create({ title: Y })).then((t) => {
563
+ We && U === void 0 && (ae.current = !1, ve(null));
564
+ }, [U, We, e]), A(() => {
565
+ !f || U !== null || ae.current || (ae.current = !0, Promise.resolve(f.create({ title: k })).then((t) => {
566
566
  if (typeof (t == null ? void 0 : t.id) != "string")
567
567
  throw new Error("auto_submit_session_create_failed");
568
- he(t.id);
568
+ ve(t.id);
569
569
  }).catch(() => {
570
- ae.current = !1, he(void 0);
570
+ ae.current = !1, ve(void 0);
571
571
  }));
572
- }, [U, Y, f]);
573
- const I = U !== void 0 ? U ?? null : ar, H = C ? lt : (f == null ? void 0 : f.switch) ?? wt ?? Te.switchTo, We = w((t) => (I && t !== I && window.dispatchEvent(new CustomEvent("boring:workspace-composer-stop", { detail: { sessionId: I } })), H(t)), [I, H]), ct = C ? lt : f ? () => f.create() : Ze ? () => Ze() : () => Te.create(), Jt = C ? lt : (f == null ? void 0 : f.delete) ?? Rt ?? Te.remove, jt = w((t) => (f && Q.length <= 1 && (me.current = !0), Jt(t)), [Q.length, Jt, f]), lr = ((ln = $.find((t) => t.id === I)) == null ? void 0 : ln.title) ?? void 0, [cr, Bt] = ht(
572
+ }, [U, k, f]);
573
+ const G = U !== void 0 ? U ?? null : dr, J = C ? ot : (f == null ? void 0 : f.switch) ?? At ?? Ne.switchTo, Ie = E((t) => (G && t !== G && window.dispatchEvent(new CustomEvent("boring:workspace-composer-stop", { detail: { sessionId: G } })), J(t)), [G, J]), at = C ? ot : f ? () => f.create() : Xe ? () => Xe() : () => Ne.create(), Jt = C ? ot : (f == null ? void 0 : f.delete) ?? Rt ?? Ne.remove, jt = E((t) => (f && Q.length <= 1 && (pe.current = !0), Jt(t)), [Q.length, Jt, f]), fr = ((fn = $.find((t) => t.id === G)) == null ? void 0 : fn.title) ?? void 0, [gr, qt] = pt(
574
574
  `${we}:drawer`,
575
- Wn,
576
- M
577
- ), qt = Tt && cr, [Z, B] = ht(
575
+ Un,
576
+ F
577
+ ), Bt = Tt && gr, [Z, q] = pt(
578
578
  // Key must NOT match resolvedSurfaceStorageKey (which stores the dockview
579
579
  // layout JSON at the same ":surface" suffix). Writing "1"/"0" to the same
580
580
  // key corrupts the JSON and drops the persisted workbench layout on reload.
581
581
  `${we}:workbenchOpen`,
582
- Gn ?? !1,
583
- M
584
- ), [ur, ut] = O(!1), [dr, ve] = ht(
582
+ Kn ?? !1,
583
+ F
584
+ ), [mr, lt] = x(!1), [pr, be] = pt(
585
585
  `${we}:workbenchLeftOpen`,
586
- et ?? !1,
587
- M
588
- ), [fr, Ge] = O(() => et ?? !1), gr = et === !1 ? fr : dr, be = J(!1), ee = J(null), te = J(Z), zt = J(G), dt = J(null);
589
- zt.current = G;
590
- const [Vt, Yt] = O(() => ({
591
- key: G,
592
- snapshot: Pn
593
- })), mr = Vt.key === G ? Vt.snapshot : Pn;
594
- E(() => {
595
- be.current = !1, me.current = !1, De({ workspaceId: e, creating: !1 }), _e({ workspaceId: e, failed: !1 }), Ft(null);
596
- }, [e]), E(() => {
597
- ut(!1);
598
- }, [G]), E(() => {
599
- if (!(!f || f.loading) && !pe && U === void 0) {
586
+ Qe ?? !1,
587
+ F
588
+ ), [hr, Ge] = x(() => Qe ?? !1), vr = Qe === !1 ? hr : pr, Se = H(!1), ee = H(null), te = H(Z), zt = H(I), ct = H(null), ut = H([]);
589
+ zt.current = I;
590
+ const [Vt, kt] = x(() => ({
591
+ key: I,
592
+ snapshot: Tn
593
+ })), br = Vt.key === I ? Vt.snapshot : Tn;
594
+ A(() => {
595
+ Se.current = !1, pe.current = !1, _e({ workspaceId: e, creating: !1 }), Le({ workspaceId: e, failed: !1 }), Ct(null);
596
+ }, [e]), A(() => {
597
+ lt(!1), ut.current = [];
598
+ }, [I]), A(() => {
599
+ if (!(!f || f.loading) && !he && U === void 0) {
600
600
  if (Q.length > 0) {
601
- be.current = !1, me.current = !1, De((t) => t.workspaceId === e && t.creating ? { workspaceId: e, creating: !1 } : t), _e((t) => t.workspaceId === e && t.failed ? { workspaceId: e, failed: !1 } : t);
601
+ Se.current = !1, pe.current = !1, _e((t) => t.workspaceId === e && t.creating ? { workspaceId: e, creating: !1 } : t), Le((t) => t.workspaceId === e && t.failed ? { workspaceId: e, failed: !1 } : t);
602
602
  return;
603
603
  }
604
- me.current || be.current || (be.current = !0, De({ workspaceId: e, creating: !0 }), _e({ workspaceId: e, failed: !1 }), Promise.resolve(f.create({ title: Y })).then((t) => {
604
+ pe.current || Se.current || (Se.current = !0, _e({ workspaceId: e, creating: !0 }), Le({ workspaceId: e, failed: !1 }), Promise.resolve(f.create({ title: k })).then((t) => {
605
605
  const a = t == null ? void 0 : t.id;
606
- typeof a == "string" && Ft({ workspaceId: e, id: a });
606
+ typeof a == "string" && Ct({ workspaceId: e, id: a });
607
607
  }).catch(() => {
608
- be.current = !1, De({ workspaceId: e, creating: !1 }), _e({ workspaceId: e, failed: !0 });
608
+ Se.current = !1, _e({ workspaceId: e, creating: !1 }), Le({ workspaceId: e, failed: !0 });
609
609
  }));
610
610
  }
611
- }, [Q.length, U, Y, pe, f, e]), E(() => {
611
+ }, [Q.length, U, k, he, f, e]), A(() => {
612
612
  te.current = Z;
613
613
  }, [Z]);
614
- const kt = w((t) => {
615
- dt.current = { key: G, api: t }, ut(!0), Yt({
616
- key: G,
614
+ const Yt = E((t) => {
615
+ ct.current = { key: I, api: t }, lt(!0), kt({
616
+ key: I,
617
617
  snapshot: t.getSnapshot()
618
618
  });
619
- }, [G]), Xt = w((t) => {
620
- Yt({
621
- key: G,
619
+ const a = ut.current.splice(0);
620
+ for (const l of a) l(t);
621
+ }, [I]), Xt = E((t) => {
622
+ ut.current.push(t);
623
+ }, []), Qt = E((t) => {
624
+ kt({
625
+ key: I,
622
626
  snapshot: t
623
627
  });
624
- }, [G]), Ie = w(() => {
625
- const t = dt.current;
628
+ }, [I]), $e = E(() => {
629
+ const t = ct.current;
626
630
  return (t == null ? void 0 : t.key) === zt.current ? t.api : null;
627
- }, []), $e = w(() => te.current, []), Ue = w(() => {
628
- te.current = !0, B(!0);
629
- }, [B]), Ke = w(() => {
630
- te.current = !0, B(!0), ve(!0), Ge(!0);
631
- }, [B, ve]), He = w(() => {
632
- te.current = !1, dt.current = null, ut(!1), B(!1);
633
- }, [B]), le = F(
634
- () => (W == null ? void 0 : W.map(Mr)) ?? [],
631
+ }, []), Zt = E(() => te.current, []), en = E(() => {
632
+ te.current = !0, q(!0);
633
+ }, [q]), tn = E(() => {
634
+ te.current = !0, q(!0), be(!0), Ge(!0);
635
+ }, [q, be]), Ue = E(() => {
636
+ te.current = !1, ct.current = null, lt(!1), q(!1);
637
+ }, [q]), le = O(() => ({
638
+ surface: $e,
639
+ isWorkbenchOpen: Zt,
640
+ openWorkbench: en,
641
+ openWorkbenchSources: tn,
642
+ closeWorkbench: Ue,
643
+ enqueue: Xt
644
+ }), [$e, Zt, en, tn, Ue, Xt]), Sr = O(() => ({
645
+ openFile: async (t) => (Sn({ kind: "openFile", params: { path: t } }, le), { seq: 0, status: "ok" }),
646
+ getActiveFile: () => {
647
+ var t;
648
+ return ((t = $e()) == null ? void 0 : t.getSnapshot().activeTab) ?? null;
649
+ },
650
+ select: () => () => {
651
+ }
652
+ }), [$e, le]), ce = O(
653
+ () => (W == null ? void 0 : W.map(Gr)) ?? [],
635
654
  [W]
636
- ), ft = F(
637
- () => le.some((t) => t.registrations.leftTabs.length > 0),
638
- [le]
639
- ), Qt = F(
640
- () => le.flatMap((t) => t.registrations.panels.map((a) => a.id)),
641
- [le]
642
- ), Zt = F(() => {
655
+ ), dt = O(
656
+ () => ce.some((t) => t.registrations.leftTabs.length > 0),
657
+ [ce]
658
+ ), nn = O(
659
+ () => ce.flatMap((t) => t.registrations.panels.map((a) => a.id)),
660
+ [ce]
661
+ ), rn = O(() => {
643
662
  const t = {};
644
- for (const a of le)
663
+ for (const a of ce)
645
664
  for (const l of a.registrations.toolRenderers)
646
665
  t[l.id] = l.render;
647
666
  return t;
648
- }, [le]), en = F(
649
- () => [...Dt ?? [], ...Qt],
650
- [Dt, Qt]
651
- ), m = X && !r && ge.workspaceId !== e ? "default" : I ?? (U !== void 0 ? "default" : ((cn = $[0]) == null ? void 0 : cn.id) ?? "default"), tn = !(f != null && f.hasMore) && !C;
652
- E(() => {
653
- var ne, un;
667
+ }, [ce]), sn = O(
668
+ () => [...Dt ?? [], ...nn],
669
+ [Dt, nn]
670
+ ), m = X && !r && me.workspaceId !== e ? "default" : G ?? (U !== void 0 ? "default" : ((gn = $[0]) == null ? void 0 : gn.id) ?? "default"), on = !(f != null && f.hasMore) && !C;
671
+ A(() => {
672
+ var ne, mn;
654
673
  if (Ce) return;
655
674
  const t = ee.current, a = new Set($.map((K) => K.id)), l = t ? t.createdId ?? (a.has(m) && !t.knownIds.has(m) ? m : ((ne = $.find((K) => !t.knownIds.has(K.id))) == null ? void 0 : ne.id) ?? null) : null;
656
675
  l && a.has(l) && (ee.current = null);
657
- const g = m === "default" && U !== void 0, v = tn && a.size > 0 && !g, A = l ?? (v && !a.has(m) ? ((un = $[0]) == null ? void 0 : un.id) ?? m : m);
658
- q((K) => {
676
+ const g = m === "default" && U !== void 0, v = on && a.size > 0 && !g, R = l ?? (v && !a.has(m) ? ((mn = $[0]) == null ? void 0 : mn.id) ?? m : m);
677
+ B((K) => {
659
678
  const re = K.workspaceId === e ? K : { workspaceId: e, ids: [], activeId: null };
660
679
  if (C && re.ids.length > 0 && !l) return re;
661
- const dn = re.ids.length > 0 ? re.ids : [A], fn = v ? dn.filter((ze) => a.has(ze) || ze === l) : dn, ce = fn.length > 0 ? fn : [A], gn = re.activeId && ce.includes(re.activeId) ? re.activeId : ce[0] ?? A, Se = l ? Ve(ce, t == null ? void 0 : t.afterId, l) : A === gn || ce.includes(A) ? ce : Sn(ce, gn, A), mn = Se.includes(A) ? A : Se[0] ?? A;
662
- return K.workspaceId === e && K.activeId === mn && K.ids.length === Se.length && K.ids.every((ze, Tr) => ze === Se[Tr]) ? K : { workspaceId: e, ids: Se, activeId: mn };
680
+ const pn = re.ids.length > 0 ? re.ids : [R], hn = v ? pn.filter((qe) => a.has(qe) || qe === l) : pn, ue = hn.length > 0 ? hn : [R], vn = re.activeId && ue.includes(re.activeId) ? re.activeId : ue[0] ?? R, ye = l ? Be(ue, t == null ? void 0 : t.afterId, l) : R === vn || ue.includes(R) ? ue : Rn(ue, vn, R), bn = ye.includes(R) ? R : ye[0] ?? R;
681
+ return K.workspaceId === e && K.activeId === bn && K.ids.length === ye.length && K.ids.every((qe, Or) => qe === ye[Or]) ? K : { workspaceId: e, ids: ye, activeId: bn };
663
682
  });
664
- }, [U, m, C, Ce, $, tn, e]);
665
- const nn = F(() => {
683
+ }, [U, m, C, Ce, $, on, e]);
684
+ const an = O(() => {
666
685
  const t = /* @__PURE__ */ new Map();
667
686
  for (const a of $) t.set(a.id, a.title);
668
687
  return t;
669
- }, [$]), gt = D.workspaceId === e ? D : { ids: [], activeId: null }, Je = gt.ids.length > 0 ? gt.ids : [m], je = gt.activeId ?? Je[0] ?? m, pr = w((t) => {
688
+ }, [$]), ft = D.workspaceId === e ? D : { ids: [], activeId: null }, Ke = ft.ids.length > 0 ? ft.ids : [m], He = ft.activeId ?? Ke[0] ?? m, yr = E((t) => {
670
689
  const l = (D.workspaceId === e ? D : { ids: [m] }).ids.includes(t);
671
- return q((g) => {
672
- const v = g.workspaceId === e ? g : { ids: [m], activeId: m }, A = v.ids.includes(t) ? v.ids : Sn(v.ids, v.activeId, t);
673
- return { workspaceId: e, ids: A, activeId: t };
674
- }), l ? H(t) : We(t);
675
- }, [D, m, H, We, e]), hr = w((t) => (q((a) => {
690
+ return B((g) => {
691
+ const v = g.workspaceId === e ? g : { ids: [m], activeId: m }, R = v.ids.includes(t) ? v.ids : Rn(v.ids, v.activeId, t);
692
+ return { workspaceId: e, ids: R, activeId: t };
693
+ }), l ? J(t) : Ie(t);
694
+ }, [D, m, J, Ie, e]), Pr = E((t) => (B((a) => {
676
695
  const l = a.workspaceId === e ? a : { ids: [m], activeId: m };
677
696
  return {
678
697
  workspaceId: e,
679
- ids: l.ids.includes(t) ? l.ids : Ve(l.ids, l.activeId, t),
698
+ ids: l.ids.includes(t) ? l.ids : Be(l.ids, l.activeId, t),
680
699
  activeId: t
681
700
  };
682
- }), H(t)), [m, H, e]), rn = w((t) => ((D.workspaceId === e ? D : { ids: [m] }).ids.includes(t) && Wt({ workspaceId: e, id: t }), q((l) => {
701
+ }), J(t)), [m, J, e]), ln = E((t) => ((D.workspaceId === e ? D : { ids: [m] }).ids.includes(t) && Wt({ workspaceId: e, id: t }), B((l) => {
683
702
  const g = l.workspaceId === e ? l : { ids: [m], activeId: m };
684
703
  return {
685
704
  workspaceId: e,
686
- ids: Ve(g.ids, g.activeId, t),
705
+ ids: Be(g.ids, g.activeId, t),
687
706
  activeId: t
688
707
  };
689
- }), H(t)), [D, m, H, e]), vr = w((t) => {
708
+ }), J(t)), [D, m, J, e]), Er = E((t) => {
690
709
  const a = D.workspaceId === e ? D : { ids: [m], activeId: m };
691
710
  if (a.ids.length <= 1) return;
692
711
  const l = a.ids.indexOf(t);
693
712
  if (l < 0) return;
694
- const g = a.ids.filter((A) => A !== t), v = a.activeId === t ? g[Math.max(0, l - 1)] ?? g[0] ?? null : a.activeId;
695
- q({ workspaceId: e, ids: g, activeId: v }), v && a.activeId === t && H(v);
696
- }, [D, m, H, e]), br = w((t) => {
713
+ const g = a.ids.filter((R) => R !== t), v = a.activeId === t ? g[Math.max(0, l - 1)] ?? g[0] ?? null : a.activeId;
714
+ B({ workspaceId: e, ids: g, activeId: v }), v && a.activeId === t && J(v);
715
+ }, [D, m, J, e]), Ar = E((t) => {
697
716
  const a = {
698
717
  afterId: t,
699
718
  knownIds: new Set($.map((g) => g.id))
700
719
  };
701
720
  ee.current = a;
702
- const l = ct();
721
+ const l = at();
703
722
  return Promise.resolve(l).then((g) => {
704
- const v = oi(g);
705
- v && (ee.current === a && (ee.current = { ...a, createdId: v }), q((A) => {
706
- const ne = A.workspaceId === e ? A : { ids: [m] };
723
+ const v = ui(g);
724
+ v && (ee.current === a && (ee.current = { ...a, createdId: v }), B((R) => {
725
+ const ne = R.workspaceId === e ? R : { ids: [m] };
707
726
  return {
708
727
  workspaceId: e,
709
- ids: Ve(ne.ids, t, v),
728
+ ids: Be(ne.ids, t, v),
710
729
  activeId: v
711
730
  };
712
731
  }));
713
732
  }).catch(() => {
714
733
  ee.current === a && (ee.current = null);
715
734
  }), l;
716
- }, [m, ct, $, e]), Sr = w((t) => {
735
+ }, [m, at, $, e]), Rr = E((t) => {
717
736
  const a = D.workspaceId === e ? D : { ids: [m], activeId: m }, l = a.ids.indexOf(t);
718
737
  let g = a.activeId;
719
738
  if (l >= 0) {
720
- const v = a.ids.filter((A) => A !== t);
721
- g = a.activeId === t ? v[Math.max(0, l - 1)] ?? v[0] ?? null : a.activeId, q({ workspaceId: e, ids: v, activeId: g }), g && a.activeId === t && We(g);
739
+ const v = a.ids.filter((R) => R !== t);
740
+ g = a.activeId === t ? v[Math.max(0, l - 1)] ?? v[0] ?? null : a.activeId, B({ workspaceId: e, ids: v, activeId: g }), g && a.activeId === t && Ie(g);
722
741
  }
723
742
  return jt(t);
724
- }, [D, m, jt, We, e]), [yr, mt] = O(oe), sn = J(e);
725
- E(() => {
726
- if (sn.current !== e) {
727
- sn.current = e, mt(oe);
743
+ }, [D, m, jt, Ie, e]), [wr, gt] = x(oe), cn = H(e);
744
+ A(() => {
745
+ if (cn.current !== e) {
746
+ cn.current = e, gt(oe);
728
747
  return;
729
748
  }
730
- oe && mt(!0);
749
+ oe && gt(!0);
731
750
  }, [oe, e]);
732
- const on = oe && X && !I, an = !!!(at && at.workspaceId === e && at.id === I) && !yr && tt !== !1 && (X ? !!I : !0), Pr = w((t) => {
733
- Yn({ workspaceId: e, status: t }), Ae == null || Ae(t);
734
- }, [Ae, e]);
735
- E(() => {
751
+ const un = oe && X && !G, dn = !!!(st && st.workspaceId === e && st.id === G) && !wr && Ze !== !1 && (X ? !!G : !0), Tr = E((t) => {
752
+ Zn({ workspaceId: e, status: t }), Re == null || Re(t);
753
+ }, [Re, e]);
754
+ A(() => {
736
755
  var a;
737
756
  const t = (l) => {
738
757
  const g = l.detail;
739
- !g || typeof g != "object" || Wr(g, {
740
- surface: Ie,
741
- isWorkbenchOpen: $e,
742
- openWorkbench: Ue,
743
- openWorkbenchSources: Ke
744
- });
758
+ !g || typeof g != "object" || Sn(g, le);
745
759
  };
746
- return (a = globalThis.addEventListener) == null || a.call(globalThis, pn, t), () => {
760
+ return (a = globalThis.addEventListener) == null || a.call(globalThis, yn, t), () => {
747
761
  var l;
748
- return (l = globalThis.removeEventListener) == null ? void 0 : l.call(globalThis, pn, t);
762
+ return (l = globalThis.removeEventListener) == null ? void 0 : l.call(globalThis, yn, t);
749
763
  };
750
- }, [Ie, $e, Ue, Ke]), E(() => {
751
- C || Pe == null || Pe(I ?? null);
752
- }, [I, Pe, C]);
753
- const pt = Le.status !== "ready", Er = pt ? /* @__PURE__ */ d(ci, { status: Le }) : void 0, Be = w(async (t) => {
764
+ }, [le]), A(() => {
765
+ C || Ee == null || Ee(G ?? null);
766
+ }, [G, Ee, C]);
767
+ const mt = Oe.status !== "ready", Nr = mt ? /* @__PURE__ */ d(gi, { status: Oe }) : void 0, Je = E(async (t) => {
754
768
  const a = `${(h == null ? void 0 : h.replace(/\/$/, "")) ?? ""}/api/v1/agent/reload`;
755
769
  try {
756
770
  const l = await fetch(a, {
757
771
  method: "POST",
758
- headers: { ...k, "content-type": "application/json" },
772
+ headers: { ...Y, "content-type": "application/json" },
759
773
  body: JSON.stringify({ sessionId: t })
760
774
  });
761
775
  if (!l.ok)
762
776
  return (await l.json().catch(() => ({}))).error || `reload failed (${l.status})`;
763
777
  const g = await l.json().catch(() => ({}));
764
- return window.dispatchEvent(new CustomEvent(Cr, { detail: g })), fi(g);
778
+ return window.dispatchEvent(new CustomEvent($r, { detail: g })), hi(g);
765
779
  } catch (l) {
766
780
  return l instanceof Error ? l.message : "Agent plugin reload failed.";
767
781
  }
768
- }, [h, k]), qe = w(
782
+ }, [h, Y]), je = E(
769
783
  (t, a = {}) => {
770
784
  const l = a.bridgeEnabled ?? !0, g = L != null && L.toolRenderers && typeof L.toolRenderers == "object" ? L.toolRenderers : void 0;
771
785
  return {
772
786
  ...L,
773
- ...on ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
787
+ ...un ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
774
788
  sessionId: t,
775
789
  apiBaseUrl: h,
776
790
  workspaceId: e,
777
791
  storageScope: e,
778
- requestHeaders: k,
792
+ requestHeaders: Y,
779
793
  showSessions: !1,
780
- onReloadAgentPlugins: (L == null ? void 0 : L.onReloadAgentPlugins) ?? (() => Be(t)),
781
- toolRenderers: { ...Zt, ...g ?? {} },
782
- bridgeEndpoint: l ? Qe : null,
783
- getSurface: Ie,
784
- isWorkbenchOpen: $e,
785
- openWorkbench: Ue,
786
- openWorkbenchSources: Ke,
787
- closeWorkbench: He,
794
+ onReloadAgentPlugins: (L == null ? void 0 : L.onReloadAgentPlugins) ?? (() => Je(t)),
795
+ toolRenderers: { ...rn, ...g ?? {} },
796
+ bridgeEndpoint: l ? Ye : null,
797
+ surfaceDispatch: le,
788
798
  extraCommands: _t,
789
- workspaceWarmupStatus: Le,
790
- hydrateMessages: an,
799
+ workspaceWarmupStatus: Oe,
800
+ hydrateMessages: dn,
791
801
  onAutoSubmitInitialDraftSettled: () => {
792
- ae.current = !1, mt(!1), he(void 0);
802
+ ae.current = !1, gt(!1), ve(void 0);
793
803
  const v = L == null ? void 0 : L.onAutoSubmitInitialDraftSettled;
794
804
  typeof v == "function" && v();
795
805
  },
796
806
  // Forward the explicit prop when set. Omitting the key (when undefined)
797
807
  // lets ChatPanel apply its own default (true) and avoids overriding a
798
808
  // value passed through chatParams.
799
- ...it !== void 0 ? { hotReloadEnabled: it } : {}
809
+ ...nt !== void 0 ? { hotReloadEnabled: nt } : {}
800
810
  };
801
811
  },
802
- [h, L, on, k, Qe, Ie, $e, Ue, Ke, He, _t, Le, an, it, Zt, Be, e]
803
- ), Ar = F(
804
- () => qe(m),
805
- [m, qe]
806
- ), wr = F(() => Je.map((t) => ({
812
+ [h, L, un, Y, Ye, le, _t, Oe, dn, nt, rn, Je, e]
813
+ ), Dr = O(
814
+ () => je(m),
815
+ [m, je]
816
+ ), _r = O(() => Ke.map((t) => ({
807
817
  id: t,
808
- title: nn.get(t) ?? (t === "default" ? Y : t),
818
+ title: an.get(t) ?? (t === "default" ? k : t),
809
819
  panel: "chat",
810
- params: qe(t, { bridgeEnabled: t === je })
811
- })), [je, Je, Y, qe, nn]), Rr = F(() => ({
812
- storageKey: G,
813
- defaultLeftTab: Ee,
820
+ params: je(t, { bridgeEnabled: t === He })
821
+ })), [He, Ke, k, je, an]), Lr = O(() => ({
822
+ storageKey: I,
823
+ defaultLeftTab: Ae,
814
824
  initialPanels: Nt,
815
- extraPanels: en,
816
- onReloadAgentPlugins: () => Be(I ?? m),
817
- onReady: kt,
818
- onChange: Xt,
819
- onClose: He
825
+ extraPanels: sn,
826
+ onReloadAgentPlugins: () => Je(G ?? m),
827
+ onReady: Yt,
828
+ onChange: Qt,
829
+ onClose: Ue
820
830
  }), [
821
- He,
822
- Ee,
831
+ Ue,
832
+ Ae,
823
833
  Nt,
824
- Be,
825
- I,
826
- m,
827
- Xt,
828
- kt,
834
+ Je,
829
835
  G,
830
- en,
831
- B
836
+ m,
837
+ Qt,
838
+ Yt,
839
+ I,
840
+ sn,
841
+ q
832
842
  ]);
833
- return /* @__PURE__ */ d("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ ye(
834
- Fr,
843
+ return /* @__PURE__ */ d("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ Pe(
844
+ Ur,
835
845
  {
836
- chatPanel: Qn,
846
+ chatPanel: nr,
837
847
  panels: y,
838
848
  commands: S,
839
849
  catalogs: j,
840
850
  plugins: W,
841
851
  excludeDefaults: V,
842
- capabilities: R,
852
+ capabilities: w,
843
853
  apiBaseUrl: h,
844
- authHeaders: Vn,
854
+ authHeaders: Qn,
845
855
  apiTimeout: p,
846
856
  defaultTheme: N,
847
- onThemeChange: Ln,
857
+ onThemeChange: Cn,
848
858
  workspaceId: e,
849
- workspaceLabel: Fn,
850
- storageKey: st,
851
- persistenceEnabled: Pt,
852
- debug: On,
859
+ workspaceLabel: $n,
860
+ appTitle: wt,
861
+ storageKey: rt,
862
+ persistenceEnabled: yt,
863
+ debug: Wn,
853
864
  bridgeEndpoint: null,
854
- onAuthError: Mn,
855
- frontPluginHotReload: zn,
856
- fullPageBasePath: xn,
865
+ onAuthError: Gn,
866
+ frontPluginHotReload: Xn,
867
+ fullPageBasePath: In,
857
868
  children: [
858
869
  u,
859
870
  /* @__PURE__ */ d(
860
- si,
871
+ ci,
861
872
  {
862
873
  workspaceId: e,
863
- requestHeaders: k,
874
+ requestHeaders: Y,
864
875
  apiBaseUrl: h,
865
- preloadPaths: jn,
866
- provisionWorkspace: tt,
867
- onStatusChange: Pr
876
+ preloadPaths: Vn,
877
+ provisionWorkspace: Ze,
878
+ onStatusChange: Tr
868
879
  }
869
880
  ),
870
881
  /* @__PURE__ */ d(
871
- yi,
882
+ Ri,
872
883
  {
873
- bridgeEndpoint: Qe,
874
- requestHeaders: k,
875
- navOpen: qt,
884
+ bridgeEndpoint: Ye,
885
+ requestHeaders: Y,
886
+ navOpen: Bt,
876
887
  surfaceOpen: Z,
877
- surfaceReady: ur,
878
- snapshot: mr
888
+ surfaceReady: mr,
889
+ snapshot: br
879
890
  }
880
891
  ),
881
- /* @__PURE__ */ ye("div", { className: "flex h-full min-h-0 flex-col", children: [
892
+ /* @__PURE__ */ Pe("div", { className: "flex h-full min-h-0 flex-col", children: [
882
893
  /* @__PURE__ */ d(
883
- Ur,
894
+ jr,
884
895
  {
885
- appTitle: Cn,
886
- sessionTitle: Ce ? "Loading sessions…" : lr ?? Y,
896
+ appTitle: wt,
897
+ sessionTitle: Ce ? "Loading sessions…" : fr ?? k,
887
898
  onCommandPalette: () => {
888
899
  document.dispatchEvent(new KeyboardEvent("keydown", {
889
900
  key: "k",
@@ -893,65 +904,66 @@ function Ji({
893
904
  cancelable: !0
894
905
  }));
895
906
  },
896
- topBarLeft: In,
897
- topBarRight: /* @__PURE__ */ ye(ue, { children: [
898
- Un ? /* @__PURE__ */ d(zr, {}) : null,
899
- $n
907
+ topBarLeft: Hn,
908
+ topBarRight: /* @__PURE__ */ Pe(de, { children: [
909
+ jn ? /* @__PURE__ */ d(Xr, {}) : null,
910
+ Jn
900
911
  ] })
901
912
  }
902
913
  ),
903
- Ce ? /* @__PURE__ */ d(hi, {}) : /* @__PURE__ */ d(
904
- Kr,
914
+ Ce ? /* @__PURE__ */ d(yi, {}) : /* @__PURE__ */ d(
915
+ qr,
905
916
  {
906
- className: qn,
907
- nav: qt ? "session-list" : null,
917
+ className: Yn,
918
+ nav: Bt ? "session-list" : null,
908
919
  navParams: {
909
920
  sessions: $,
910
- activeId: je,
911
- openIds: Je,
912
- pinnedIds: kn,
913
- onTogglePin: Xn,
914
- onSwitch: pr,
915
- onOpenAsTab: rn,
916
- onCreate: ct,
917
- onDelete: Sr,
921
+ activeId: He,
922
+ openIds: Ke,
923
+ pinnedIds: er,
924
+ onTogglePin: tr,
925
+ onSwitch: yr,
926
+ onOpenAsTab: ln,
927
+ onCreate: at,
928
+ onDelete: Rr,
918
929
  onLoadMore: f == null ? void 0 : f.loadMore,
919
930
  hasMore: f == null ? void 0 : f.hasMore,
920
931
  loadingMore: f == null ? void 0 : f.loadingMore,
921
- onClose: () => Bt(!1)
932
+ onClose: () => qt(!1)
922
933
  },
923
934
  center: "chat",
924
- centerParams: Ar,
925
- chatPanes: wr,
926
- activeChatPaneId: je,
927
- onActiveChatPaneChange: hr,
928
- onCloseChatPane: vr,
929
- onCreateChatPaneAfter: br,
930
- onDropChatSession: rn,
935
+ centerParams: Dr,
936
+ chatPanes: _r,
937
+ activeChatPaneId: He,
938
+ onActiveChatPaneChange: Pr,
939
+ onCloseChatPane: Er,
940
+ onCreateChatPaneAfter: Ar,
941
+ onDropChatSession: ln,
931
942
  flashChatPaneId: (ie == null ? void 0 : ie.workspaceId) === e ? ie.id : null,
932
943
  surface: Z ? "artifact-surface" : null,
933
- surfaceParams: Rr,
934
- surfaceOverlay: Er,
935
- sidebar: Z && !pt && ft && gr ? "workbench-left" : null,
936
- sidebarParams: Z && !pt && ft ? {
937
- ...Ee ? { defaultTab: Ee } : {},
944
+ surfaceParams: Lr,
945
+ surfaceOverlay: Nr,
946
+ sidebar: Z && !mt && dt && vr ? "workbench-left" : null,
947
+ sidebarParams: Z && !mt && dt ? {
948
+ ...Ae ? { defaultTab: Ae } : {},
949
+ bridge: Sr,
938
950
  onClose: () => {
939
- ve(!1), Ge(!1);
951
+ be(!1), Ge(!1);
940
952
  },
941
953
  onCollapse: () => {
942
- ve(!1), Ge(!1);
954
+ be(!1), Ge(!1);
943
955
  }
944
956
  } : void 0,
945
- storageKey: M ? we : void 0,
957
+ storageKey: F ? we : void 0,
946
958
  onOpenNav: Tt ? () => {
947
- Bt(!0), nt == null || nt();
959
+ qt(!0), et == null || et();
948
960
  } : void 0,
949
961
  onOpenSurface: () => {
950
- te.current = !0, B(!0), rt == null || rt();
962
+ te.current = !0, q(!0), tt == null || tt();
951
963
  },
952
- surfaceButtonBottomOffset: Bn,
953
- onOpenSidebar: ft ? () => {
954
- te.current = !0, B(!0), ve(!0), Ge(!0);
964
+ surfaceButtonBottomOffset: kn,
965
+ onOpenSidebar: dt ? () => {
966
+ te.current = !0, q(!0), be(!0), Ge(!0);
955
967
  } : void 0
956
968
  }
957
969
  )
@@ -961,8 +973,8 @@ function Ji({
961
973
  }
962
974
  ) });
963
975
  }
964
- const Pi = 500;
965
- function Ei(e) {
976
+ const wi = 500;
977
+ function Ti(e) {
966
978
  return new Promise((n, r) => {
967
979
  let i;
968
980
  const s = () => {
@@ -976,68 +988,68 @@ function Ei(e) {
976
988
  }
977
989
  i = globalThis.setTimeout(() => {
978
990
  s(), n();
979
- }, Pi), e.addEventListener("abort", o, { once: !0 });
991
+ }, wi), e.addEventListener("abort", o, { once: !0 });
980
992
  });
981
993
  }
982
- function ji({
994
+ function Vi({
983
995
  workspaceId: e,
984
996
  requestHeaders: n,
985
997
  apiBaseUrl: r,
986
- preloadPaths: i = wn,
998
+ preloadPaths: i = _n,
987
999
  provisionWorkspace: s = !0,
988
1000
  loadingFallback: o,
989
1001
  errorFallback: c,
990
1002
  children: u
991
1003
  }) {
992
- const [b, y] = O({
1004
+ const [b, y] = x({
993
1005
  status: "loading",
994
1006
  label: "Waking workspace runtime"
995
1007
  });
996
- return E(() => {
997
- const S = new AbortController(), j = ke(e, n);
998
- async function W(R) {
999
- const h = await fetch(Tn(r, R), {
1008
+ return A(() => {
1009
+ const S = new AbortController(), j = Ve(e, n);
1010
+ async function W(w) {
1011
+ const h = await fetch(On(r, w), {
1000
1012
  headers: j,
1001
1013
  signal: S.signal
1002
- }), T = await Xe(h);
1014
+ }), T = await ke(h);
1003
1015
  if (!h.ok) {
1004
- if (St(T)) return "preparing";
1005
- throw new Error(yt(T) ?? `${R} failed with ${h.status}`);
1016
+ if (bt(T)) return "preparing";
1017
+ throw new Error(St(T) ?? `${w} failed with ${h.status}`);
1006
1018
  }
1007
- if (Nn(R)) {
1008
- const N = Ye(T);
1019
+ if (xn(w)) {
1020
+ const N = ze(T);
1009
1021
  if ((N == null ? void 0 : N.state) === "degraded") throw new Error(N.message ?? "Workspace failed to prepare");
1010
1022
  }
1011
- return Gr(R) !== null && T && typeof T == "object" && Dn(r, j["x-boring-workspace-id"] ?? e, R, T), "ready";
1023
+ return Kr(w) !== null && T && typeof T == "object" && Mn(r, j["x-boring-workspace-id"] ?? e, w, T), "ready";
1012
1024
  }
1013
1025
  async function V() {
1014
1026
  y({ status: "loading", label: "Waking workspace runtime" });
1015
1027
  try {
1016
- const R = Rn(i, s);
1017
- let h = await Promise.all(R.map(async (p) => ({ path: p, status: await W(p) }))), T = h.filter((p) => p.status === "preparing").map((p) => p.path);
1028
+ const w = Ln(i, s);
1029
+ let h = await Promise.all(w.map(async (p) => ({ path: p, status: await W(p) }))), T = h.filter((p) => p.status === "preparing").map((p) => p.path);
1018
1030
  for (; T.length > 0; ) {
1019
- if (y({ status: "loading", label: "Workspace is still preparing" }), await Ei(S.signal), S.signal.aborted) return;
1031
+ if (y({ status: "loading", label: "Workspace is still preparing" }), await Ti(S.signal), S.signal.aborted) return;
1020
1032
  h = await Promise.all(T.map(async (p) => ({ path: p, status: await W(p) }))), T = h.filter((p) => p.status === "preparing").map((p) => p.path);
1021
1033
  }
1022
1034
  S.signal.aborted || y({ status: "ready" });
1023
- } catch (R) {
1035
+ } catch (w) {
1024
1036
  if (S.signal.aborted) return;
1025
1037
  y({
1026
1038
  status: "error",
1027
- message: R instanceof Error ? R.message : "Unknown workspace boot error"
1039
+ message: w instanceof Error ? w.message : "Unknown workspace boot error"
1028
1040
  });
1029
1041
  }
1030
1042
  }
1031
1043
  return V(), () => S.abort();
1032
- }, [r, i, s, n, e]), b.status === "ready" ? /* @__PURE__ */ d(ue, { children: u }) : b.status === "error" ? typeof c == "function" ? /* @__PURE__ */ d(ue, { children: c(b.message) }) : c ? /* @__PURE__ */ d(ue, { children: c }) : /* @__PURE__ */ d(
1033
- vn,
1044
+ }, [r, i, s, n, e]), b.status === "ready" ? /* @__PURE__ */ d(de, { children: u }) : b.status === "error" ? typeof c == "function" ? /* @__PURE__ */ d(de, { children: c(b.message) }) : c ? /* @__PURE__ */ d(de, { children: c }) : /* @__PURE__ */ d(
1045
+ En,
1034
1046
  {
1035
1047
  title: "Workspace failed to open",
1036
1048
  description: b.message,
1037
1049
  status: "Retry by reloading the page"
1038
1050
  }
1039
- ) : typeof o == "function" ? /* @__PURE__ */ d(ue, { children: o(b.label) }) : o ? /* @__PURE__ */ d(ue, { children: o }) : /* @__PURE__ */ d(
1040
- vn,
1051
+ ) : typeof o == "function" ? /* @__PURE__ */ d(de, { children: o(b.label) }) : o ? /* @__PURE__ */ d(de, { children: o }) : /* @__PURE__ */ d(
1052
+ En,
1041
1053
  {
1042
1054
  title: "Opening workspace",
1043
1055
  description: "Preparing secure runtime, files, sessions, and layout.",
@@ -1045,11 +1057,11 @@ function ji({
1045
1057
  }
1046
1058
  );
1047
1059
  }
1048
- const Ai = "FULL_PAGE_PANEL_MISSING_COMPONENT", wi = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", Ri = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", Ti = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", Ni = "FULL_PAGE_PANEL_NOT_SUPPORTED", Di = "FULL_PAGE_PANEL_RENDER_FAILED";
1049
- function x() {
1060
+ const Ni = "FULL_PAGE_PANEL_MISSING_COMPONENT", Di = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", _i = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", Li = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", Oi = "FULL_PAGE_PANEL_NOT_SUPPORTED", xi = "FULL_PAGE_PANEL_RENDER_FAILED";
1061
+ function M() {
1050
1062
  }
1051
- const _i = { dispose: x }, P = () => _i;
1052
- function Li(e) {
1063
+ const Mi = { dispose: M }, P = () => Mi;
1064
+ function Fi(e) {
1053
1065
  return {
1054
1066
  id: `full-page:${e}`,
1055
1067
  title: e,
@@ -1059,19 +1071,19 @@ function Li(e) {
1059
1071
  width: 0,
1060
1072
  height: 0,
1061
1073
  location: { type: "grid", referenceGroup: void 0 },
1062
- setActive: x,
1074
+ setActive: M,
1063
1075
  setTitle: (n) => {
1064
1076
  document.title = n;
1065
1077
  },
1066
- setSize: x,
1078
+ setSize: M,
1067
1079
  close: () => {
1068
1080
  window.close();
1069
1081
  },
1070
- moveTo: x,
1071
- maximize: x,
1072
- exitMaximized: x,
1082
+ moveTo: M,
1083
+ maximize: M,
1084
+ exitMaximized: M,
1073
1085
  isMaximized: () => !1,
1074
- minimize: x,
1086
+ minimize: M,
1075
1087
  onDidActiveChange: P,
1076
1088
  onDidVisibilityChange: P,
1077
1089
  onDidDimensionsChange: P,
@@ -1083,7 +1095,7 @@ function Li(e) {
1083
1095
  onWillFocus: P
1084
1096
  };
1085
1097
  }
1086
- function Oi() {
1098
+ function Ci() {
1087
1099
  return {
1088
1100
  width: window.innerWidth,
1089
1101
  height: window.innerHeight,
@@ -1095,20 +1107,20 @@ function Oi() {
1095
1107
  panels: [],
1096
1108
  groups: [],
1097
1109
  activeGroup: void 0,
1098
- addPanel: x,
1099
- addGroup: x,
1100
- removePanel: x,
1101
- removeGroup: x,
1110
+ addPanel: M,
1111
+ addGroup: M,
1112
+ removePanel: M,
1113
+ removeGroup: M,
1102
1114
  getPanel: () => {
1103
1115
  },
1104
1116
  getGroup: () => {
1105
1117
  },
1106
- moveGroupOrPanel: x,
1107
- fromJSON: x,
1118
+ moveGroupOrPanel: M,
1119
+ fromJSON: M,
1108
1120
  toJSON: () => ({}),
1109
- clear: x,
1110
- focus: x,
1111
- layout: x,
1121
+ clear: M,
1122
+ focus: M,
1123
+ layout: M,
1112
1124
  onDidLayoutChange: P,
1113
1125
  onDidLayoutFromJSON: P,
1114
1126
  onDidAddPanel: P,
@@ -1125,28 +1137,28 @@ function Oi() {
1125
1137
  onDidActivePanelChange_: P
1126
1138
  };
1127
1139
  }
1128
- function bt({ code: e, title: n, description: r }) {
1140
+ function vt({ code: e, title: n, description: r }) {
1129
1141
  return /* @__PURE__ */ d(
1130
1142
  "div",
1131
1143
  {
1132
1144
  className: "flex min-h-screen items-center justify-center bg-background p-6 text-foreground",
1133
1145
  "data-testid": "full-page-error-state",
1134
1146
  "data-full-page-error-code": e,
1135
- children: /* @__PURE__ */ d(qr, { className: "w-full max-w-lg", title: n, description: r })
1147
+ children: /* @__PURE__ */ d(Yr, { className: "w-full max-w-lg", title: n, description: r })
1136
1148
  }
1137
1149
  );
1138
1150
  }
1139
- function Bi({ componentId: e, params: n = {} }) {
1140
- const r = _n(), { errors: i } = Ir(), s = r.get(e), o = r.getComponents()[e];
1141
- Dr(() => {
1151
+ function ki({ componentId: e, params: n = {} }) {
1152
+ const r = Fn(), { errors: i } = Hr(), s = r.get(e), o = r.getComponents()[e];
1153
+ Mr(() => {
1142
1154
  document.title = (s == null ? void 0 : s.title) ?? e;
1143
1155
  }, [e, s == null ? void 0 : s.title]);
1144
- const c = F(() => ({
1156
+ const c = O(() => ({
1145
1157
  params: n,
1146
- api: Li(e),
1147
- containerApi: Oi(),
1158
+ api: Fi(e),
1159
+ containerApi: Ci(),
1148
1160
  className: "h-full"
1149
- }), [e, n]), u = F(() => {
1161
+ }), [e, n]), u = O(() => {
1150
1162
  if (!s) return null;
1151
1163
  const b = s.pluginId ?? s.id;
1152
1164
  for (let y = i.length - 1; y >= 0; y -= 1) {
@@ -1157,29 +1169,29 @@ function Bi({ componentId: e, params: n = {} }) {
1157
1169
  return null;
1158
1170
  }, [e, i, s]);
1159
1171
  return s ? !s.supportsFullPage || !o ? /* @__PURE__ */ d(
1160
- bt,
1172
+ vt,
1161
1173
  {
1162
- code: Ni,
1174
+ code: Oi,
1163
1175
  title: "Panel does not support full-page mode",
1164
1176
  description: `Panel "${e}" can render in the workspace, but it has not opted into the dedicated full-page pane route.`
1165
1177
  }
1166
1178
  ) : u ? /* @__PURE__ */ d(
1167
- bt,
1179
+ vt,
1168
1180
  {
1169
- code: Di,
1181
+ code: xi,
1170
1182
  title: "Panel failed to render",
1171
1183
  description: `Panel "${e}" crashed while rendering in full-page mode: ${u.error.message}`
1172
1184
  }
1173
- ) : /* @__PURE__ */ d("div", { className: "min-h-screen bg-background text-foreground", children: /* @__PURE__ */ d($r, { mode: "full-page", children: /* @__PURE__ */ d(o, { ...c }) }) }) : /* @__PURE__ */ d(
1174
- bt,
1185
+ ) : /* @__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(
1186
+ vt,
1175
1187
  {
1176
- code: Ti,
1188
+ code: Li,
1177
1189
  title: "Unknown panel",
1178
1190
  description: `No full-page panel component is registered as "${e}".`
1179
1191
  }
1180
1192
  );
1181
1193
  }
1182
- function qi(e) {
1194
+ function Yi(e) {
1183
1195
  var o;
1184
1196
  const n = new URLSearchParams(e), r = ((o = n.get("component")) == null ? void 0 : o.trim()) ?? "";
1185
1197
  if (!r)
@@ -1187,7 +1199,7 @@ function qi(e) {
1187
1199
  componentId: null,
1188
1200
  params: {},
1189
1201
  error: {
1190
- code: Ai,
1202
+ code: Ni,
1191
1203
  message: "Missing full-page panel component id."
1192
1204
  }
1193
1205
  };
@@ -1202,7 +1214,7 @@ function qi(e) {
1202
1214
  componentId: null,
1203
1215
  params: {},
1204
1216
  error: {
1205
- code: wi,
1217
+ code: Di,
1206
1218
  message: "Invalid full-page panel params JSON."
1207
1219
  }
1208
1220
  };
@@ -1211,23 +1223,23 @@ function qi(e) {
1211
1223
  componentId: null,
1212
1224
  params: {},
1213
1225
  error: {
1214
- code: Ri,
1226
+ code: _i,
1215
1227
  message: "Full-page panel params must be a JSON object."
1216
1228
  }
1217
1229
  } : { componentId: r, params: s };
1218
1230
  }
1219
1231
  export {
1220
- wi as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
1221
- Ai as FULL_PAGE_PANEL_MISSING_COMPONENT,
1222
- Ni as FULL_PAGE_PANEL_NOT_SUPPORTED,
1223
- Ri as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
1224
- Di as FULL_PAGE_PANEL_RENDER_FAILED,
1225
- Ti as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
1226
- Ji as WorkspaceAgentFront,
1227
- si as WorkspaceBackgroundBoot,
1228
- ji as WorkspaceBootGate,
1229
- Bi as WorkspaceFullPagePanel,
1230
- Xr as createLocalStorageSessions,
1231
- qi as parseFullPagePanelLocation,
1232
- Qr as useLocalStorageSessions
1232
+ Di as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
1233
+ Ni as FULL_PAGE_PANEL_MISSING_COMPONENT,
1234
+ Oi as FULL_PAGE_PANEL_NOT_SUPPORTED,
1235
+ _i as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
1236
+ xi as FULL_PAGE_PANEL_RENDER_FAILED,
1237
+ Li as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
1238
+ zi as WorkspaceAgentFront,
1239
+ ci as WorkspaceBackgroundBoot,
1240
+ Vi as WorkspaceBootGate,
1241
+ ki as WorkspaceFullPagePanel,
1242
+ ti as createLocalStorageSessions,
1243
+ Yi as parseFullPagePanelLocation,
1244
+ ni as useLocalStorageSessions
1233
1245
  };