@marimo-team/islands 0.25.3-dev402 → 0.25.3-dev409
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-1DGGwl88.js → ConnectedDataExplorerComponent-DCW4bXq-.js} +1 -1
- package/dist/{ErrorBoundary-DfbzIKA3.js → ErrorBoundary-DvqXHbNZ.js} +1 -1
- package/dist/{chat-ui-r3PPIMn0.js → chat-ui-BGEXB6V4.js} +1354 -1320
- package/dist/{code-visibility-CXijswY7.js → code-visibility-U0UkDKVw.js} +1 -1
- package/dist/{common-Cm5ENbUw.js → common-DIbea_dy.js} +1 -1
- package/dist/{data-grid-overlay-editor-Dv0TkGKt.js → data-grid-overlay-editor-DfXNDUyH.js} +1 -1
- package/dist/{feedback-button-Xk-mOev4.js → feedback-button-MbaK_7gC.js} +2 -2
- package/dist/{glide-data-editor-DdxBDWAj.js → glide-data-editor-BFIyRGll.js} +3 -3
- package/dist/{globals-DR3VVkF6.js → globals-B19LJT4z.js} +1 -1
- package/dist/main.js +6160 -6141
- package/dist/{number-overlay-editor-Cc5gJryh.js → number-overlay-editor-VHIfift0.js} +1 -1
- package/dist/{process-output-39KkAXSF.js → process-output-BvCDoG-m.js} +14 -25
- package/dist/{reveal-component-Dm5K9KPi.js → reveal-component-2v0Bn3oO.js} +2 -2
- package/dist/{spec-Ww0JjShW.js → spec-DV8oNpRR.js} +46 -49
- package/dist/{semaphore-8KhQouXt.js → useDeepCompareMemoize-C90a6_io.js} +15 -5
- package/dist/{vega-component-DQZhTzVQ.js → vega-component-ArEoBGzQ.js} +197 -198
- package/package.json +1 -1
- package/src/components/chat/__tests__/chat-utils.test.ts +48 -0
- package/src/components/chat/__tests__/message-queue.test.tsx +94 -1
- package/src/components/chat/__tests__/pending-chat-prompt.test.tsx +568 -0
- package/src/components/chat/__tests__/useFileState.test.tsx +176 -15
- package/src/components/chat/chat-components.tsx +3 -2
- package/src/components/chat/chat-panel.tsx +199 -74
- package/src/components/chat/chat-utils.ts +148 -34
- package/src/components/chat/user-message.tsx +15 -6
- package/src/components/data-table/charts/__tests__/altair-generator.test.ts +42 -27
- package/src/components/data-table/charts/chart-spec/altair-generator.ts +2 -6
- package/src/core/ai/__tests__/attachments.test.ts +153 -0
- package/src/core/ai/attachments.ts +80 -0
- package/src/utils/python-poet/poet.ts +12 -2
- package/dist/useDeepCompareMemoize-Bvrue1iy.js +0 -11
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import { FRONTEND_TOOL_REGISTRY } from "@/core/ai/tools/registry";
|
|
|
6
6
|
import { describe, expect, it, vi } from "vitest";
|
|
7
7
|
import {
|
|
8
8
|
handleToolCall,
|
|
9
|
+
hasAssistantProgress,
|
|
9
10
|
hasPendingToolCalls,
|
|
10
11
|
hasUnresolvedToolCalls,
|
|
11
12
|
shouldFlushQueue,
|
|
@@ -36,6 +37,53 @@ const assistantToolMessage = (
|
|
|
36
37
|
parts,
|
|
37
38
|
});
|
|
38
39
|
|
|
40
|
+
describe("hasAssistantProgress", () => {
|
|
41
|
+
it("does not continue a previous turn when the latest user message failed", () => {
|
|
42
|
+
expect(
|
|
43
|
+
hasAssistantProgress([
|
|
44
|
+
assistantToolMessage([{ type: "text", text: "Previous answer" }]),
|
|
45
|
+
userMessage("next question"),
|
|
46
|
+
]),
|
|
47
|
+
).toBe(false);
|
|
48
|
+
expect(hasAssistantProgress([])).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it.each<UIMessage["parts"]>([
|
|
52
|
+
[],
|
|
53
|
+
[{ type: "step-start" }],
|
|
54
|
+
[{ type: "text", text: "", state: "streaming" }],
|
|
55
|
+
[{ type: "reasoning", text: " ", state: "streaming" }],
|
|
56
|
+
])("retries when only an empty response was received: %j", (...parts) => {
|
|
57
|
+
expect(hasAssistantProgress([assistantToolMessage(parts)])).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it.each<UIMessage["parts"]>([
|
|
61
|
+
[{ type: "text", text: "Partial answer", state: "streaming" }],
|
|
62
|
+
[{ type: "reasoning", text: "Work so far", state: "streaming" }],
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
type: "tool-run_query",
|
|
66
|
+
toolCallId: "call-1",
|
|
67
|
+
state: "output-available",
|
|
68
|
+
input: {},
|
|
69
|
+
output: 1,
|
|
70
|
+
},
|
|
71
|
+
{ type: "step-start" },
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
{
|
|
75
|
+
type: "dynamic-tool",
|
|
76
|
+
toolName: "edit_cell",
|
|
77
|
+
toolCallId: "call-1",
|
|
78
|
+
state: "input-available",
|
|
79
|
+
input: {},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
])("continues when assistant progress was received: %j", (...parts) => {
|
|
83
|
+
expect(hasAssistantProgress([assistantToolMessage(parts)])).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
39
87
|
describe("hasPendingToolCalls", () => {
|
|
40
88
|
it("returns false when there are no messages", () => {
|
|
41
89
|
expect(hasPendingToolCalls([])).toBe(false);
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { act, renderHook } from "@testing-library/react";
|
|
4
4
|
import { describe, expect, it, vi } from "vitest";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type ChatMessagePart,
|
|
7
|
+
useMessageQueue,
|
|
8
|
+
validateChatAttachments,
|
|
9
|
+
} from "../chat-utils";
|
|
6
10
|
|
|
7
11
|
function textPart(text: string): ChatMessagePart {
|
|
8
12
|
return { type: "text", text };
|
|
@@ -104,6 +108,64 @@ describe("useMessageQueue", () => {
|
|
|
104
108
|
expect(result.current.messages).toEqual([]);
|
|
105
109
|
});
|
|
106
110
|
|
|
111
|
+
it("preserves a queued image when the model changes, then sends it after switching back", () => {
|
|
112
|
+
const { result, rerender } = renderHook(
|
|
113
|
+
({ types }) => {
|
|
114
|
+
const queue = useMessageQueue();
|
|
115
|
+
return {
|
|
116
|
+
...queue,
|
|
117
|
+
validate: (parts: ChatMessagePart[]) =>
|
|
118
|
+
validateChatAttachments(parts, types),
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
{ initialProps: { types: ["text/*", "image/png"] } },
|
|
122
|
+
);
|
|
123
|
+
const parts: ChatMessagePart[] = [
|
|
124
|
+
textPart("describe this"),
|
|
125
|
+
{
|
|
126
|
+
type: "file",
|
|
127
|
+
mediaType: "image/png",
|
|
128
|
+
filename: "chart.png",
|
|
129
|
+
url: "data:image/png;base64,aW1hZ2U=",
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
const send = vi.fn();
|
|
133
|
+
act(() => result.current.enqueue(parts));
|
|
134
|
+
const queued = result.current.messages;
|
|
135
|
+
rerender({ types: ["text/*"] });
|
|
136
|
+
|
|
137
|
+
act(() => result.current.flushNext(send, result.current.validate));
|
|
138
|
+
|
|
139
|
+
expect(send).not.toHaveBeenCalled();
|
|
140
|
+
expect(result.current.messages).toEqual(queued);
|
|
141
|
+
expect(result.current.hasQueuedRef.current).toBe(true);
|
|
142
|
+
|
|
143
|
+
rerender({ types: ["text/*", "image/png"] });
|
|
144
|
+
act(() => result.current.flushNext(send, result.current.validate));
|
|
145
|
+
|
|
146
|
+
expect(send).toHaveBeenCalledExactlyOnceWith(parts);
|
|
147
|
+
expect(result.current.messages).toEqual([]);
|
|
148
|
+
expect(result.current.hasQueuedRef.current).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("rejects images resolved from context for a text-only model", () => {
|
|
152
|
+
expect(
|
|
153
|
+
validateChatAttachments(
|
|
154
|
+
[
|
|
155
|
+
textPart("describe @cell"),
|
|
156
|
+
{
|
|
157
|
+
type: "file",
|
|
158
|
+
mediaType: "image/png",
|
|
159
|
+
filename: "cell.png",
|
|
160
|
+
url: "data:image/png;base64,aW1hZ2U=",
|
|
161
|
+
providerMetadata: { marimo: { source: "context" } },
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
["text/*"],
|
|
165
|
+
),
|
|
166
|
+
).toBe(false);
|
|
167
|
+
});
|
|
168
|
+
|
|
107
169
|
it("clear empties the queue", () => {
|
|
108
170
|
const { result } = renderHook(() => useMessageQueue());
|
|
109
171
|
|
|
@@ -115,6 +177,37 @@ describe("useMessageQueue", () => {
|
|
|
115
177
|
expect(result.current.hasQueuedRef.current).toBe(false);
|
|
116
178
|
});
|
|
117
179
|
|
|
180
|
+
it("allows later messages to send after removing a blocked head", () => {
|
|
181
|
+
const { result } = renderHook(() => useMessageQueue());
|
|
182
|
+
const blocked: ChatMessagePart[] = [
|
|
183
|
+
{
|
|
184
|
+
type: "file",
|
|
185
|
+
mediaType: "image/png",
|
|
186
|
+
url: "data:image/png;base64,aW1hZ2U=",
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
const later = [textPart("never mind, just answer this")];
|
|
190
|
+
const send = vi.fn();
|
|
191
|
+
const canSend = (parts: ChatMessagePart[]) =>
|
|
192
|
+
validateChatAttachments(parts, ["text/*"]);
|
|
193
|
+
act(() => {
|
|
194
|
+
result.current.enqueue(blocked);
|
|
195
|
+
result.current.enqueue(later);
|
|
196
|
+
result.current.flushNext(send, canSend);
|
|
197
|
+
});
|
|
198
|
+
expect(send).not.toHaveBeenCalled();
|
|
199
|
+
const blockedId = result.current.messages[0].id;
|
|
200
|
+
|
|
201
|
+
act(() => {
|
|
202
|
+
result.current.remove(blockedId);
|
|
203
|
+
result.current.flushNext(send, canSend);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
expect(send).toHaveBeenCalledExactlyOnceWith(later);
|
|
207
|
+
expect(result.current.messages).toEqual([]);
|
|
208
|
+
expect(result.current.hasQueuedRef.current).toBe(false);
|
|
209
|
+
});
|
|
210
|
+
|
|
118
211
|
it("hasQueuedRef stays in sync when enqueue and flush run in the same act", () => {
|
|
119
212
|
const { result } = renderHook(() => useMessageQueue());
|
|
120
213
|
const send = vi.fn();
|