@marimo-team/islands 0.23.9-dev8 → 0.23.9
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-OzrfMM5L.js → ConnectedDataExplorerComponent-CyV83R2m.js} +4 -4
- package/dist/assets/__vite-browser-external-Ci2ZQfXU.js +1 -0
- package/dist/assets/{worker-CpBbwbQo.js → worker-ip3AI_sN.js} +2 -2
- package/dist/{chat-ui-BDI3FMI8.js → chat-ui-ChD4VvCo.js} +3060 -3033
- package/dist/{code-visibility-SqsoLwxQ.js → code-visibility-BkuwTYAm.js} +1368 -1204
- package/dist/{formats-DQ5qjo_Q.js → formats-DHxc-FdY.js} +1 -1
- package/dist/{glide-data-editor-DqRY9naW.js → glide-data-editor-BOmK9ETQ.js} +2 -2
- package/dist/{html-to-image-CiSinpSR.js → html-to-image-BHv7CEU_.js} +2145 -2153
- package/dist/{input-CZD2z6X2.js → input-_2sjvfne.js} +1 -1
- package/dist/main.js +680 -705
- package/dist/{mermaid-IU93XzmY.js → mermaid-lXOw5Py9.js} +2 -2
- package/dist/{process-output-5qJjMRKh.js → process-output-BvySRgli.js} +33 -25
- package/dist/{reveal-component-v4zHgynl.js → reveal-component-DeBkkDcg.js} +312 -291
- package/dist/{spec-a6DaqW__.js → spec-B96zNUEA.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{toDate-ZVVIBmdk.js → toDate-x-WRDCH7.js} +1 -1
- package/dist/{useAsyncData-C008zUPi.js → useAsyncData-iRgKDT5s.js} +1 -1
- package/dist/{useDeepCompareMemoize-BrA3_n61.js → useDeepCompareMemoize-CkQ57VS2.js} +1 -1
- package/dist/{useLifecycle-BNaoJ5a4.js → useLifecycle-BBO9PIph.js} +1 -1
- package/dist/{useTheme-7O0YWlE5.js → useTheme-DHIrRQOe.js} +34 -21
- package/dist/{vega-component-DJNmOdUj.js → vega-component-Dq-SH463.js} +5 -5
- package/package.json +1 -1
- package/src/components/ai/__tests__/ai-utils.test.ts +43 -38
- package/src/components/ai/ai-model-dropdown.tsx +2 -2
- package/src/components/app-config/ai-config.tsx +147 -16
- package/src/components/app-config/user-config-form.tsx +37 -1
- package/src/components/chat/__tests__/chat-utils.test.ts +269 -0
- package/src/components/chat/chat-panel.tsx +38 -5
- package/src/components/chat/chat-utils.ts +14 -58
- package/src/components/data-table/TableBottomBar.tsx +5 -8
- package/src/components/data-table/__tests__/column-explorer.test.tsx +128 -0
- package/src/components/data-table/__tests__/header-items.test.tsx +220 -10
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +95 -29
- package/src/components/data-table/column-header.tsx +17 -12
- package/src/components/data-table/data-table.tsx +4 -0
- package/src/components/data-table/export-actions.tsx +19 -12
- package/src/components/data-table/header-items.tsx +40 -16
- package/src/components/data-table/hooks/use-column-visibility.ts +14 -0
- package/src/components/data-table/schemas.ts +2 -2
- package/src/components/data-table/table-explorer-panel/table-explorer-panel.tsx +16 -6
- package/src/components/databases/display.tsx +2 -0
- package/src/components/datasources/__tests__/utils.test.ts +82 -0
- package/src/components/datasources/utils.ts +16 -15
- package/src/components/editor/Disconnected.tsx +1 -60
- package/src/components/editor/__tests__/viewer-banner.test.tsx +89 -0
- package/src/components/editor/actions/pair-with-agent-modal.tsx +1 -0
- package/src/components/editor/actions/useCellActionButton.tsx +3 -3
- package/src/components/editor/actions/useNotebookActions.tsx +5 -2
- package/src/components/editor/cell/code/cell-editor.tsx +25 -5
- package/src/components/editor/chrome/types.ts +13 -6
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +6 -4
- package/src/components/editor/chrome/wrapper/footer-items/ai-status.tsx +10 -1
- package/src/components/editor/chrome/wrapper/sidebar.tsx +7 -5
- package/src/components/editor/errors/auto-fix.tsx +3 -3
- package/src/components/editor/header/__tests__/status.test.tsx +0 -15
- package/src/components/editor/header/app-header.tsx +1 -4
- package/src/components/editor/header/status.tsx +4 -13
- package/src/components/editor/navigation/__tests__/navigation.test.ts +15 -0
- package/src/components/editor/navigation/navigation.ts +5 -0
- package/src/components/editor/output/MarimoErrorOutput.tsx +103 -25
- package/src/components/editor/output/MarimoTracebackOutput.tsx +28 -39
- package/src/components/editor/renderers/cell-array.tsx +27 -24
- package/src/components/editor/renderers/slides-layout/__tests__/compute-slide-cells.test.ts +30 -17
- package/src/components/editor/renderers/slides-layout/compute-slide-cells.ts +17 -8
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +10 -12
- package/src/components/editor/viewer-banner.tsx +82 -0
- package/src/components/slides/minimap.tsx +45 -9
- package/src/components/slides/reveal-component.tsx +82 -37
- package/src/components/slides/slide-cell-view.tsx +12 -1
- package/src/components/slides/slide-form.tsx +11 -3
- package/src/components/static-html/static-banner.tsx +28 -22
- package/src/core/ai/__tests__/model-registry.test.ts +72 -60
- package/src/core/ai/model-registry.ts +33 -28
- package/src/core/cells/__tests__/actions.test.ts +48 -0
- package/src/core/cells/actions.ts +5 -6
- package/src/core/codemirror/__tests__/setup.test.ts +29 -0
- package/src/core/codemirror/cells/traceback-decorations.ts +1 -1
- package/src/core/codemirror/cm.ts +50 -3
- package/src/core/codemirror/completion/hints.ts +4 -1
- package/src/core/codemirror/format.ts +1 -0
- package/src/core/codemirror/keymaps/vim.ts +63 -0
- package/src/core/codemirror/language/languages/sql/sql.ts +1 -0
- package/src/core/codemirror/language/languages/sql/utils.ts +2 -0
- package/src/core/config/__tests__/config-schema.test.ts +4 -0
- package/src/core/config/config-schema.ts +4 -0
- package/src/core/config/config.ts +16 -0
- package/src/core/edit-app.tsx +3 -0
- package/src/core/islands/bootstrap.ts +2 -0
- package/src/core/kernel/__tests__/handlers.test.ts +5 -0
- package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +0 -13
- package/src/core/websocket/types.ts +0 -6
- package/src/core/websocket/useMarimoKernelConnection.tsx +3 -12
- package/src/css/app/Cell.css +0 -1
- package/src/plugins/impl/DataTablePlugin.tsx +48 -22
- package/src/plugins/impl/chat/ChatPlugin.tsx +7 -1
- package/src/plugins/impl/chat/__tests__/chat-ui.test.ts +278 -0
- package/src/plugins/impl/chat/chat-ui.tsx +106 -59
- package/src/plugins/impl/chat/types.ts +5 -0
- package/src/utils/__tests__/json-parser.test.ts +1 -69
- package/src/utils/json/json-parser.ts +0 -30
- package/dist/assets/__vite-browser-external-CAdMKBac.js +0 -1
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { UIMessage } from "ai";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { hasPendingToolCalls } from "../chat-utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `hasPendingToolCalls` powers `sendAutomaticallyWhen` in `mo.ui.chat`:
|
|
9
|
+
* returns true only when the last assistant message *ends* with a tool
|
|
10
|
+
* call in a ready-to-round-trip state. Any trailing non-tool part (text,
|
|
11
|
+
* file, source-*, reasoning, data-*, new step-start) means the assistant
|
|
12
|
+
* has already answered and we leave the next turn to the user. The
|
|
13
|
+
* approval flow relies on this firing for `approval-responded`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const userMessage = (text: string): UIMessage => ({
|
|
17
|
+
id: `user-${text}`,
|
|
18
|
+
role: "user",
|
|
19
|
+
parts: [{ type: "text", text }],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const assistantToolMessage = (
|
|
23
|
+
parts: UIMessage["parts"],
|
|
24
|
+
id = "assistant-1",
|
|
25
|
+
): UIMessage => ({
|
|
26
|
+
id,
|
|
27
|
+
role: "assistant",
|
|
28
|
+
parts,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("hasPendingToolCalls", () => {
|
|
32
|
+
it("returns false when there are no messages", () => {
|
|
33
|
+
expect(hasPendingToolCalls([])).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("returns false when the last message is a user message", () => {
|
|
37
|
+
expect(hasPendingToolCalls([userMessage("hi")])).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("returns false when the last assistant message has no tool parts", () => {
|
|
41
|
+
expect(
|
|
42
|
+
hasPendingToolCalls([
|
|
43
|
+
userMessage("hi"),
|
|
44
|
+
assistantToolMessage([{ type: "text", text: "hello!" }]),
|
|
45
|
+
]),
|
|
46
|
+
).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("returns false while a tool is still streaming or awaiting approval", () => {
|
|
50
|
+
expect(
|
|
51
|
+
hasPendingToolCalls([
|
|
52
|
+
userMessage("delete it"),
|
|
53
|
+
assistantToolMessage([
|
|
54
|
+
{
|
|
55
|
+
type: "tool-delete_file",
|
|
56
|
+
toolCallId: "call-1",
|
|
57
|
+
state: "approval-requested",
|
|
58
|
+
input: { path: "secrets.env" },
|
|
59
|
+
approval: { id: "approval-1" },
|
|
60
|
+
} as unknown as UIMessage["parts"][number],
|
|
61
|
+
]),
|
|
62
|
+
]),
|
|
63
|
+
).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("returns true when the user has responded to an approval request", () => {
|
|
67
|
+
// The chat must auto-resume as soon as Approve/Deny is clicked.
|
|
68
|
+
expect(
|
|
69
|
+
hasPendingToolCalls([
|
|
70
|
+
userMessage("delete it"),
|
|
71
|
+
assistantToolMessage([
|
|
72
|
+
{
|
|
73
|
+
type: "tool-delete_file",
|
|
74
|
+
toolCallId: "call-1",
|
|
75
|
+
state: "approval-responded",
|
|
76
|
+
input: { path: "secrets.env" },
|
|
77
|
+
approval: { id: "approval-1", approved: true },
|
|
78
|
+
} as unknown as UIMessage["parts"][number],
|
|
79
|
+
]),
|
|
80
|
+
]),
|
|
81
|
+
).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("returns true when a tool reached a terminal output state", () => {
|
|
85
|
+
expect(
|
|
86
|
+
hasPendingToolCalls([
|
|
87
|
+
userMessage("run it"),
|
|
88
|
+
assistantToolMessage([
|
|
89
|
+
{
|
|
90
|
+
type: "tool-run_query",
|
|
91
|
+
toolCallId: "call-1",
|
|
92
|
+
state: "output-available",
|
|
93
|
+
input: { sql: "select 1" },
|
|
94
|
+
output: 1,
|
|
95
|
+
} as unknown as UIMessage["parts"][number],
|
|
96
|
+
]),
|
|
97
|
+
]),
|
|
98
|
+
).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("returns false when only some tool calls are ready", () => {
|
|
102
|
+
expect(
|
|
103
|
+
hasPendingToolCalls([
|
|
104
|
+
userMessage("two things"),
|
|
105
|
+
assistantToolMessage([
|
|
106
|
+
{
|
|
107
|
+
type: "tool-first",
|
|
108
|
+
toolCallId: "call-1",
|
|
109
|
+
state: "output-available",
|
|
110
|
+
input: {},
|
|
111
|
+
output: 1,
|
|
112
|
+
} as unknown as UIMessage["parts"][number],
|
|
113
|
+
{
|
|
114
|
+
type: "tool-second",
|
|
115
|
+
toolCallId: "call-2",
|
|
116
|
+
state: "input-available",
|
|
117
|
+
input: {},
|
|
118
|
+
} as unknown as UIMessage["parts"][number],
|
|
119
|
+
]),
|
|
120
|
+
]),
|
|
121
|
+
).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("returns false once the assistant has appended text after the tool result", () => {
|
|
125
|
+
expect(
|
|
126
|
+
hasPendingToolCalls([
|
|
127
|
+
userMessage("run it"),
|
|
128
|
+
assistantToolMessage([
|
|
129
|
+
{
|
|
130
|
+
type: "tool-run_query",
|
|
131
|
+
toolCallId: "call-1",
|
|
132
|
+
state: "output-available",
|
|
133
|
+
input: {},
|
|
134
|
+
output: 1,
|
|
135
|
+
} as unknown as UIMessage["parts"][number],
|
|
136
|
+
{ type: "text", text: "The query returned 1." },
|
|
137
|
+
]),
|
|
138
|
+
]),
|
|
139
|
+
).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("returns false when a file part trails the completed tool call", () => {
|
|
143
|
+
// Regression: tool → text → file used to loop because only trailing
|
|
144
|
+
// text counted as "the assistant has answered".
|
|
145
|
+
expect(
|
|
146
|
+
hasPendingToolCalls([
|
|
147
|
+
userMessage("show me Starry Night"),
|
|
148
|
+
assistantToolMessage([
|
|
149
|
+
{ type: "step-start" },
|
|
150
|
+
{
|
|
151
|
+
type: "tool-search_artwork",
|
|
152
|
+
toolCallId: "call-1",
|
|
153
|
+
state: "output-available",
|
|
154
|
+
input: { artist: "Van Gogh" },
|
|
155
|
+
output: { title: "The Starry Night" },
|
|
156
|
+
} as unknown as UIMessage["parts"][number],
|
|
157
|
+
{ type: "text", text: "Here is the painting:" },
|
|
158
|
+
{
|
|
159
|
+
type: "file",
|
|
160
|
+
mediaType: "image/jpeg",
|
|
161
|
+
url: "https://example.com/starry-night.jpg",
|
|
162
|
+
} as unknown as UIMessage["parts"][number],
|
|
163
|
+
]),
|
|
164
|
+
]),
|
|
165
|
+
).toBe(false);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("returns false when a source-url part trails the completed tool call", () => {
|
|
169
|
+
expect(
|
|
170
|
+
hasPendingToolCalls([
|
|
171
|
+
userMessage("cite your sources"),
|
|
172
|
+
assistantToolMessage([
|
|
173
|
+
{
|
|
174
|
+
type: "tool-web_search",
|
|
175
|
+
toolCallId: "call-1",
|
|
176
|
+
state: "output-available",
|
|
177
|
+
input: { q: "marimo notebook" },
|
|
178
|
+
output: "found",
|
|
179
|
+
} as unknown as UIMessage["parts"][number],
|
|
180
|
+
{ type: "text", text: "marimo is a reactive notebook." },
|
|
181
|
+
{
|
|
182
|
+
type: "source-url",
|
|
183
|
+
sourceId: "src-1",
|
|
184
|
+
url: "https://marimo.io",
|
|
185
|
+
} as unknown as UIMessage["parts"][number],
|
|
186
|
+
]),
|
|
187
|
+
]),
|
|
188
|
+
).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("returns false when a reasoning part trails the completed tool call", () => {
|
|
192
|
+
expect(
|
|
193
|
+
hasPendingToolCalls([
|
|
194
|
+
userMessage("explain"),
|
|
195
|
+
assistantToolMessage([
|
|
196
|
+
{
|
|
197
|
+
type: "tool-lookup",
|
|
198
|
+
toolCallId: "call-1",
|
|
199
|
+
state: "output-available",
|
|
200
|
+
input: {},
|
|
201
|
+
output: 1,
|
|
202
|
+
} as unknown as UIMessage["parts"][number],
|
|
203
|
+
{
|
|
204
|
+
type: "reasoning",
|
|
205
|
+
text: "Now I'll summarize.",
|
|
206
|
+
} as unknown as UIMessage["parts"][number],
|
|
207
|
+
]),
|
|
208
|
+
]),
|
|
209
|
+
).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("returns false when a new step-start follows the completed tool call", () => {
|
|
213
|
+
expect(
|
|
214
|
+
hasPendingToolCalls([
|
|
215
|
+
userMessage("multi-step"),
|
|
216
|
+
assistantToolMessage([
|
|
217
|
+
{ type: "step-start" },
|
|
218
|
+
{
|
|
219
|
+
type: "tool-run_query",
|
|
220
|
+
toolCallId: "call-1",
|
|
221
|
+
state: "output-available",
|
|
222
|
+
input: {},
|
|
223
|
+
output: 1,
|
|
224
|
+
} as unknown as UIMessage["parts"][number],
|
|
225
|
+
{ type: "step-start" },
|
|
226
|
+
]),
|
|
227
|
+
]),
|
|
228
|
+
).toBe(false);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("ignores providerExecuted tools", () => {
|
|
232
|
+
// Provider-side tools are resolved by the model, not the runtime, so
|
|
233
|
+
// they must not drive an auto-resume.
|
|
234
|
+
expect(
|
|
235
|
+
hasPendingToolCalls([
|
|
236
|
+
userMessage("hi"),
|
|
237
|
+
assistantToolMessage([
|
|
238
|
+
{
|
|
239
|
+
type: "tool-web_search",
|
|
240
|
+
toolCallId: "call-1",
|
|
241
|
+
state: "output-available",
|
|
242
|
+
input: {},
|
|
243
|
+
output: 1,
|
|
244
|
+
providerExecuted: true,
|
|
245
|
+
} as unknown as UIMessage["parts"][number],
|
|
246
|
+
]),
|
|
247
|
+
]),
|
|
248
|
+
).toBe(false);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("returns true for dynamic-tool parts in a terminal state", () => {
|
|
252
|
+
// `dynamic-tool` parts must drive auto-resume alongside `tool-*`.
|
|
253
|
+
expect(
|
|
254
|
+
hasPendingToolCalls([
|
|
255
|
+
userMessage("run it"),
|
|
256
|
+
assistantToolMessage([
|
|
257
|
+
{
|
|
258
|
+
type: "dynamic-tool",
|
|
259
|
+
toolName: "run_query",
|
|
260
|
+
toolCallId: "call-1",
|
|
261
|
+
state: "output-available",
|
|
262
|
+
input: {},
|
|
263
|
+
output: 1,
|
|
264
|
+
} as unknown as UIMessage["parts"][number],
|
|
265
|
+
]),
|
|
266
|
+
]),
|
|
267
|
+
).toBe(true);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
@@ -15,11 +15,13 @@ import { useAtom, useAtomValue, useSetAtom, useStore } from "jotai";
|
|
|
15
15
|
import {
|
|
16
16
|
BotMessageSquareIcon,
|
|
17
17
|
HatGlasses,
|
|
18
|
+
ArrowRightIcon,
|
|
18
19
|
Loader2,
|
|
19
20
|
type LucideIcon,
|
|
20
21
|
MessageCircleIcon,
|
|
21
22
|
NotebookText,
|
|
22
23
|
PlusIcon,
|
|
24
|
+
SparklesIcon,
|
|
23
25
|
SettingsIcon,
|
|
24
26
|
} from "lucide-react";
|
|
25
27
|
import { memo, useEffect, useRef, useState } from "react";
|
|
@@ -49,15 +51,17 @@ import {
|
|
|
49
51
|
FRONTEND_TOOL_REGISTRY,
|
|
50
52
|
} from "@/core/ai/tools/registry";
|
|
51
53
|
import { useCellActions } from "@/core/cells/cells";
|
|
52
|
-
import { aiAtom,
|
|
54
|
+
import { aiAtom, aiModelConfiguredAtom } from "@/core/config/config";
|
|
53
55
|
import { DEFAULT_AI_MODEL } from "@/core/config/config-schema";
|
|
54
56
|
import { useRequestClient } from "@/core/network/requests";
|
|
55
57
|
import { useRuntimeManager } from "@/core/runtime/config";
|
|
58
|
+
import { isWasm } from "@/core/wasm/utils";
|
|
56
59
|
import { ErrorBanner } from "@/plugins/impl/common/error-banner";
|
|
57
60
|
import { cn } from "@/utils/cn";
|
|
58
61
|
import { Logger } from "@/utils/Logger";
|
|
59
62
|
import { AIModelDropdown } from "../ai/ai-model-dropdown";
|
|
60
63
|
import { useOpenSettingsToTab } from "../app-config/state";
|
|
64
|
+
import { PairWithAgentModal } from "../editor/actions/pair-with-agent-modal";
|
|
61
65
|
import { PromptInput } from "../editor/ai/add-cell-with-ai";
|
|
62
66
|
import {
|
|
63
67
|
addContextCompletion,
|
|
@@ -65,6 +69,7 @@ import {
|
|
|
65
69
|
} from "../editor/ai/completion-utils";
|
|
66
70
|
import { PanelEmptyState } from "../editor/chrome/panels/empty-state";
|
|
67
71
|
import { CopyClipboardIcon } from "../icons/copy-icon";
|
|
72
|
+
import { useImperativeModal } from "../modal/ImperativeModal";
|
|
68
73
|
import { MCPStatusIndicator } from "../mcp/mcp-status-indicator";
|
|
69
74
|
import { Tooltip, TooltipProvider } from "../ui/tooltip";
|
|
70
75
|
import {
|
|
@@ -416,8 +421,28 @@ const ChatInput: React.FC<ChatInputProps> = memo(
|
|
|
416
421
|
|
|
417
422
|
ChatInput.displayName = "ChatInput";
|
|
418
423
|
|
|
424
|
+
const PairWithAgentCallout: React.FC<{
|
|
425
|
+
onPairWithAgent: () => void;
|
|
426
|
+
}> = ({ onPairWithAgent }) => {
|
|
427
|
+
if (isWasm()) {
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return (
|
|
432
|
+
<Button
|
|
433
|
+
variant="text"
|
|
434
|
+
className="gap-1.5 text-sm text-link hover:underline"
|
|
435
|
+
onClick={onPairWithAgent}
|
|
436
|
+
>
|
|
437
|
+
<SparklesIcon className="h-3.5 w-3.5 shrink-0" />
|
|
438
|
+
<span>Work on this notebook with your own agent</span>
|
|
439
|
+
<ArrowRightIcon className="h-3 w-3 shrink-0" />
|
|
440
|
+
</Button>
|
|
441
|
+
);
|
|
442
|
+
};
|
|
443
|
+
|
|
419
444
|
const ChatPanel = () => {
|
|
420
|
-
const aiConfigured = useAtomValue(
|
|
445
|
+
const aiConfigured = useAtomValue(aiModelConfiguredAtom);
|
|
421
446
|
const { handleClick } = useOpenSettingsToTab();
|
|
422
447
|
|
|
423
448
|
if (!aiConfigured) {
|
|
@@ -455,6 +480,7 @@ const ChatPanelBody = () => {
|
|
|
455
480
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
456
481
|
const runtimeManager = useRuntimeManager();
|
|
457
482
|
const { invokeAiTool, sendRun } = useRequestClient();
|
|
483
|
+
const { openModal, closeModal } = useImperativeModal();
|
|
458
484
|
|
|
459
485
|
const activeChatId = activeChat?.id;
|
|
460
486
|
const store = useStore();
|
|
@@ -614,6 +640,10 @@ const ChatPanelBody = () => {
|
|
|
614
640
|
clearFiles();
|
|
615
641
|
});
|
|
616
642
|
|
|
643
|
+
const handlePairWithAgent = useEvent(() => {
|
|
644
|
+
openModal(<PairWithAgentModal onClose={closeModal} />);
|
|
645
|
+
});
|
|
646
|
+
|
|
617
647
|
const handleMessageEdit = useEvent((index: number, newValue: string) => {
|
|
618
648
|
const editedMessage = messages[index];
|
|
619
649
|
const fileParts = editedMessage.parts?.filter((p) => p.type === "file");
|
|
@@ -724,9 +754,12 @@ const ChatPanelBody = () => {
|
|
|
724
754
|
ref={scrollContainerRef}
|
|
725
755
|
>
|
|
726
756
|
{isNewThread && (
|
|
727
|
-
<div className="
|
|
728
|
-
|
|
729
|
-
|
|
757
|
+
<div className="flex flex-col gap-2">
|
|
758
|
+
<div className="rounded-md border bg-background">
|
|
759
|
+
{filesPills}
|
|
760
|
+
{chatInput}
|
|
761
|
+
</div>
|
|
762
|
+
<PairWithAgentCallout onPairWithAgent={handlePairWithAgent} />
|
|
730
763
|
</div>
|
|
731
764
|
)}
|
|
732
765
|
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
type ChatAddToolOutputFunction,
|
|
6
6
|
type FileUIPart,
|
|
7
7
|
isToolUIPart,
|
|
8
|
-
|
|
8
|
+
lastAssistantMessageIsCompleteWithApprovalResponses,
|
|
9
|
+
lastAssistantMessageIsCompleteWithToolCalls,
|
|
9
10
|
type UIMessage,
|
|
10
11
|
} from "ai";
|
|
11
12
|
import { useState } from "react";
|
|
@@ -17,7 +18,6 @@ import type {
|
|
|
17
18
|
InvokeAiToolRequest,
|
|
18
19
|
InvokeAiToolResponse,
|
|
19
20
|
} from "@/core/network/types";
|
|
20
|
-
import { logNever } from "@/utils/assertNever";
|
|
21
21
|
import { blobToString } from "@/utils/fileToBase64";
|
|
22
22
|
import { Logger } from "@/utils/Logger";
|
|
23
23
|
import { getAICompletionBodyWithAttachments } from "../editor/ai/completion-utils";
|
|
@@ -169,69 +169,25 @@ export async function handleToolCall({
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
switch (state) {
|
|
178
|
-
case "output-available":
|
|
179
|
-
case "output-error":
|
|
180
|
-
case "output-denied":
|
|
181
|
-
case "approval-responded":
|
|
182
|
-
return true;
|
|
183
|
-
case "input-streaming":
|
|
184
|
-
case "input-available":
|
|
185
|
-
case "approval-requested":
|
|
186
|
-
return false;
|
|
187
|
-
default:
|
|
188
|
-
logNever(state);
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Checks if we should send a message automatically based on the messages.
|
|
195
|
-
* We auto-send when every tool call on the last assistant message has either
|
|
196
|
-
* finished (output-available/error/denied) or has just received a user
|
|
197
|
-
* approval response, and the assistant hasn't replied yet.
|
|
172
|
+
* Auto-send the next turn when the last assistant message ends with a
|
|
173
|
+
* tool call ready to round-trip. Any non-tool trailing part (text, file,
|
|
174
|
+
* source-*, reasoning, data-*, new step-start) means the assistant has
|
|
175
|
+
* already answered, so we leave the next turn to the user. State checks
|
|
176
|
+
* are delegated to the SDK to stay in sync with upstream.
|
|
198
177
|
*/
|
|
199
178
|
export function hasPendingToolCalls(messages: UIMessage[]): boolean {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const lastMessage = messages[messages.length - 1];
|
|
205
|
-
const parts = lastMessage.parts;
|
|
206
|
-
|
|
207
|
-
if (parts.length === 0) {
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Only auto-send if the last message is an assistant message
|
|
212
|
-
// Because assistant messages are the ones that can have tool calls
|
|
213
|
-
if (lastMessage.role !== "assistant") {
|
|
179
|
+
const lastMessage = messages.at(-1);
|
|
180
|
+
if (!lastMessage || lastMessage.role !== "assistant") {
|
|
214
181
|
return false;
|
|
215
182
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (toolParts.length === 0) {
|
|
183
|
+
const lastPart = lastMessage.parts.at(-1);
|
|
184
|
+
if (!lastPart || !isToolUIPart(lastPart)) {
|
|
220
185
|
return false;
|
|
221
186
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
187
|
+
return (
|
|
188
|
+
lastAssistantMessageIsCompleteWithToolCalls({ messages }) ||
|
|
189
|
+
lastAssistantMessageIsCompleteWithApprovalResponses({ messages })
|
|
225
190
|
);
|
|
226
|
-
|
|
227
|
-
// Check if the last part has any text content
|
|
228
|
-
const lastPart = parts[parts.length - 1];
|
|
229
|
-
const hasTextContent =
|
|
230
|
-
lastPart.type === "text" && lastPart.text?.trim().length > 0;
|
|
231
|
-
|
|
232
|
-
Logger.debug("All tool calls ready to send: %s", allToolCallsReady);
|
|
233
|
-
|
|
234
|
-
return allToolCallsReady && !hasTextContent;
|
|
235
191
|
}
|
|
236
192
|
|
|
237
193
|
export function useFileState() {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "../editor/chrome/panels/context-aware-panel/context-aware-panel";
|
|
14
14
|
import { Button } from "../ui/button";
|
|
15
15
|
import { toast } from "../ui/use-toast";
|
|
16
|
-
import {
|
|
16
|
+
import { getColumnCountForDisplay } from "./hooks/use-column-visibility";
|
|
17
17
|
import { DataTablePagination, prettifyRowColumnCount } from "./pagination";
|
|
18
18
|
import { CellSelectionStats } from "./range-focus/cell-selection-stats";
|
|
19
19
|
import type { DataTableSelection } from "./types";
|
|
@@ -147,15 +147,12 @@ export const TableBottomBar = <TData,>({
|
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
// subset, so the visible/hidden math must use that subset's total. The
|
|
153
|
-
// dataset-wide `totalColumns` prop is only correct for the no-hidden
|
|
154
|
-
// "N columns" label.
|
|
150
|
+
const { totalColumns: effectiveTotalColumns, hiddenColumns } =
|
|
151
|
+
getColumnCountForDisplay(table, totalColumns);
|
|
155
152
|
const { rowsAndColumns, hiddenSuffix } = prettifyRowColumnCount({
|
|
156
153
|
numRows: table.getRowCount(),
|
|
157
|
-
totalColumns:
|
|
158
|
-
hiddenColumns
|
|
154
|
+
totalColumns: effectiveTotalColumns,
|
|
155
|
+
hiddenColumns,
|
|
159
156
|
locale,
|
|
160
157
|
});
|
|
161
158
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ColumnDef,
|
|
5
|
+
getCoreRowModel,
|
|
6
|
+
useReactTable,
|
|
7
|
+
} from "@tanstack/react-table";
|
|
8
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
9
|
+
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
10
|
+
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
11
|
+
import { ColumnExplorerPanel } from "../column-explorer-panel/column-explorer";
|
|
12
|
+
import type { FieldTypesWithExternalType } from "../types";
|
|
13
|
+
|
|
14
|
+
beforeAll(() => {
|
|
15
|
+
global.HTMLElement.prototype.scrollIntoView = () => {};
|
|
16
|
+
if (!global.HTMLElement.prototype.hasPointerCapture) {
|
|
17
|
+
global.HTMLElement.prototype.hasPointerCapture = () => false;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const FIELD_TYPES: FieldTypesWithExternalType = [
|
|
22
|
+
["customer_name", ["string", "str"]],
|
|
23
|
+
["cust_age", ["integer", "int"]],
|
|
24
|
+
["order_total", ["number", "float"]],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
type Row = Record<string, unknown>;
|
|
28
|
+
|
|
29
|
+
const TEST_COLUMNS: ColumnDef<Row>[] = [
|
|
30
|
+
{ id: "customer_name", accessorKey: "customer_name" },
|
|
31
|
+
{ id: "cust_age", accessorKey: "cust_age" },
|
|
32
|
+
{ id: "order_total", accessorKey: "order_total" },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
interface HarnessProps {
|
|
36
|
+
totalColumns?: number;
|
|
37
|
+
initiallyHidden?: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function PanelHarness({
|
|
41
|
+
totalColumns = 3,
|
|
42
|
+
initiallyHidden = [],
|
|
43
|
+
}: HarnessProps) {
|
|
44
|
+
const table = useReactTable<Row>({
|
|
45
|
+
data: [],
|
|
46
|
+
columns: TEST_COLUMNS,
|
|
47
|
+
getCoreRowModel: getCoreRowModel(),
|
|
48
|
+
locale: "en-US",
|
|
49
|
+
state: {
|
|
50
|
+
columnVisibility: Object.fromEntries(
|
|
51
|
+
initiallyHidden.map((id) => [id, false]),
|
|
52
|
+
),
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
return (
|
|
56
|
+
<ColumnExplorerPanel
|
|
57
|
+
previewColumn={vi.fn().mockResolvedValue({})}
|
|
58
|
+
fieldTypes={FIELD_TYPES}
|
|
59
|
+
totalRows={3}
|
|
60
|
+
totalColumns={totalColumns}
|
|
61
|
+
tableId="t1"
|
|
62
|
+
table={table}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function renderPanel(props?: HarnessProps) {
|
|
68
|
+
return render(
|
|
69
|
+
<TooltipProvider>
|
|
70
|
+
<PanelHarness {...(props ?? {})} />
|
|
71
|
+
</TooltipProvider>,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getSearchInput() {
|
|
76
|
+
return screen.getByPlaceholderText("Search columns...");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
describe("ColumnExplorerPanel search", () => {
|
|
80
|
+
it("shows all columns when search is empty", () => {
|
|
81
|
+
renderPanel();
|
|
82
|
+
expect(screen.getByText("customer_name")).toBeInTheDocument();
|
|
83
|
+
expect(screen.getByText("cust_age")).toBeInTheDocument();
|
|
84
|
+
expect(screen.getByText("order_total")).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("matches a word prefix against any column word", () => {
|
|
88
|
+
renderPanel();
|
|
89
|
+
fireEvent.change(getSearchInput(), { target: { value: "cust" } });
|
|
90
|
+
expect(screen.getByText("customer_name")).toBeInTheDocument();
|
|
91
|
+
expect(screen.getByText("cust_age")).toBeInTheDocument();
|
|
92
|
+
expect(screen.queryByText("order_total")).not.toBeInTheDocument();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("matches multi-word queries across column words in any order", () => {
|
|
96
|
+
renderPanel();
|
|
97
|
+
fireEvent.change(getSearchInput(), { target: { value: "name cust" } });
|
|
98
|
+
expect(screen.getByText("customer_name")).toBeInTheDocument();
|
|
99
|
+
expect(screen.queryByText("cust_age")).not.toBeInTheDocument();
|
|
100
|
+
expect(screen.queryByText("order_total")).not.toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("filters out columns that don't match any needle word", () => {
|
|
104
|
+
renderPanel();
|
|
105
|
+
fireEvent.change(getSearchInput(), { target: { value: "xyz" } });
|
|
106
|
+
expect(screen.queryByText("customer_name")).not.toBeInTheDocument();
|
|
107
|
+
expect(screen.queryByText("cust_age")).not.toBeInTheDocument();
|
|
108
|
+
expect(screen.queryByText("order_total")).not.toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe("ColumnExplorerPanel header counts", () => {
|
|
113
|
+
it("uses rendered-subset total when a clipped column is hidden", () => {
|
|
114
|
+
// Dataset has 100 columns server-side; only 3 are rendered into the
|
|
115
|
+
// TanStack table (the clipped subset). Hiding one of the rendered columns
|
|
116
|
+
// must report "2 visible (1 hidden)", not "99 visible (1 hidden)".
|
|
117
|
+
renderPanel({ totalColumns: 100, initiallyHidden: ["cust_age"] });
|
|
118
|
+
expect(screen.getByText(/2 visible/)).toBeInTheDocument();
|
|
119
|
+
expect(screen.getByText(/\(1 hidden\)/)).toBeInTheDocument();
|
|
120
|
+
expect(screen.queryByText(/99 visible/)).not.toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("uses dataset-wide total when no column is hidden", () => {
|
|
124
|
+
renderPanel({ totalColumns: 100 });
|
|
125
|
+
expect(screen.getByText(/100 columns/)).toBeInTheDocument();
|
|
126
|
+
expect(screen.queryByText(/hidden/)).not.toBeInTheDocument();
|
|
127
|
+
});
|
|
128
|
+
});
|