@burdenoff/fe-libs 2026.716.2 → 2026.717.2
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/shared/components/assistantWidget/AssistantWidget.d.ts +30 -2
- package/dist/shared/components/assistantWidget/AssistantWidget.d.ts.map +1 -1
- package/dist/shared/components/assistantWidget/AssistantWidget.js +214 -168
- package/dist/shared/components/index.d.ts +1 -1
- package/dist/shared/components/index.d.ts.map +1 -1
- package/dist/shared/graphql/fetch.d.ts +20 -0
- package/dist/shared/graphql/fetch.d.ts.map +1 -1
- package/dist/shared/graphql/fetch.js +136 -106
- package/dist/shared/providers/AppShellProvider.d.ts.map +1 -1
- package/dist/shared/providers/AppShellProvider.js +152 -146
- package/dist/shared/utils/authErrorHandling.d.ts +6 -0
- package/dist/shared/utils/authErrorHandling.d.ts.map +1 -1
- package/dist/shared/utils/authErrorHandling.js +17 -7
- package/package.json +1 -1
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { AssistantTransport } from './types';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* One selectable assistant mode. Supply two or more via `modes` to render a
|
|
5
|
+
* mode switcher in the header — e.g. a "Workflow" assistant and a "Build a node"
|
|
6
|
+
* assistant, each with its own transport. Switching modes starts that mode's
|
|
7
|
+
* conversation (state is not shared across modes).
|
|
8
|
+
*/
|
|
9
|
+
export interface AssistantModeOption {
|
|
10
|
+
/** Stable id used for selection + persistence. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Short label shown in the mode switcher. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** Backend adapter for this mode. */
|
|
5
15
|
transport: AssistantTransport;
|
|
16
|
+
/** Optional per-mode header title / empty-state subtitle / input placeholder. */
|
|
17
|
+
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AssistantWidgetProps {
|
|
22
|
+
/**
|
|
23
|
+
* Backend adapter supplied by the host product. Optional only when `modes` is
|
|
24
|
+
* provided (each mode carries its own transport); supply exactly one of the two.
|
|
25
|
+
*/
|
|
26
|
+
transport?: AssistantTransport;
|
|
27
|
+
/**
|
|
28
|
+
* Two or more assistant modes, rendered as a switcher in the header. When
|
|
29
|
+
* omitted, the widget is single-mode and behaves exactly as before.
|
|
30
|
+
*/
|
|
31
|
+
modes?: AssistantModeOption[];
|
|
32
|
+
/** Initially-selected mode id when `modes` is used (defaults to the first). */
|
|
33
|
+
defaultModeId?: string;
|
|
6
34
|
/** Window header title. */
|
|
7
35
|
title?: string;
|
|
8
36
|
/** Short helper line shown above the first message. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantWidget.d.ts","sourceRoot":"","sources":["../../../../src/shared/components/assistantWidget/AssistantWidget.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAML,KAAK,EAAE,EAER,MAAM,OAAO,CAAC;AAiBf,OAAO,KAAK,EAA2B,kBAAkB,EAA0B,MAAM,SAAS,CAAC;AAEnG,MAAM,WAAW,oBAAoB;IACnC
|
|
1
|
+
{"version":3,"file":"AssistantWidget.d.ts","sourceRoot":"","sources":["../../../../src/shared/components/assistantWidget/AssistantWidget.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAML,KAAK,EAAE,EAER,MAAM,OAAO,CAAC;AAiBf,OAAO,KAAK,EAA2B,kBAAkB,EAA0B,MAAM,SAAS,CAAC;AAEnG;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC9B,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,8EAA8E;AAC9E,eAAO,MAAM,6BAA6B,+BAA+B,CAAC;AA6C1E,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAwsBpD,CAAC"}
|
|
@@ -2,145 +2,170 @@ import { cn as e } from "../../utils/cn.js";
|
|
|
2
2
|
import { useVoiceInput as t } from "./useVoiceInput.js";
|
|
3
3
|
import { MessageContent as n } from "./MessageContent.js";
|
|
4
4
|
import { useCallback as r, useEffect as i, useMemo as ee, useRef as a, useState as o } from "react";
|
|
5
|
-
import { History as
|
|
6
|
-
import { Fragment as
|
|
5
|
+
import { History as te, Loader2 as s, MessageCircle as ne, Mic as re, PanelLeftClose as ie, PanelLeftOpen as ae, Plus as oe, Send as se, Sparkles as c, Trash2 as ce, X as l } from "lucide-react";
|
|
6
|
+
import { Fragment as le, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
7
|
//#region src/shared/components/assistantWidget/AssistantWidget.tsx
|
|
8
|
-
var
|
|
9
|
-
function
|
|
8
|
+
var f = "bf:toggle-assistant-widget", p = "bf:assistant-widget:isOpen", m = "bf:assistant-widget:railOpen";
|
|
9
|
+
function ue() {
|
|
10
10
|
if (typeof window > "u") return !0;
|
|
11
11
|
try {
|
|
12
|
-
return window.sessionStorage.getItem(
|
|
12
|
+
return window.sessionStorage.getItem(m) !== "0";
|
|
13
13
|
} catch {
|
|
14
14
|
return !0;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function de(e) {
|
|
18
18
|
if (!(typeof window > "u")) try {
|
|
19
|
-
window.sessionStorage.setItem(
|
|
19
|
+
window.sessionStorage.setItem(m, e ? "1" : "0");
|
|
20
20
|
} catch {}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function fe() {
|
|
23
23
|
if (typeof window > "u") return !1;
|
|
24
24
|
try {
|
|
25
|
-
return window.sessionStorage.getItem(
|
|
25
|
+
return window.sessionStorage.getItem(p) === "1";
|
|
26
26
|
} catch {
|
|
27
27
|
return !1;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function h(e) {
|
|
31
31
|
if (!(typeof window > "u")) try {
|
|
32
|
-
window.sessionStorage.setItem(
|
|
32
|
+
window.sessionStorage.setItem(p, e ? "1" : "0");
|
|
33
33
|
} catch {}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function pe() {
|
|
36
36
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
let
|
|
40
|
-
|
|
38
|
+
var g = ({ transport: p, modes: m, defaultModeId: g, title: _ = "AI Assistant", subtitle: v = "Ask me to do things on this screen — I can run them for you.", placeholder: y = "Ask anything, or describe what to create…", launcherClassName: b, voiceLang: me = "en-US", layout: x = "floating", showSessionPanel: he = !1, onNavigate: ge, topOffsetPx: S = 0 }) => {
|
|
39
|
+
let C = ee(() => m && m.length > 0 ? m : [{
|
|
40
|
+
id: "__default__",
|
|
41
|
+
label: _,
|
|
42
|
+
transport: p,
|
|
43
|
+
title: _,
|
|
44
|
+
subtitle: v,
|
|
45
|
+
placeholder: y
|
|
46
|
+
}], [
|
|
47
|
+
m,
|
|
48
|
+
p,
|
|
49
|
+
_,
|
|
50
|
+
v,
|
|
51
|
+
y
|
|
52
|
+
]), [w, _e] = o(() => g ?? C[0]?.id ?? "__default__"), T = C.find((e) => e.id === w) ?? C[0], E = T.transport, ve = T.title ?? _, ye = T.subtitle ?? v, be = T.placeholder ?? y;
|
|
53
|
+
i(() => {
|
|
54
|
+
C.some((e) => e.id === w) || _e(C[0]?.id ?? "__default__");
|
|
55
|
+
}, [C, w]);
|
|
56
|
+
let D = !!E;
|
|
57
|
+
i(() => {
|
|
58
|
+
D || console.error("[AssistantWidget] No transport available — supply `transport`, or a non-empty `modes` where each entry has a transport.");
|
|
59
|
+
}, [D]);
|
|
60
|
+
let [O, k] = o(() => fe()), [A, j] = o([]), [M, N] = o(""), [P, F] = o(!1), [xe, I] = o(!1), [L, R] = o([]), [z, B] = o(!1), [Se, V] = o(!1), [H, Ce] = o(() => ue()), U = a(null), W = a(null), G = a(null), K = a(!1), q = x === "sidebar", we = he && !!E?.newSession, Te = r(() => {
|
|
61
|
+
Ce((e) => {
|
|
41
62
|
let t = !e;
|
|
42
|
-
return
|
|
63
|
+
return de(t), t;
|
|
43
64
|
});
|
|
44
|
-
}, []),
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
|
|
65
|
+
}, []), J = t(me), Ee = r(() => {
|
|
66
|
+
h(!0), k(!0), E.prewarm?.("full");
|
|
67
|
+
}, [E]), Y = r(() => {
|
|
68
|
+
h(!1), k(!1), E.suspend?.();
|
|
69
|
+
}, [E]), X = r(() => {
|
|
70
|
+
k((e) => {
|
|
50
71
|
let t = !e;
|
|
51
|
-
return
|
|
72
|
+
return h(t), t ? E.prewarm?.("full") : E.suspend?.(), t;
|
|
52
73
|
});
|
|
53
|
-
}, [
|
|
74
|
+
}, [E]);
|
|
54
75
|
i(() => {
|
|
55
76
|
let e = (e) => {
|
|
56
77
|
let t = e.detail;
|
|
57
|
-
t?.open === !0 ?
|
|
78
|
+
t?.open === !0 ? Ee() : t?.open === !1 ? Y() : X();
|
|
58
79
|
};
|
|
59
|
-
return window.addEventListener(
|
|
80
|
+
return window.addEventListener(f, e), () => window.removeEventListener(f, e);
|
|
60
81
|
}, [
|
|
61
|
-
|
|
82
|
+
Ee,
|
|
62
83
|
Y,
|
|
63
84
|
X
|
|
64
85
|
]), i(() => {
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
J.isListening && J.transcript && N(J.transcript);
|
|
87
|
+
}, [J.transcript, J.isListening]);
|
|
88
|
+
let De = a(w);
|
|
89
|
+
i(() => {
|
|
90
|
+
De.current !== w && (De.current = w, G.current?.abort(), G.current = null, F(!1), j([]), N(""), R([]), B(!1), I(!1), K.current = !1);
|
|
91
|
+
}, [w]), i(() => {
|
|
92
|
+
if (!O || K.current) return;
|
|
93
|
+
let e = E.loadHistory;
|
|
69
94
|
if (!e) {
|
|
70
|
-
|
|
95
|
+
K.current = !0;
|
|
71
96
|
return;
|
|
72
97
|
}
|
|
73
|
-
|
|
98
|
+
K.current = !0;
|
|
74
99
|
let t = !1;
|
|
75
|
-
return
|
|
100
|
+
return I(!0), (async () => {
|
|
76
101
|
try {
|
|
77
102
|
let n = await e();
|
|
78
|
-
!t && n.length > 0 &&
|
|
103
|
+
!t && n.length > 0 && j((e) => e.length === 0 ? n : e);
|
|
79
104
|
} catch {} finally {
|
|
80
|
-
t ||
|
|
105
|
+
t || I(!1);
|
|
81
106
|
}
|
|
82
107
|
})(), () => {
|
|
83
108
|
t = !0;
|
|
84
109
|
};
|
|
85
|
-
}, [
|
|
86
|
-
|
|
87
|
-
}, [
|
|
110
|
+
}, [O, E]), i(() => {
|
|
111
|
+
O && W.current && (W.current.scrollTop = W.current.scrollHeight);
|
|
112
|
+
}, [A, O]);
|
|
88
113
|
let Z = r((e, t) => {
|
|
89
|
-
|
|
114
|
+
j((n) => n.map((n) => n.id === e ? {
|
|
90
115
|
...n,
|
|
91
116
|
...t
|
|
92
117
|
} : n));
|
|
93
118
|
}, []), Q = r(async () => {
|
|
94
|
-
if (
|
|
95
|
-
|
|
119
|
+
if (E.listSessions) {
|
|
120
|
+
V(!0);
|
|
96
121
|
try {
|
|
97
|
-
|
|
122
|
+
R(await E.listSessions());
|
|
98
123
|
} catch {
|
|
99
|
-
|
|
124
|
+
R([]);
|
|
100
125
|
} finally {
|
|
101
|
-
|
|
126
|
+
V(!1);
|
|
102
127
|
}
|
|
103
128
|
}
|
|
104
|
-
}, [
|
|
105
|
-
!
|
|
106
|
-
}, [
|
|
107
|
-
if (!(!
|
|
108
|
-
|
|
129
|
+
}, [E]), Oe = r(async () => {
|
|
130
|
+
!E.newSession || P || (j([]), N(""), B(!1), await E.newSession());
|
|
131
|
+
}, [E, P]), ke = r(async (e, t) => {
|
|
132
|
+
if (!(!E.deleteSession || P)) {
|
|
133
|
+
R((t) => t.filter((t) => t.id !== e)), t && (j([]), N(""));
|
|
109
134
|
try {
|
|
110
|
-
await
|
|
135
|
+
await E.deleteSession(e);
|
|
111
136
|
} finally {
|
|
112
137
|
Q();
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
}, [
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
E,
|
|
142
|
+
P,
|
|
118
143
|
Q
|
|
119
|
-
]),
|
|
120
|
-
|
|
121
|
-
}, [Q]),
|
|
122
|
-
if (!(!
|
|
123
|
-
|
|
144
|
+
]), Ae = r(() => {
|
|
145
|
+
B((e) => (e || Q(), !e));
|
|
146
|
+
}, [Q]), je = r(async (e) => {
|
|
147
|
+
if (!(!E.selectSession || P)) {
|
|
148
|
+
I(!0);
|
|
124
149
|
try {
|
|
125
|
-
|
|
150
|
+
j(await E.selectSession(e)), B(!1), Q();
|
|
126
151
|
} catch {} finally {
|
|
127
|
-
|
|
152
|
+
I(!1);
|
|
128
153
|
}
|
|
129
154
|
}
|
|
130
155
|
}, [
|
|
131
|
-
|
|
132
|
-
|
|
156
|
+
E,
|
|
157
|
+
P,
|
|
133
158
|
Q
|
|
134
159
|
]), $ = r(async () => {
|
|
135
|
-
let e =
|
|
136
|
-
if (!e ||
|
|
137
|
-
|
|
160
|
+
let e = M.trim();
|
|
161
|
+
if (!e || P) return;
|
|
162
|
+
J.isListening && J.stop(), J.reset(), N(""), U.current && (U.current.style.height = "auto");
|
|
138
163
|
let t = {
|
|
139
|
-
id:
|
|
164
|
+
id: pe(),
|
|
140
165
|
role: "user",
|
|
141
166
|
content: e
|
|
142
|
-
}, n =
|
|
143
|
-
|
|
167
|
+
}, n = pe();
|
|
168
|
+
j((e) => [
|
|
144
169
|
...e,
|
|
145
170
|
t,
|
|
146
171
|
{
|
|
@@ -149,11 +174,11 @@ var y = ({ transport: h, title: g = "AI Assistant", subtitle: y = "Ask me to do
|
|
|
149
174
|
content: "",
|
|
150
175
|
pending: !0
|
|
151
176
|
}
|
|
152
|
-
]),
|
|
177
|
+
]), F(!0);
|
|
153
178
|
let r = new AbortController();
|
|
154
|
-
|
|
179
|
+
G.current = r;
|
|
155
180
|
try {
|
|
156
|
-
let { text: t } = await
|
|
181
|
+
let { text: t } = await E.sendPrompt({
|
|
157
182
|
prompt: e,
|
|
158
183
|
signal: r.signal,
|
|
159
184
|
onProgress: (e) => Z(n, { content: e })
|
|
@@ -169,217 +194,238 @@ var y = ({ transport: h, title: g = "AI Assistant", subtitle: y = "Ask me to do
|
|
|
169
194
|
error: !0
|
|
170
195
|
});
|
|
171
196
|
} finally {
|
|
172
|
-
|
|
197
|
+
F(!1), G.current = null, z && Q();
|
|
173
198
|
}
|
|
174
199
|
}, [
|
|
175
|
-
|
|
176
|
-
|
|
200
|
+
M,
|
|
201
|
+
P,
|
|
177
202
|
Z,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
E,
|
|
204
|
+
J,
|
|
205
|
+
z,
|
|
181
206
|
Q
|
|
182
|
-
]),
|
|
207
|
+
]), Me = r((e) => {
|
|
183
208
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), $());
|
|
184
|
-
}, [$]),
|
|
185
|
-
let e =
|
|
209
|
+
}, [$]), Ne = r(() => {
|
|
210
|
+
let e = U.current;
|
|
186
211
|
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
|
|
187
|
-
}, []),
|
|
188
|
-
|
|
189
|
-
}, [
|
|
190
|
-
return /* @__PURE__ */ p(se, { children: [ee(() => /* @__PURE__ */ f("button", {
|
|
212
|
+
}, []), Pe = r(() => {
|
|
213
|
+
J.isListening ? J.stop() : J.start();
|
|
214
|
+
}, [J]), Fe = ee(() => /* @__PURE__ */ u("button", {
|
|
191
215
|
type: "button",
|
|
192
216
|
onClick: X,
|
|
193
|
-
onMouseEnter: () => !
|
|
194
|
-
onFocus: () => !
|
|
195
|
-
"aria-label":
|
|
196
|
-
"aria-expanded":
|
|
217
|
+
onMouseEnter: () => !O && E.prewarm?.("probe"),
|
|
218
|
+
onFocus: () => !O && E.prewarm?.("probe"),
|
|
219
|
+
"aria-label": O ? "Close AI assistant" : "Open AI assistant",
|
|
220
|
+
"aria-expanded": O,
|
|
197
221
|
"data-testid": "assistant-widget-launcher",
|
|
198
222
|
className: e("fixed bottom-6 right-6 z-[100] inline-flex size-14 items-center justify-center rounded-full", "bg-action-primary-bg text-action-primary-text shadow-xl transition-transform duration-200", "hover:scale-105 hover:bg-action-primary-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer", b),
|
|
199
|
-
children:
|
|
223
|
+
children: u(O ? l : c, { className: "size-6" })
|
|
200
224
|
}), [
|
|
201
|
-
|
|
225
|
+
O,
|
|
202
226
|
X,
|
|
203
227
|
b,
|
|
204
|
-
|
|
205
|
-
])
|
|
228
|
+
E
|
|
229
|
+
]);
|
|
230
|
+
return D ? /* @__PURE__ */ d(le, { children: [Fe, O ? /* @__PURE__ */ d("div", {
|
|
206
231
|
role: "dialog",
|
|
207
|
-
"aria-label":
|
|
232
|
+
"aria-label": ve,
|
|
208
233
|
"data-testid": "assistant-widget-window",
|
|
209
|
-
"data-layout":
|
|
210
|
-
style:
|
|
211
|
-
top:
|
|
212
|
-
height: `calc(100vh - ${String(
|
|
234
|
+
"data-layout": x,
|
|
235
|
+
style: q ? {
|
|
236
|
+
top: S,
|
|
237
|
+
height: `calc(100vh - ${String(S)}px)`
|
|
213
238
|
} : void 0,
|
|
214
|
-
className: e("fixed z-[100] flex overflow-hidden border-border-default bg-bg-surface shadow-2xl",
|
|
215
|
-
children: [
|
|
239
|
+
className: e("fixed z-[100] flex overflow-hidden border-border-default bg-bg-surface shadow-2xl", q ? "bottom-0 right-0 w-full border-l sm:w-[480px] lg:w-[560px] animate-in slide-in-from-right duration-200" : "flex-col rounded-xl border bottom-24 right-6 h-[560px] max-h-[calc(100vh-7rem)] w-[calc(100vw-3rem)] sm:w-[400px] animate-in slide-in-from-bottom-2 fade-in duration-200"),
|
|
240
|
+
children: [q && we && H ? /* @__PURE__ */ d("aside", {
|
|
216
241
|
"data-testid": "assistant-session-panel",
|
|
217
242
|
className: "flex w-[168px] shrink-0 flex-col gap-1 border-r border-border-subtle bg-bg-sunken p-2",
|
|
218
243
|
children: [
|
|
219
|
-
/* @__PURE__ */
|
|
244
|
+
/* @__PURE__ */ d("button", {
|
|
220
245
|
type: "button",
|
|
221
|
-
onClick:
|
|
246
|
+
onClick: Te,
|
|
222
247
|
"aria-label": "Hide chats",
|
|
223
248
|
"aria-expanded": !0,
|
|
224
249
|
title: "Hide chats",
|
|
225
250
|
"data-testid": "assistant-rail-toggle",
|
|
226
251
|
className: "mb-1 flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium text-text-secondary transition-colors hover:bg-bg-surface hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
227
|
-
children: [/* @__PURE__ */
|
|
252
|
+
children: [/* @__PURE__ */ u(ie, { className: "size-4 shrink-0" }), "Hide chats"]
|
|
228
253
|
}),
|
|
229
|
-
/* @__PURE__ */
|
|
254
|
+
/* @__PURE__ */ d("button", {
|
|
230
255
|
type: "button",
|
|
231
|
-
onClick: () => void
|
|
232
|
-
disabled:
|
|
256
|
+
onClick: () => void Oe(),
|
|
257
|
+
disabled: P,
|
|
233
258
|
"data-testid": "assistant-new-chat",
|
|
234
259
|
className: "flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium text-text-primary transition-colors hover:bg-bg-surface disabled:opacity-50 cursor-pointer",
|
|
235
|
-
children: [/* @__PURE__ */
|
|
260
|
+
children: [/* @__PURE__ */ u(oe, { className: "size-4 shrink-0" }), "New chat"]
|
|
236
261
|
}),
|
|
237
|
-
/* @__PURE__ */
|
|
262
|
+
/* @__PURE__ */ d("button", {
|
|
238
263
|
type: "button",
|
|
239
|
-
onClick:
|
|
240
|
-
"aria-expanded":
|
|
264
|
+
onClick: Ae,
|
|
265
|
+
"aria-expanded": z,
|
|
241
266
|
"data-testid": "assistant-history-toggle",
|
|
242
267
|
className: "flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium text-text-primary transition-colors hover:bg-bg-surface cursor-pointer",
|
|
243
|
-
children: [/* @__PURE__ */
|
|
268
|
+
children: [/* @__PURE__ */ u(te, { className: "size-4 shrink-0" }), "History"]
|
|
244
269
|
}),
|
|
245
|
-
|
|
270
|
+
z ? /* @__PURE__ */ u("div", {
|
|
246
271
|
"data-testid": "assistant-history-list",
|
|
247
272
|
className: "mt-1 flex-1 space-y-0.5 overflow-y-auto border-t border-border-subtle pt-2",
|
|
248
|
-
children:
|
|
273
|
+
children: Se && L.length === 0 ? /* @__PURE__ */ d("p", {
|
|
249
274
|
className: "flex items-center gap-1.5 px-2 py-1 text-[11px] text-text-muted",
|
|
250
|
-
children: [/* @__PURE__ */
|
|
251
|
-
}) :
|
|
275
|
+
children: [/* @__PURE__ */ u(s, { className: "size-3 animate-spin" }), "Loading…"]
|
|
276
|
+
}) : L.length === 0 ? /* @__PURE__ */ u("p", {
|
|
252
277
|
className: "px-2 py-1 text-[11px] leading-relaxed text-text-muted",
|
|
253
278
|
children: "No past chats yet."
|
|
254
|
-
}) :
|
|
279
|
+
}) : L.map((t) => /* @__PURE__ */ d("div", {
|
|
255
280
|
"data-testid": "assistant-history-row",
|
|
256
281
|
className: e("group flex items-center gap-1 rounded pr-1 transition-colors", t.active ? "bg-bg-surface" : "hover:bg-bg-surface"),
|
|
257
|
-
children: [/* @__PURE__ */
|
|
282
|
+
children: [/* @__PURE__ */ u("button", {
|
|
258
283
|
type: "button",
|
|
259
|
-
onClick: () => void
|
|
284
|
+
onClick: () => void je(t.id),
|
|
260
285
|
title: t.title,
|
|
261
286
|
"data-testid": "assistant-history-item",
|
|
262
287
|
className: e("min-w-0 flex-1 truncate rounded px-2 py-1.5 text-left text-[11px] leading-relaxed cursor-pointer", t.active ? "font-medium text-text-primary" : "text-text-secondary group-hover:text-text-primary"),
|
|
263
288
|
children: t.title
|
|
264
|
-
}),
|
|
289
|
+
}), E.deleteSession ? /* @__PURE__ */ u("button", {
|
|
265
290
|
type: "button",
|
|
266
|
-
onClick: () => void
|
|
267
|
-
disabled:
|
|
291
|
+
onClick: () => void ke(t.id, !!t.active),
|
|
292
|
+
disabled: P,
|
|
268
293
|
"aria-label": `Delete chat: ${t.title}`,
|
|
269
294
|
title: "Delete this chat",
|
|
270
295
|
"data-testid": "assistant-delete-chat",
|
|
271
296
|
className: "inline-flex size-6 shrink-0 items-center justify-center rounded text-text-muted opacity-0 transition-opacity hover:text-status-error-bg focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-30 cursor-pointer",
|
|
272
|
-
children: /* @__PURE__ */
|
|
297
|
+
children: /* @__PURE__ */ u(ce, { className: "size-3.5" })
|
|
273
298
|
}) : null]
|
|
274
299
|
}, t.id))
|
|
275
300
|
}) : null
|
|
276
301
|
]
|
|
277
|
-
}) : null, /* @__PURE__ */
|
|
302
|
+
}) : null, /* @__PURE__ */ d("div", {
|
|
278
303
|
className: "flex min-w-0 flex-1 flex-col",
|
|
279
304
|
children: [
|
|
280
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ d("div", {
|
|
281
306
|
className: "flex items-center justify-between gap-2 border-b border-border-subtle bg-bg-surface px-4 py-3",
|
|
282
|
-
children: [/* @__PURE__ */
|
|
307
|
+
children: [/* @__PURE__ */ d("div", {
|
|
283
308
|
className: "flex min-w-0 items-center gap-2",
|
|
284
|
-
children: [
|
|
309
|
+
children: [q && we && !H ? /* @__PURE__ */ d("button", {
|
|
285
310
|
type: "button",
|
|
286
|
-
onClick:
|
|
311
|
+
onClick: Te,
|
|
287
312
|
"aria-label": "Show chats",
|
|
288
313
|
"aria-expanded": !1,
|
|
289
314
|
title: "Show chats",
|
|
290
315
|
"data-testid": "assistant-rail-toggle",
|
|
291
316
|
className: "inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border-subtle px-2 py-1.5 text-xs font-medium text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
292
|
-
children: [/* @__PURE__ */
|
|
293
|
-
}) : /* @__PURE__ */
|
|
317
|
+
children: [/* @__PURE__ */ u(ae, { className: "size-4" }), "Chats"]
|
|
318
|
+
}) : /* @__PURE__ */ u("span", {
|
|
294
319
|
className: "inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-action-primary-bg/10 text-action-primary-bg",
|
|
295
|
-
children: /* @__PURE__ */
|
|
296
|
-
}), /* @__PURE__ */
|
|
320
|
+
children: /* @__PURE__ */ u(c, { className: "size-4" })
|
|
321
|
+
}), /* @__PURE__ */ u("h2", {
|
|
297
322
|
className: "truncate text-sm font-semibold text-text-primary",
|
|
298
|
-
children:
|
|
323
|
+
children: ve
|
|
299
324
|
})]
|
|
300
|
-
}), /* @__PURE__ */
|
|
325
|
+
}), /* @__PURE__ */ u("button", {
|
|
301
326
|
type: "button",
|
|
302
327
|
onClick: Y,
|
|
303
328
|
"aria-label": "Close AI assistant",
|
|
304
329
|
"data-testid": "assistant-widget-close",
|
|
305
330
|
className: "inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
306
|
-
children: /* @__PURE__ */
|
|
331
|
+
children: /* @__PURE__ */ u(l, { className: "size-4" })
|
|
307
332
|
})]
|
|
308
333
|
}),
|
|
309
|
-
/* @__PURE__ */
|
|
310
|
-
|
|
334
|
+
C.length > 1 ? /* @__PURE__ */ u("div", {
|
|
335
|
+
role: "tablist",
|
|
336
|
+
"aria-label": "Assistant mode",
|
|
337
|
+
"data-testid": "assistant-mode-switcher",
|
|
338
|
+
className: "flex items-center gap-1 border-b border-border-subtle bg-bg-surface px-3 py-2",
|
|
339
|
+
children: C.map((t) => {
|
|
340
|
+
let n = t.id === w;
|
|
341
|
+
return /* @__PURE__ */ u("button", {
|
|
342
|
+
type: "button",
|
|
343
|
+
role: "tab",
|
|
344
|
+
"aria-selected": n,
|
|
345
|
+
tabIndex: n ? 0 : -1,
|
|
346
|
+
onClick: () => _e(t.id),
|
|
347
|
+
disabled: P,
|
|
348
|
+
title: P ? "Finish the current turn before switching" : t.label,
|
|
349
|
+
"data-testid": `assistant-mode-${t.id}`,
|
|
350
|
+
className: e("rounded-md px-2.5 py-1 text-xs font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer", n ? "bg-action-primary-bg text-action-primary-text" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"),
|
|
351
|
+
children: t.label
|
|
352
|
+
}, t.id);
|
|
353
|
+
})
|
|
354
|
+
}) : null,
|
|
355
|
+
/* @__PURE__ */ u("div", {
|
|
356
|
+
ref: W,
|
|
311
357
|
className: "flex-1 space-y-3 overflow-y-auto px-4 py-4",
|
|
312
358
|
"data-testid": "assistant-widget-messages",
|
|
313
|
-
children:
|
|
359
|
+
children: A.length === 0 && xe ? /* @__PURE__ */ d("div", {
|
|
314
360
|
"data-testid": "assistant-widget-restoring",
|
|
315
361
|
className: "flex h-full flex-col items-center justify-center gap-3 text-center",
|
|
316
|
-
children: [/* @__PURE__ */
|
|
362
|
+
children: [/* @__PURE__ */ u(s, { className: "size-5 animate-spin text-text-secondary" }), /* @__PURE__ */ u("p", {
|
|
317
363
|
className: "text-xs leading-relaxed text-text-secondary",
|
|
318
364
|
children: "Restoring your conversation…"
|
|
319
365
|
})]
|
|
320
|
-
}) :
|
|
366
|
+
}) : A.length === 0 ? /* @__PURE__ */ d("div", {
|
|
321
367
|
className: "flex h-full flex-col items-center justify-center gap-3 text-center",
|
|
322
|
-
children: [/* @__PURE__ */
|
|
368
|
+
children: [/* @__PURE__ */ u("span", {
|
|
323
369
|
className: "inline-flex size-12 items-center justify-center rounded-full bg-bg-sunken text-action-primary-bg",
|
|
324
|
-
children: /* @__PURE__ */
|
|
325
|
-
}), /* @__PURE__ */
|
|
370
|
+
children: /* @__PURE__ */ u(ne, { className: "size-6" })
|
|
371
|
+
}), /* @__PURE__ */ u("p", {
|
|
326
372
|
className: "max-w-[16rem] text-xs leading-relaxed text-text-secondary",
|
|
327
|
-
children:
|
|
373
|
+
children: ye
|
|
328
374
|
})]
|
|
329
|
-
}) :
|
|
375
|
+
}) : A.map((t) => /* @__PURE__ */ u("div", {
|
|
330
376
|
className: e("flex", t.role === "user" ? "justify-end" : "justify-start"),
|
|
331
|
-
children: /* @__PURE__ */
|
|
377
|
+
children: /* @__PURE__ */ d("div", {
|
|
332
378
|
"data-testid": `assistant-widget-message-${t.role}`,
|
|
333
|
-
className: e("whitespace-pre-wrap break-words rounded-lg px-3 py-2 text-xs leading-relaxed",
|
|
334
|
-
children: [t.content ? /* @__PURE__ */
|
|
379
|
+
className: e("whitespace-pre-wrap break-words rounded-lg px-3 py-2 text-xs leading-relaxed", q ? "max-w-[92%]" : "max-w-[85%]", t.role === "user" ? "bg-action-primary-bg text-action-primary-text" : t.error ? "bg-status-error-bg/10 text-status-error-bg" : "bg-bg-sunken text-text-primary"),
|
|
380
|
+
children: [t.content ? /* @__PURE__ */ u(n, {
|
|
335
381
|
content: t.content,
|
|
336
|
-
onNavigate:
|
|
337
|
-
}) : null, t.pending ? /* @__PURE__ */
|
|
382
|
+
onNavigate: ge
|
|
383
|
+
}) : null, t.pending ? /* @__PURE__ */ d("span", {
|
|
338
384
|
"data-testid": "assistant-widget-working",
|
|
339
385
|
className: e("inline-flex items-center gap-1 text-text-secondary", t.content ? "mt-1" : ""),
|
|
340
|
-
children: [/* @__PURE__ */
|
|
386
|
+
children: [/* @__PURE__ */ u(s, { className: "size-3 animate-spin" }), t.content ? null : /* @__PURE__ */ u("span", { children: "Working on it…" })]
|
|
341
387
|
}) : null]
|
|
342
388
|
})
|
|
343
389
|
}, t.id))
|
|
344
390
|
}),
|
|
345
|
-
/* @__PURE__ */
|
|
391
|
+
/* @__PURE__ */ d("div", {
|
|
346
392
|
className: "flex items-end gap-2 border-t border-border-default bg-bg-surface px-3 py-2.5",
|
|
347
393
|
children: [
|
|
348
|
-
|
|
394
|
+
J.isSupported ? /* @__PURE__ */ u("button", {
|
|
349
395
|
type: "button",
|
|
350
|
-
onClick:
|
|
351
|
-
"aria-label":
|
|
352
|
-
"aria-pressed":
|
|
396
|
+
onClick: Pe,
|
|
397
|
+
"aria-label": J.isListening ? "Stop voice input" : "Start voice input",
|
|
398
|
+
"aria-pressed": J.isListening,
|
|
353
399
|
"data-testid": "assistant-widget-mic",
|
|
354
|
-
className: e("flex size-9 shrink-0 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer",
|
|
355
|
-
children: /* @__PURE__ */
|
|
400
|
+
className: e("flex size-9 shrink-0 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong cursor-pointer", J.isListening ? "animate-pulse bg-status-error-bg text-action-primary-text" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
|
|
401
|
+
children: /* @__PURE__ */ u(re, { className: "size-4" })
|
|
356
402
|
}) : null,
|
|
357
|
-
/* @__PURE__ */
|
|
358
|
-
ref:
|
|
359
|
-
value:
|
|
360
|
-
onChange: (e) =>
|
|
361
|
-
onKeyDown:
|
|
362
|
-
onInput:
|
|
403
|
+
/* @__PURE__ */ u("textarea", {
|
|
404
|
+
ref: U,
|
|
405
|
+
value: M,
|
|
406
|
+
onChange: (e) => N(e.target.value),
|
|
407
|
+
onKeyDown: Me,
|
|
408
|
+
onInput: Ne,
|
|
363
409
|
rows: 1,
|
|
364
|
-
placeholder:
|
|
410
|
+
placeholder: be,
|
|
365
411
|
"aria-label": "Message the assistant",
|
|
366
412
|
"data-testid": "assistant-widget-input",
|
|
367
413
|
className: "flex-1 resize-none rounded-lg border border-border-default bg-bg-sunken px-3 py-2 text-xs leading-relaxed text-text-primary placeholder:text-text-muted focus:border-action-primary-bg focus:outline-none"
|
|
368
414
|
}),
|
|
369
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ u("button", {
|
|
370
416
|
type: "button",
|
|
371
417
|
onClick: () => void $(),
|
|
372
|
-
disabled:
|
|
418
|
+
disabled: P || M.trim().length === 0,
|
|
373
419
|
"aria-label": "Send message",
|
|
374
420
|
"data-testid": "assistant-widget-send",
|
|
375
421
|
className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg text-action-primary-text transition-colors hover:bg-action-primary-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:opacity-50 cursor-pointer",
|
|
376
|
-
children:
|
|
422
|
+
children: P ? /* @__PURE__ */ u(s, { className: "size-4 animate-spin" }) : /* @__PURE__ */ u(se, { className: "size-4" })
|
|
377
423
|
})
|
|
378
424
|
]
|
|
379
425
|
})
|
|
380
426
|
]
|
|
381
427
|
})]
|
|
382
|
-
}) : null] });
|
|
428
|
+
}) : null] }) : null;
|
|
383
429
|
};
|
|
384
430
|
//#endregion
|
|
385
|
-
export {
|
|
431
|
+
export { f as ASSISTANT_WIDGET_TOGGLE_EVENT, g as AssistantWidget };
|