@hachej/boring-workspace 0.1.33 → 0.1.35

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.
@@ -1,11 +1,11 @@
1
- import { jsxs as u, jsx as r, Fragment as ae } from "react/jsx-runtime";
2
- import { useState as M, useCallback as p, useMemo as G, useEffect as k, useRef as T, useSyncExternalStore as fe, Suspense as me } from "react";
3
- import { IconButton as E, LoadingState as ge, ResizeHandle as be, Button as we, Kbd as pe } from "@hachej/boring-ui-kit";
4
- import { ChevronLeft as ve, MessageSquare as xe, Search as ke, Plus as ye } from "lucide-react";
1
+ import { jsxs as h, jsx as a, Fragment as ce } from "react/jsx-runtime";
2
+ import { useState as V, useCallback as v, useMemo as Y, useEffect as C, useRef as Z, useSyncExternalStore as we, Suspense as ve } from "react";
3
+ import { IconButton as F, LoadingState as xe, ResizeHandle as pe, Button as Ce, Kbd as ke } from "@hachej/boring-ui-kit";
4
+ import { ChevronLeft as ye, MessageSquare as Se, Search as Pe, Plus as _e } from "lucide-react";
5
5
  import { c as m } from "./utils-B6yFEsav.js";
6
- import { al as Ce, a2 as Se, ad as _e, G as Ne, aw as oe, au as We, a7 as Pe, u as Oe, ao as Ie } from "./WorkspaceProvider-CuIZx1ua.js";
7
- function Fe(e, t, a = !0) {
8
- if (!a || typeof window > "u") return t;
6
+ import { al as Ne, a2 as We, ad as Ie, G as Oe, as as de, aG as Be, a7 as ze, aJ as Re, aK as Q, u as Le, ao as Ae } from "./WorkspaceProvider-BhRPFy5R.js";
7
+ function Ue(e, t, r = !0) {
8
+ if (!r || typeof window > "u") return t;
9
9
  try {
10
10
  const n = window.localStorage.getItem(e);
11
11
  if (n === "1") return !0;
@@ -14,66 +14,66 @@ function Fe(e, t, a = !0) {
14
14
  }
15
15
  return t;
16
16
  }
17
- function Ve(e, t, a = !0) {
18
- if (!(!a || typeof window > "u"))
17
+ function Xe(e, t, r = !0) {
18
+ if (!(!r || typeof window > "u"))
19
19
  try {
20
20
  window.localStorage.setItem(e, t ? "1" : "0");
21
21
  } catch {
22
22
  }
23
23
  }
24
- function ie(e, t, a = !0) {
25
- if (!a || typeof window > "u") return t;
24
+ function le(e, t, r = !0) {
25
+ if (!r || typeof window > "u") return t;
26
26
  try {
27
27
  const n = window.localStorage.getItem(e);
28
28
  if (n === null) return t;
29
- const c = Number(n);
30
- return Number.isFinite(c) ? c : t;
29
+ const d = Number(n);
30
+ return Number.isFinite(d) ? d : t;
31
31
  } catch {
32
32
  }
33
33
  return t;
34
34
  }
35
- function ze(e, t, a = !0) {
36
- if (!(!a || typeof window > "u"))
35
+ function De(e, t, r = !0) {
36
+ if (!(!r || typeof window > "u"))
37
37
  try {
38
38
  window.localStorage.setItem(e, String(Math.round(t)));
39
39
  } catch {
40
40
  }
41
41
  }
42
- function je(e = {}) {
42
+ function Ge(e = {}) {
43
43
  const {
44
44
  nav: t = "session-list",
45
- navParams: a,
45
+ navParams: r,
46
46
  center: n = "chat",
47
- centerParams: c,
47
+ centerParams: d,
48
48
  surface: i,
49
49
  surfaceParams: l,
50
50
  sidebar: s,
51
- sidebarParams: x
52
- } = e, v = [];
53
- return t && v.push({
51
+ sidebarParams: p
52
+ } = e, x = [];
53
+ return t && x.push({
54
54
  id: "nav",
55
55
  position: "left",
56
56
  panel: t,
57
- params: a,
57
+ params: r,
58
58
  locked: !0,
59
59
  hideHeader: !0,
60
60
  constraints: { minWidth: 60, maxWidth: 60 }
61
- }), v.push({
61
+ }), x.push({
62
62
  id: "center",
63
63
  position: "center",
64
64
  panel: n,
65
- params: c,
65
+ params: d,
66
66
  hideHeader: !0
67
- }), s && v.push({
67
+ }), s && x.push({
68
68
  id: "sidebar",
69
69
  position: "left",
70
70
  panel: s,
71
- params: x,
71
+ params: p,
72
72
  hideHeader: !0,
73
73
  collapsible: !0,
74
74
  collapsedWidth: 40,
75
75
  constraints: { minWidth: 200, maxWidthViewportRatio: 0.5 }
76
- }), i && v.push({
76
+ }), i && x.push({
77
77
  id: "surface",
78
78
  position: "right",
79
79
  panel: i,
@@ -81,156 +81,156 @@ function je(e = {}) {
81
81
  hideHeader: !0,
82
82
  dynamic: !0,
83
83
  placeholder: "empty"
84
- }), { version: "2.0", groups: v };
84
+ }), { version: "2.0", groups: x };
85
85
  }
86
- function $e(e) {
87
- var ne;
88
- const t = e.nav !== null, a = e.surface !== void 0, n = !!e.surface, c = e.nav || "session-list", i = e.center ?? "chat", l = e.surface || "artifact-surface", s = Re(), [x, v] = se(
86
+ function Te(e) {
87
+ var ie, se;
88
+ const t = e.nav !== null, r = e.surface !== void 0, n = !!e.surface, d = e.nav || "session-list", i = e.center ?? "chat", l = e.surface || "artifact-surface", s = Ee(), [p, x] = ue(
89
89
  e.storageKey ? `${e.storageKey}:drawerWidth` : void 0,
90
90
  260
91
- ), [le, ue] = se(
91
+ ), [me, ge] = ue(
92
92
  e.storageKey ? `${e.storageKey}:surfaceWidth` : void 0,
93
93
  680
94
- ), [d, g] = Be(
94
+ ), [c, g] = Me(
95
95
  e.storageKey ? `${e.storageKey}:chatCollapsed` : void 0,
96
96
  !1
97
- ), [he, N] = M(!1), { blockers: H } = Ce(), b = Se(), K = D(x, 200, 360), Z = Math.max(480, Math.floor(s * 0.72)), F = D(le, 480, Z), V = S(e.centerParams, "getSurface"), j = S(e.centerParams, "isWorkbenchOpen"), $ = S(e.centerParams, "openWorkbench"), J = S(e.centerParams, "openWorkbenchSources"), Q = S(e.centerParams, "closeWorkbench"), w = A(e.navParams, "onClose"), f = A(e.surfaceParams, "onClose"), y = A(e.sidebarParams, "onClose"), U = A(e.navParams, "onCreate"), C = !!e.sidebar, W = t ? !!w : !!e.onOpenNav, P = n ? !!f : !!e.onOpenSurface, O = C ? !!y : !!e.onOpenSidebar, I = p(() => {
97
+ ), [be, W] = V(!1), { blockers: j } = Ne(), b = We(), $ = M(p, 200, 360), te = Math.max(480, Math.floor(s * 0.72)), q = M(me, 480, te), U = S(e.centerParams, "getSurface"), X = S(e.centerParams, "isWorkbenchOpen"), G = S(e.centerParams, "openWorkbench"), ne = S(e.centerParams, "openWorkbenchSources"), ae = S(e.centerParams, "closeWorkbench"), w = E(e.navParams, "onClose"), f = E(e.surfaceParams, "onClose"), k = E(e.sidebarParams, "onClose"), T = E(e.navParams, "onCreate"), P = ((ie = e.chatPanes) == null ? void 0 : ie.filter((o) => o.id.length > 0)) ?? [], J = P.length > 0, y = !!e.sidebar, I = t ? !!w : !!e.onOpenNav, O = n ? !!f : !!e.onOpenSurface, B = y ? !!k : !!e.onOpenSidebar, z = v(() => {
98
98
  var o;
99
99
  if (t) {
100
100
  w == null || w();
101
101
  return;
102
102
  }
103
103
  (o = e.onOpenNav) == null || o.call(e);
104
- }, [w, t, e.onOpenNav]), z = p(() => {
104
+ }, [w, t, e.onOpenNav]), R = v(() => {
105
105
  var o;
106
106
  if (n) {
107
107
  f == null || f();
108
108
  return;
109
109
  }
110
110
  (o = e.onOpenSurface) == null || o.call(e);
111
- }, [f, e.onOpenSurface, n]), B = p(() => {
111
+ }, [f, e.onOpenSurface, n]), L = v(() => {
112
112
  var o;
113
- if (C) {
114
- y == null || y();
113
+ if (y) {
114
+ k == null || k();
115
115
  return;
116
116
  }
117
117
  (o = e.onOpenSidebar) == null || o.call(e);
118
- }, [y, e.onOpenSidebar, C]), R = p(() => {
119
- d && g(!1), t && (w == null || w()), n && (f == null || f()), Y(), de();
120
- }, [d, w, f, t, g, n]), L = p(() => {
118
+ }, [k, e.onOpenSidebar, y]), A = v(() => {
119
+ c && g(!1), t && (w == null || w()), n && (f == null || f()), ee(), fe();
120
+ }, [c, w, f, t, g, n]), D = v(() => {
121
121
  g((o) => {
122
- var re;
123
- const h = !o;
124
- return h && !n && ((re = e.onOpenSurface) == null || re.call(e)), h;
125
- }), N(!1);
122
+ var N;
123
+ const u = !o;
124
+ return u && !n && ((N = e.onOpenSurface) == null || N.call(e)), u;
125
+ }), W(!1);
126
126
  }, [g, n, e.onOpenSurface]);
127
- _e({
128
- shortcuts: G(() => {
127
+ Ie({
128
+ shortcuts: Y(() => {
129
129
  const o = [];
130
- return W && o.push({ key: "1", mod: !0, handler: I }), P && o.push({ key: "2", mod: !0, handler: z }), O && o.push({ key: "3", mod: !0, allowInEditable: !0, handler: B }), i === "chat" && (o.push({ key: "Escape", allowInEditable: !0, handler: R }), o.push({ key: "\\", mod: !0, allowInEditable: !0, handler: L })), o;
131
- }, [W, O, P, i, R, L, I, B, z])
132
- }), k(() => {
133
- const o = "workspace:chat-layout", h = "agent:chat-layout";
134
- return b.unregisterByPluginId(o), b.unregisterByPluginId(h), b.registerCommand({
130
+ return I && o.push({ key: "1", mod: !0, handler: z }), O && o.push({ key: "2", mod: !0, handler: R }), B && o.push({ key: "3", mod: !0, allowInEditable: !0, handler: L }), i === "chat" && (o.push({ key: "Escape", allowInEditable: !0, handler: A }), o.push({ key: "\\", mod: !0, allowInEditable: !0, handler: D })), o;
131
+ }, [I, B, O, i, A, D, z, L, R])
132
+ }), C(() => {
133
+ const o = "workspace:chat-layout", u = "agent:chat-layout";
134
+ return b.unregisterByPluginId(o), b.unregisterByPluginId(u), b.registerCommand({
135
135
  id: "workspace:open-session-history",
136
136
  title: t ? "Close Session History" : "Open Session History",
137
137
  keywords: ["sessions", "history", "drawer", t ? "close" : "open"],
138
138
  shortcut: "⌘1",
139
139
  pluginId: o,
140
- when: () => W,
141
- run: I
140
+ when: () => I,
141
+ run: z
142
142
  }), b.registerCommand({
143
143
  id: "workspace:open-workbench",
144
144
  title: n ? "Close Workbench" : "Open Workbench",
145
145
  keywords: ["surface", "artifacts", "sources", "workbench", n ? "close" : "open"],
146
146
  shortcut: "⌘2",
147
147
  pluginId: o,
148
- when: () => P,
149
- run: z
148
+ when: () => O,
149
+ run: R
150
150
  }), b.registerCommand({
151
151
  id: "workspace:toggle-workbench-left-panel",
152
- title: C ? "Close Workbench Left Panel" : "Open Workbench Left Panel",
153
- keywords: ["left", "sidebar", "tabs", "workbench", C ? "close" : "open"],
152
+ title: y ? "Close Workbench Left Panel" : "Open Workbench Left Panel",
153
+ keywords: ["left", "sidebar", "tabs", "workbench", y ? "close" : "open"],
154
154
  shortcut: "⌘3",
155
155
  pluginId: o,
156
- when: () => O,
157
- run: B
156
+ when: () => B,
157
+ run: L
158
158
  }), i === "chat" && b.registerCommand({
159
159
  id: "agent:focus-chat",
160
160
  title: "Focus Chat",
161
161
  keywords: ["agent", "chat", "prompt", "composer", "input", "focus"],
162
- pluginId: h,
163
- run: R
164
- }), U && b.registerCommand({
162
+ pluginId: u,
163
+ run: A
164
+ }), T && b.registerCommand({
165
165
  id: "agent:new-chat",
166
166
  title: "New Chat",
167
167
  keywords: ["agent", "chat", "session", "new"],
168
- pluginId: h,
169
- run: U
168
+ pluginId: u,
169
+ run: T
170
170
  }), () => {
171
- b.unregisterByPluginId(o), b.unregisterByPluginId(h);
171
+ b.unregisterByPluginId(o), b.unregisterByPluginId(u);
172
172
  };
173
173
  }, [
174
174
  b,
175
175
  t,
176
176
  i,
177
- a,
177
+ r,
178
178
  n,
179
179
  e.navParams,
180
180
  e.surfaceParams,
181
181
  e.onOpenNav,
182
182
  e.onOpenSurface,
183
183
  e.onOpenSidebar,
184
- W,
185
- P,
184
+ I,
186
185
  O,
186
+ B,
187
187
  w,
188
188
  f,
189
+ k,
190
+ T,
191
+ A,
189
192
  y,
190
- U,
191
- R,
192
- C,
193
- I,
194
193
  z,
195
- B
196
- ]), k(() => {
197
- if (!V || !j || !$) return;
194
+ R,
195
+ L
196
+ ]), C(() => {
197
+ if (!U || !X || !G) return;
198
198
  const o = {
199
- surface: V,
200
- isWorkbenchOpen: j,
201
- openWorkbench: $,
202
- openWorkbenchSources: J,
203
- closeWorkbench: Q
199
+ surface: U,
200
+ isWorkbenchOpen: X,
201
+ openWorkbench: G,
202
+ openWorkbenchSources: ne,
203
+ closeWorkbench: ae
204
204
  };
205
- return Ne.on(oe.uiCommand, ({ command: h }) => {
206
- We(h, o);
205
+ return Oe.on(de.uiCommand, ({ command: u }) => {
206
+ Be(u, o);
207
207
  });
208
- }, [V, j, $, J, Q]), Pe(oe.agentData, () => {
209
- d && N(!0);
210
- }), k(() => {
211
- if (!d) {
212
- N(!1);
208
+ }, [U, X, G, ne, ae]), ze(de.agentData, () => {
209
+ c && W(!0);
210
+ }), C(() => {
211
+ if (!c) {
212
+ W(!1);
213
213
  return;
214
214
  }
215
- H.length > 0 && (g(!1), N(!1), de());
216
- }, [H.length, d, g]);
217
- const _ = (ne = e.centerParams) == null ? void 0 : ne.sessionId, ee = T(_);
218
- k(() => {
219
- const o = ee.current;
220
- ee.current = _, o !== void 0 && _ !== void 0 && _ !== o && d && g(!1);
221
- }, [_, d, g]);
222
- const te = T(n);
223
- return k(() => {
224
- const o = te.current;
225
- te.current = n, o && !n && d && g(!1);
226
- }, [n, d, g]), /* @__PURE__ */ u(
215
+ j.length > 0 && (g(!1), W(!1), fe());
216
+ }, [j.length, c, g]);
217
+ const _ = e.activeChatPaneId ?? ((se = e.centerParams) == null ? void 0 : se.sessionId), re = Z(_);
218
+ C(() => {
219
+ const o = re.current;
220
+ re.current = _, o !== void 0 && _ !== void 0 && _ !== o && c && g(!1);
221
+ }, [_, c, g]);
222
+ const oe = Z(n);
223
+ return C(() => {
224
+ const o = oe.current;
225
+ oe.current = n, o && !n && c && g(!1);
226
+ }, [n, c, g]), /* @__PURE__ */ h(
227
227
  "div",
228
228
  {
229
229
  "data-boring-workspace": "",
230
230
  "data-boring-workspace-part": "shell",
231
231
  className: m("relative flex h-full min-h-0 w-full overflow-hidden bg-background", e.className),
232
232
  children: [
233
- /* @__PURE__ */ u(
233
+ /* @__PURE__ */ h(
234
234
  "aside",
235
235
  {
236
236
  "data-boring-workspace-part": "session-drawer",
@@ -243,13 +243,13 @@ function $e(e) {
243
243
  t && "border-r border-[color:oklch(from_var(--border)_l_c_h/0.6)]"
244
244
  ),
245
245
  style: {
246
- width: t ? K : 0,
247
- minWidth: t ? K : 0,
248
- maxWidth: t ? K : 0,
246
+ width: t ? $ : 0,
247
+ minWidth: t ? $ : 0,
248
+ maxWidth: t ? $ : 0,
249
249
  willChange: "width"
250
250
  },
251
251
  children: [
252
- /* @__PURE__ */ r(
252
+ /* @__PURE__ */ a(
253
253
  "div",
254
254
  {
255
255
  className: m(
@@ -257,64 +257,85 @@ function $e(e) {
257
257
  "transition-opacity duration-[200ms] ease-[cubic-bezier(0.22,1,0.36,1)]",
258
258
  t ? "opacity-100" : "opacity-0"
259
259
  ),
260
- children: /* @__PURE__ */ r(X, { id: c, params: e.navParams })
260
+ children: /* @__PURE__ */ a(K, { id: d, params: e.navParams })
261
261
  }
262
262
  ),
263
- t ? /* @__PURE__ */ r(
264
- ce,
263
+ t ? /* @__PURE__ */ a(
264
+ he,
265
265
  {
266
266
  side: "drawer-right",
267
267
  ariaLabel: "Resize sessions drawer",
268
- onResize: (o) => v((h) => D(h + o, 200, 360))
268
+ onResize: (o) => x((u) => M(u + o, 200, 360))
269
269
  }
270
270
  ) : null
271
271
  ]
272
272
  }
273
273
  ),
274
- /* @__PURE__ */ u("div", { className: "relative flex h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-background", children: [
275
- /* @__PURE__ */ u(
274
+ /* @__PURE__ */ h("div", { className: "relative flex h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-background", children: [
275
+ /* @__PURE__ */ h(
276
276
  "main",
277
277
  {
278
278
  "data-boring-workspace-part": "chat-stage",
279
- "data-boring-state": d ? "collapsed" : "expanded",
280
- "aria-label": d ? "Collapsed chat" : "Chat",
281
- "aria-hidden": d,
279
+ "data-boring-state": c ? "collapsed" : "expanded",
280
+ "aria-label": c ? "Collapsed chat" : "Chat",
281
+ "aria-hidden": c,
282
282
  className: m(
283
283
  "relative h-full min-h-0 min-w-0 overflow-hidden bg-background",
284
284
  // Animate flex-grow (not just width) so the chat slides open/closed
285
285
  // like the fixed-width nav/workbench panes instead of snapping.
286
286
  "transition-[flex-grow,flex-basis,width,min-width,max-width] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]",
287
- d ? "min-w-0 flex-[0_0_0px]" : "flex-1 border-r border-[color:oklch(from_var(--border)_l_c_h/0.6)]"
287
+ c ? "min-w-0 flex-[0_0_0px]" : "flex-1 border-r border-[color:oklch(from_var(--border)_l_c_h/0.6)]"
288
288
  ),
289
289
  children: [
290
- /* @__PURE__ */ r(
290
+ /* @__PURE__ */ a(
291
291
  "div",
292
292
  {
293
293
  className: m(
294
294
  "h-full min-h-0 overflow-hidden",
295
295
  "transition-opacity duration-[200ms] ease-[cubic-bezier(0.22,1,0.36,1)]",
296
- d ? "opacity-0" : "opacity-100"
296
+ c ? "opacity-0" : "opacity-100"
297
297
  ),
298
- children: /* @__PURE__ */ r(X, { id: i, params: e.centerParams })
298
+ children: J ? /* @__PURE__ */ a(
299
+ Re,
300
+ {
301
+ panes: P,
302
+ activePaneId: e.activeChatPaneId,
303
+ onActivePaneChange: e.onActiveChatPaneChange,
304
+ onClosePane: e.onCloseChatPane,
305
+ flashPaneId: e.flashChatPaneId,
306
+ storageKey: e.storageKey,
307
+ onDropSession: e.onDropChatSession,
308
+ engine: e.chatPaneEngine,
309
+ renderPane: (o) => /* @__PURE__ */ a(
310
+ K,
311
+ {
312
+ id: o.panel ?? i,
313
+ params: o.params ?? e.centerParams
314
+ }
315
+ )
316
+ }
317
+ ) : /* @__PURE__ */ a(K, { id: i, params: e.centerParams })
299
318
  }
300
319
  ),
301
- d ? null : /* @__PURE__ */ r(
302
- E,
320
+ c ? null : /* @__PURE__ */ a(Q, { label: "Collapse chat", hint: "⌘\\", side: "bottom", children: /* @__PURE__ */ a(
321
+ F,
303
322
  {
304
323
  type: "button",
305
324
  variant: "ghost",
306
325
  size: "icon-xs",
307
- onClick: L,
308
- className: "absolute right-2 top-2 z-20",
326
+ onClick: D,
327
+ className: m(
328
+ "absolute right-2 z-30 rounded-full bg-background/80 text-muted-foreground shadow-sm backdrop-blur hover:bg-muted hover:text-foreground",
329
+ J && P.length > 1 ? "bottom-2" : "top-2"
330
+ ),
309
331
  "aria-label": "Collapse chat",
310
- title: "Collapse chat (⌘\\\\)",
311
- children: /* @__PURE__ */ r(ve, { className: "h-4 w-4", strokeWidth: 1.75 })
332
+ children: /* @__PURE__ */ a(ye, { className: "h-4 w-4", strokeWidth: 1.75 })
312
333
  }
313
- )
334
+ ) })
314
335
  ]
315
336
  }
316
337
  ),
317
- a ? /* @__PURE__ */ u(
338
+ r ? /* @__PURE__ */ h(
318
339
  "aside",
319
340
  {
320
341
  "data-boring-workspace-part": "workbench",
@@ -325,18 +346,18 @@ function $e(e) {
325
346
  "relative h-full min-h-0 overflow-hidden bg-background",
326
347
  // When chat is collapsed the workbench grows to fill the freed
327
348
  // space (full width); otherwise it's a fixed-width side panel.
328
- d && n ? "min-w-0 flex-1" : "shrink-0",
349
+ c && n ? "min-w-0 flex-1" : "shrink-0",
329
350
  "transition-[flex-grow,flex-basis,width,min-width,max-width] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]",
330
351
  n && "border-l border-[color:oklch(from_var(--border)_l_c_h/0.6)]"
331
352
  ),
332
- style: d && n ? { willChange: "width" } : {
333
- width: n ? F : 0,
334
- minWidth: n ? F : 0,
335
- maxWidth: n ? F : 0,
353
+ style: c && n ? { willChange: "width" } : {
354
+ width: n ? q : 0,
355
+ minWidth: n ? q : 0,
356
+ maxWidth: n ? q : 0,
336
357
  willChange: "width"
337
358
  },
338
359
  children: [
339
- /* @__PURE__ */ r(
360
+ /* @__PURE__ */ a(
340
361
  "div",
341
362
  {
342
363
  className: m(
@@ -346,12 +367,12 @@ function $e(e) {
346
367
  // When the chat is collapsed the workbench fills the full width
347
368
  // and the left-edge "expand chat" float button would sit on top
348
369
  // of the filetree — inset the content to leave a clear gutter.
349
- d && n && !t && "pl-14"
370
+ c && n && !t && "pl-14"
350
371
  ),
351
- children: e.surfaceOverlay ? /* @__PURE__ */ u("div", { className: "relative h-full min-h-0", children: [
372
+ children: e.surfaceOverlay ? /* @__PURE__ */ h("div", { className: "relative h-full min-h-0", children: [
352
373
  e.surfaceOverlay,
353
- f ? /* @__PURE__ */ r(
354
- E,
374
+ f ? /* @__PURE__ */ a(Q, { label: "Close workbench", hint: "⌘2", side: "left", children: /* @__PURE__ */ a(
375
+ F,
355
376
  {
356
377
  type: "button",
357
378
  variant: "ghost",
@@ -359,27 +380,26 @@ function $e(e) {
359
380
  onClick: f,
360
381
  className: "absolute right-3 top-3 z-20 rounded-full bg-background/80 text-muted-foreground shadow-sm backdrop-blur hover:bg-muted hover:text-foreground",
361
382
  "aria-label": "Close workbench",
362
- title: "Close workbench (⌘2)",
363
- children: /* @__PURE__ */ r("span", { "aria-hidden": "true", children: "›" })
383
+ children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" })
364
384
  }
365
- ) : null
366
- ] }) : /* @__PURE__ */ r(X, { id: l, params: e.surfaceParams })
385
+ ) }) : null
386
+ ] }) : /* @__PURE__ */ a(K, { id: l, params: e.surfaceParams })
367
387
  }
368
388
  ),
369
- n && !d ? /* @__PURE__ */ r(
370
- ce,
389
+ n && !c ? /* @__PURE__ */ a(
390
+ he,
371
391
  {
372
392
  side: "surface-left",
373
393
  ariaLabel: "Resize workbench",
374
- onResize: (o) => ue((h) => D(h - o, 480, Z))
394
+ onResize: (o) => ge((u) => M(u - o, 480, te))
375
395
  }
376
396
  ) : null
377
397
  ]
378
398
  }
379
399
  ) : null
380
400
  ] }),
381
- !t && e.onOpenNav ? /* @__PURE__ */ r(
382
- q,
401
+ !t && e.onOpenNav ? /* @__PURE__ */ a(
402
+ H,
383
403
  {
384
404
  side: "left",
385
405
  icon: "sessions",
@@ -388,20 +408,34 @@ function $e(e) {
388
408
  hint: "⌘1"
389
409
  }
390
410
  ) : null,
391
- d ? /* @__PURE__ */ r(
392
- q,
411
+ !c && !t && J && e.onCreateChatPaneAfter ? /* @__PURE__ */ a(
412
+ H,
413
+ {
414
+ side: "left",
415
+ icon: "plus",
416
+ onClick: () => {
417
+ var u, N;
418
+ const o = e.activeChatPaneId ?? ((u = P[P.length - 1]) == null ? void 0 : u.id);
419
+ o && ((N = e.onCreateChatPaneAfter) == null || N.call(e, o));
420
+ },
421
+ label: "New chat",
422
+ stackIndex: e.onOpenNav ? 1 : 0
423
+ }
424
+ ) : null,
425
+ c ? /* @__PURE__ */ a(
426
+ H,
393
427
  {
394
428
  side: "left",
395
429
  icon: "chat",
396
- onClick: L,
430
+ onClick: D,
397
431
  label: "Expand chat",
398
432
  hint: "⌘\\\\",
399
433
  stackIndex: 1,
400
- pulse: he || H.length > 0
434
+ pulse: be || j.length > 0
401
435
  }
402
436
  ) : null,
403
- !n && e.onOpenSurface ? /* @__PURE__ */ r(
404
- q,
437
+ !n && e.onOpenSurface ? /* @__PURE__ */ a(
438
+ H,
405
439
  {
406
440
  side: "right",
407
441
  icon: "workbench",
@@ -415,30 +449,30 @@ function $e(e) {
415
449
  }
416
450
  );
417
451
  }
418
- function D(e, t, a) {
419
- return Math.max(t, Math.min(a, e));
452
+ function M(e, t, r) {
453
+ return Math.max(t, Math.min(r, e));
420
454
  }
421
- function se(e, t) {
422
- const [a, n] = M(
423
- () => e ? ie(e, t) : t
455
+ function ue(e, t) {
456
+ const [r, n] = V(
457
+ () => e ? le(e, t) : t
424
458
  );
425
- k(() => {
426
- n(e ? ie(e, t) : t);
459
+ C(() => {
460
+ n(e ? le(e, t) : t);
427
461
  }, [e, t]);
428
- const c = p(
462
+ const d = v(
429
463
  (i) => {
430
464
  n((l) => {
431
465
  const s = typeof i == "function" ? i(l) : i;
432
- return e && ze(e, s), s;
466
+ return e && De(e, s), s;
433
467
  });
434
468
  },
435
469
  [e]
436
470
  );
437
- return [a, c];
471
+ return [r, d];
438
472
  }
439
- function Be(e, t) {
440
- const [a, n] = M(() => !e || typeof window > "u" ? t : window.localStorage.getItem(e) === "1");
441
- k(() => {
473
+ function Me(e, t) {
474
+ const [r, n] = V(() => !e || typeof window > "u" ? t : window.localStorage.getItem(e) === "1");
475
+ C(() => {
442
476
  if (!e || typeof window > "u") {
443
477
  n(t);
444
478
  return;
@@ -446,7 +480,7 @@ function Be(e, t) {
446
480
  const i = window.localStorage.getItem(e);
447
481
  n(i == null ? t : i === "1");
448
482
  }, [e, t]);
449
- const c = p(
483
+ const d = v(
450
484
  (i) => {
451
485
  n((l) => {
452
486
  const s = typeof i == "function" ? i(l) : i;
@@ -455,31 +489,31 @@ function Be(e, t) {
455
489
  },
456
490
  [e]
457
491
  );
458
- return [a, c];
492
+ return [r, d];
459
493
  }
460
- function Re() {
461
- const [e, t] = M(() => typeof window < "u" ? window.innerWidth : 1200);
462
- return k(() => {
463
- const a = () => t(window.innerWidth);
464
- return window.addEventListener("resize", a), () => window.removeEventListener("resize", a);
494
+ function Ee() {
495
+ const [e, t] = V(() => typeof window < "u" ? window.innerWidth : 1200);
496
+ return C(() => {
497
+ const r = () => t(window.innerWidth);
498
+ return window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
465
499
  }, []), e;
466
500
  }
467
- function ce({ side: e, ariaLabel: t, onResize: a }) {
468
- const n = T(null), c = p((s) => {
501
+ function he({ side: e, ariaLabel: t, onResize: r }) {
502
+ const n = Z(null), d = v((s) => {
469
503
  s.preventDefault(), n.current = s.clientX, s.currentTarget.setPointerCapture(s.pointerId), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
470
- }, []), i = p((s) => {
504
+ }, []), i = v((s) => {
471
505
  if (n.current === null) return;
472
- const x = s.clientX - n.current;
473
- n.current = s.clientX, a(x);
474
- }, [a]), l = p((s) => {
506
+ const p = s.clientX - n.current;
507
+ n.current = s.clientX, r(p);
508
+ }, [r]), l = v((s) => {
475
509
  n.current !== null && (n.current = null, s.currentTarget.releasePointerCapture(s.pointerId), document.body.style.cursor = "", document.body.style.userSelect = "");
476
510
  }, []);
477
- return /* @__PURE__ */ r(
478
- be,
511
+ return /* @__PURE__ */ a(
512
+ pe,
479
513
  {
480
514
  "aria-label": t,
481
515
  orientation: "vertical",
482
- onResizeStart: c,
516
+ onResizeStart: d,
483
517
  onPointerMove: i,
484
518
  onPointerUp: l,
485
519
  onPointerCancel: l,
@@ -494,31 +528,33 @@ function ce({ side: e, ariaLabel: t, onResize: a }) {
494
528
  );
495
529
  }
496
530
  function S(e, t) {
497
- const a = e == null ? void 0 : e[t];
498
- return typeof a == "function" ? a : void 0;
531
+ const r = e == null ? void 0 : e[t];
532
+ return typeof r == "function" ? r : void 0;
499
533
  }
500
- function A(e, t) {
534
+ function E(e, t) {
501
535
  return S(e, t);
502
536
  }
503
- function Y() {
537
+ function ee() {
504
538
  if (typeof document > "u") return;
505
- const e = document.querySelector(
539
+ const r = (document.querySelector(
540
+ '[data-boring-workspace-part="chat-pane"][data-boring-state="active"]'
541
+ ) ?? document).querySelector(
506
542
  '[data-boring-agent] textarea[name="message"], textarea[name="message"]'
507
543
  );
508
- e == null || e.focus();
544
+ r == null || r.focus();
509
545
  }
510
- function de() {
546
+ function fe() {
511
547
  typeof window > "u" || window.requestAnimationFrame(() => {
512
- Y(), window.setTimeout(Y, 320);
548
+ ee(), window.setTimeout(ee, 320);
513
549
  });
514
550
  }
515
- function X({ id: e, params: t }) {
516
- const a = Oe(), { debug: n } = Ie(), c = fe(
517
- a.subscribe,
518
- a.getSnapshot,
519
- a.getSnapshot
520
- ), l = G(() => a.getComponents(), [a, c])[e], s = G(() => Le(e), [e]);
521
- return l ? /* @__PURE__ */ r(me, { fallback: /* @__PURE__ */ r(ge, { centered: !0 }), children: /* @__PURE__ */ r(
551
+ function K({ id: e, params: t }) {
552
+ const r = Le(), { debug: n } = Ae(), d = we(
553
+ r.subscribe,
554
+ r.getSnapshot,
555
+ r.getSnapshot
556
+ ), l = Y(() => r.getComponents(), [r, d])[e], s = Y(() => Ke(e), [e]);
557
+ return l ? /* @__PURE__ */ a(ve, { fallback: /* @__PURE__ */ a(xe, { centered: !0 }), children: /* @__PURE__ */ a(
522
558
  l,
523
559
  {
524
560
  params: { ...t, debug: n },
@@ -527,7 +563,7 @@ function X({ id: e, params: t }) {
527
563
  }
528
564
  ) }) : null;
529
565
  }
530
- function Le(e) {
566
+ function Ke(e) {
531
567
  return {
532
568
  id: e,
533
569
  title: e,
@@ -563,56 +599,55 @@ function Le(e) {
563
599
  } })
564
600
  };
565
601
  }
566
- function q({
602
+ function H({
567
603
  side: e,
568
604
  icon: t,
569
- onClick: a,
605
+ onClick: r,
570
606
  label: n,
571
- hint: c,
607
+ hint: d,
572
608
  bottomOffset: i,
573
609
  stackIndex: l = 0,
574
610
  pulse: s = !1
575
611
  }) {
576
- const x = e === "right" && i !== void 0, v = l * 44;
577
- return /* @__PURE__ */ r(
578
- E,
612
+ const p = e === "right" && i !== void 0, x = l * 44;
613
+ return /* @__PURE__ */ a(Q, { label: n, hint: d, side: e === "left" ? "right" : "left", children: /* @__PURE__ */ a(
614
+ F,
579
615
  {
580
616
  type: "button",
581
617
  variant: "ghost",
582
618
  size: "icon-sm",
583
- onClick: a,
619
+ onClick: r,
584
620
  "aria-label": n,
585
- title: c ? `${n} (${c})` : n,
586
621
  className: m(
587
622
  "absolute z-30 h-9 w-9 gap-0.5 rounded-lg bg-background text-muted-foreground",
588
623
  e === "left" ? "left-2" : "right-2",
589
- x ? "hover:-translate-y-0.5" : "top-1/2 hover:-translate-y-[1px]",
624
+ p ? "hover:-translate-y-0.5" : "top-1/2 hover:-translate-y-[1px]",
590
625
  "shadow-[0_1px_2px_-1px_oklch(0_0_0/0.08),0_2px_8px_-4px_oklch(0_0_0/0.10),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.7)]",
591
626
  "hover:bg-muted/60 hover:text-foreground hover:shadow-[0_2px_4px_-1px_oklch(0_0_0/0.08),0_4px_12px_-4px_oklch(0_0_0/0.10),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.9)]",
592
627
  "focus-visible:ring-ring/40"
593
628
  ),
594
- style: x ? { bottom: i } : { transform: `translateY(calc(-50% - ${v}px))` },
595
- children: t === "sessions" ? /* @__PURE__ */ u("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
596
- /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "1.8" }),
597
- /* @__PURE__ */ r("path", { d: "M12 7v5l3.2 2", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
598
- ] }) : t === "chat" ? /* @__PURE__ */ u("span", { className: "relative flex items-center justify-center", children: [
599
- /* @__PURE__ */ r(xe, { className: "h-[15px] w-[15px]", strokeWidth: 1.8, "aria-hidden": "true" }),
600
- s ? /* @__PURE__ */ r("span", { className: "absolute -right-1.5 -top-1.5 h-2 w-2 rounded-full bg-[color:var(--accent)]", "aria-hidden": "true" }) : null
601
- ] }) : /* @__PURE__ */ r("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M3 7.5 A1.5 1.5 0 0 1 4.5 6 h4 l2 2 h9 A1.5 1.5 0 0 1 21 9.5 V17.5 A1.5 1.5 0 0 1 19.5 19 H4.5 A1.5 1.5 0 0 1 3 17.5 Z", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round" }) })
629
+ style: p ? { bottom: i } : { transform: `translateY(calc(-50% - ${x}px))` },
630
+ children: t === "sessions" ? /* @__PURE__ */ h("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
631
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "1.8" }),
632
+ /* @__PURE__ */ a("path", { d: "M12 7v5l3.2 2", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
633
+ ] }) : t === "chat" ? /* @__PURE__ */ h("span", { className: "relative flex items-center justify-center", children: [
634
+ /* @__PURE__ */ a(Se, { className: "h-[15px] w-[15px]", strokeWidth: 1.8, "aria-hidden": "true" }),
635
+ s ? /* @__PURE__ */ a("span", { className: "absolute -right-1.5 -top-1.5 h-2 w-2 rounded-full bg-[color:var(--accent)]", "aria-hidden": "true" }) : null
636
+ ] }) : t === "plus" ? /* @__PURE__ */ a("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" }) }) : /* @__PURE__ */ a("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ a("path", { d: "M3 7.5 A1.5 1.5 0 0 1 4.5 6 h4 l2 2 h9 A1.5 1.5 0 0 1 21 9.5 V17.5 A1.5 1.5 0 0 1 19.5 19 H4.5 A1.5 1.5 0 0 1 3 17.5 Z", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round" }) })
602
637
  }
603
- );
638
+ ) });
604
639
  }
605
- function Ue({
640
+ function Je({
606
641
  appTitle: e = "Boring",
607
642
  sessionTitle: t,
608
- onCommandPalette: a,
643
+ onCommandPalette: r,
609
644
  onNewChat: n,
610
- topBarLeft: c,
645
+ topBarLeft: d,
611
646
  topBarRight: i,
612
647
  className: l
613
648
  }) {
614
649
  const s = i ?? null;
615
- return /* @__PURE__ */ u(
650
+ return /* @__PURE__ */ h(
616
651
  "header",
617
652
  {
618
653
  "data-boring-workspace-part": "topbar",
@@ -623,8 +658,8 @@ function Ue({
623
658
  ),
624
659
  "aria-label": "App top bar",
625
660
  children: [
626
- /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1 items-center gap-2.5 leading-none", children: c ?? /* @__PURE__ */ u(ae, { children: [
627
- /* @__PURE__ */ r(
661
+ /* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1 items-center gap-2.5 leading-none", children: d ?? /* @__PURE__ */ h(ce, { children: [
662
+ /* @__PURE__ */ a(
628
663
  "span",
629
664
  {
630
665
  "aria-hidden": "true",
@@ -632,32 +667,32 @@ function Ue({
632
667
  children: ((e == null ? void 0 : e[0]) ?? "B").toUpperCase()
633
668
  }
634
669
  ),
635
- t ? /* @__PURE__ */ u(ae, { children: [
636
- /* @__PURE__ */ r("span", { className: "shrink-0 text-[13px] font-medium leading-none tracking-tight text-foreground/65", children: e }),
637
- /* @__PURE__ */ r("span", { "aria-hidden": "true", className: "text-[13px] leading-none text-muted-foreground/45", children: "·" }),
638
- /* @__PURE__ */ r("span", { className: "truncate text-[13px] font-medium leading-none tracking-tight text-foreground", children: t })
639
- ] }) : /* @__PURE__ */ r("span", { className: "truncate text-[13px] font-medium leading-none tracking-tight text-foreground", children: e })
670
+ t ? /* @__PURE__ */ h(ce, { children: [
671
+ /* @__PURE__ */ a("span", { className: "shrink-0 text-[13px] font-medium leading-none tracking-tight text-foreground/65", children: e }),
672
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "text-[13px] leading-none text-muted-foreground/45", children: "·" }),
673
+ /* @__PURE__ */ a("span", { className: "truncate text-[13px] font-medium leading-none tracking-tight text-foreground", children: t })
674
+ ] }) : /* @__PURE__ */ a("span", { className: "truncate text-[13px] font-medium leading-none tracking-tight text-foreground", children: e })
640
675
  ] }) }),
641
- /* @__PURE__ */ u(
642
- we,
676
+ /* @__PURE__ */ h(
677
+ Ce,
643
678
  {
644
679
  type: "button",
645
680
  variant: "ghost",
646
681
  size: "sm",
647
- onClick: a,
682
+ onClick: r,
648
683
  className: "group h-7 gap-1.5 px-2 text-[13px] leading-none text-muted-foreground/75 hover:bg-muted/70 hover:text-foreground focus-visible:text-foreground",
649
684
  "aria-label": "Search catalogs and commands",
650
685
  title: "Command palette (⌘K)",
651
686
  children: [
652
- /* @__PURE__ */ r(ke, { className: "h-3.5 w-3.5 shrink-0 opacity-80", strokeWidth: 1.75 }),
653
- /* @__PURE__ */ r("span", { className: "font-normal tracking-tight", children: "Search" }),
654
- /* @__PURE__ */ r(pe, { className: "ml-0.5 bg-muted/40 leading-none shadow-none", children: "⌘K" })
687
+ /* @__PURE__ */ a(Pe, { className: "h-3.5 w-3.5 shrink-0 opacity-80", strokeWidth: 1.75 }),
688
+ /* @__PURE__ */ a("span", { className: "font-normal tracking-tight", children: "Search" }),
689
+ /* @__PURE__ */ a(ke, { className: "ml-0.5 bg-muted/40 leading-none shadow-none", children: "⌘K" })
655
690
  ]
656
691
  }
657
692
  ),
658
- /* @__PURE__ */ u("div", { className: "flex flex-1 shrink-0 items-center justify-end gap-1", children: [
659
- n && /* @__PURE__ */ r(
660
- E,
693
+ /* @__PURE__ */ h("div", { className: "flex flex-1 shrink-0 items-center justify-end gap-1", children: [
694
+ n && /* @__PURE__ */ a(
695
+ F,
661
696
  {
662
697
  type: "button",
663
698
  variant: "ghost",
@@ -665,7 +700,7 @@ function Ue({
665
700
  onClick: n,
666
701
  "aria-label": "New chat",
667
702
  title: "New chat",
668
- children: /* @__PURE__ */ r(ye, { className: "h-4 w-4" })
703
+ children: /* @__PURE__ */ a(_e, { className: "h-4 w-4" })
669
704
  }
670
705
  ),
671
706
  s
@@ -674,14 +709,14 @@ function Ue({
674
709
  }
675
710
  );
676
711
  }
677
- function Xe({
712
+ function Ye({
678
713
  title: e = "Loading workspace",
679
714
  description: t = "Preparing the workspace context.",
680
- status: a = "Loading",
715
+ status: r = "Loading",
681
716
  fullscreen: n = !0,
682
- className: c
717
+ className: d
683
718
  }) {
684
- return /* @__PURE__ */ r(
719
+ return /* @__PURE__ */ a(
685
720
  "section",
686
721
  {
687
722
  role: "status",
@@ -690,30 +725,30 @@ function Xe({
690
725
  className: m(
691
726
  "flex h-full w-full items-center justify-center bg-background px-6 text-foreground",
692
727
  n ? "min-h-screen" : "min-h-[240px]",
693
- c
728
+ d
694
729
  ),
695
- children: /* @__PURE__ */ u("div", { className: "flex w-full max-w-sm flex-col items-center gap-5 text-center", children: [
696
- /* @__PURE__ */ r("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg border border-border bg-card text-foreground", children: /* @__PURE__ */ r(
730
+ children: /* @__PURE__ */ h("div", { className: "flex w-full max-w-sm flex-col items-center gap-5 text-center", children: [
731
+ /* @__PURE__ */ a("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg border border-border bg-card text-foreground", children: /* @__PURE__ */ a(
697
732
  "span",
698
733
  {
699
734
  "aria-hidden": "true",
700
735
  className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent opacity-70"
701
736
  }
702
737
  ) }),
703
- /* @__PURE__ */ u("div", { className: "space-y-2", children: [
704
- /* @__PURE__ */ r("h2", { className: "text-base font-medium text-foreground", children: e }),
705
- t ? /* @__PURE__ */ r("p", { className: "text-sm leading-6 text-muted-foreground", children: t }) : null
738
+ /* @__PURE__ */ h("div", { className: "space-y-2", children: [
739
+ /* @__PURE__ */ a("h2", { className: "text-base font-medium text-foreground", children: e }),
740
+ t ? /* @__PURE__ */ a("p", { className: "text-sm leading-6 text-muted-foreground", children: t }) : null
706
741
  ] }),
707
- a ? /* @__PURE__ */ r("p", { className: "text-xs font-medium text-muted-foreground/80", children: a }) : null
742
+ r ? /* @__PURE__ */ a("p", { className: "text-xs font-medium text-muted-foreground/80", children: r }) : null
708
743
  ] })
709
744
  }
710
745
  );
711
746
  }
712
747
  export {
713
- $e as C,
714
- Ue as T,
715
- Xe as W,
716
- je as b,
717
- Fe as r,
718
- Ve as w
748
+ Te as C,
749
+ Je as T,
750
+ Ye as W,
751
+ Ge as b,
752
+ Ue as r,
753
+ Xe as w
719
754
  };