@marimo-team/islands 0.23.17-dev33 → 0.23.17-dev35
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/{ConnectedDataExplorerComponent-BEb8RZam.js → ConnectedDataExplorerComponent-emE_tsrt.js} +11 -11
- package/dist/{ErrorBoundary-8ZHte0h9.js → ErrorBoundary-o6wEnSCc.js} +2 -2
- package/dist/{any-language-editor-CioNaP-T.js → any-language-editor-Cls8lx9d.js} +4 -4
- package/dist/chat-ui-1-XgwfDv.js +8620 -0
- package/dist/{check-CCvJTB2E.js → check-D-BaEjEh.js} +1 -1
- package/dist/{common-C2Coc2Bh.js → common-mBzwyg_G.js} +18 -18
- package/dist/{copy-D45ZUY3j.js → copy-BkA3t7rJ.js} +1 -1
- package/dist/{dist-DgzzIPS4.js → dist-DarwE0ZO.js} +10 -10
- package/dist/{error-banner-DHfPl1w3.js → error-banner-dmkbm21G.js} +1 -1
- package/dist/{esm-DJsE6wi-.js → esm-CfyRntAe.js} +1 -1
- package/dist/{extends-xQ_2Cylt.js → extends-DzpiytFg.js} +3 -3
- package/dist/{formats-D10vOEsT.js → formats-DcO6TofP.js} +1 -1
- package/dist/{glide-data-editor-FiwJJzrV.js → glide-data-editor-C99Bp4Hk.js} +8 -8
- package/dist/{html-to-image-Bgb6aaXi.js → html-to-image-CgznkzKG.js} +13 -13
- package/dist/{input-DtTqU0xh.js → input-CwPuFkJt.js} +5 -5
- package/dist/{label-5IC840tS.js → label-CzHncDvS.js} +1 -1
- package/dist/main.js +29 -29
- package/dist/{mermaid-BNhC-PrB.js → mermaid-Sy0p3RJY.js} +4 -4
- package/dist/{process-output-D2Oxf11p.js → process-output-DUNqOGZS.js} +3 -3
- package/dist/{reveal-component--Ln8gdbm.js → reveal-component-BKPirLwd.js} +9 -9
- package/dist/{spec-C7rMyZ_8.js → spec-Be9MhFWh.js} +4 -4
- package/dist/{strings-CITcoFNY.js → strings-BUDhKc0s.js} +298 -298
- package/dist/{toDate-kxcuDOWd.js → toDate-eW__SzBR.js} +2 -2
- package/dist/{tooltip-BkSv4x8S.js → tooltip-CkCWlUOf.js} +2 -2
- package/dist/{types-kNUyqkDD.js → types-uENjXsiC.js} +1 -1
- package/dist/{useAsyncData-Uo4VFafD.js → useAsyncData-B8UxSH4O.js} +1 -1
- package/dist/{useDateFormatter-ZCfHadYP.js → useDateFormatter-BeN3fHMH.js} +2 -2
- package/dist/{useDeepCompareMemoize-s3ZvmdK3.js → useDeepCompareMemoize-BnhKck7C.js} +1 -1
- package/dist/{useLifecycle-CLPBATCv.js → useLifecycle-B7J7yvFt.js} +2 -2
- package/dist/{useTheme-CEMsu1Js.js → useTheme-BUY7pfI9.js} +1 -1
- package/dist/{vega-component-DGkcoXu3.js → vega-component-BOeMnvAb.js} +8 -8
- package/dist/{zod-DdNi9290.js → zod-yTHHzJiv.js} +36 -37
- package/package.json +3 -3
- package/src/components/chat/__tests__/chat-abort.test.ts +51 -0
- package/src/components/chat/chat-abort.ts +44 -0
- package/src/components/chat/chat-display.tsx +17 -0
- package/src/components/chat/chat-panel.tsx +85 -37
- package/src/components/chat/chat-utils.ts +1 -1
- package/src/components/editor/ai/add-cell-with-ai.tsx +2 -2
- package/src/components/editor/ai/ai-completion-editor.tsx +2 -2
- package/src/core/ai/constants.ts +7 -0
- package/src/core/ai/staged-cells.ts +3 -0
- package/src/plugins/impl/chat/chat-ui.tsx +51 -3
- package/dist/chat-ui-Cjd9kIcO.js +0 -8369
|
@@ -176,14 +176,17 @@ export function useStagedCells(store: JotaiStore) {
|
|
|
176
176
|
case "message-metadata":
|
|
177
177
|
case "tool-input-available":
|
|
178
178
|
case "tool-output-available":
|
|
179
|
+
case "tool-approval-response":
|
|
179
180
|
case "reasoning-start":
|
|
180
181
|
case "reasoning-delta":
|
|
181
182
|
case "reasoning-end":
|
|
182
183
|
case "file":
|
|
184
|
+
case "reasoning-file":
|
|
183
185
|
case "source-document":
|
|
184
186
|
case "source-url":
|
|
185
187
|
case "tool-input-start":
|
|
186
188
|
case "tool-input-delta":
|
|
189
|
+
case "custom":
|
|
187
190
|
Logger.debug(chunk.type, { chunk });
|
|
188
191
|
break;
|
|
189
192
|
default:
|
|
@@ -26,6 +26,11 @@ import {
|
|
|
26
26
|
} from "lucide-react";
|
|
27
27
|
import React, { useEffect, useRef, useState } from "react";
|
|
28
28
|
import { z } from "zod";
|
|
29
|
+
import {
|
|
30
|
+
describeChatAbortReason,
|
|
31
|
+
getAbortReasonFromChunk,
|
|
32
|
+
resolveChatAbortReason,
|
|
33
|
+
} from "@/components/chat/chat-abort";
|
|
29
34
|
import { renderUIMessage } from "@/components/chat/chat-display";
|
|
30
35
|
import {
|
|
31
36
|
convertToFileUIPart,
|
|
@@ -168,6 +173,12 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
168
173
|
// different message_id are stale (from an aborted-but-not-yet-cancelled run
|
|
169
174
|
// on the kernel) and must be dropped
|
|
170
175
|
const activeRequestIdRef = useRef<string | null>(null);
|
|
176
|
+
const lastAbortReasonRef = useRef<string | null>(null);
|
|
177
|
+
const [abortNotice, setAbortNotice] = useState<string | null>(null);
|
|
178
|
+
const clearAbortState = () => {
|
|
179
|
+
lastAbortReasonRef.current = null;
|
|
180
|
+
setAbortNotice(null);
|
|
181
|
+
};
|
|
171
182
|
|
|
172
183
|
const { data: backendMessages } = useAsyncData(async () => {
|
|
173
184
|
const response = await props.get_chat_history({});
|
|
@@ -231,6 +242,7 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
231
242
|
// Client-generated id used to (a) route chunks back to this stream
|
|
232
243
|
// and (b) ask the kernel to cancel just this run on Stop.
|
|
233
244
|
const requestId = generateUUID();
|
|
245
|
+
clearAbortState();
|
|
234
246
|
|
|
235
247
|
const stream = new ReadableStream<UIMessageChunk>({
|
|
236
248
|
start(controller) {
|
|
@@ -297,15 +309,30 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
297
309
|
},
|
|
298
310
|
}),
|
|
299
311
|
messages: initialMessages,
|
|
300
|
-
onFinish: (
|
|
312
|
+
onFinish: ({ messages, isAbort, finishReason }) => {
|
|
301
313
|
setFiles(undefined);
|
|
302
314
|
|
|
303
315
|
if (fileInputRef.current) {
|
|
304
316
|
fileInputRef.current.value = "";
|
|
305
317
|
}
|
|
306
|
-
Logger.debug("Finished streaming message:",
|
|
318
|
+
Logger.debug("Finished streaming message:", { finishReason, isAbort });
|
|
319
|
+
|
|
320
|
+
if (isAbort) {
|
|
321
|
+
const reason = resolveChatAbortReason({
|
|
322
|
+
isAbort: true,
|
|
323
|
+
streamReason: lastAbortReasonRef.current,
|
|
324
|
+
});
|
|
325
|
+
clearAbortState();
|
|
326
|
+
if (reason != null) {
|
|
327
|
+
const description = describeChatAbortReason(reason);
|
|
328
|
+
Logger.debug("Chat stream aborted", { reason, finishReason });
|
|
329
|
+
setAbortNotice(description);
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
clearAbortState();
|
|
333
|
+
}
|
|
307
334
|
|
|
308
|
-
props.setValue(
|
|
335
|
+
props.setValue(messages);
|
|
309
336
|
},
|
|
310
337
|
onError: (error) => {
|
|
311
338
|
Logger.error("An error occurred:", error);
|
|
@@ -323,6 +350,17 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
323
350
|
if (!parsedMessage.success) {
|
|
324
351
|
return;
|
|
325
352
|
}
|
|
353
|
+
// Only record abort reasons for the active request. Late chunks from a
|
|
354
|
+
// cancelled run must not overwrite the next turn's reason
|
|
355
|
+
if (
|
|
356
|
+
parsedMessage.data.content &&
|
|
357
|
+
parsedMessage.data.message_id === activeRequestIdRef.current
|
|
358
|
+
) {
|
|
359
|
+
const abortReason = getAbortReasonFromChunk(parsedMessage.data.content);
|
|
360
|
+
if (abortReason !== undefined) {
|
|
361
|
+
lastAbortReasonRef.current = abortReason;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
326
364
|
routeIncomingChatChunk(parsedMessage.data, {
|
|
327
365
|
controllerRef: frontendStreamControllerRef,
|
|
328
366
|
activeRequestIdRef,
|
|
@@ -340,6 +378,9 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
340
378
|
setMessages(newMessages);
|
|
341
379
|
|
|
342
380
|
props.setValue(newMessages);
|
|
381
|
+
if (newMessages.length === 0) {
|
|
382
|
+
clearAbortState();
|
|
383
|
+
}
|
|
343
384
|
}
|
|
344
385
|
};
|
|
345
386
|
|
|
@@ -389,6 +430,7 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
389
430
|
props.setValue([]);
|
|
390
431
|
props.delete_chat_history({});
|
|
391
432
|
clearError();
|
|
433
|
+
clearAbortState();
|
|
392
434
|
};
|
|
393
435
|
|
|
394
436
|
return (
|
|
@@ -483,6 +525,12 @@ export const Chatbot: React.FC<Props> = (props) => {
|
|
|
483
525
|
</Button>
|
|
484
526
|
</div>
|
|
485
527
|
)}
|
|
528
|
+
|
|
529
|
+
{abortNotice && !isLoading && !error && (
|
|
530
|
+
<div className="flex justify-center py-2">
|
|
531
|
+
<span className="text-xs text-muted-foreground">{abortNotice}</span>
|
|
532
|
+
</div>
|
|
533
|
+
)}
|
|
486
534
|
</div>
|
|
487
535
|
<form
|
|
488
536
|
onSubmit={async (evt) => {
|