@aintela/chat 0.2.47 → 0.2.49
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/README.md +29 -0
- package/dist/components.js +3775 -3656
- package/dist/components.js.map +1 -1
- package/dist/index.js +98 -96
- package/dist/src/components/AiChat/ChatPane/AskUserSheet.d.ts +6 -0
- package/dist/src/components/AiChat/useTurnOpen.d.ts +18 -0
- package/dist/src/components/Library/TurnAwareButton.d.ts +46 -0
- package/dist/src/components/Library/TurnAwareButton.test.d.ts +1 -0
- package/dist/src/components/Library/turnAwareButtonState.d.ts +42 -0
- package/dist/src/components/Library/turnAwareButtonState.test.d.ts +1 -0
- package/dist/src/components/index.d.ts +4 -0
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { C as s, F as n, a as o, I as r, L as i, S as c, b as l, c as
|
|
3
|
-
import { A as
|
|
2
|
+
import { C as s, F as n, a as o, I as r, L as i, S as c, b as l, c as A, d as S, e as C, T as p, f as g, g as d, h as I, i as E, s as h, j as v } from "./serializer-DNt8QqNO.js";
|
|
3
|
+
import { A as m, a as T, C as L, M as x, b as P, S as U, i as f } from "./Memory-DjLZqgbF.js";
|
|
4
4
|
import { C as M, C as y } from "./ClientMessage-EKgfuTp8.js";
|
|
5
5
|
import { C as D, P as B } from "./Prompt-DZb7OaPp.js";
|
|
6
6
|
import { A as k, a as F, b, c as N, d as H, e as G, C as O, f as W, D as w, E as z, g as J, G as j, h as K, M as q, i as X, R as Y, j as Q, S as Z, l as $, m as ee, n as ae, o as te, p as se, q as ne, r as oe, s as re, t as ie, u as ce } from "./environmentUtils-CUVZ6Dq1.js";
|
|
7
|
-
import { A as
|
|
7
|
+
import { A as Ae, a as Se, E as Ce, H as pe, I as ge, L as de, W as Ie } from "./httpArtifactService-CcYAfh2q.js";
|
|
8
8
|
import { A as he } from "./artifactHtmlHandler-CMQJf1cX.js";
|
|
9
|
-
import { H as
|
|
10
|
-
import { APPBAR_V2_HEIGHT as xe, ASK_USER_CANCELLED as Pe, AgentActivityV2 as Ue, AiChat as fe, AiChatDrawer as Re, AiChatFloating as Me, AiChatFloatingV2 as ye, AiChatProvider as _e, AiChatServiceContext as De, AiChatV2Pane as Be, AppBarV2 as Ve, AppRailV2 as ke, AppShellV2 as Fe, ArtifactRender as be, AskUserDialog as Ne, AskUserSheet as He, BoxedPart as Ge, BrainIcon as Oe, ChartIcon as We, ChatIcon as we, ChatPane as ze, ChatsHistoryV2 as Je, CheckIcon as je, ChevronIcon as Ke, ChevronRightIcon as qe, CloseIcon as Xe, CodeIcon as Ye, ComposerIcon as Qe, CurrentMessage as Ze, DEFAULT_PART_RENDERERS as $e, DashboardIcon as ea, DataExplorerIcon as aa, DelayTextComponent as ta, EnvironmentProvider as sa, FileIcon as na, FunctionPart as oa, GlobeIcon as ra, HistoryIcon as ia, IDLE_TIMEOUT as ca, InertEnvironmentProvider as la, JsxErrorBoundary as
|
|
11
|
-
import { u as
|
|
12
|
-
import { A as
|
|
13
|
-
import { S as
|
|
14
|
-
import { u as
|
|
15
|
-
import { Score as
|
|
9
|
+
import { H as ue, d as me, r as Te } from "./httpSessionService-BDlqebW2.js";
|
|
10
|
+
import { APPBAR_V2_HEIGHT as xe, ASK_USER_CANCELLED as Pe, AgentActivityV2 as Ue, AiChat as fe, AiChatDrawer as Re, AiChatFloating as Me, AiChatFloatingV2 as ye, AiChatProvider as _e, AiChatServiceContext as De, AiChatV2Pane as Be, AppBarV2 as Ve, AppRailV2 as ke, AppShellV2 as Fe, ArtifactRender as be, AskUserDialog as Ne, AskUserSheet as He, BoxedPart as Ge, BrainIcon as Oe, ChartIcon as We, ChatIcon as we, ChatPane as ze, ChatsHistoryV2 as Je, CheckIcon as je, ChevronIcon as Ke, ChevronRightIcon as qe, CloseIcon as Xe, CodeIcon as Ye, ComposerIcon as Qe, CurrentMessage as Ze, DEFAULT_PART_RENDERERS as $e, DashboardIcon as ea, DataExplorerIcon as aa, DelayTextComponent as ta, EnvironmentProvider as sa, FileIcon as na, FunctionPart as oa, GlobeIcon as ra, HistoryIcon as ia, IDLE_TIMEOUT as ca, InertEnvironmentProvider as la, JsxErrorBoundary as Aa, LIVE_TSX_DEFAULT_MAX_CHARS_FOR_FULL as Sa, LastPromptsV2 as Ca, LinearBackgroundProgress as pa, LinearProgressBarWithMarkers as ga, ListCheckIcon as da, LiveJsxBlock as Ia, LiveTsxConfigProvider as Ea, LlmResponseRender as ha, LoadingDots as va, LockClosedIcon as ua, LockOpenIcon as ma, MOBILE_NAV_DEFAULT as Ta, MarkdownExtended as La, MenuIcon as xa, Message as Pa, MobileDrawerV2 as Ua, PanelIcon as fa, PauseIcon as Ra, PinIcon as Ma, PlusIcon as ya, PromptDateMarkers as _a, PromptV2 as Da, RunProgressPanelV2 as Ba, RunProgressStripV2 as Va, SearchIcon as ka, SendIcon as Fa, SessionStateManagerService as ba, SparkleIcon as Na, Sparkline as Ha, StopIcon as Ga, Stopwatch as Oa, SubAgentBox as Wa, SubAgentBoxV2 as wa, SuspendedPart as za, TableIcon as Ja, TaskListV2 as ja, TerminalIcon as Ka, TextPart as qa, ThoughtPart as Xa, ToolIcon as Ya, TrashIcon as Qa, TurnAwareButton as Za, UiToolDispatcher as $a, UsersIcon as et, V2_CHART_PALETTE as at, WARNING_THRESHOLD as tt, WaitingPart as st, classifyPart as nt, configureFriendlyMapping as ot, createAiChatEngine as rt, createAiChatSessionStore as it, createAiChatSessionStore as ct, createUiToolRegistry as lt, disposeSharedAiChatEngine as At, extendDefaultScope as St, extendModuleRegistry as Ct, getDefaultJsxScope as pt, getFriendlyLabel as gt, getSharedAiChatEngine as dt, parseClientOutput as It, parseContentBlocks as Et, parseUiArgs as ht, useAiChatServices as vt, useAiChatSessionStore as ut, useEnvironment as mt, useEnvironmentOptional as Tt, useLiveSession as Lt, useLiveTsxMaxCharsForFull as xt, useParkedAskUser as Pt, useResponsiveLayout as Ut, useTurnOpen as ft, v2Card as Rt, v2Chip as Mt, v2IconBtn as yt, v2MonoMeta as _t, v2SectionLabel as Dt, v2Theme as Bt } from "./components.js";
|
|
11
|
+
import { u as kt, a as Ft, b as bt, c as Nt } from "./useContainerWidth-CDv8UQyZ.js";
|
|
12
|
+
import { A as Gt, a as Ot, b as Wt, G as wt, d as zt, c as Jt, e as jt, f as Kt, g as qt, h as Xt, i as Yt, j as Qt, k as Zt, l as $t, m as es, n as as, o as ts, p as ss, q as ns, r as os, s as rs, t as is, u as cs, v as ls } from "./auth-xpQrzSI2.js";
|
|
13
|
+
import { S as Ss, c as Cs, a as ps, e as gs, b as ds, f as Is, i as Es, d as hs, p as vs, g as us, s as ms, k as Ts, t as Ls } from "./atMentions-CJUmkOh9.js";
|
|
14
|
+
import { u as Ps } from "./useChatSessions-sbBneRk9.js";
|
|
15
|
+
import { Score as fs } from "./interfaces.js";
|
|
16
16
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
Gt as ALLOWED_DOMAINS,
|
|
18
|
+
Ot as ALLOWED_EMAILS,
|
|
19
19
|
k as ANALYTICS_AGENT_NAME,
|
|
20
20
|
xe as APPBAR_V2_HEIGHT,
|
|
21
21
|
Pe as ASK_USER_CANCELLED,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Wt as AUTH_CONFIG,
|
|
23
|
+
m as Account,
|
|
24
24
|
Ue as AgentActivityV2,
|
|
25
25
|
F as AgentConfig,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Ae as AgentGatewayService,
|
|
27
|
+
Se as AgentGatewayWSAsync,
|
|
28
28
|
T as AgentKind,
|
|
29
29
|
b as AgentMode,
|
|
30
30
|
N as AgentType,
|
|
@@ -77,19 +77,19 @@ export {
|
|
|
77
77
|
n as FunctionCallContent,
|
|
78
78
|
oa as FunctionPart,
|
|
79
79
|
o as FunctionResultContent,
|
|
80
|
-
|
|
80
|
+
wt as GOOGLE_CLIENT_ID,
|
|
81
81
|
j as GetEventTypeFromDotNetName,
|
|
82
82
|
K as GetEventTypeFromPythonName,
|
|
83
83
|
ra as GlobeIcon,
|
|
84
84
|
ia as HistoryIcon,
|
|
85
85
|
pe as HttpArtifactService,
|
|
86
|
-
|
|
86
|
+
ue as HttpSessionService,
|
|
87
87
|
ca as IDLE_TIMEOUT,
|
|
88
88
|
la as InertEnvironmentProvider,
|
|
89
89
|
r as InteractionPartUtils,
|
|
90
90
|
ge as InteractionService,
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
Aa as JsxErrorBoundary,
|
|
92
|
+
Sa as LIVE_TSX_DEFAULT_MAX_CHARS_FOR_FULL,
|
|
93
93
|
Ca as LastPromptsV2,
|
|
94
94
|
pa as LinearBackgroundProgress,
|
|
95
95
|
ga as LinearProgressBarWithMarkers,
|
|
@@ -100,8 +100,8 @@ export {
|
|
|
100
100
|
ha as LlmResponseRender,
|
|
101
101
|
va as LoadingDots,
|
|
102
102
|
de as LocalStorageService,
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
ua as LockClosedIcon,
|
|
104
|
+
ma as LockOpenIcon,
|
|
105
105
|
Ta as MOBILE_NAV_DEFAULT,
|
|
106
106
|
La as MarkdownExtended,
|
|
107
107
|
x as MemoryContextLabels,
|
|
@@ -123,20 +123,20 @@ export {
|
|
|
123
123
|
Ba as RunProgressPanelV2,
|
|
124
124
|
Va as RunProgressStripV2,
|
|
125
125
|
U as SUB_AGENT_TERMINAL_STATUSES,
|
|
126
|
-
|
|
126
|
+
fs as Score,
|
|
127
127
|
ka as SearchIcon,
|
|
128
128
|
Fa as SendIcon,
|
|
129
129
|
c as ServerEvent,
|
|
130
130
|
ba as SessionStateManagerService,
|
|
131
131
|
Z as SkillLevel,
|
|
132
|
-
|
|
132
|
+
Ss as SortableTable,
|
|
133
133
|
Na as SparkleIcon,
|
|
134
134
|
Ha as Sparkline,
|
|
135
135
|
Ga as StopIcon,
|
|
136
136
|
Oa as Stopwatch,
|
|
137
137
|
l as StreamingFunctionCallUpdateContent,
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
A as StreamingReasoningContent,
|
|
139
|
+
S as StreamingResponse,
|
|
140
140
|
C as StreamingTextContent,
|
|
141
141
|
Wa as SubAgentBox,
|
|
142
142
|
wa as SubAgentBoxV2,
|
|
@@ -149,96 +149,98 @@ export {
|
|
|
149
149
|
Xa as ThoughtPart,
|
|
150
150
|
Ya as ToolIcon,
|
|
151
151
|
Qa as TrashIcon,
|
|
152
|
-
Za as
|
|
153
|
-
$a as
|
|
154
|
-
et as
|
|
155
|
-
at as
|
|
156
|
-
tt as
|
|
152
|
+
Za as TurnAwareButton,
|
|
153
|
+
$a as UiToolDispatcher,
|
|
154
|
+
et as UsersIcon,
|
|
155
|
+
at as V2_CHART_PALETTE,
|
|
156
|
+
tt as WARNING_THRESHOLD,
|
|
157
|
+
st as WaitingPart,
|
|
157
158
|
Ie as WebSocketConnecionV2,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
Cs as chipLocations,
|
|
160
|
+
ps as chunkArray,
|
|
161
|
+
nt as classifyPart,
|
|
162
|
+
ot as configureFriendlyMapping,
|
|
163
|
+
rt as createAiChatEngine,
|
|
164
|
+
it as createAiChatSessionStore,
|
|
165
|
+
ct as createAiChatStore,
|
|
165
166
|
g as createEventSerializer,
|
|
166
167
|
d as createStreamingResponseSerializer,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
lt as createUiToolRegistry,
|
|
169
|
+
zt as dateReviver,
|
|
170
|
+
Jt as decodeBase64,
|
|
171
|
+
me as decodeSessionEvents,
|
|
172
|
+
jt as decodeUri,
|
|
173
|
+
Kt as decodeUriFromPython,
|
|
173
174
|
I as deserializeEvent,
|
|
174
175
|
E as deserializePayload,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
At as disposeSharedAiChatEngine,
|
|
177
|
+
qt as encodeBase64,
|
|
178
|
+
Xt as encodeUri,
|
|
178
179
|
St as extendDefaultScope,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
Ct as extendModuleRegistry,
|
|
181
|
+
gs as extractInteractionId,
|
|
182
|
+
ds as extractLinkAction,
|
|
183
|
+
Is as fetchAtMentions,
|
|
184
|
+
Yt as getAgentBaseUrl,
|
|
184
185
|
$ as getAgentServerBaseUrl,
|
|
185
|
-
|
|
186
|
+
Qt as getArtifactsBaseUrl,
|
|
186
187
|
ee as getConnectionStateColor,
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
pt as getDefaultJsxScope,
|
|
189
|
+
Zt as getDotNetBaseUrl,
|
|
189
190
|
ae as getEnvVar,
|
|
190
191
|
te as getEnvironmentInfo,
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
gt as getFriendlyLabel,
|
|
193
|
+
$t as getIconByName,
|
|
193
194
|
se as getModelVendor,
|
|
194
195
|
ne as getRandomUUID,
|
|
195
196
|
oe as getServerBaseUrl,
|
|
196
197
|
re as getServerClientBaseUrl,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
dt as getSharedAiChatEngine,
|
|
199
|
+
es as iconCategories,
|
|
200
|
+
as as isBase64Encoded,
|
|
201
|
+
Es as isSectionStart,
|
|
201
202
|
ie as isServer,
|
|
202
203
|
f as isSubAgentTerminalStatus,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
ts as isUriEncoded,
|
|
205
|
+
hs as isValidInteractionId,
|
|
206
|
+
ss as isValidUri,
|
|
207
|
+
ns as materialIcons,
|
|
208
|
+
vs as parseAndValidateArtifactUrl,
|
|
209
|
+
os as parseArtifactFromJson,
|
|
210
|
+
It as parseClientOutput,
|
|
211
|
+
Et as parseContentBlocks,
|
|
212
|
+
us as parseKnownNumbers,
|
|
213
|
+
ht as parseUiArgs,
|
|
214
|
+
rs as parseUriParams,
|
|
214
215
|
Te as resolveAccessToken,
|
|
215
216
|
ce as resolveApiUrl,
|
|
216
217
|
h as sanitizeJsonString,
|
|
217
|
-
|
|
218
|
+
is as searchIcons,
|
|
218
219
|
v as serializeEvent,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
220
|
+
cs as setEbiContextData,
|
|
221
|
+
ls as setEbiContextSessionId,
|
|
222
|
+
ms as splitBigLinesWithSpaces,
|
|
223
|
+
Ts as startsWithInteractionId,
|
|
224
|
+
Ls as tokenizeForHighlight,
|
|
225
|
+
vt as useAiChatServices,
|
|
226
|
+
ut as useAiChatSessionStore,
|
|
227
|
+
Ps as useChatSessions,
|
|
228
|
+
kt as useContainerRectangle,
|
|
229
|
+
Ft as useContainerWidth,
|
|
229
230
|
mt as useEnvironment,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
231
|
+
Tt as useEnvironmentOptional,
|
|
232
|
+
bt as useInterval,
|
|
233
|
+
Lt as useLiveSession,
|
|
234
|
+
xt as useLiveTsxMaxCharsForFull,
|
|
235
|
+
Pt as useParkedAskUser,
|
|
236
|
+
Nt as usePromptAssist,
|
|
237
|
+
Ut as useResponsiveLayout,
|
|
238
|
+
ft as useTurnOpen,
|
|
239
|
+
Rt as v2Card,
|
|
240
|
+
Mt as v2Chip,
|
|
241
|
+
yt as v2IconBtn,
|
|
242
|
+
_t as v2MonoMeta,
|
|
243
|
+
Dt as v2SectionLabel,
|
|
244
|
+
Bt as v2Theme
|
|
243
245
|
};
|
|
244
246
|
//# sourceMappingURL=index.js.map
|
|
@@ -37,6 +37,12 @@ import { default as React } from 'react';
|
|
|
37
37
|
export interface AskUserSheetProps {
|
|
38
38
|
/** Height of the composer to dock above, in px. Omit to stay positioning-agnostic. */
|
|
39
39
|
promptHeight?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Leading label of the eyebrow, before the tool name. Defaults to pt-BR, like the
|
|
42
|
+
* library's other user-facing strings (`atPersonLabel`, `datePresets`). Pass `null`
|
|
43
|
+
* to drop the eyebrow entirely.
|
|
44
|
+
*/
|
|
45
|
+
eyebrowLabel?: string | null;
|
|
40
46
|
}
|
|
41
47
|
declare const AskUserSheet: React.FC<AskUserSheetProps>;
|
|
42
48
|
export default AskUserSheet;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live "is the agent streaming a turn?" flag, readable from ANYWHERE — including
|
|
3
|
+
* outside an `<AiChat>` provider, where it is simply `false`.
|
|
4
|
+
*
|
|
5
|
+
* That tolerance is the whole point, and it is why this doesn't just call
|
|
6
|
+
* `useAiChatSessionStore((s) => s.turnOpen)`: that hook throws without a provider,
|
|
7
|
+
* and its `useStore` needs a store instance that a hook cannot conditionally
|
|
8
|
+
* acquire. Components shared between the chat surface and a plain page (obtapp's
|
|
9
|
+
* flight cards are rendered in both) would otherwise have to know which one they
|
|
10
|
+
* are in. Subscribing by hand to the store off the context handles the missing
|
|
11
|
+
* provider and keeps the re-render narrowed to `turnOpen` alone.
|
|
12
|
+
*
|
|
13
|
+
* Prefer this over `UiToolContext.onGoing` when the question is "is a turn open
|
|
14
|
+
* right now": `onGoing` is a snapshot of the SURFACE a part was rendered on
|
|
15
|
+
* (`true` in the live bubble, hardcoded `false` in settled history), so a card in
|
|
16
|
+
* history reports `false` forever even while a later turn streams.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useTurnOpen(): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material/Button';
|
|
2
|
+
/**
|
|
3
|
+
* The handler. Return a promise (e.g. the `sendMessage(...)` you kick off) and the
|
|
4
|
+
* button keeps waiting until it settles — see the note on the open_turn gap below.
|
|
5
|
+
*/
|
|
6
|
+
export type TurnAwareClickHandler = () => void | Promise<unknown>;
|
|
7
|
+
export interface TurnAwareButtonProps extends Omit<ButtonProps, 'onClick'> {
|
|
8
|
+
/** Runs on click, but only while no turn is open. */
|
|
9
|
+
onClick?: TurnAwareClickHandler;
|
|
10
|
+
/** Tooltip explaining the wait. */
|
|
11
|
+
waitingTitle?: string;
|
|
12
|
+
/** Drop the inline spinner (the button still blocks — this is presentation only). */
|
|
13
|
+
hideSpinner?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A `Button` that will not act while the agent's turn is open.
|
|
17
|
+
*
|
|
18
|
+
* Chat-rendered components are drawn mid-turn — a `present_tripstretch` card
|
|
19
|
+
* appears while the agent is still talking — and acting on one then races the run
|
|
20
|
+
* that is still writing to the session. So for as long as the turn is open this
|
|
21
|
+
* button is disabled AND spinning: the spinner is the point, not the disabling.
|
|
22
|
+
* A user who clicks a card mid-turn has usually just not noticed that the agent
|
|
23
|
+
* is still writing, and the spinner is what tells them; a plainly dead button
|
|
24
|
+
* would leave them clicking at nothing. Everything else is a plain MUI `Button`:
|
|
25
|
+
* same props, same theming, drop-in at the call site.
|
|
26
|
+
*
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <TurnAwareButton variant="contained" onClick={() => sendMessage('escolhi a opção 2')}>
|
|
29
|
+
* selecionar ida
|
|
30
|
+
* </TurnAwareButton>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Outside an `<AiChat>` provider there is no turn, so it behaves exactly like
|
|
34
|
+
* `Button` — components shared between the chat and a plain page need no branch.
|
|
35
|
+
*
|
|
36
|
+
* ⚠️ **The open_turn gap.** `turnOpen` only flips true when the server's
|
|
37
|
+
* `open_turn` command arrives, so for a moment after a handler sends a message the
|
|
38
|
+
* turn still reads as closed. Return the promise from your handler (`onClick={() =>
|
|
39
|
+
* sendMessage(…)}`, not `onClick={() => { sendMessage(…); }}`) and the button stays
|
|
40
|
+
* disabled across that window instead of briefly offering itself for a second click.
|
|
41
|
+
*
|
|
42
|
+
* The decision logic lives in `turnAwareButtonState.ts` (pure, unit-tested);
|
|
43
|
+
* this component is the React/MUI shell around it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function TurnAwareButton({ onClick, waitingTitle, hideSpinner, disabled, children, endIcon, sx, ...buttonProps }: TurnAwareButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export default TurnAwareButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decision logic behind {@link TurnAwareButton}, kept as pure functions so
|
|
3
|
+
* it can be unit-tested without a DOM (this package's vitest runs in `node`).
|
|
4
|
+
*
|
|
5
|
+
* The problem it solves: a chat-rendered component (a `present_tripstretch`
|
|
6
|
+
* card, say) is drawn WHILE the agent is still streaming its turn. Acting on it
|
|
7
|
+
* mid-turn races the run that is still writing to the session — and the click is
|
|
8
|
+
* usually a mistake anyway: the user didn't notice the agent was still writing.
|
|
9
|
+
* So the button blocks the click and SHOWS why, which is the part that helps.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* What the button itself is doing, independent of the turn:
|
|
13
|
+
* - `idle` — nothing pending.
|
|
14
|
+
* - `running` — the caller's handler is executing (an async handler that returned
|
|
15
|
+
* a promise keeps this until the promise settles).
|
|
16
|
+
*/
|
|
17
|
+
export type TurnAwarePhase = 'idle' | 'running';
|
|
18
|
+
export interface TurnAwareButtonSnapshot {
|
|
19
|
+
/** Live `turnOpen` from the chat session store — true while the agent streams a turn. */
|
|
20
|
+
turnOpen: boolean;
|
|
21
|
+
phase: TurnAwarePhase;
|
|
22
|
+
/** The caller's own `disabled`. Always wins. */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Should the button show its waiting affordance (spinner + tooltip)? True while
|
|
27
|
+
* the turn is open, and while our own handler is still running — the whole span
|
|
28
|
+
* in which the button is not ready to be clicked.
|
|
29
|
+
*
|
|
30
|
+
* This is the cue, not just decoration: a user clicking a card mid-turn has
|
|
31
|
+
* usually missed that the agent is still writing, and the spinner is what tells
|
|
32
|
+
* them. It always accompanies the block — the button is never inertly dead.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isWaiting(snapshot: TurnAwareButtonSnapshot): boolean;
|
|
35
|
+
/** Should the underlying MUI button be `disabled`? Whenever it is waiting, plus the caller's own flag. */
|
|
36
|
+
export declare function isBlocked(snapshot: TurnAwareButtonSnapshot): boolean;
|
|
37
|
+
export type TurnAwareClickDecision = 'run' | 'ignore';
|
|
38
|
+
/**
|
|
39
|
+
* What a click right now should do. `ignore` is belt-and-braces: a blocked button
|
|
40
|
+
* fires no click event, but the two must not be able to drift apart.
|
|
41
|
+
*/
|
|
42
|
+
export declare function decideClick(snapshot: TurnAwareButtonSnapshot): TurnAwareClickDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,6 +5,7 @@ export { AiChatProvider } from './AiChat/AiChatProvider';
|
|
|
5
5
|
export { AiChatDrawer } from './AiChat/AiChatDrawer';
|
|
6
6
|
export { AiChatFloating } from './AiChat/AiChatFloating';
|
|
7
7
|
export { AiChatServiceContext, useAiChatServices, useAiChatSessionStore, } from './AiChat/AiChatContext';
|
|
8
|
+
export { useTurnOpen } from './AiChat/useTurnOpen';
|
|
8
9
|
export type { AiChatContextState as AiChatServices } from './AiChat/AiChatContext';
|
|
9
10
|
export type { AiChatProps, AiChatHandle, AiChatStyleProps, AiChatDrawerProps, AiChatFloatingProps, ConnectionInformation, AuthPromptContext, } from './AiChat/AiChatTypes';
|
|
10
11
|
export type { AiChatState, AiChatStore, SubAgentState } from './AiChat/stateConfiguration';
|
|
@@ -38,6 +39,9 @@ export { default as ArtifactRender } from './Library/ArtifactRender';
|
|
|
38
39
|
export { default as LinearBackgroundProgress } from './Library/LinearBackgroundProgress';
|
|
39
40
|
export { default as LinearProgressBarWithMarkers } from './Library/LinearProgressBarWithMarkers';
|
|
40
41
|
export { default as DelayTextComponent } from './Library/DelayTextComponent';
|
|
42
|
+
export { default as TurnAwareButton } from './Library/TurnAwareButton';
|
|
43
|
+
export type { TurnAwareButtonProps, TurnAwareClickHandler } from './Library/TurnAwareButton';
|
|
44
|
+
export type { TurnAwarePhase } from './Library/turnAwareButtonState';
|
|
41
45
|
export { LlmResponseRender, LiveJsxBlock, JsxErrorBoundary, EnvironmentProvider, InertEnvironmentProvider, useEnvironment, useEnvironmentOptional, LiveTsxConfigProvider, useLiveTsxMaxCharsForFull, LIVE_TSX_DEFAULT_MAX_CHARS_FOR_FULL, extendModuleRegistry, extendDefaultScope, getDefaultJsxScope, parseContentBlocks, } from './LlmResponseRender';
|
|
42
46
|
export type { ContentBlock } from './LlmResponseRender';
|
|
43
47
|
export * from './v2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aintela/chat",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -116,6 +116,8 @@
|
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@microlink/react-json-view": "^1.27.0",
|
|
119
|
+
"@testing-library/dom": "^10.4.1",
|
|
120
|
+
"@testing-library/react": "^16.3.2",
|
|
119
121
|
"@types/lodash": "^4.17.0",
|
|
120
122
|
"@types/node": "^20.11.0",
|
|
121
123
|
"@types/react": "^18.2.0",
|
|
@@ -123,6 +125,7 @@
|
|
|
123
125
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
124
126
|
"@vitejs/plugin-react": "^4.5.2",
|
|
125
127
|
"@vitest/coverage-v8": "^4.1.7",
|
|
128
|
+
"happy-dom": "^20.11.1",
|
|
126
129
|
"html-react-parser": "^5.2.0",
|
|
127
130
|
"js-base64": "^3.7.0",
|
|
128
131
|
"recharts": "^2.15.0",
|