@marimo-team/islands 0.23.9-dev4 → 0.23.9-dev40
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-VZebNmSs.js → code-visibility-CajOShec.js} +1634 -1314
- 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 +1522 -1556
- 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-DZtPMEoM.js → reveal-component-B-fRdTqs.js} +17 -17
- 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 +27 -6
- package/src/components/data-table/TableTopBar.tsx +7 -1
- package/src/components/data-table/__tests__/TableBottomBar.test.tsx +73 -0
- package/src/components/data-table/__tests__/column-explorer.test.tsx +128 -0
- package/src/components/data-table/__tests__/data-table.test.tsx +52 -1
- package/src/components/data-table/__tests__/header-items.test.tsx +257 -1
- package/src/components/data-table/__tests__/useColumnVisibility.test.ts +42 -0
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +98 -26
- package/src/components/data-table/column-header.tsx +19 -12
- package/src/components/data-table/columns.tsx +3 -4
- package/src/components/data-table/data-table.tsx +37 -0
- package/src/components/data-table/export-actions.tsx +36 -18
- package/src/components/data-table/header-items.tsx +58 -17
- package/src/components/data-table/hooks/use-column-visibility.ts +56 -0
- package/src/components/data-table/pagination.tsx +16 -3
- 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/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 +7 -4
- 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/errors/mangled-local-chip.tsx +50 -0
- 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 +110 -27
- package/src/components/editor/output/MarimoTracebackOutput.tsx +55 -37
- package/src/components/editor/renderers/cell-array.tsx +27 -24
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +1 -1
- package/src/components/slides/reveal-component.tsx +3 -3
- 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 +3 -2
- 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/css/app/Cell.css +0 -1
- package/src/plugins/impl/DataTablePlugin.tsx +94 -33
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +1 -0
- 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/plugins/impl/data-frames/DataFramePlugin.tsx +8 -6
- package/src/stories/dataframe.stories.tsx +1 -0
- package/src/utils/__tests__/json-parser.test.ts +1 -69
- package/src/utils/__tests__/local-variables.test.ts +132 -0
- package/src/utils/json/json-parser.ts +0 -30
- package/src/utils/local-variables.ts +67 -0
- package/dist/assets/__vite-browser-external-CAdMKBac.js +0 -1
|
@@ -147,7 +147,7 @@ export function errorLineHighlighter(
|
|
|
147
147
|
backgroundColor: "color-mix(in srgb, var(--red-4) 40%, transparent)",
|
|
148
148
|
},
|
|
149
149
|
"&.cm-focused .cm-error-line.cm-activeLine": {
|
|
150
|
-
backgroundColor: "color-mix(in srgb, var(--red-
|
|
150
|
+
backgroundColor: "color-mix(in srgb, var(--red-5) 40%, transparent)",
|
|
151
151
|
},
|
|
152
152
|
}),
|
|
153
153
|
];
|
|
@@ -182,6 +182,7 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
|
|
|
182
182
|
diagnosticsConfig,
|
|
183
183
|
} = opts;
|
|
184
184
|
const placeholderType = getPlaceholderType(opts);
|
|
185
|
+
const autoClosePairs = completionConfig.auto_close_pairs !== false;
|
|
185
186
|
|
|
186
187
|
return [
|
|
187
188
|
///// View
|
|
@@ -208,10 +209,10 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
|
|
|
208
209
|
copilotBundle(completionConfig),
|
|
209
210
|
foldGutter(),
|
|
210
211
|
stringsAutoCloseBraces(),
|
|
211
|
-
closeBrackets(),
|
|
212
|
+
autoClosePairs ? closeBrackets() : [],
|
|
212
213
|
completionKeymap(acceptCompletionOnEnter),
|
|
213
214
|
// to avoid clash with charDeleteBackward keymap
|
|
214
|
-
Prec.high(keymap.of(closeBracketsKeymap)),
|
|
215
|
+
autoClosePairs ? Prec.high(keymap.of(closeBracketsKeymap)) : [],
|
|
215
216
|
bracketMatching(),
|
|
216
217
|
indentOnInput(),
|
|
217
218
|
indentUnit.of(" "),
|
|
@@ -112,6 +112,35 @@ export function vimKeymapExtension(): Extension[] {
|
|
|
112
112
|
];
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
function scrollCursorTo(cm: CodeMirror, position: "center" | "start" | "end") {
|
|
116
|
+
const view = cm.cm6;
|
|
117
|
+
if (!view) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const coords = view.coordsAtPos(view.state.selection.main.head);
|
|
121
|
+
if (!coords) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const appEl = document.getElementById("App");
|
|
125
|
+
if (!appEl) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const viewportHeight = appEl.clientHeight;
|
|
129
|
+
let delta: number;
|
|
130
|
+
switch (position) {
|
|
131
|
+
case "center":
|
|
132
|
+
delta = (coords.top + coords.bottom) / 2 - viewportHeight / 2;
|
|
133
|
+
break;
|
|
134
|
+
case "start":
|
|
135
|
+
delta = coords.top;
|
|
136
|
+
break;
|
|
137
|
+
case "end":
|
|
138
|
+
delta = coords.bottom - viewportHeight;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
appEl.scrollBy({ top: delta, behavior: "smooth" });
|
|
142
|
+
}
|
|
143
|
+
|
|
115
144
|
const addCustomVimCommandsOnce = once(() => {
|
|
116
145
|
// Go to definition
|
|
117
146
|
Vim.defineAction("goToDefinition", (cm: CodeMirror) => {
|
|
@@ -120,6 +149,40 @@ const addCustomVimCommandsOnce = once(() => {
|
|
|
120
149
|
});
|
|
121
150
|
Vim.mapCommand("gd", "action", "goToDefinition", {}, { context: "normal" });
|
|
122
151
|
|
|
152
|
+
// Scroll cursor to center/top/bottom of viewport (mirrors zz/zt/zb in classic vim)
|
|
153
|
+
Vim.defineAction("scrollCursorToCenter", (cm: CodeMirror) =>
|
|
154
|
+
scrollCursorTo(cm, "center"),
|
|
155
|
+
);
|
|
156
|
+
Vim.mapCommand(
|
|
157
|
+
"zz",
|
|
158
|
+
"action",
|
|
159
|
+
"scrollCursorToCenter",
|
|
160
|
+
{},
|
|
161
|
+
{ context: "normal" },
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
Vim.defineAction("scrollCursorToTop", (cm: CodeMirror) =>
|
|
165
|
+
scrollCursorTo(cm, "start"),
|
|
166
|
+
);
|
|
167
|
+
Vim.mapCommand(
|
|
168
|
+
"zt",
|
|
169
|
+
"action",
|
|
170
|
+
"scrollCursorToTop",
|
|
171
|
+
{},
|
|
172
|
+
{ context: "normal" },
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
Vim.defineAction("scrollCursorToBottom", (cm: CodeMirror) =>
|
|
176
|
+
scrollCursorTo(cm, "end"),
|
|
177
|
+
);
|
|
178
|
+
Vim.mapCommand(
|
|
179
|
+
"zb",
|
|
180
|
+
"action",
|
|
181
|
+
"scrollCursorToBottom",
|
|
182
|
+
{},
|
|
183
|
+
{ context: "normal" },
|
|
184
|
+
);
|
|
185
|
+
|
|
123
186
|
// Save command
|
|
124
187
|
Vim.defineEx("write", "w", (cm: CodeMirror) => {
|
|
125
188
|
const view = cm.cm6;
|
|
@@ -52,6 +52,7 @@ const KNOWN_DIALECTS_ARRAY = [
|
|
|
52
52
|
"databricks",
|
|
53
53
|
"datafusion",
|
|
54
54
|
"microsoft sql server",
|
|
55
|
+
"dremio",
|
|
55
56
|
] as const;
|
|
56
57
|
const KNOWN_DIALECTS: ReadonlySet<string> = new Set(KNOWN_DIALECTS_ARRAY);
|
|
57
58
|
type KnownDialect = (typeof KNOWN_DIALECTS_ARRAY)[number];
|
|
@@ -115,6 +116,7 @@ export function guessDialect(
|
|
|
115
116
|
case "spark":
|
|
116
117
|
case "databricks":
|
|
117
118
|
case "datafusion":
|
|
119
|
+
case "dremio":
|
|
118
120
|
Logger.debug("Unsupported dialect", { dialect });
|
|
119
121
|
return ModifiedStandardSQL;
|
|
120
122
|
default:
|
|
@@ -46,6 +46,7 @@ test("default UserConfig - empty", () => {
|
|
|
46
46
|
{
|
|
47
47
|
"ai": {
|
|
48
48
|
"custom_providers": {},
|
|
49
|
+
"enabled": true,
|
|
49
50
|
"inline_tooltip": false,
|
|
50
51
|
"mode": "manual",
|
|
51
52
|
"models": {
|
|
@@ -56,6 +57,7 @@ test("default UserConfig - empty", () => {
|
|
|
56
57
|
},
|
|
57
58
|
"completion": {
|
|
58
59
|
"activate_on_typing": true,
|
|
60
|
+
"auto_close_pairs": true,
|
|
59
61
|
"copilot": false,
|
|
60
62
|
"signature_hint_on_typing": false,
|
|
61
63
|
},
|
|
@@ -117,6 +119,7 @@ test("default UserConfig - one level", () => {
|
|
|
117
119
|
{
|
|
118
120
|
"ai": {
|
|
119
121
|
"custom_providers": {},
|
|
122
|
+
"enabled": true,
|
|
120
123
|
"inline_tooltip": false,
|
|
121
124
|
"mode": "manual",
|
|
122
125
|
"models": {
|
|
@@ -127,6 +130,7 @@ test("default UserConfig - one level", () => {
|
|
|
127
130
|
},
|
|
128
131
|
"completion": {
|
|
129
132
|
"activate_on_typing": true,
|
|
133
|
+
"auto_close_pairs": true,
|
|
130
134
|
"copilot": false,
|
|
131
135
|
"signature_hint_on_typing": false,
|
|
132
136
|
},
|
|
@@ -75,6 +75,7 @@ export const UserConfigSchema = z
|
|
|
75
75
|
.object({
|
|
76
76
|
activate_on_typing: z.boolean().prefault(true),
|
|
77
77
|
signature_hint_on_typing: z.boolean().prefault(false),
|
|
78
|
+
auto_close_pairs: z.boolean().prefault(true),
|
|
78
79
|
copilot: z
|
|
79
80
|
.union([z.boolean(), z.enum(["github", "codeium", "custom"])])
|
|
80
81
|
.prefault(false)
|
|
@@ -157,7 +158,9 @@ export const UserConfigSchema = z
|
|
|
157
158
|
.prefault({}),
|
|
158
159
|
ai: z
|
|
159
160
|
.looseObject({
|
|
161
|
+
enabled: z.boolean().prefault(true),
|
|
160
162
|
rules: z.string().prefault(""),
|
|
163
|
+
max_tokens: z.number().int().positive().nullable().optional(),
|
|
161
164
|
mode: z.enum(COPILOT_MODES).prefault("manual"),
|
|
162
165
|
inline_tooltip: z.boolean().prefault(false),
|
|
163
166
|
open_ai: AiConfigSchema.optional(),
|
|
@@ -207,6 +210,7 @@ export const UserConfigSchema = z
|
|
|
207
210
|
.looseObject({
|
|
208
211
|
html: z.boolean().optional(),
|
|
209
212
|
wasm: z.boolean().optional(),
|
|
213
|
+
molab: z.boolean().optional(),
|
|
210
214
|
})
|
|
211
215
|
.optional(),
|
|
212
216
|
mcp: z
|
|
@@ -78,6 +78,14 @@ export const aiEnabledAtom = atom<boolean>((get) => {
|
|
|
78
78
|
return isAiEnabled(get(resolvedMarimoConfigAtom));
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
export const aiModelConfiguredAtom = atom<boolean>((get) => {
|
|
82
|
+
return isAiModelConfigured(get(resolvedMarimoConfigAtom));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const aiFeaturesEnabledAtom = atom<boolean>((get) => {
|
|
86
|
+
return isAiFeatureEnabled(get(resolvedMarimoConfigAtom));
|
|
87
|
+
});
|
|
88
|
+
|
|
81
89
|
export const editorFontSizeAtom = atom<number>((get) => {
|
|
82
90
|
return get(resolvedMarimoConfigAtom).display.code_editor_font_size;
|
|
83
91
|
});
|
|
@@ -87,6 +95,10 @@ export const localeAtom = atom<string | null | undefined>((get) => {
|
|
|
87
95
|
});
|
|
88
96
|
|
|
89
97
|
export function isAiEnabled(config: UserConfig) {
|
|
98
|
+
return config.ai?.enabled !== false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function isAiModelConfigured(config: UserConfig) {
|
|
90
102
|
return (
|
|
91
103
|
Boolean(config.ai?.models?.chat_model) ||
|
|
92
104
|
Boolean(config.ai?.models?.edit_model) ||
|
|
@@ -94,6 +106,10 @@ export function isAiEnabled(config: UserConfig) {
|
|
|
94
106
|
);
|
|
95
107
|
}
|
|
96
108
|
|
|
109
|
+
export function isAiFeatureEnabled(config: UserConfig) {
|
|
110
|
+
return isAiEnabled(config) && isAiModelConfigured(config);
|
|
111
|
+
}
|
|
112
|
+
|
|
97
113
|
/**
|
|
98
114
|
* Atom for storing the app config.
|
|
99
115
|
*/
|
package/src/css/app/Cell.css
CHANGED
|
@@ -8,8 +8,9 @@ import type {
|
|
|
8
8
|
PaginationState,
|
|
9
9
|
RowSelectionState,
|
|
10
10
|
SortingState,
|
|
11
|
+
Table as TanstackTable,
|
|
11
12
|
} from "@tanstack/react-table";
|
|
12
|
-
import { Provider } from "jotai";
|
|
13
|
+
import { Provider, useAtomValue } from "jotai";
|
|
13
14
|
import { Table2Icon } from "lucide-react";
|
|
14
15
|
import type { JSX } from "react";
|
|
15
16
|
import React, {
|
|
@@ -28,6 +29,7 @@ import { TablePanel } from "@/components/data-table/charts/charts";
|
|
|
28
29
|
import { hasChart } from "@/components/data-table/charts/storage";
|
|
29
30
|
import { ColumnChartSpecModel } from "@/components/data-table/column-summary/chart-spec-model";
|
|
30
31
|
import { ColumnChartContext } from "@/components/data-table/column-summary/column-summary";
|
|
32
|
+
import { downloadSizeLimitAtom } from "@/components/data-table/download-policy/atoms";
|
|
31
33
|
import { filtersToFilterGroup } from "@/components/data-table/filters";
|
|
32
34
|
import { usePanelOwnership } from "@/components/data-table/hooks/use-panel-ownership";
|
|
33
35
|
import { LoadingTable } from "@/components/data-table/loading-table";
|
|
@@ -190,11 +192,11 @@ interface Data<T> {
|
|
|
190
192
|
fieldTypes?: FieldTypesWithExternalType | null;
|
|
191
193
|
freezeColumnsLeft?: string[];
|
|
192
194
|
freezeColumnsRight?: string[];
|
|
195
|
+
hiddenColumns?: string[];
|
|
193
196
|
textJustifyColumns?: Record<string, "left" | "center" | "right">;
|
|
194
197
|
wrappedColumns?: string[];
|
|
195
198
|
headerTooltip?: Record<string, string>;
|
|
196
199
|
totalColumns: number;
|
|
197
|
-
sizeBytes?: number | null;
|
|
198
200
|
maxColumns: number | "all";
|
|
199
201
|
hasStableRowId: boolean;
|
|
200
202
|
lazy: boolean;
|
|
@@ -221,12 +223,14 @@ type DataTableFunctions = {
|
|
|
221
223
|
cell_styles?: CellStyleState | null;
|
|
222
224
|
cell_hover_texts?: Record<string, Record<string, string | null>> | null;
|
|
223
225
|
raw_data?: TableData<T> | null;
|
|
224
|
-
size_bytes?: number | null;
|
|
225
226
|
}>;
|
|
226
227
|
get_data_url?: GetDataUrl;
|
|
227
228
|
get_row_ids?: GetRowIds;
|
|
228
229
|
calculate_top_k_rows?: CalculateTopKRows;
|
|
229
230
|
preview_column?: PreviewColumn;
|
|
231
|
+
get_size_bytes: (opts: Record<string, never>) => Promise<{
|
|
232
|
+
size_bytes?: number | null;
|
|
233
|
+
}>;
|
|
230
234
|
};
|
|
231
235
|
|
|
232
236
|
type S = (number | string | { rowId: string; columnName?: string })[];
|
|
@@ -265,6 +269,7 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
265
269
|
rowHeaders: columnToFieldTypesSchema,
|
|
266
270
|
freezeColumnsLeft: z.array(z.string()).optional(),
|
|
267
271
|
freezeColumnsRight: z.array(z.string()).optional(),
|
|
272
|
+
hiddenColumns: z.array(z.string()).optional(),
|
|
268
273
|
textJustifyColumns: z
|
|
269
274
|
.record(z.string(), z.enum(["left", "center", "right"]))
|
|
270
275
|
.optional(),
|
|
@@ -272,7 +277,6 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
272
277
|
headerTooltip: z.record(z.string(), z.string()).optional(),
|
|
273
278
|
fieldTypes: columnToFieldTypesSchema.nullish(),
|
|
274
279
|
totalColumns: z.number(),
|
|
275
|
-
sizeBytes: z.number().nullish(),
|
|
276
280
|
maxColumns: z.union([z.number(), z.literal("all")]).default("all"),
|
|
277
281
|
hasStableRowId: z.boolean().default(false),
|
|
278
282
|
maxHeight: z.number().optional(),
|
|
@@ -330,7 +334,6 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
330
334
|
.nullable(),
|
|
331
335
|
cell_hover_texts: cellHoverTextSchema.nullable(),
|
|
332
336
|
raw_data: z.union([z.string(), z.array(z.looseObject({}))]).nullish(),
|
|
333
|
-
size_bytes: z.number().nullish(),
|
|
334
337
|
}),
|
|
335
338
|
),
|
|
336
339
|
get_row_ids: rpc.input(z.object({}).passthrough()).output(
|
|
@@ -362,6 +365,9 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
362
365
|
stats: columnStats.nullable(),
|
|
363
366
|
}),
|
|
364
367
|
),
|
|
368
|
+
get_size_bytes: rpc
|
|
369
|
+
.input(z.object({}))
|
|
370
|
+
.output(z.object({ size_bytes: z.number().nullish() })),
|
|
365
371
|
})
|
|
366
372
|
.renderer((props) => {
|
|
367
373
|
return (
|
|
@@ -536,7 +542,6 @@ export const LoadingDataTableComponent = memo(
|
|
|
536
542
|
rows: T[];
|
|
537
543
|
rawRows?: T[];
|
|
538
544
|
totalRows: number | TooManyRows;
|
|
539
|
-
sizeBytes?: number | null;
|
|
540
545
|
cellStyles: CellStyleState | undefined | null;
|
|
541
546
|
cellHoverTexts?: Record<string, Record<string, string | null>> | null;
|
|
542
547
|
}>(async () => {
|
|
@@ -553,7 +558,6 @@ export const LoadingDataTableComponent = memo(
|
|
|
553
558
|
let tableData = props.data;
|
|
554
559
|
let rawTableData: TableData<T> | undefined | null = props.rawData;
|
|
555
560
|
let totalRows = props.totalRows;
|
|
556
|
-
let sizeBytes = props.sizeBytes ?? null;
|
|
557
561
|
let cellStyles = props.cellStyles;
|
|
558
562
|
let cellHoverTexts = props.cellHoverTexts;
|
|
559
563
|
|
|
@@ -597,7 +601,6 @@ export const LoadingDataTableComponent = memo(
|
|
|
597
601
|
tableData = searchResults.data;
|
|
598
602
|
rawTableData = searchResults.raw_data;
|
|
599
603
|
totalRows = searchResults.total_rows;
|
|
600
|
-
sizeBytes = searchResults.size_bytes ?? null;
|
|
601
604
|
cellStyles = searchResults.cell_styles || {};
|
|
602
605
|
cellHoverTexts = searchResults.cell_hover_texts || {};
|
|
603
606
|
}
|
|
@@ -610,7 +613,6 @@ export const LoadingDataTableComponent = memo(
|
|
|
610
613
|
rows: tableData,
|
|
611
614
|
rawRows: rawData,
|
|
612
615
|
totalRows: totalRows,
|
|
613
|
-
sizeBytes,
|
|
614
616
|
cellStyles,
|
|
615
617
|
cellHoverTexts,
|
|
616
618
|
};
|
|
@@ -622,7 +624,6 @@ export const LoadingDataTableComponent = memo(
|
|
|
622
624
|
useDeepCompareMemoize(props.fieldTypes),
|
|
623
625
|
props.data,
|
|
624
626
|
props.totalRows,
|
|
625
|
-
props.sizeBytes,
|
|
626
627
|
props.lazy,
|
|
627
628
|
props.cellHoverTexts,
|
|
628
629
|
props.cellStyles,
|
|
@@ -630,6 +631,34 @@ export const LoadingDataTableComponent = memo(
|
|
|
630
631
|
paginationState.pageIndex,
|
|
631
632
|
]);
|
|
632
633
|
|
|
634
|
+
const policy = useAtomValue(downloadSizeLimitAtom);
|
|
635
|
+
const { data: sizeBytesData, isPending: sizeBytesPending } = useAsyncData<
|
|
636
|
+
number | null
|
|
637
|
+
>(async () => {
|
|
638
|
+
if (
|
|
639
|
+
!policy ||
|
|
640
|
+
!props.showDownload ||
|
|
641
|
+
props.lazy ||
|
|
642
|
+
props.totalRows === 0
|
|
643
|
+
) {
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
const result = await props.get_size_bytes({});
|
|
647
|
+
return result.size_bytes ?? null;
|
|
648
|
+
}, [
|
|
649
|
+
policy,
|
|
650
|
+
props.showDownload,
|
|
651
|
+
props.get_size_bytes,
|
|
652
|
+
props.lazy,
|
|
653
|
+
props.totalRows,
|
|
654
|
+
searchQuery,
|
|
655
|
+
useDeepCompareMemoize(filters),
|
|
656
|
+
useDeepCompareMemoize(sorting),
|
|
657
|
+
]);
|
|
658
|
+
const sizeBytes = sizeBytesData ?? null;
|
|
659
|
+
const sizeBytesIsLoading =
|
|
660
|
+
!!policy && props.showDownload && sizeBytesPending;
|
|
661
|
+
|
|
633
662
|
const getRow = useCallback(
|
|
634
663
|
async (rowId: number) => {
|
|
635
664
|
const sortArgs =
|
|
@@ -737,7 +766,8 @@ export const LoadingDataTableComponent = memo(
|
|
|
737
766
|
setFilters={setFilters}
|
|
738
767
|
reloading={isFetching && !isPending}
|
|
739
768
|
totalRows={data?.totalRows ?? props.totalRows}
|
|
740
|
-
sizeBytes={
|
|
769
|
+
sizeBytes={sizeBytes}
|
|
770
|
+
sizeBytesIsLoading={sizeBytesIsLoading}
|
|
741
771
|
paginationState={paginationState}
|
|
742
772
|
setPaginationState={setPaginationState}
|
|
743
773
|
cellStyles={data?.cellStyles ?? props.cellStyles}
|
|
@@ -785,6 +815,7 @@ const DataTableComponent = ({
|
|
|
785
815
|
rawData,
|
|
786
816
|
totalRows,
|
|
787
817
|
sizeBytes,
|
|
818
|
+
sizeBytesIsLoading,
|
|
788
819
|
maxColumns,
|
|
789
820
|
pagination,
|
|
790
821
|
selection,
|
|
@@ -814,6 +845,7 @@ const DataTableComponent = ({
|
|
|
814
845
|
reloading,
|
|
815
846
|
freezeColumnsLeft,
|
|
816
847
|
freezeColumnsRight,
|
|
848
|
+
hiddenColumns,
|
|
817
849
|
textJustifyColumns,
|
|
818
850
|
wrappedColumns,
|
|
819
851
|
headerTooltip,
|
|
@@ -835,6 +867,8 @@ const DataTableComponent = ({
|
|
|
835
867
|
rawData?: unknown[];
|
|
836
868
|
columnSummaries?: ColumnSummaries;
|
|
837
869
|
getRow: (rowIdx: number) => Promise<GetRowResult>;
|
|
870
|
+
sizeBytes?: number | null;
|
|
871
|
+
sizeBytesIsLoading?: boolean;
|
|
838
872
|
}): JSX.Element => {
|
|
839
873
|
const id = useId();
|
|
840
874
|
const [viewedRowIdx, setViewedRowIdx] = useState(0);
|
|
@@ -1007,6 +1041,52 @@ const DataTableComponent = ({
|
|
|
1007
1041
|
const isInVscode = isInVscodeExtension();
|
|
1008
1042
|
const isIslandsMode = isIslands();
|
|
1009
1043
|
|
|
1044
|
+
const renderTableExplorerPanel = useMemo(() => {
|
|
1045
|
+
if (!isAnyPanelOpen || !(showRowExplorer || canShowColumnExplorer)) {
|
|
1046
|
+
return undefined;
|
|
1047
|
+
}
|
|
1048
|
+
return (table: TanstackTable<unknown>) => (
|
|
1049
|
+
<ContextAwarePanelItem>
|
|
1050
|
+
<TableExplorerPanel
|
|
1051
|
+
rowIdx={viewedRowIdx}
|
|
1052
|
+
setRowIdx={setViewedRow}
|
|
1053
|
+
totalRows={totalRows}
|
|
1054
|
+
fieldTypes={memoizedUnclampedFieldTypes}
|
|
1055
|
+
getRow={getRow}
|
|
1056
|
+
isSelectable={isSelectable}
|
|
1057
|
+
isRowSelected={Boolean(rowSelection[viewedRowIdx])}
|
|
1058
|
+
handleRowSelectionChange={handleRowSelectionChange}
|
|
1059
|
+
previewColumn={preview_column}
|
|
1060
|
+
totalColumns={totalColumns}
|
|
1061
|
+
tableId={id}
|
|
1062
|
+
table={table}
|
|
1063
|
+
showRowExplorer={showRowExplorer && !isInVscode}
|
|
1064
|
+
showColumnExplorer={canShowColumnExplorer && !isInVscode}
|
|
1065
|
+
activeTab={panelType}
|
|
1066
|
+
onTabChange={setPanelType}
|
|
1067
|
+
/>
|
|
1068
|
+
</ContextAwarePanelItem>
|
|
1069
|
+
);
|
|
1070
|
+
}, [
|
|
1071
|
+
isAnyPanelOpen,
|
|
1072
|
+
showRowExplorer,
|
|
1073
|
+
canShowColumnExplorer,
|
|
1074
|
+
viewedRowIdx,
|
|
1075
|
+
setViewedRow,
|
|
1076
|
+
totalRows,
|
|
1077
|
+
memoizedUnclampedFieldTypes,
|
|
1078
|
+
getRow,
|
|
1079
|
+
isSelectable,
|
|
1080
|
+
rowSelection,
|
|
1081
|
+
handleRowSelectionChange,
|
|
1082
|
+
preview_column,
|
|
1083
|
+
totalColumns,
|
|
1084
|
+
id,
|
|
1085
|
+
isInVscode,
|
|
1086
|
+
panelType,
|
|
1087
|
+
setPanelType,
|
|
1088
|
+
]);
|
|
1089
|
+
|
|
1010
1090
|
return (
|
|
1011
1091
|
<>
|
|
1012
1092
|
{/* When the totalRows is "too_many" and the pageSize is the same as the
|
|
@@ -1032,28 +1112,6 @@ const DataTableComponent = ({
|
|
|
1032
1112
|
</Banner>
|
|
1033
1113
|
)}
|
|
1034
1114
|
|
|
1035
|
-
{isAnyPanelOpen && (showRowExplorer || canShowColumnExplorer) && (
|
|
1036
|
-
<ContextAwarePanelItem>
|
|
1037
|
-
<TableExplorerPanel
|
|
1038
|
-
rowIdx={viewedRowIdx}
|
|
1039
|
-
setRowIdx={setViewedRow}
|
|
1040
|
-
totalRows={totalRows}
|
|
1041
|
-
fieldTypes={memoizedUnclampedFieldTypes}
|
|
1042
|
-
getRow={getRow}
|
|
1043
|
-
isSelectable={isSelectable}
|
|
1044
|
-
isRowSelected={Boolean(rowSelection[viewedRowIdx])}
|
|
1045
|
-
handleRowSelectionChange={handleRowSelectionChange}
|
|
1046
|
-
previewColumn={preview_column}
|
|
1047
|
-
totalColumns={totalColumns}
|
|
1048
|
-
tableId={id}
|
|
1049
|
-
showRowExplorer={showRowExplorer && !isInVscode}
|
|
1050
|
-
showColumnExplorer={canShowColumnExplorer && !isInVscode}
|
|
1051
|
-
activeTab={panelType}
|
|
1052
|
-
onTabChange={setPanelType}
|
|
1053
|
-
/>
|
|
1054
|
-
</ContextAwarePanelItem>
|
|
1055
|
-
)}
|
|
1056
|
-
|
|
1057
1115
|
<ColumnChartContext value={chartSpecModel}>
|
|
1058
1116
|
<Labeled label={label} align="top" fullWidth={true}>
|
|
1059
1117
|
<DataTable
|
|
@@ -1065,6 +1123,7 @@ const DataTableComponent = ({
|
|
|
1065
1123
|
sorting={sorting}
|
|
1066
1124
|
totalRows={totalRows}
|
|
1067
1125
|
sizeBytes={sizeBytes}
|
|
1126
|
+
sizeBytesIsLoading={sizeBytesIsLoading}
|
|
1068
1127
|
totalColumns={totalColumns}
|
|
1069
1128
|
manualSorting={true}
|
|
1070
1129
|
setSorting={setSorting}
|
|
@@ -1090,6 +1149,7 @@ const DataTableComponent = ({
|
|
|
1090
1149
|
onRowSelectionChange={handleRowSelectionChange}
|
|
1091
1150
|
freezeColumnsLeft={freezeColumnsLeft}
|
|
1092
1151
|
freezeColumnsRight={freezeColumnsRight}
|
|
1152
|
+
hiddenColumns={hiddenColumns}
|
|
1093
1153
|
onCellSelectionChange={handleCellSelectionChange}
|
|
1094
1154
|
getRowIds={get_row_ids}
|
|
1095
1155
|
toggleDisplayHeader={toggleDisplayHeader}
|
|
@@ -1108,6 +1168,7 @@ const DataTableComponent = ({
|
|
|
1108
1168
|
isAnyPanelOpen={isAnyPanelOpen}
|
|
1109
1169
|
viewedRowIdx={viewedRowIdx}
|
|
1110
1170
|
onViewedRowChange={(rowIdx) => setViewedRowIdx(rowIdx)}
|
|
1171
|
+
renderTableExplorerPanel={renderTableExplorerPanel}
|
|
1111
1172
|
/>
|
|
1112
1173
|
</Labeled>
|
|
1113
1174
|
</ColumnChartContext>
|
|
@@ -107,6 +107,7 @@ describe("LoadingDataTableComponent", () => {
|
|
|
107
107
|
}),
|
|
108
108
|
get_data_url: vi.fn() as GetDataUrl,
|
|
109
109
|
get_row_ids: vi.fn() as GetRowIds,
|
|
110
|
+
get_size_bytes: vi.fn().mockResolvedValue({ size_bytes: null }),
|
|
110
111
|
};
|
|
111
112
|
|
|
112
113
|
const Wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
@@ -6,7 +6,7 @@ import { z } from "zod";
|
|
|
6
6
|
import { createPlugin } from "@/plugins/core/builder";
|
|
7
7
|
import { rpc } from "@/plugins/core/rpc";
|
|
8
8
|
import { Arrays } from "@/utils/arrays";
|
|
9
|
-
import type { SendMessageRequest } from "./types";
|
|
9
|
+
import type { CancelPromptRequest, SendMessageRequest } from "./types";
|
|
10
10
|
|
|
11
11
|
const LazyChatbot = React.lazy(() =>
|
|
12
12
|
import("./chat-ui").then((m) => ({ default: m.Chatbot })),
|
|
@@ -18,6 +18,7 @@ export type PluginFunctions = {
|
|
|
18
18
|
delete_chat_history: (req: {}) => Promise<null>;
|
|
19
19
|
delete_chat_message: (req: { index: number }) => Promise<null>;
|
|
20
20
|
send_prompt: (req: SendMessageRequest) => Promise<unknown>;
|
|
21
|
+
cancel_prompt: (req: CancelPromptRequest) => Promise<null>;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
const messageSchema = z.array(
|
|
@@ -65,11 +66,15 @@ export const ChatPlugin = createPlugin<{ messages: UIMessage[] }>(
|
|
|
65
66
|
send_prompt: rpc
|
|
66
67
|
.input(
|
|
67
68
|
z.object({
|
|
69
|
+
request_id: z.string(),
|
|
68
70
|
messages: messageSchema,
|
|
69
71
|
config: configSchema,
|
|
70
72
|
}),
|
|
71
73
|
)
|
|
72
74
|
.output(z.unknown()),
|
|
75
|
+
cancel_prompt: rpc
|
|
76
|
+
.input(z.object({ request_id: z.string() }))
|
|
77
|
+
.output(z.null()),
|
|
73
78
|
})
|
|
74
79
|
.renderer((props) => (
|
|
75
80
|
<Suspense>
|
|
@@ -84,6 +89,7 @@ export const ChatPlugin = createPlugin<{ messages: UIMessage[] }>(
|
|
|
84
89
|
delete_chat_history={props.functions.delete_chat_history}
|
|
85
90
|
delete_chat_message={props.functions.delete_chat_message}
|
|
86
91
|
send_prompt={props.functions.send_prompt}
|
|
92
|
+
cancel_prompt={props.functions.cancel_prompt}
|
|
87
93
|
value={props.value?.messages || Arrays.EMPTY}
|
|
88
94
|
setValue={(messages) => props.setValue({ messages })}
|
|
89
95
|
host={props.host}
|