@hachej/boring-workspace 0.1.22 → 0.1.24

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