@hachej/boring-workspace 0.1.34 → 0.1.36

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-hCE2wXKZ.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-CpK401MG.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 = Ke(), [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 = K(e.navParams, "onClose"), f = K(e.surfaceParams, "onClose"), k = K(e.sidebarParams, "onClose"), T = K(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,84 @@ 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(E, { 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
+ renderPane: (o) => /* @__PURE__ */ a(
309
+ E,
310
+ {
311
+ id: o.panel ?? i,
312
+ params: o.params ?? e.centerParams
313
+ }
314
+ )
315
+ }
316
+ ) : /* @__PURE__ */ a(E, { id: i, params: e.centerParams })
299
317
  }
300
318
  ),
301
- d ? null : /* @__PURE__ */ r(
302
- E,
319
+ c ? null : /* @__PURE__ */ a(Q, { label: "Collapse chat", hint: "⌘\\", side: "bottom", children: /* @__PURE__ */ a(
320
+ F,
303
321
  {
304
322
  type: "button",
305
323
  variant: "ghost",
306
324
  size: "icon-xs",
307
- onClick: L,
308
- className: "absolute right-2 top-2 z-20",
325
+ onClick: D,
326
+ className: m(
327
+ "absolute right-2 z-30 rounded-full bg-background/80 text-muted-foreground shadow-sm backdrop-blur hover:bg-muted hover:text-foreground",
328
+ J && P.length > 1 ? "bottom-2" : "top-2"
329
+ ),
309
330
  "aria-label": "Collapse chat",
310
- title: "Collapse chat (⌘\\\\)",
311
- children: /* @__PURE__ */ r(ve, { className: "h-4 w-4", strokeWidth: 1.75 })
331
+ children: /* @__PURE__ */ a(ye, { className: "h-4 w-4", strokeWidth: 1.75 })
312
332
  }
313
- )
333
+ ) })
314
334
  ]
315
335
  }
316
336
  ),
