@hachej/boring-workspace 0.1.23 → 0.1.26

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,350 +1,604 @@
1
- import { jsx as d, jsxs as xe, Fragment as $ } from "react/jsx-runtime";
2
- import { useSyncExternalStore as qe, useMemo as P, useCallback as v, useRef as K, useState as re, useEffect as y } from "react";
3
- import { ChatPanel as et, useSessions as tt } from "@hachej/boring-agent/front";
4
- import { ak as st, U as We, o as rt, al as nt, u as ot, am as at } from "./WorkspaceProvider-Cn0sPgaB.js";
5
- import { T as ct, C as it, r as Le, w as lt, W as Re } from "./WorkspaceLoadingState-hKrnYCL3.js";
6
- function ut() {
1
+ import { jsx as c, jsxs as Te, Fragment as B } from "react/jsx-runtime";
2
+ import { useSyncExternalStore as Xt, useEffect as E, useMemo as S, useState as G, useRef as O, useCallback as _, useLayoutEffect as Zt } from "react";
3
+ import { ChatPanel as er, useSessions as tr } from "@hachej/boring-agent/front";
4
+ import { as as rr, at as nr, U as lt, p as or, au as sr, u as pt, ag as ir, av as ar } from "./WorkspaceProvider-DQ-325Qs.js";
5
+ import { T as lr, C as cr, r as ct, w as ur, W as ut } from "./WorkspaceLoadingState-DVCLcOQu.js";
6
+ import { ErrorState as dr } from "@hachej/boring-ui-kit";
7
+ function fr() {
7
8
  const e = `s${Date.now()}`;
8
9
  return {
9
10
  sessions: [{ id: e, title: "New session", updatedAt: Date.now() }],
10
11
  activeId: e
11
12
  };
12
13
  }
13
- function ft(e, t) {
14
- var n;
14
+ function pr(e, t) {
15
+ var r;
15
16
  if (typeof localStorage > "u") return t();
16
17
  try {
17
- const s = localStorage.getItem(e);
18
- if (s) {
19
- const r = JSON.parse(s), c = Array.isArray(r.sessions) ? r.sessions : Array.isArray(r.items) ? r.items : null;
20
- if (c)
21
- return { sessions: c, activeId: r.activeId ?? ((n = c[0]) == null ? void 0 : n.id) ?? "" };
18
+ const o = localStorage.getItem(e);
19
+ if (o) {
20
+ const n = JSON.parse(o), s = Array.isArray(n.sessions) ? n.sessions : Array.isArray(n.items) ? n.items : null;
21
+ if (s)
22
+ return { sessions: s, activeId: n.activeId ?? ((r = s[0]) == null ? void 0 : r.id) ?? "" };
22
23
  }
23
24
  } catch {
24
25
  }
25
26
  return t();
26
27
  }
27
- function dt(e, t) {
28
+ function mr(e, t) {
28
29
  if (!(typeof localStorage > "u"))
29
30
  try {
30
31
  localStorage.setItem(e, JSON.stringify(t));
31
32
  } catch {
32
33
  }
33
34
  }
34
- function pt(e = {}) {
35
- const t = e.storageKey ?? "workspace:sessions", n = e.initial ?? ut;
36
- let s = ft(t, n);
37
- const r = /* @__PURE__ */ new Set(), c = (a) => {
38
- s = a, dt(t, s), r.forEach((i) => i());
35
+ function gr(e = {}) {
36
+ const t = e.storageKey ?? "workspace:sessions", r = e.initial ?? fr;
37
+ let o = pr(t, r);
38
+ const n = /* @__PURE__ */ new Set(), s = (i) => {
39
+ o = i, mr(t, o), n.forEach((l) => l());
39
40
  };
40
41
  return {
41
- getState: () => s,
42
- subscribe(a) {
43
- return r.add(a), () => {
44
- r.delete(a);
42
+ getState: () => o,
43
+ subscribe(i) {
44
+ return n.add(i), () => {
45
+ n.delete(i);
45
46
  };
46
47
  },
47
- switchTo(a) {
48
- c({ ...s, activeId: a });
48
+ switchTo(i) {
49
+ s({ ...o, activeId: i });
49
50
  },
50
51
  create() {
51
- const a = `s${Date.now()}`, i = {
52
- id: a,
52
+ const i = `s${Date.now()}`, l = {
53
+ id: i,
53
54
  title: "New session",
54
55
  updatedAt: Date.now()
55
56
  };
56
- c({ sessions: [i, ...s.sessions], activeId: a });
57
+ s({ sessions: [l, ...o.sessions], activeId: i });
57
58
  },
58
- remove(a) {
59
- var u;
60
- const i = s.sessions.filter((m) => m.id !== a), h = s.activeId === a ? ((u = i[0]) == null ? void 0 : u.id) ?? "" : s.activeId;
61
- c({ sessions: i, activeId: h });
59
+ remove(i) {
60
+ var g;
61
+ const l = o.sessions.filter((f) => f.id !== i), b = o.activeId === i ? ((g = l[0]) == null ? void 0 : g.id) ?? "" : o.activeId;
62
+ s({ sessions: l, activeId: b });
62
63
  }
63
64
  };
64
65
  }
65
- function ht(e) {
66
- return qe(e.subscribe, e.getState, e.getState);
66
+ function br(e) {
67
+ return Xt(e.subscribe, e.getState, e.getState);
67
68
  }
68
- function mt(e, t) {
69
+ const mt = ["/api/v1/tree?path=.", "/api/v1/agent/sessions"], hr = /* @__PURE__ */ new Set([
70
+ "WORKSPACE_NOT_READY",
71
+ "AGENT_RUNTIME_NOT_READY",
72
+ "RUNTIME_PROVISIONING_LOCKED"
73
+ ]);
74
+ function gt(e, t) {
75
+ return /^https?:\/\//i.test(t) || !e ? t : `${e.replace(/\/$/, "")}/${t.replace(/^\//, "")}`;
76
+ }
77
+ function le(e, t) {
78
+ const r = { ...t ?? {} };
79
+ for (const o of Object.keys(r))
80
+ o.toLowerCase() === "x-boring-workspace-id" && delete r[o];
81
+ return r["x-boring-workspace-id"] = e, r;
82
+ }
83
+ function bt(e) {
84
+ const t = new URL(e, "http://workspace.local");
85
+ return t.pathname !== "/api/v1/tree" ? null : t.searchParams.get("path") ?? ".";
86
+ }
87
+ function ht(e, t, r, o) {
88
+ const n = bt(r);
89
+ n === null || !o || !Array.isArray(o.entries) || rr(e, t, n, o.entries);
90
+ }
91
+ const vr = /* @__PURE__ */ new Set(["workspace-fs", "sandbox-exec", "ui-bridge"]);
92
+ function yr(e) {
93
+ const t = e;
94
+ if (!t || typeof t != "object") return null;
95
+ const r = t.error ?? t, o = r.details ?? t.details ?? r;
96
+ return !o || typeof o != "object" ? null : {
97
+ code: o.code ?? r.code ?? t.code,
98
+ retryable: o.retryable ?? r.retryable,
99
+ requirement: o.requirement ?? r.requirement
100
+ };
101
+ }
102
+ function vt(e) {
103
+ const t = yr(e);
104
+ if (typeof (t == null ? void 0 : t.code) != "string" || !hr.has(t.code) || t.retryable !== !0) return null;
105
+ const r = typeof t.requirement == "string" && vr.has(t.requirement) ? t.requirement : void 0;
106
+ return r ? { requirement: r } : {};
107
+ }
108
+ function Pr(e) {
109
+ const t = new URL(e, "http://workspace.local");
110
+ return t.pathname === "/api/v1/agent/sessions" || t.pathname === "/api/v1/ready-status";
111
+ }
112
+ function yt(e) {
113
+ return new URL(e, "http://workspace.local").pathname === "/api/v1/ready-status";
114
+ }
115
+ function Pt(e, t) {
116
+ const r = t ? [...e, "/api/v1/ready-status"] : e.filter((o) => !Pr(o));
117
+ return Array.from(new Set(r));
118
+ }
119
+ function wt(e) {
120
+ if (typeof e == "string") return e || null;
121
+ if (!e || typeof e != "object") return null;
122
+ const t = e;
123
+ if (typeof t.message == "string" && t.message) return t.message;
124
+ const r = t.error;
125
+ return typeof (r == null ? void 0 : r.message) == "string" && r.message ? r.message : null;
126
+ }
127
+ function Et(e) {
128
+ if (typeof e != "string" || !e.trim()) return null;
129
+ const t = e.split(/\n\n+/);
130
+ for (let r = t.length - 1; r >= 0; r -= 1) {
131
+ const o = t[r].split(`
132
+ `).filter((n) => n.startsWith("data:")).map((n) => n.slice(5).trim());
133
+ if (o.length !== 0)
134
+ try {
135
+ const n = JSON.parse(o.join(`
136
+ `));
137
+ return {
138
+ state: typeof n.state == "string" ? n.state : void 0,
139
+ message: typeof n.message == "string" ? n.message : void 0
140
+ };
141
+ } catch {
142
+ return null;
143
+ }
144
+ }
145
+ return null;
146
+ }
147
+ async function St(e) {
148
+ const t = await e.text().catch(() => "");
149
+ if (!t) return null;
150
+ try {
151
+ return JSON.parse(t);
152
+ } catch {
153
+ return t;
154
+ }
155
+ }
156
+ const wr = 500;
157
+ function Er(e) {
158
+ return new Promise((t, r) => {
159
+ let o;
160
+ const n = () => {
161
+ o && globalThis.clearTimeout(o), e.removeEventListener("abort", s);
162
+ }, s = () => {
163
+ n(), r(new DOMException("Warmup aborted", "AbortError"));
164
+ };
165
+ if (e.aborted) {
166
+ s();
167
+ return;
168
+ }
169
+ o = globalThis.setTimeout(() => {
170
+ n(), t();
171
+ }, wr), e.addEventListener("abort", s, { once: !0 });
172
+ });
173
+ }
174
+ async function Sr({
175
+ apiBaseUrl: e,
176
+ path: t,
177
+ headers: r,
178
+ signal: o,
179
+ workspaceId: n
180
+ }) {
181
+ const s = await fetch(gt(e, t), { headers: r, signal: o }), i = await St(s);
182
+ if (!s.ok) {
183
+ const l = vt(i);
184
+ if (l) return { status: "preparing", ...l };
185
+ throw new Error(wt(i) ?? `${t} failed with ${s.status}`);
186
+ }
187
+ if (yt(t)) {
188
+ const l = Et(i);
189
+ if ((l == null ? void 0 : l.state) === "degraded") throw new Error(l.message ?? "Workspace failed to prepare");
190
+ }
191
+ return i && typeof i == "object" && ht(e, r["x-boring-workspace-id"] ?? n, t, i), { status: "ready" };
192
+ }
193
+ function Ar({
194
+ workspaceId: e,
195
+ requestHeaders: t,
196
+ apiBaseUrl: r,
197
+ preloadPaths: o = mt,
198
+ provisionWorkspace: n = !0,
199
+ onStatusChange: s
200
+ }) {
201
+ return E(() => {
202
+ let i = !1;
203
+ const l = new AbortController(), b = le(e, t);
204
+ async function g() {
205
+ s == null || s({ status: "preparing" });
206
+ try {
207
+ const f = Pt(o, n), T = (u) => Sr({
208
+ apiBaseUrl: r,
209
+ path: u,
210
+ headers: b,
211
+ signal: l.signal,
212
+ workspaceId: e
213
+ });
214
+ let P = await Promise.all(f.map(async (u) => ({ path: u, result: await T(u) })));
215
+ if (i || l.signal.aborted) return;
216
+ let R = P.filter((u) => u.result.status === "preparing");
217
+ for (; R.length > 0; ) {
218
+ let u;
219
+ for (const m of R)
220
+ if (m.result.status === "preparing" && m.result.requirement) {
221
+ u = m.result.requirement;
222
+ break;
223
+ }
224
+ if (s == null || s({ status: "preparing", message: "Workspace is still preparing", ...u ? { requirement: u } : {} }), await Er(l.signal), i || l.signal.aborted || (P = await Promise.all(R.map(async (m) => ({ path: m.path, result: await T(m.path) }))), i || l.signal.aborted)) return;
225
+ R = P.filter((m) => m.result.status === "preparing");
226
+ }
227
+ s == null || s({ status: "ready" });
228
+ } catch (f) {
229
+ if (i || l.signal.aborted) return;
230
+ s == null || s({
231
+ status: "failed",
232
+ message: f instanceof Error ? f.message : "Workspace failed to prepare"
233
+ });
234
+ }
235
+ }
236
+ return g(), () => {
237
+ i = !0, l.abort();
238
+ };
239
+ }, [r, s, o, n, t, e]), null;
240
+ }
241
+ function _r(e, t) {
69
242
  return e.endsWith(":surface") ? e.slice(0, -8) : t;
70
243
  }
71
- function se(e, t, n) {
72
- const [s, r] = re(() => Le(e, t, n));
73
- y(() => {
74
- r(Le(e, t, n));
75
- }, [e, t, n]);
76
- const c = v(
77
- (a) => {
78
- r(a), lt(e, a, n);
244
+ function Re(e, t, r) {
245
+ const [o, n] = G(() => ct(e, t, r));
246
+ E(() => {
247
+ n(ct(e, t, r));
248
+ }, [e, t, r]);
249
+ const s = _(
250
+ (i) => {
251
+ n(i), ur(e, i, r);
79
252
  },
80
- [n, e]
253
+ [r, e]
81
254
  );
82
- return [s, c];
255
+ return [o, s];
83
256
  }
84
- const gt = {}, De = {
257
+ const De = {}, dt = { status: "preparing" }, ft = {
85
258
  openTabs: [],
86
259
  activeTab: null
87
260
  };
88
- function vt(e) {
261
+ function Nr({ status: e }) {
262
+ const t = e.status === "ready" ? void 0 : e.requirement, r = e.status !== "failed", o = r ? t === "workspace-fs" ? "Preparing files…" : t === "sandbox-exec" ? "Waking sandbox…" : t === "ui-bridge" ? "Connecting workspace UI…" : "Preparing workspace…" : "Workspace workbench failed", n = e.status === "failed" ? e.message : "Chat is ready while files, tools, and workspace panels finish warming up.";
263
+ return /* @__PURE__ */ c("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Te("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
264
+ r ? /* @__PURE__ */ c("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,
265
+ /* @__PURE__ */ c("div", { className: "text-sm font-semibold text-foreground", children: o }),
266
+ /* @__PURE__ */ c("p", { className: "mt-2 text-sm text-muted-foreground", children: n }),
267
+ e.status === "failed" ? /* @__PURE__ */ c("p", { className: "mt-3 text-xs text-muted-foreground", children: "Reload the workspace to retry." }) : null
268
+ ] }) });
269
+ }
270
+ function Lr(e) {
89
271
  if (!e) return "/api/v1/ui";
90
- const t = e.replace(/\/$/, ""), n = "/api/v1/ui";
91
- return t.endsWith(n) ? t : `${t}${n}`;
272
+ const t = e.replace(/\/$/, ""), r = "/api/v1/ui";
273
+ return t.endsWith(r) ? t : `${t}${r}`;
92
274
  }
93
- function yt(e) {
94
- return `${vt(e)}/state`;
275
+ function Rr(e) {
276
+ return `${Lr(e)}/state`;
95
277
  }
96
- function St(e) {
97
- var s;
98
- const t = e.openTabs.find((r) => r.id === e.activeTab), n = (s = t == null ? void 0 : t.params) == null ? void 0 : s.path;
99
- return typeof n == "string" ? n : null;
278
+ function Dr(e) {
279
+ var o;
280
+ const t = e.openTabs.find((n) => n.id === e.activeTab), r = (o = t == null ? void 0 : t.params) == null ? void 0 : o.path;
281
+ return typeof r == "string" ? r : null;
100
282
  }
101
- function wt({
283
+ function Or({
102
284
  bridgeEndpoint: e,
103
285
  requestHeaders: t,
104
- navOpen: n,
105
- surfaceOpen: s,
106
- snapshot: r
286
+ navOpen: r,
287
+ surfaceOpen: o,
288
+ snapshot: n
107
289
  }) {
108
- const c = ot(), a = K(null);
109
- return y(() => {
110
- var u;
290
+ const s = pt(), i = O(null);
291
+ return E(() => {
292
+ var g;
111
293
  if (e === null) return;
112
- (u = a.current) == null || u.abort();
113
- const i = new AbortController();
114
- a.current = i;
115
- const h = {
294
+ (g = i.current) == null || g.abort();
295
+ const l = new AbortController();
296
+ i.current = l;
297
+ const b = {
116
298
  v: 1,
117
- drawerOpen: n,
118
- workbenchOpen: s,
119
- openTabs: r.openTabs,
120
- activeTab: r.activeTab,
121
- activeFile: St(r),
122
- availablePanels: c.list().map((m) => m.id)
299
+ drawerOpen: r,
300
+ workbenchOpen: o,
301
+ openTabs: n.openTabs,
302
+ activeTab: n.activeTab,
303
+ activeFile: Dr(n),
304
+ availablePanels: s.list().map((f) => f.id)
123
305
  };
124
- return fetch(yt(e), {
306
+ return fetch(Rr(e), {
125
307
  method: "PUT",
126
308
  headers: { ...t, "Content-Type": "application/json" },
127
- body: JSON.stringify({ state: h, causedBy: "user" }),
128
- signal: i.signal
309
+ body: JSON.stringify({ state: b, causedBy: "user" }),
310
+ signal: l.signal
129
311
  }).catch(() => {
130
312
  }), () => {
131
- i.abort();
313
+ l.abort();
132
314
  };
133
- }, [e, n, c, t, r, s]), null;
315
+ }, [e, r, s, t, n, o]), null;
134
316
  }
135
- function xt({
317
+ function zr({
136
318
  workspaceId: e,
137
319
  chatPanel: t,
138
- useSessions: n,
139
- requestHeaders: s = gt,
140
- sessionStorageKey: r,
141
- providerStorageKey: c,
142
- surfaceStorageKey: a,
143
- beforeShell: i,
144
- afterShell: h,
145
- panels: u,
146
- commands: m,
147
- catalogs: M,
148
- plugins: S,
149
- excludeDefaults: g,
150
- capabilities: k,
151
- apiBaseUrl: O,
152
- authHeaders: E,
153
- apiTimeout: J,
154
- defaultTheme: Ne,
155
- onThemeChange: Ie,
156
- persistenceEnabled: ne,
157
- bridgeEndpoint: V,
158
- onAuthError: Ae,
159
- sessions: oe,
160
- activeSessionId: ae,
161
- onSwitchSession: ce,
162
- onCreateSession: ie,
163
- onDeleteSession: le,
164
- onActiveSessionIdChange: x,
165
- appTitle: Ue = "Boring",
166
- defaultSessionTitle: F = "New session",
167
- defaultSurfaceOpen: Be,
168
- defaultWorkbenchLeftTab: W,
169
- topBarLeft: _e,
170
- topBarRight: je,
171
- chatParams: ue,
172
- hotReloadEnabled: z,
173
- frontPluginHotReload: Me,
174
- extraPanels: fe,
175
- extraCommands: de,
176
- onOpenNav: G,
177
- onOpenSurface: Y,
178
- className: Je
320
+ useSessions: r,
321
+ requestHeaders: o,
322
+ sessionStorageKey: n,
323
+ providerStorageKey: s,
324
+ surfaceStorageKey: i,
325
+ beforeShell: l,
326
+ afterShell: b,
327
+ panels: g,
328
+ commands: f,
329
+ catalogs: T,
330
+ plugins: P,
331
+ excludeDefaults: R,
332
+ capabilities: u,
333
+ apiBaseUrl: m,
334
+ authHeaders: y,
335
+ apiTimeout: h,
336
+ defaultTheme: W,
337
+ onThemeChange: At,
338
+ persistenceEnabled: xe,
339
+ bridgeEndpoint: ce,
340
+ fullPageBasePath: _t,
341
+ onAuthError: Nt,
342
+ sessions: ke,
343
+ activeSessionId: We,
344
+ onSwitchSession: Ue,
345
+ onCreateSession: Fe,
346
+ onDeleteSession: Ge,
347
+ onActiveSessionIdChange: H,
348
+ appTitle: Lt = "Boring",
349
+ defaultSessionTitle: M = "New session",
350
+ navEnabled: Me = !0,
351
+ defaultNavOpen: Rt = !1,
352
+ defaultSurfaceOpen: Dt,
353
+ defaultWorkbenchLeftTab: V,
354
+ surfaceInitialPanels: $e,
355
+ topBarLeft: Ot,
356
+ topBarRight: Tt,
357
+ chatParams: D,
358
+ hotReloadEnabled: ue,
359
+ frontPluginHotReload: xt,
360
+ extraPanels: Ie,
361
+ extraCommands: Ce,
362
+ provisionWorkspace: de,
363
+ bootPreloadPaths: kt,
364
+ onWorkspaceWarmupStatusChange: Y,
365
+ onOpenNav: fe,
366
+ onOpenSurface: pe,
367
+ surfaceButtonBottomOffset: Wt,
368
+ className: Ut
179
369
  }) {
180
- var Ke, Oe;
181
- const Q = c ?? `boring-ui-v2:layout:${e}`, f = a ?? `${Q}:surface`, L = mt(
182
- f,
370
+ var it, at;
371
+ const me = s ?? `boring-ui-v2:layout:${e}`, w = i ?? `${me}:surface`, z = _r(
372
+ w,
373
+ me
374
+ ), Q = xe !== !1, ge = n ?? `boring-workspace:sessions:${e}`, $ = S(
375
+ () => le(e, o ?? De),
376
+ [o, e]
377
+ ), Ft = S(
378
+ () => le(e, { ...o ?? De, ...y ?? De }),
379
+ [y, o, e]
380
+ ), X = S(
381
+ () => gr({ storageKey: ge }),
382
+ [ge]
383
+ ), Ke = br(X), [je, Gt] = G(() => ({
384
+ workspaceId: e,
385
+ status: dt
386
+ })), I = je.workspaceId === e ? je.status : dt, Mt = t ?? er, $t = r ?? tr, C = !t || !!r, be = C && de !== !1, he = () => {
387
+ }, ve = $t({
388
+ requestHeaders: $,
389
+ storageKey: ge,
390
+ enabled: be,
391
+ refreshKey: I.status === "ready" ? "workspace-ready" : void 0
392
+ }), ye = be && !ve.loading && !ve.error, K = be && !ye, p = C && ye ? ve : void 0, Pe = ke !== void 0 || We !== void 0 || Ue !== void 0 || Fe !== void 0 || Ge !== void 0, It = p == null ? void 0 : p.sessions.map((a) => ({
393
+ ...a,
394
+ title: a.title ?? "New session"
395
+ })), we = p ? It ?? [] : K ? [] : Pe ? ke ?? [] : Ke.sessions, Ee = p ? p.activeSessionId ?? null : K ? null : Pe ? We ?? null : Ke.activeId, U = (D == null ? void 0 : D.autoSubmitInitialDraft) === !0, Z = U && C && !Pe, [N, j] = G(() => Z ? null : void 0), Je = O(e), F = O(!1);
396
+ E(() => {
397
+ if (Je.current !== e) {
398
+ Je.current = e, F.current = !1, j(Z ? null : void 0);
399
+ return;
400
+ }
401
+ Z && N === void 0 && (F.current = !1, j(null));
402
+ }, [N, Z, e]), E(() => {
403
+ !p || N !== null || F.current || (F.current = !0, Promise.resolve(p.create({ title: M })).then((a) => {
404
+ if (typeof (a == null ? void 0 : a.id) != "string")
405
+ throw new Error("auto_submit_session_create_failed");
406
+ j(a.id);
407
+ }).catch(() => {
408
+ F.current = !1, j(void 0);
409
+ }));
410
+ }, [N, M, p]);
411
+ const A = N !== void 0 ? N ?? null : Ee, qe = K ? he : (p == null ? void 0 : p.switch) ?? Ue ?? X.switchTo, Ct = _((a) => (A && a !== A && window.dispatchEvent(new CustomEvent("boring:workspace-composer-stop", { detail: { sessionId: A } })), qe(a)), [A, qe]), Be = K ? he : p ? () => p.create() : Fe ?? X.create, Kt = K ? he : (p == null ? void 0 : p.delete) ?? Ge ?? X.remove, jt = ((it = we.find((a) => a.id === A)) == null ? void 0 : it.title) ?? void 0, [Jt, He] = Re(
412
+ `${z}:drawer`,
413
+ Rt,
183
414
  Q
184
- ), R = ne !== !1, X = r ?? `boring-workspace:sessions:${e}`, D = P(
185
- () => pt({ storageKey: X }),
186
- [X]
187
- ), pe = ht(D), Ve = t ?? et, Z = n ?? (t ? void 0 : tt), l = Z == null ? void 0 : Z({
188
- requestHeaders: s,
189
- storageKey: X
190
- }), he = oe !== void 0 || ae !== void 0 || ce !== void 0 || ie !== void 0 || le !== void 0, Fe = l == null ? void 0 : l.sessions.map((o) => ({
191
- ...o,
192
- title: o.title ?? "New session"
193
- })), H = l ? Fe ?? [] : he ? oe ?? [] : pe.sessions, p = l ? l.activeSessionId ?? null : he ? ae ?? null : pe.activeId, me = (l == null ? void 0 : l.switch) ?? ce ?? D.switchTo, ze = v((o) => (p && o !== p && window.dispatchEvent(new CustomEvent("boring:workspace-composer-stop", { detail: { sessionId: p } })), me(o)), [me, p]), ge = l ? () => l.create() : ie ?? D.create, Ge = (l == null ? void 0 : l.delete) ?? le ?? D.remove, Ye = ((Ke = H.find((o) => o.id === p)) == null ? void 0 : Ke.title) ?? void 0, [ve, ye] = se(
194
- `${L}:drawer`,
195
- !0,
196
- R
197
- ), [w, b] = se(
415
+ ), Ve = Me && Jt, [x, L] = Re(
198
416
  // Key must NOT match resolvedSurfaceStorageKey (which stores the dockview
199
417
  // layout JSON at the same ":surface" suffix). Writing "1"/"0" to the same
200
418
  // key corrupts the JSON and drops the persisted workbench layout on reload.
201
- `${L}:workbenchOpen`,
202
- Be ?? !1,
203
- R
204
- ), [Qe, q] = se(
205
- `${L}:workbenchLeftOpen`,
419
+ `${z}:workbenchOpen`,
420
+ Dt ?? !1,
421
+ Q
422
+ ), [qt, J] = Re(
423
+ `${z}:workbenchLeftOpen`,
206
424
  !0,
207
- R
208
- ), C = K(!1), T = K(w), Se = K(f), we = K(null);
209
- Se.current = f;
210
- const [be, Pe] = re(() => ({
211
- key: f,
212
- snapshot: De
213
- })), Xe = be.key === f ? be.snapshot : De;
214
- y(() => {
215
- C.current = !1;
216
- }, [e]), y(() => {
217
- if (!(!l || l.loading)) {
218
- if (l.sessions.length > 0) {
219
- C.current = !1;
425
+ Q
426
+ ), q = O(!1), k = O(x), Ye = O(w), Se = O(null);
427
+ Ye.current = w;
428
+ const [ze, Qe] = G(() => ({
429
+ key: w,
430
+ snapshot: ft
431
+ })), Bt = ze.key === w ? ze.snapshot : ft;
432
+ E(() => {
433
+ q.current = !1;
434
+ }, [e]), E(() => {
435
+ if (!(!p || p.loading) && N === void 0) {
436
+ if (p.sessions.length > 0) {
437
+ q.current = !1;
220
438
  return;
221
439
  }
222
- C.current || (C.current = !0, Promise.resolve(l.create({ title: F })).catch(() => {
223
- C.current = !1;
440
+ q.current || (q.current = !0, Promise.resolve(p.create({ title: M })).catch(() => {
441
+ q.current = !1;
224
442
  }));
225
443
  }
226
- }, [F, l]), y(() => {
227
- T.current = w;
228
- }, [w]);
229
- const ke = v((o) => {
230
- we.current = { key: f, api: o }, Pe({
231
- key: f,
232
- snapshot: o.getSnapshot()
444
+ }, [N, M, p]), E(() => {
445
+ k.current = x;
446
+ }, [x]);
447
+ const Xe = _((a) => {
448
+ Se.current = { key: w, api: a }, Qe({
449
+ key: w,
450
+ snapshot: a.getSnapshot()
233
451
  });
234
- }, [f]), Te = v((o) => {
235
- Pe({
236
- key: f,
237
- snapshot: o
452
+ }, [w]), Ze = _((a) => {
453
+ Qe({
454
+ key: w,
455
+ snapshot: a
238
456
  });
239
- }, [f]), N = v(() => {
240
- const o = we.current;
241
- return (o == null ? void 0 : o.key) === Se.current ? o.api : null;
242
- }, []), I = v(() => T.current, []), A = v(() => {
243
- T.current = !0, b(!0);
244
- }, [b]), U = v(() => {
245
- T.current = !1, b(!1);
246
- }, [b]), B = P(
247
- () => (S == null ? void 0 : S.map(st)) ?? [],
248
- [S]
249
- ), ee = P(
250
- () => B.some((o) => o.registrations.leftTabs.length > 0),
251
- [B]
252
- ), Ee = P(
253
- () => B.flatMap((o) => o.registrations.panels.map((_) => _.id)),
254
- [B]
255
- ), Ce = P(
256
- () => [...fe ?? [], ...Ee],
257
- [fe, Ee]
258
- ), $e = p ?? ((Oe = H[0]) == null ? void 0 : Oe.id) ?? "default";
259
- y(() => {
260
- var _;
261
- const o = (j) => {
262
- const te = j.detail;
263
- !te || typeof te != "object" || nt(te, {
264
- surface: N,
265
- isWorkbenchOpen: I,
266
- openWorkbench: A
457
+ }, [w]), ee = _(() => {
458
+ const a = Se.current;
459
+ return (a == null ? void 0 : a.key) === Ye.current ? a.api : null;
460
+ }, []), te = _(() => k.current, []), re = _(() => {
461
+ k.current = !0, L(!0);
462
+ }, [L]), ne = _(() => {
463
+ k.current = !0, L(!0), J(!0);
464
+ }, [L, J]), oe = _(() => {
465
+ k.current = !1, Se.current = null, L(!1);
466
+ }, [L]), se = S(
467
+ () => (P == null ? void 0 : P.map(nr)) ?? [],
468
+ [P]
469
+ ), Ae = S(
470
+ () => se.some((a) => a.registrations.leftTabs.length > 0),
471
+ [se]
472
+ ), et = S(
473
+ () => se.flatMap((a) => a.registrations.panels.map((ie) => ie.id)),
474
+ [se]
475
+ ), tt = S(
476
+ () => [...Ie ?? [], ...et],
477
+ [Ie, et]
478
+ ), rt = A ?? (N !== void 0 ? "default" : ((at = we[0]) == null ? void 0 : at.id) ?? "default"), [Ht, _e] = G(U), nt = O(e);
479
+ E(() => {
480
+ if (nt.current !== e) {
481
+ nt.current = e, _e(U);
482
+ return;
483
+ }
484
+ U && _e(!0);
485
+ }, [U, e]);
486
+ const ot = U && C && !A, st = !Ht && de !== !1 && (C ? ye && !!Ee : !0), Vt = _((a) => {
487
+ Gt({ workspaceId: e, status: a }), Y == null || Y(a);
488
+ }, [Y, e]);
489
+ E(() => {
490
+ var ie;
491
+ const a = (ae) => {
492
+ const Le = ae.detail;
493
+ !Le || typeof Le != "object" || sr(Le, {
494
+ surface: ee,
495
+ isWorkbenchOpen: te,
496
+ openWorkbench: re,
497
+ openWorkbenchSources: ne
267
498
  });
268
499
  };
269
- return (_ = globalThis.addEventListener) == null || _.call(globalThis, We, o), () => {
270
- var j;
271
- return (j = globalThis.removeEventListener) == null ? void 0 : j.call(globalThis, We, o);
500
+ return (ie = globalThis.addEventListener) == null || ie.call(globalThis, lt, a), () => {
501
+ var ae;
502
+ return (ae = globalThis.removeEventListener) == null ? void 0 : ae.call(globalThis, lt, a);
272
503
  };
273
- }, [N, I, A]), y(() => {
274
- p && (x == null || x(p));
275
- }, [p, x]);
276
- const Ze = P(
504
+ }, [ee, te, re, ne]), E(() => {
505
+ A && (H == null || H(A));
506
+ }, [A, H]);
507
+ const Ne = I.status !== "ready", Yt = Ne ? /* @__PURE__ */ c(Nr, { status: I }) : void 0, zt = S(
277
508
  () => ({
278
- ...ue,
279
- sessionId: $e,
280
- requestHeaders: s,
281
- bridgeEndpoint: V,
282
- getSurface: N,
283
- isWorkbenchOpen: I,
284
- openWorkbench: A,
285
- closeWorkbench: U,
286
- extraCommands: de,
509
+ ...D,
510
+ ...ot ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
511
+ sessionId: rt,
512
+ requestHeaders: $,
513
+ bridgeEndpoint: ce,
514
+ getSurface: ee,
515
+ isWorkbenchOpen: te,
516
+ openWorkbench: re,
517
+ openWorkbenchSources: ne,
518
+ closeWorkbench: oe,
519
+ extraCommands: Ce,
520
+ workspaceWarmupStatus: I,
521
+ hydrateMessages: st,
522
+ onAutoSubmitInitialDraftSettled: () => {
523
+ F.current = !1, _e(!1), j(void 0);
524
+ const a = D == null ? void 0 : D.onAutoSubmitInitialDraftSettled;
525
+ typeof a == "function" && a();
526
+ },
287
527
  // Forward the explicit prop when set. Omitting the key (when undefined)
288
528
  // lets ChatPanel apply its own default (true) and avoids overriding a
289
529
  // value passed through chatParams.
290
- ...z !== void 0 ? { hotReloadEnabled: z } : {}
530
+ ...ue !== void 0 ? { hotReloadEnabled: ue } : {}
291
531
  }),
292
- [ue, $e, s, V, N, I, A, U, de, z]
293
- ), He = P(() => ({
294
- storageKey: f,
295
- defaultLeftTab: W,
296
- extraPanels: Ce,
297
- onReady: ke,
298
- onChange: Te,
299
- onClose: U
532
+ [D, ot, rt, $, ce, ee, te, re, ne, oe, Ce, I, st, ue]
533
+ ), Qt = S(() => ({
534
+ storageKey: w,
535
+ defaultLeftTab: V,
536
+ initialPanels: $e,
537
+ extraPanels: tt,
538
+ onReady: Xe,
539
+ onChange: Ze,
540
+ onClose: oe
300
541
  }), [
301
- U,
302
- W,
303
- Te,
304
- ke,
305
- f,
306
- Ce,
307
- b
542
+ oe,
543
+ V,
544
+ $e,
545
+ Ze,
546
+ Xe,
547
+ w,
548
+ tt,
549
+ L
308
550
  ]);
309
- return /* @__PURE__ */ d("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ xe(
310
- rt,
551
+ return /* @__PURE__ */ c("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ Te(
552
+ or,
311
553
  {
312
- chatPanel: Ve,
313
- panels: u,
314
- commands: m,
315
- catalogs: M,
316
- plugins: S,
317
- excludeDefaults: g,
318
- capabilities: k,
319
- apiBaseUrl: O,
320
- authHeaders: E,
321
- apiTimeout: J,
322
- defaultTheme: Ne,
323
- onThemeChange: Ie,
554
+ chatPanel: Mt,
555
+ panels: g,
556
+ commands: f,
557
+ catalogs: T,
558
+ plugins: P,
559
+ excludeDefaults: R,
560
+ capabilities: u,
561
+ apiBaseUrl: m,
562
+ authHeaders: Ft,
563
+ apiTimeout: h,
564
+ defaultTheme: W,
565
+ onThemeChange: At,
324
566
  workspaceId: e,
325
- storageKey: Q,
326
- persistenceEnabled: ne,
567
+ storageKey: me,
568
+ persistenceEnabled: xe,
327
569
  bridgeEndpoint: null,
328
- onAuthError: Ae,
329
- frontPluginHotReload: Me,
570
+ onAuthError: Nt,
571
+ frontPluginHotReload: xt,
572
+ fullPageBasePath: _t,
330
573
  children: [
331
- i,
332
- /* @__PURE__ */ d(
333
- wt,
574
+ l,
575
+ /* @__PURE__ */ c(
576
+ Ar,
334
577
  {
335
- bridgeEndpoint: V,
336
- requestHeaders: s,
337
- navOpen: ve,
338
- surfaceOpen: w,
339
- snapshot: Xe
578
+ workspaceId: e,
579
+ requestHeaders: $,
580
+ apiBaseUrl: m,
581
+ preloadPaths: kt,
582
+ provisionWorkspace: de,
583
+ onStatusChange: Vt
340
584
  }
341
585
  ),
342
- /* @__PURE__ */ xe("div", { className: "flex h-full min-h-0 flex-col", children: [
343
- /* @__PURE__ */ d(
344
- ct,
586
+ /* @__PURE__ */ c(
587
+ Or,
588
+ {
589
+ bridgeEndpoint: ce,
590
+ requestHeaders: $,
591
+ navOpen: Ve,
592
+ surfaceOpen: x,
593
+ snapshot: Bt
594
+ }
595
+ ),
596
+ /* @__PURE__ */ Te("div", { className: "flex h-full min-h-0 flex-col", children: [
597
+ /* @__PURE__ */ c(
598
+ lr,
345
599
  {
346
- appTitle: Ue,
347
- sessionTitle: Ye ?? F,
600
+ appTitle: Lt,
601
+ sessionTitle: jt ?? M,
348
602
  onCommandPalette: () => {
349
603
  document.dispatchEvent(new KeyboardEvent("keydown", {
350
604
  key: "k",
@@ -354,121 +608,321 @@ function xt({
354
608
  cancelable: !0
355
609
  }));
356
610
  },
357
- onNewChat: ge,
358
- topBarLeft: _e,
359
- topBarRight: je
611
+ onNewChat: Be,
612
+ topBarLeft: Ot,
613
+ topBarRight: Tt
360
614
  }
361
615
  ),
362
- /* @__PURE__ */ d(
363
- it,
616
+ /* @__PURE__ */ c(
617
+ cr,
364
618
  {
365
- className: Je,
366
- nav: ve ? "session-list" : null,
619
+ className: Ut,
620
+ nav: Ve ? "session-list" : null,
367
621
  navParams: {
368
- sessions: H,
369
- activeId: p,
370
- onSwitch: ze,
371
- onCreate: ge,
372
- onDelete: Ge,
373
- onClose: () => ye(!1)
622
+ sessions: we,
623
+ activeId: Ee,
624
+ onSwitch: Ct,
625
+ onCreate: Be,
626
+ onDelete: Kt,
627
+ onClose: () => He(!1)
374
628
  },
375
629
  center: "chat",
376
- centerParams: Ze,
377
- surface: w ? "artifact-surface" : null,
378
- surfaceParams: He,
379
- sidebar: w && ee && Qe ? "workbench-left" : null,
380
- sidebarParams: w && ee ? {
381
- ...W ? { defaultTab: W } : {},
382
- onClose: () => q(!1),
383
- onCollapse: () => q(!1)
630
+ centerParams: zt,
631
+ surface: x ? "artifact-surface" : null,
632
+ surfaceParams: Qt,
633
+ surfaceOverlay: Yt,
634
+ sidebar: x && !Ne && Ae && qt ? "workbench-left" : null,
635
+ sidebarParams: x && !Ne && Ae ? {
636
+ ...V ? { defaultTab: V } : {},
637
+ onClose: () => J(!1),
638
+ onCollapse: () => J(!1)
639
+ } : void 0,
640
+ storageKey: Q ? z : void 0,
641
+ onOpenNav: Me ? () => {
642
+ He(!0), fe == null || fe();
384
643
  } : void 0,
385
- storageKey: R ? L : void 0,
386
- onOpenNav: () => {
387
- ye(!0), G == null || G();
388
- },
389
644
  onOpenSurface: () => {
390
- T.current = !0, b(!0), Y == null || Y();
645
+ k.current = !0, L(!0), pe == null || pe();
391
646
  },
392
- onOpenSidebar: ee ? () => {
393
- T.current = !0, b(!0), q(!0);
647
+ surfaceButtonBottomOffset: Wt,
648
+ onOpenSidebar: Ae ? () => {
649
+ k.current = !0, L(!0), J(!0);
394
650
  } : void 0
395
651
  }
396
652
  )
397
653
  ] }),
398
- h
654
+ b
399
655
  ]
400
656
  }
401
657
  ) });
402
658
  }
403
- const bt = ["/api/v1/tree?path=.", "/api/v1/agent/sessions"];
404
- function Pt(e, t) {
405
- return /^https?:\/\//i.test(t) || !e ? t : `${e.replace(/\/$/, "")}/${t.replace(/^\//, "")}`;
406
- }
407
- function kt(e) {
408
- const t = new URL(e, "http://workspace.local");
409
- return t.pathname !== "/api/v1/tree" ? null : t.searchParams.get("path") ?? ".";
659
+ const Tr = 500;
660
+ function xr(e) {
661
+ return new Promise((t, r) => {
662
+ let o;
663
+ const n = () => {
664
+ o && globalThis.clearTimeout(o), e.removeEventListener("abort", s);
665
+ }, s = () => {
666
+ n(), r(new DOMException("Workspace boot aborted", "AbortError"));
667
+ };
668
+ if (e.aborted) {
669
+ s();
670
+ return;
671
+ }
672
+ o = globalThis.setTimeout(() => {
673
+ n(), t();
674
+ }, Tr), e.addEventListener("abort", s, { once: !0 });
675
+ });
410
676
  }
411
- function Wt({
677
+ function Qr({
412
678
  workspaceId: e,
413
679
  requestHeaders: t,
414
- apiBaseUrl: n,
415
- preloadPaths: s = bt,
416
- loadingFallback: r,
417
- errorFallback: c,
418
- children: a
680
+ apiBaseUrl: r,
681
+ preloadPaths: o = mt,
682
+ provisionWorkspace: n = !0,
683
+ loadingFallback: s,
684
+ errorFallback: i,
685
+ children: l
419
686
  }) {
420
- const [i, h] = re({
687
+ const [b, g] = G({
421
688
  status: "loading",
422
689
  label: "Waking workspace runtime"
423
690
  });
424
- return y(() => {
425
- const u = new AbortController(), m = t ?? { "x-boring-workspace-id": e };
426
- async function M(g) {
427
- const k = await fetch(Pt(n, g), {
428
- headers: m,
429
- signal: u.signal
430
- });
431
- if (!k.ok) {
432
- const J = await k.text().catch(() => "");
433
- throw new Error(J || `${g} failed with ${k.status}`);
691
+ return E(() => {
692
+ const f = new AbortController(), T = le(e, t);
693
+ async function P(u) {
694
+ const m = await fetch(gt(r, u), {
695
+ headers: T,
696
+ signal: f.signal
697
+ }), y = await St(m);
698
+ if (!m.ok) {
699
+ if (vt(y)) return "preparing";
700
+ throw new Error(wt(y) ?? `${u} failed with ${m.status}`);
434
701
  }
435
- const O = kt(g);
436
- if (O === null) return;
437
- const E = await k.clone().json().catch(() => null);
438
- !E || !Array.isArray(E.entries) || at(n, m["x-boring-workspace-id"] ?? e, O, E.entries);
702
+ if (yt(u)) {
703
+ const W = Et(y);
704
+ if ((W == null ? void 0 : W.state) === "degraded") throw new Error(W.message ?? "Workspace failed to prepare");
705
+ }
706
+ return bt(u) !== null && y && typeof y == "object" && ht(r, T["x-boring-workspace-id"] ?? e, u, y), "ready";
439
707
  }
440
- async function S() {
441
- h({ status: "loading", label: "Waking workspace runtime" });
708
+ async function R() {
709
+ g({ status: "loading", label: "Waking workspace runtime" });
442
710
  try {
443
- await Promise.all(s.map(M)), u.signal.aborted || h({ status: "ready" });
444
- } catch (g) {
445
- if (u.signal.aborted) return;
446
- h({
711
+ const u = Pt(o, n);
712
+ let m = await Promise.all(u.map(async (h) => ({ path: h, status: await P(h) }))), y = m.filter((h) => h.status === "preparing").map((h) => h.path);
713
+ for (; y.length > 0; ) {
714
+ if (g({ status: "loading", label: "Workspace is still preparing" }), await xr(f.signal), f.signal.aborted) return;
715
+ m = await Promise.all(y.map(async (h) => ({ path: h, status: await P(h) }))), y = m.filter((h) => h.status === "preparing").map((h) => h.path);
716
+ }
717
+ f.signal.aborted || g({ status: "ready" });
718
+ } catch (u) {
719
+ if (f.signal.aborted) return;
720
+ g({
447
721
  status: "error",
448
- message: g instanceof Error ? g.message : "Unknown workspace boot error"
722
+ message: u instanceof Error ? u.message : "Unknown workspace boot error"
449
723
  });
450
724
  }
451
725
  }
452
- return S(), () => u.abort();
453
- }, [n, s, t, e]), i.status === "ready" ? /* @__PURE__ */ d($, { children: a }) : i.status === "error" ? typeof c == "function" ? /* @__PURE__ */ d($, { children: c(i.message) }) : c ? /* @__PURE__ */ d($, { children: c }) : /* @__PURE__ */ d(
454
- Re,
726
+ return R(), () => f.abort();
727
+ }, [r, o, n, t, e]), b.status === "ready" ? /* @__PURE__ */ c(B, { children: l }) : b.status === "error" ? typeof i == "function" ? /* @__PURE__ */ c(B, { children: i(b.message) }) : i ? /* @__PURE__ */ c(B, { children: i }) : /* @__PURE__ */ c(
728
+ ut,
455
729
  {
456
730
  title: "Workspace failed to open",
457
- description: i.message,
731
+ description: b.message,
458
732
  status: "Retry by reloading the page"
459
733
  }
460
- ) : typeof r == "function" ? /* @__PURE__ */ d($, { children: r(i.label) }) : r ? /* @__PURE__ */ d($, { children: r }) : /* @__PURE__ */ d(
461
- Re,
734
+ ) : typeof s == "function" ? /* @__PURE__ */ c(B, { children: s(b.label) }) : s ? /* @__PURE__ */ c(B, { children: s }) : /* @__PURE__ */ c(
735
+ ut,
462
736
  {
463
737
  title: "Opening workspace",
464
738
  description: "Waking the sandbox and preparing files, sessions, and layout.",
465
- status: i.label
739
+ status: b.label
740
+ }
741
+ );
742
+ }
743
+ const kr = "FULL_PAGE_PANEL_MISSING_COMPONENT", Wr = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", Ur = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", Fr = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", Gr = "FULL_PAGE_PANEL_NOT_SUPPORTED", Mr = "FULL_PAGE_PANEL_RENDER_FAILED";
744
+ function v() {
745
+ }
746
+ const $r = { dispose: v }, d = () => $r;
747
+ function Ir(e) {
748
+ return {
749
+ id: `full-page:${e}`,
750
+ title: e,
751
+ isFocused: !0,
752
+ isActive: !0,
753
+ isVisible: !0,
754
+ width: 0,
755
+ height: 0,
756
+ location: { type: "grid", referenceGroup: void 0 },
757
+ setActive: v,
758
+ setTitle: (t) => {
759
+ document.title = t;
760
+ },
761
+ setSize: v,
762
+ close: () => {
763
+ window.close();
764
+ },
765
+ moveTo: v,
766
+ maximize: v,
767
+ exitMaximized: v,
768
+ isMaximized: () => !1,
769
+ minimize: v,
770
+ onDidActiveChange: d,
771
+ onDidVisibilityChange: d,
772
+ onDidDimensionsChange: d,
773
+ onDidFocusChange: d,
774
+ onDidLocationChange: d,
775
+ onDidParametersChange: d,
776
+ onDidTitleChange: d,
777
+ onDidRenamed: d,
778
+ onWillFocus: d
779
+ };
780
+ }
781
+ function Cr() {
782
+ return {
783
+ width: window.innerWidth,
784
+ height: window.innerHeight,
785
+ minimumHeight: 0,
786
+ maximumHeight: 1 / 0,
787
+ minimumWidth: 0,
788
+ maximumWidth: 1 / 0,
789
+ activePanel: void 0,
790
+ panels: [],
791
+ groups: [],
792
+ activeGroup: void 0,
793
+ addPanel: v,
794
+ addGroup: v,
795
+ removePanel: v,
796
+ removeGroup: v,
797
+ getPanel: () => {
798
+ },
799
+ getGroup: () => {
800
+ },
801
+ moveGroupOrPanel: v,
802
+ fromJSON: v,
803
+ toJSON: () => ({}),
804
+ clear: v,
805
+ focus: v,
806
+ layout: v,
807
+ onDidLayoutChange: d,
808
+ onDidLayoutFromJSON: d,
809
+ onDidAddPanel: d,
810
+ onDidRemovePanel: d,
811
+ onDidActivePanelChange: d,
812
+ onDidAddGroup: d,
813
+ onDidRemoveGroup: d,
814
+ onDidActiveGroupChange: d,
815
+ onUnhandledDragOverEvent: d,
816
+ onDidDrop: d,
817
+ onWillDrop: d,
818
+ onWillDragGroup: d,
819
+ onWillDragPanel: d,
820
+ onDidActivePanelChange_: d
821
+ };
822
+ }
823
+ function Oe({ code: e, title: t, description: r }) {
824
+ return /* @__PURE__ */ c(
825
+ "div",
826
+ {
827
+ className: "flex min-h-screen items-center justify-center bg-background p-6 text-foreground",
828
+ "data-testid": "full-page-error-state",
829
+ "data-full-page-error-code": e,
830
+ children: /* @__PURE__ */ c(dr, { className: "w-full max-w-lg", title: t, description: r })
831
+ }
832
+ );
833
+ }
834
+ function Xr({ componentId: e, params: t = {} }) {
835
+ const r = pt(), { errors: o } = ir(), n = r.get(e), s = r.getComponents()[e];
836
+ Zt(() => {
837
+ document.title = (n == null ? void 0 : n.title) ?? e;
838
+ }, [e, n == null ? void 0 : n.title]);
839
+ const i = S(() => ({
840
+ params: t,
841
+ api: Ir(e),
842
+ containerApi: Cr(),
843
+ className: "h-full"
844
+ }), [e, t]), l = S(() => {
845
+ if (!n) return null;
846
+ const b = n.pluginId ?? n.id;
847
+ for (let g = o.length - 1; g >= 0; g -= 1) {
848
+ const f = o[g];
849
+ if (f.contributionKind === "panel" && f.contributionId === e && f.pluginId === b)
850
+ return f;
851
+ }
852
+ return null;
853
+ }, [e, o, n]);
854
+ return n ? !n.supportsFullPage || !s ? /* @__PURE__ */ c(
855
+ Oe,
856
+ {
857
+ code: Gr,
858
+ title: "Panel does not support full-page mode",
859
+ description: `Panel "${e}" can render in the workspace, but it has not opted into the dedicated full-page pane route.`
860
+ }
861
+ ) : l ? /* @__PURE__ */ c(
862
+ Oe,
863
+ {
864
+ code: Mr,
865
+ title: "Panel failed to render",
866
+ description: `Panel "${e}" crashed while rendering in full-page mode: ${l.error.message}`
867
+ }
868
+ ) : /* @__PURE__ */ c("div", { className: "min-h-screen bg-background text-foreground", children: /* @__PURE__ */ c(ar, { mode: "full-page", children: /* @__PURE__ */ c(s, { ...i }) }) }) : /* @__PURE__ */ c(
869
+ Oe,
870
+ {
871
+ code: Fr,
872
+ title: "Unknown panel",
873
+ description: `No full-page panel component is registered as "${e}".`
466
874
  }
467
875
  );
468
876
  }
877
+ function Zr(e) {
878
+ var s;
879
+ const t = new URLSearchParams(e), r = ((s = t.get("component")) == null ? void 0 : s.trim()) ?? "";
880
+ if (!r)
881
+ return {
882
+ componentId: null,
883
+ params: {},
884
+ error: {
885
+ code: kr,
886
+ message: "Missing full-page panel component id."
887
+ }
888
+ };
889
+ const o = t.get("params");
890
+ if (!o)
891
+ return { componentId: r, params: {} };
892
+ let n;
893
+ try {
894
+ n = JSON.parse(o);
895
+ } catch {
896
+ return {
897
+ componentId: null,
898
+ params: {},
899
+ error: {
900
+ code: Wr,
901
+ message: "Invalid full-page panel params JSON."
902
+ }
903
+ };
904
+ }
905
+ return n === null || Array.isArray(n) || typeof n != "object" ? {
906
+ componentId: null,
907
+ params: {},
908
+ error: {
909
+ code: Ur,
910
+ message: "Full-page panel params must be a JSON object."
911
+ }
912
+ } : { componentId: r, params: n };
913
+ }
469
914
  export {
470
- xt as WorkspaceAgentFront,
471
- Wt as WorkspaceBootGate,
472
- pt as createLocalStorageSessions,
473
- ht as useLocalStorageSessions
915
+ Wr as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
916
+ kr as FULL_PAGE_PANEL_MISSING_COMPONENT,
917
+ Gr as FULL_PAGE_PANEL_NOT_SUPPORTED,
918
+ Ur as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
919
+ Mr as FULL_PAGE_PANEL_RENDER_FAILED,
920
+ Fr as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
921
+ zr as WorkspaceAgentFront,
922
+ Ar as WorkspaceBackgroundBoot,
923
+ Qr as WorkspaceBootGate,
924
+ Xr as WorkspaceFullPagePanel,
925
+ gr as createLocalStorageSessions,
926
+ Zr as parseFullPagePanelLocation,
927
+ br as useLocalStorageSessions
474
928
  };