317
- a ? /* @__PURE__ */ u(
337
+ r ? /* @__PURE__ */ h(
318
338
  "aside",
319
339
  {
320
340
  "data-boring-workspace-part": "workbench",
@@ -325,18 +345,18 @@ function $e(e) {
325
345
  "relative h-full min-h-0 overflow-hidden bg-background",
326
346
  // When chat is collapsed the workbench grows to fill the freed
327
347
  // space (full width); otherwise it's a fixed-width side panel.
328
- d && n ? "min-w-0 flex-1" : "shrink-0",
348
+ c && n ? "min-w-0 flex-1" : "shrink-0",
329
349
  "transition-[flex-grow,flex-basis,width,min-width,max-width] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]",
330
350
  n && "border-l border-[color:oklch(from_var(--border)_l_c_h/0.6)]"
331
351
  ),
332
- style: d && n ? { willChange: "width" } : {
333
- width: n ? F : 0,
334
- minWidth: n ? F : 0,
335
- maxWidth: n ? F : 0,
352
+ style: c && n ? { willChange: "width" } : {
353
+ width: n ? q : 0,
354
+ minWidth: n ? q : 0,
355
+ maxWidth: n ? q : 0,
336
356
  willChange: "width"
337
357
  },
338
358
  children: [
339
- /* @__PURE__ */ r(
359
+ /* @__PURE__ */ a(
340
360
  "div",
341
361
  {
342
362
  className: m(
@@ -346,12 +366,12 @@ function $e(e) {
346
366
  // When the chat is collapsed the workbench fills the full width
347
367
  // and the left-edge "expand chat" float button would sit on top
348
368
  // of the filetree — inset the content to leave a clear gutter.
349
- d && n && !t && "pl-14"
369
+ c && n && !t && "pl-14"
350
370
  ),
351
- children: e.surfaceOverlay ? /* @__PURE__ */ u("div", { className: "relative h-full min-h-0", children: [
371
+ children: e.surfaceOverlay ? /* @__PURE__ */ h("div", { className: "relative h-full min-h-0", children: [
352
372
  e.surfaceOverlay,
353
- f ? /* @__PURE__ */ r(
354
- E,
373
+ f ? /* @__PURE__ */ a(Q, { label: "Close workbench", hint: "⌘2", side: "left", children: /* @__PURE__ */ a(
374
+ F,
355
375
  {
356
376
  type: "button",
357
377
  variant: "ghost",
@@ -359,27 +379,26 @@ function $e(e) {
359
379
  onClick: f,
360
380
  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
381
  "aria-label": "Close workbench",
362
- title: "Close workbench (⌘2)",
363
- children: /* @__PURE__ */ r("span", { "aria-hidden": "true", children: "›" })
382
+ children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" })
364
383
  }
365
- ) : null
366
- ] }) : /* @__PURE__ */ r(X, { id: l, params: e.surfaceParams })
384
+ ) }) : null
385
+ ] }) : /* @__PURE__ */ a(E, { id: l, params: e.surfaceParams })
367
386
  }
368
387
  ),
369
- n && !d ? /* @__PURE__ */ r(
370
- ce,
388
+ n && !c ? /* @__PURE__ */ a(
389
+ he,
371
390
  {
372
391
  side: "surface-left",
373
392
  ariaLabel: "Resize workbench",
374
- onResize: (o) => ue((h) => D(h - o, 480, Z))
393
+ onResize: (o) => ge((u) => M(u - o, 480, te))
375
394
  }
376
395
  ) : null
377
396
  ]
378
397
  }
379
398
  ) : null
380
399
  ] }),
381
- !t && e.onOpenNav ? /* @__PURE__ */ r(
382
- q,
400
+ !t && e.onOpenNav ? /* @__PURE__ */ a(
401
+ H,
383
402
  {
384
403
  side: "left",
385
404
  icon: "sessions",
@@ -388,20 +407,34 @@ function $e(e) {
388
407
  hint: "⌘1"
389
408
  }
390
409
  ) : null,
391
- d ? /* @__PURE__ */ r(
392
- q,
410
+ !c && !t && J && e.onCreateChatPaneAfter ? /* @__PURE__ */ a(
411
+ H,
412
+ {
413
+ side: "left",
414
+ icon: "plus",
415
+ onClick: () => {
416
+ var u, N;
417
+ const o = e.activeChatPaneId ?? ((u = P[P.length - 1]) == null ? void 0 : u.id);
418
+ o && ((N = e.onCreateChatPaneAfter) == null || N.call(e, o));
419
+ },
420
+ label: "New chat",
421
+ stackIndex: e.onOpenNav ? 1 : 0
422
+ }
423
+ ) : null,
424
+ c ? /* @__PURE__ */ a(
425
+ H,
393
426
  {
394
427
  side: "left",
395
428
  icon: "chat",
396
- onClick: L,
429
+ onClick: D,
397
430
  label: "Expand chat",
398
431
  hint: "⌘\\\\",
399
432
  stackIndex: 1,
400
- pulse: he || H.length > 0
433
+ pulse: be || j.length > 0
401
434
  }
402
435
  ) : null,
403
- !n && e.onOpenSurface ? /* @__PURE__ */ r(
404
- q,
436
+ !n && e.onOpenSurface ? /* @__PURE__ */ a(
437
+ H,
405
438
  {
406
439
  side: "right",
407
440
  icon: "workbench",
@@ -415,30 +448,30 @@ function $e(e) {
415
448
  }
416
449
  );
417
450
  }
418
- function D(e, t, a) {
419
- return Math.max(t, Math.min(a, e));
451
+ function M(e, t, r) {
452
+ return Math.max(t, Math.min(r, e));
420
453
  }
421
- function se(e, t) {
422
- const [a, n] = M(
423
- () => e ? ie(e, t) : t
454
+ function ue(e, t) {
455
+ const [r, n] = V(
456
+ () => e ? le(e, t) : t
424
457
  );
425
- k(() => {
426
- n(e ? ie(e, t) : t);
458
+ C(() => {
459
+ n(e ? le(e, t) : t);
427
460
  }, [e, t]);
428
- const c = p(
461
+ const d = v(
429
462
  (i) => {
430
463
  n((l) => {
431
464
  const s = typeof i == "function" ? i(l) : i;
432
- return e && ze(e, s), s;
465
+ return e && De(e, s), s;
433
466
  });
434
467
  },
435
468
  [e]
436
469
  );
437
- return [a, c];
470
+ return [r, d];
438
471
  }
439
- function Be(e, t) {
440
- const [a, n] = M(() => !e || typeof window > "u" ? t : window.localStorage.getItem(e) === "1");
441
- k(() => {
472
+ function Me(e, t) {
473
+ const [r, n] = V(() => !e || typeof window > "u" ? t : window.localStorage.getItem(e) === "1");
474
+ C(() => {
442
475
  if (!e || typeof window > "u") {
443
476
  n(t);
444
477
  return;
@@ -446,7 +479,7 @@ function Be(e, t) {
446
479
  const i = window.localStorage.getItem(e);
447
480
  n(i == null ? t : i === "1");
448
481
  }, [e, t]);
449
- const c = p(
482
+ const d = v(
450
483
  (i) => {
451
484
  n((l) => {
452
485
  const s = typeof i == "function" ? i(l) : i;
@@ -455,31 +488,31 @@ function Be(e, t) {
455
488
  },
456
489
  [e]
457
490
  );
458
- return [a, c];
491
+ return [r, d];
459
492
  }
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);
493
+ function Ke() {
494
+ const [e, t] = V(() => typeof window < "u" ? window.innerWidth : 1200);
495
+ return C(() => {
496
+ const r = () => t(window.innerWidth);
497
+ return window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
465
498
  }, []), e;
466
499
  }
467
- function ce({ side: e, ariaLabel: t, onResize: a }) {
468
- const n = T(null), c = p((s) => {
500
+ function he({ side: e, ariaLabel: t, onResize: r }) {
501
+ const n = Z(null), d = v((s) => {
469
502
  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) => {
503
+ }, []), i = v((s) => {
471
504
  if (n.current === null) return;
472
- const x = s.clientX - n.current;
473
- n.current = s.clientX, a(x);
474
- }, [a]), l = p((s) => {
505
+ const p = s.clientX - n.current;
506
+ n.current = s.clientX, r(p);
507
+ }, [r]), l = v((s) => {
475
508
  n.current !== null && (n.current = null, s.currentTarget.releasePointerCapture(s.pointerId), document.body.style.cursor = "", document.body.style.userSelect = "");
476
509
  }, []);
477
- return /* @__PURE__ */ r(
478
- be,
510
+ return /* @__PURE__ */ a(
511
+ pe,
479
512
  {
480
513
  "aria-label": t,
481
514
  orientation: "vertical",
482
- onResizeStart: c,
515
+ onResizeStart: d,
483
516
  onPointerMove: i,
484
517
  onPointerUp: l,
485
518
  onPointerCancel: l,
@@ -494,31 +527,33 @@ function ce({ side: e, ariaLabel: t, onResize: a }) {
494
527
  );
495
528
  }
496
529
  function S(e, t) {
497
- const a = e == null ? void 0 : e[t];
498
- return typeof a == "function" ? a : void 0;
530
+ const r = e == null ? void 0 : e[t];
531
+ return typeof r == "function" ? r : void 0;
499
532
  }
500
- function A(e, t) {
533
+ function K(e, t) {
501
534
  return S(e, t);
502
535
  }
503
- function Y() {
536
+ function ee() {
504
537
  if (typeof document > "u") return;
505
- const e = document.querySelector(
538
+ const r = (document.querySelector(
539
+ '[data-boring-workspace-part="chat-pane"][data-boring-state="active"]'
540
+ ) ?? document).querySelector(
506
541
  '[data-boring-agent] textarea[name="message"], textarea[name="message"]'
507
542
  );
508
- e == null || e.focus();
543
+ r == null || r.focus();
509
544
  }
510
- function de() {
545
+ function fe() {
511
546
  typeof window > "u" || window.requestAnimationFrame(() => {
512
- Y(), window.setTimeout(Y, 320);
547
+ ee(), window.setTimeout(ee, 320);
513
548
  });
514
549
  }
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(
550
+ function E({ id: e, params: t }) {
551
+ const r = Le(), { debug: n } = Ae(), d = we(
552
+ r.subscribe,
553
+ r.getSnapshot,
554
+ r.getSnapshot
555
+ ), l = Y(() => r.getComponents(), [r, d])[e], s = Y(() => Ee(e), [e]);
556
+ return l ? /* @__PURE__ */ a(ve, { fallback: /* @__PURE__ */ a(xe, { centered: !0 }), children: /* @__PURE__ */ a(
522
557
  l,
523
558
  {
524
559
  params: { ...t, debug: n },
@@ -527,7 +562,7 @@ function X({ id: e, params: t }) {
527
562
  }
528
563
  ) }) : null;
529
564
  }
530
- function Le(e) {
565
+ function Ee(e) {
531
566
  return {
532
567
  id: e,
533
568
  title: e,
@@ -563,56 +598,55 @@ function Le(e) {
563
598
  } })
564
599
  };
565
600
  }
566
- function q({
601
+ function H({
567
602
  side: e,
568
603
  icon: t,
569
- onClick: a,
604
+ onClick: r,
570
605
  label: n,
571
- hint: c,
606
+ hint: d,
572
607
  bottomOffset: i,
573
608
  stackIndex: l = 0,
574
609
  pulse: s = !1
575
610
  }) {
576
- const x = e === "right" && i !== void 0, v = l * 44;
577
- return /* @__PURE__ */ r(
578
- E,
611
+ const p = e === "right" && i !== void 0, x = l * 44;
612
+ return /* @__PURE__ */ a(Q, { label: n, hint: d, side: e === "left" ? "right" : "left", children: /* @__PURE__ */ a(
613
+ F,
579
614
  {
580
615
  type: "button",
581
616
  variant: "ghost",
582
617
  size: "icon-sm",
583
- onClick: a,
618
+ onClick: r,
584
619
  "aria-label": n,
585
- title: c ? `${n} (${c})` : n,
586
620
  className: m(
587
621
  "absolute z-30 h-9 w-9 gap-0.5 rounded-lg bg-background text-muted-foreground",
588
622
  e === "left" ? "left-2" : "right-2",
589
- x ? "hover:-translate-y-0.5" : "top-1/2 hover:-translate-y-[1px]",
623
+ p ? "hover:-translate-y-0.5" : "top-1/2 hover:-translate-y-[1px]",
590
624
  "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
625
  "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
626
  "focus-visible:ring-ring/40"
593
627
  ),
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" }) })
628
+ style: p ? { bottom: i } : { transform: `translateY(calc(-50% - ${x}px))` },
629
+ children: t === "sessions" ? /* @__PURE__ */ h("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
630
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "1.8" }),
631
+ /* @__PURE__ */ a("path", { d: "M12 7v5l3.2 2", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
632
+ ] }) : t === "chat" ? /* @__PURE__ */ h("span", { className: "relative flex items-center justify-center", children: [
633
+ /* @__PURE__ */ a(Se, { className: "h-[15px] w-[15px]", strokeWidth: 1.8, "aria-hidden": "true" }),
634
+ 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
635
+ ] }) : 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
636
  }
603
- );
637
+ ) });
604
638
  }
605
- function Ue({
639
+ function Je({
606
640
  appTitle: e = "Boring",
607
641
  sessionTitle: t,
608
- onCommandPalette: a,
642
+ onCommandPalette: r,
609
643
  onNewChat: n,
610
- topBarLeft: c,
644
+ topBarLeft: d,
611
645
  topBarRight: i,
612
646
  className: l
613
647
  }) {
614
648
  const s = i ?? null;
615
- return /* @__PURE__ */ u(
649
+ return /* @__PURE__ */ h(
616
650
  "header",
617
651
  {
618
652
  "data-boring-workspace-part": "topbar",
@@ -623,8 +657,8 @@ function Ue({
623
657
  ),
624
658
  "aria-label": "App top bar",
625
659
  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(
660
+ /* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1 items-center gap-2.5 leading-none", children: d ?? /* @__PURE__ */ h(ce, { children: [
661
+ /* @__PURE__ */ a(
628
662
  "span",
629
663
  {
630
664
  "aria-hidden": "true",
@@ -632,32 +666,32 @@ function Ue({
632
666
  children: ((e == null ? void 0 : e[0]) ?? "B").toUpperCase()
633
667
  }
634
668
  ),
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 })
669
+ t ? /* @__PURE__ */ h(ce, { children: [
670
+ /* @__PURE__ */ a("span", { className: "shrink-0 text-[13px] font-medium leading-none tracking-tight text-foreground/65", children: e }),
671
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "text-[13px] leading-none text-muted-foreground/45", children: "·" }),
672
+ /* @__PURE__ */ a("span", { className: "truncate text-[13px] font-medium leading-none tracking-tight text-foreground", children: t })
673
+ ] }) : /* @__PURE__ */ a("span", { className: "truncate text-[13px] font-medium leading-none tracking-tight text-foreground", children: e })
640
674
  ] }) }),
641
- /* @__PURE__ */ u(
642
- we,
675
+ /* @__PURE__ */ h(
676
+ Ce,
643
677
  {
644
678
  type: "button",
645
679
  variant: "ghost",
646
680
  size: "sm",
647
- onClick: a,
681
+ onClick: r,
648
682
  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
683
  "aria-label": "Search catalogs and commands",
650
684
  title: "Command palette (⌘K)",
651
685
  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" })
686
+ /* @__PURE__ */ a(Pe, { className: "h-3.5 w-3.5 shrink-0 opacity-80", strokeWidth: 1.75 }),
687
+ /* @__PURE__ */ a("span", { className: "font-normal tracking-tight", children: "Search" }),
688
+ /* @__PURE__ */ a(ke, { className: "ml-0.5 bg-muted/40 leading-none shadow-none", children: "⌘K" })
655
689
  ]
656
690
  }
657
691
  ),
658
- /* @__PURE__ */ u("div", { className: "flex flex-1 shrink-0 items-center justify-end gap-1", children: [
659
- n && /* @__PURE__ */ r(
660
- E,
692
+ /* @__PURE__ */ h("div", { className: "flex flex-1 shrink-0 items-center justify-end gap-1", children: [
693
+ n && /* @__PURE__ */ a(
694
+ F,
661
695
  {
662
696
  type: "button",
663
697
  variant: "ghost",
@@ -665,7 +699,7 @@ function Ue({
665
699
  onClick: n,
666
700
  "aria-label": "New chat",
667
701
  title: "New chat",
668
- children: /* @__PURE__ */ r(ye, { className: "h-4 w-4" })
702
+ children: /* @__PURE__ */ a(_e, { className: "h-4 w-4" })
669
703
  }
670
704
  ),
671
705
  s
@@ -674,14 +708,14 @@ function Ue({
674
708
  }
675
709
  );
676
710
  }
677
- function Xe({
711
+ function Ye({
678
712
  title: e = "Loading workspace",
679
713
  description: t = "Preparing the workspace context.",
680
- status: a = "Loading",
714
+ status: r = "Loading",
681
715
  fullscreen: n = !0,
682
- className: c
716
+ className: d
683
717
  }) {
684
- return /* @__PURE__ */ r(
718
+ return /* @__PURE__ */ a(
685
719
  "section",
686
720
  {
687
721
  role: "status",
@@ -690,30 +724,30 @@ function Xe({
690
724
  className: m(
691
725
  "flex h-full w-full items-center justify-center bg-background px-6 text-foreground",
692
726
  n ? "min-h-screen" : "min-h-[240px]",
693
- c
727
+ d
694
728
  ),
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(
729
+ children: /* @__PURE__ */ h("div", { className: "flex w-full max-w-sm flex-col items-center gap-5 text-center", children: [
730
+ /* @__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
731
  "span",
698
732
  {
699
733
  "aria-hidden": "true",
700
734
  className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent opacity-70"
701
735
  }
702
736
  ) }),
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
737
+ /* @__PURE__ */ h("div", { className: "space-y-2", children: [
738
+ /* @__PURE__ */ a("h2", { className: "text-base font-medium text-foreground", children: e }),
739
+ t ? /* @__PURE__ */ a("p", { className: "text-sm leading-6 text-muted-foreground", children: t }) : null
706
740
  ] }),
707
- a ? /* @__PURE__ */ r("p", { className: "text-xs font-medium text-muted-foreground/80", children: a }) : null
741
+ r ? /* @__PURE__ */ a("p", { className: "text-xs font-medium text-muted-foreground/80", children: r }) : null
708
742
  ] })
709
743
  }
710
744
  );
711
745
  }
712
746
  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
747
+ Te as C,
748
+ Je as T,
749
+ Ye as W,
750
+ Ge as b,
751
+ Ue as r,
752
+ Xe as w
719
753
  };