@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
|
@@ -24,7 +24,7 @@ import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
|
|
|
24
24
|
import { SETUP_CELL_ID } from "@/core/cells/ids";
|
|
25
25
|
import { LanguageAdapters } from "@/core/codemirror/language/LanguageAdapters";
|
|
26
26
|
import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
|
|
27
|
-
import { aiEnabledAtom } from "@/core/config/config";
|
|
27
|
+
import { aiEnabledAtom, aiFeaturesEnabledAtom } from "@/core/config/config";
|
|
28
28
|
import { canInteractWithAppAtom } from "@/core/network/connection";
|
|
29
29
|
import { useBoolean } from "@/hooks/useBoolean";
|
|
30
30
|
import { cn } from "@/utils/cn";
|
|
@@ -261,6 +261,7 @@ const AddCellButtons: React.FC<{
|
|
|
261
261
|
const { createNewCell } = useCellActions();
|
|
262
262
|
const [isAiButtonOpen, isAiButtonOpenActions] = useBoolean(false);
|
|
263
263
|
const aiEnabled = useAtomValue(aiEnabledAtom);
|
|
264
|
+
const aiFeaturesEnabled = useAtomValue(aiFeaturesEnabledAtom);
|
|
264
265
|
const canInteractWithApp = useAtomValue(canInteractWithAppAtom);
|
|
265
266
|
const { handleClick } = useOpenSettingsToTab();
|
|
266
267
|
|
|
@@ -270,7 +271,7 @@ const AddCellButtons: React.FC<{
|
|
|
270
271
|
);
|
|
271
272
|
|
|
272
273
|
const renderBody = () => {
|
|
273
|
-
if (isAiButtonOpen) {
|
|
274
|
+
if (aiEnabled && isAiButtonOpen) {
|
|
274
275
|
return <AddCellWithAI onClose={isAiButtonOpenActions.toggle} />;
|
|
275
276
|
}
|
|
276
277
|
|
|
@@ -328,30 +329,32 @@ const AddCellButtons: React.FC<{
|
|
|
328
329
|
<DatabaseIcon className="mr-2 size-4 shrink-0" />
|
|
329
330
|
SQL
|
|
330
331
|
</Button>
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
delayDuration={100}
|
|
338
|
-
asChild={false}
|
|
339
|
-
>
|
|
340
|
-
<Button
|
|
341
|
-
className={buttonClass}
|
|
342
|
-
variant="text"
|
|
343
|
-
size="sm"
|
|
344
|
-
disabled={!canInteractWithApp}
|
|
345
|
-
onClick={
|
|
346
|
-
aiEnabled
|
|
347
|
-
? isAiButtonOpenActions.toggle
|
|
348
|
-
: () => handleClick("ai", "ai-providers")
|
|
332
|
+
{aiEnabled && (
|
|
333
|
+
<Tooltip
|
|
334
|
+
content={
|
|
335
|
+
aiFeaturesEnabled ? null : (
|
|
336
|
+
<span>AI provider not found or Edit model not selected</span>
|
|
337
|
+
)
|
|
349
338
|
}
|
|
339
|
+
delayDuration={100}
|
|
340
|
+
asChild={false}
|
|
350
341
|
>
|
|
351
|
-
<
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
342
|
+
<Button
|
|
343
|
+
className={buttonClass}
|
|
344
|
+
variant="text"
|
|
345
|
+
size="sm"
|
|
346
|
+
disabled={!canInteractWithApp}
|
|
347
|
+
onClick={
|
|
348
|
+
aiFeaturesEnabled
|
|
349
|
+
? isAiButtonOpenActions.toggle
|
|
350
|
+
: () => handleClick("ai", "ai-providers")
|
|
351
|
+
}
|
|
352
|
+
>
|
|
353
|
+
<SparklesIcon className="mr-2 size-4 shrink-0" />
|
|
354
|
+
Generate with AI
|
|
355
|
+
</Button>
|
|
356
|
+
</Tooltip>
|
|
357
|
+
)}
|
|
355
358
|
</>
|
|
356
359
|
);
|
|
357
360
|
};
|
|
@@ -231,7 +231,7 @@ const RevealSlidesComponent = ({
|
|
|
231
231
|
activeIndex,
|
|
232
232
|
onSlideChange,
|
|
233
233
|
mode,
|
|
234
|
-
configWidth
|
|
234
|
+
configWidth, // px
|
|
235
235
|
isEditable = false,
|
|
236
236
|
}: {
|
|
237
237
|
cellsWithOutput: RuntimeCell[];
|
|
@@ -240,7 +240,7 @@ const RevealSlidesComponent = ({
|
|
|
240
240
|
activeIndex?: number;
|
|
241
241
|
onSlideChange?: (index: number) => void;
|
|
242
242
|
mode: AppMode;
|
|
243
|
-
configWidth
|
|
243
|
+
configWidth: number;
|
|
244
244
|
isEditable?: boolean;
|
|
245
245
|
}) => {
|
|
246
246
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
@@ -439,7 +439,7 @@ const RevealSlidesComponent = ({
|
|
|
439
439
|
<div className="group relative" style={{ width, height }}>
|
|
440
440
|
<Deck
|
|
441
441
|
deckRef={deckRef}
|
|
442
|
-
className="aspect-video w-full overflow-hidden border rounded bg-background mo-slides-theme prose-slides"
|
|
442
|
+
className="aspect-video w-full overflow-hidden border rounded bg-background mo-slides-theme prose-slides focus:outline-none focus-visible:outline-none"
|
|
443
443
|
config={revealConfig}
|
|
444
444
|
onReady={handleDeckReady}
|
|
445
445
|
onSlideChange={handleSlideChange}
|
|
@@ -26,15 +26,23 @@ import type {
|
|
|
26
26
|
SlidesLayout,
|
|
27
27
|
SlideType,
|
|
28
28
|
} from "../editor/renderers/slides-layout/types";
|
|
29
|
-
import {
|
|
29
|
+
import { useAtom } from "jotai";
|
|
30
|
+
import { atomWithStorage } from "jotai/utils";
|
|
30
31
|
import { Tooltip } from "../ui/tooltip";
|
|
31
32
|
import { Button } from "../ui/button";
|
|
32
33
|
import { Kbd } from "../ui/kbd";
|
|
33
34
|
import type { RuntimeCell } from "@/core/cells/types";
|
|
35
|
+
import { jotaiJsonStorage } from "@/utils/storage/jotai";
|
|
34
36
|
|
|
35
37
|
export const DEFAULT_SLIDE_TYPE: SlideType = "slide";
|
|
36
38
|
export const DEFAULT_DECK_TRANSITION: DeckTransition = "slide";
|
|
37
39
|
const COLLAPSED_CONFIG_WIDTH = 36;
|
|
40
|
+
const slideConfigOpenAtom = atomWithStorage<boolean>(
|
|
41
|
+
"marimo:slides:config-open",
|
|
42
|
+
true,
|
|
43
|
+
jotaiJsonStorage,
|
|
44
|
+
{ getOnInit: true },
|
|
45
|
+
);
|
|
38
46
|
|
|
39
47
|
export interface SlideTypeOption {
|
|
40
48
|
value: SlideType;
|
|
@@ -322,7 +330,7 @@ export const SlideSidebar = ({
|
|
|
322
330
|
setLayout: (layout: SlidesLayout) => void;
|
|
323
331
|
activeConfigCell?: RuntimeCell;
|
|
324
332
|
}) => {
|
|
325
|
-
const [isConfigOpen, setIsConfigOpen] =
|
|
333
|
+
const [isConfigOpen, setIsConfigOpen] = useAtom(slideConfigOpenAtom);
|
|
326
334
|
|
|
327
335
|
return (
|
|
328
336
|
<aside
|
|
@@ -350,7 +358,7 @@ export const SlideSidebar = ({
|
|
|
350
358
|
variant="ghost"
|
|
351
359
|
size="icon"
|
|
352
360
|
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
353
|
-
onClick={() => setIsConfigOpen(!
|
|
361
|
+
onClick={() => setIsConfigOpen((open) => !open)}
|
|
354
362
|
aria-expanded={isConfigOpen}
|
|
355
363
|
aria-controls="slide-config-panel"
|
|
356
364
|
>
|
|
@@ -6,6 +6,7 @@ import { useAtomValue } from "jotai";
|
|
|
6
6
|
import { CopyIcon, DownloadIcon } from "lucide-react";
|
|
7
7
|
import type React from "react";
|
|
8
8
|
import { Constants } from "@/core/constants";
|
|
9
|
+
import { useResolvedMarimoConfig } from "@/core/config/config";
|
|
9
10
|
import { codeAtom } from "@/core/saving/file-state";
|
|
10
11
|
import { useFilename } from "@/core/saving/filename";
|
|
11
12
|
import { isStaticNotebook } from "@/core/static/static-state";
|
|
@@ -66,6 +67,9 @@ const StaticBannerDialog = ({ code }: { code: string }) => {
|
|
|
66
67
|
filename = filename.slice(lastSlash + 1);
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
const [resolvedConfig] = useResolvedMarimoConfig();
|
|
71
|
+
const molabEnabled = resolvedConfig.sharing?.molab !== false;
|
|
72
|
+
|
|
69
73
|
const href = window.location.href;
|
|
70
74
|
const molabLink = createShareableLink({
|
|
71
75
|
code,
|
|
@@ -118,28 +122,30 @@ const StaticBannerDialog = ({ code }: { code: string }) => {
|
|
|
118
122
|
</div>
|
|
119
123
|
)}
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
{molabEnabled && (
|
|
126
|
+
<div className="pt-3 border-t flex gap-2 items-center">
|
|
127
|
+
<Button
|
|
128
|
+
asChild={true}
|
|
129
|
+
variant="outline"
|
|
130
|
+
size="xs"
|
|
131
|
+
className="shrink-0"
|
|
132
|
+
>
|
|
133
|
+
<a href={molabLink} target="_blank" rel="noopener noreferrer">
|
|
134
|
+
<MarimoPlusIcon
|
|
135
|
+
size={12}
|
|
136
|
+
strokeWidth={1.5}
|
|
137
|
+
className="mr-1.5 mt-px text-(--grass-11)"
|
|
138
|
+
/>
|
|
139
|
+
Open in molab
|
|
140
|
+
</a>
|
|
141
|
+
</Button>
|
|
142
|
+
<p className="text-sm text-(--sky-12)">
|
|
143
|
+
Run this notebook in{" "}
|
|
144
|
+
<span className="font-semibold">molab</span>, marimo's
|
|
145
|
+
cloud-hosted notebook platform.
|
|
146
|
+
</p>
|
|
147
|
+
</div>
|
|
148
|
+
)}
|
|
143
149
|
</DialogDescription>
|
|
144
150
|
</DialogHeader>
|
|
145
151
|
<div className="flex gap-3 pt-2">
|
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
3
|
|
|
4
|
-
// Mock the models.json import
|
|
5
4
|
vi.mock("@marimo-team/llm-info/models.json", () => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
5
|
+
const make = (
|
|
6
|
+
overrides: Partial<AiModel> & Pick<AiModel, "name" | "model">,
|
|
7
|
+
): AiModel => ({
|
|
8
|
+
description: "",
|
|
9
|
+
roles: ["chat", "edit"],
|
|
10
|
+
capabilities: [],
|
|
11
|
+
input_types: [],
|
|
12
|
+
output_types: [],
|
|
13
|
+
release_date: "1970-01-01",
|
|
14
|
+
...overrides,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const multiModel = make({
|
|
18
|
+
name: "Multi Provider Model",
|
|
19
|
+
model: "multi-model",
|
|
20
|
+
description: "Model available on multiple providers",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const models: Record<string, AiModel[]> = {
|
|
24
|
+
openai: [
|
|
25
|
+
make({
|
|
26
|
+
name: "GPT-4",
|
|
27
|
+
model: "gpt-4",
|
|
28
|
+
description: "OpenAI GPT-4 model",
|
|
29
|
+
}),
|
|
30
|
+
multiModel,
|
|
31
|
+
],
|
|
32
|
+
anthropic: [
|
|
33
|
+
make({
|
|
34
|
+
name: "Claude 3",
|
|
35
|
+
model: "claude-3-sonnet",
|
|
36
|
+
description: "Anthropic Claude 3 Sonnet",
|
|
37
|
+
}),
|
|
38
|
+
multiModel,
|
|
39
|
+
],
|
|
40
|
+
google: [
|
|
41
|
+
make({
|
|
42
|
+
name: "Gemini Pro",
|
|
43
|
+
model: "gemini-pro",
|
|
44
|
+
description: "Google Gemini Pro model",
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
43
47
|
};
|
|
48
|
+
|
|
49
|
+
return { models };
|
|
44
50
|
});
|
|
45
51
|
|
|
46
52
|
import type { AiModel } from "@marimo-team/llm-info";
|
|
@@ -107,14 +113,15 @@ describe("AiModelRegistry", () => {
|
|
|
107
113
|
});
|
|
108
114
|
|
|
109
115
|
const ids = [...registry.getModelsMap().keys()];
|
|
110
|
-
// Include custom and all default ones
|
|
116
|
+
// Include custom and all default ones; iteration follows provider
|
|
117
|
+
// sections in the source data (openai → anthropic → google).
|
|
111
118
|
expect(ids).toEqual([
|
|
112
119
|
"openai/custom-gpt",
|
|
113
120
|
"openai/gpt-4",
|
|
114
|
-
"anthropic/claude-3-sonnet",
|
|
115
|
-
"google/gemini-pro",
|
|
116
121
|
"openai/multi-model",
|
|
122
|
+
"anthropic/claude-3-sonnet",
|
|
117
123
|
"anthropic/multi-model",
|
|
124
|
+
"google/gemini-pro",
|
|
118
125
|
]);
|
|
119
126
|
});
|
|
120
127
|
});
|
|
@@ -125,9 +132,9 @@ describe("AiModelRegistry", () => {
|
|
|
125
132
|
const openaiModels = registry.getModelsByProvider("openai");
|
|
126
133
|
|
|
127
134
|
expect(openaiModels).toHaveLength(2); // gpt-4 and multi-model
|
|
128
|
-
expect(
|
|
129
|
-
|
|
130
|
-
)
|
|
135
|
+
expect(openaiModels.every((model) => model.provider === "openai")).toBe(
|
|
136
|
+
true,
|
|
137
|
+
);
|
|
131
138
|
});
|
|
132
139
|
|
|
133
140
|
it("should return empty array for provider with no models", () => {
|
|
@@ -147,9 +154,9 @@ describe("AiModelRegistry", () => {
|
|
|
147
154
|
expect(customModel?.name).toBe("custom-gpt");
|
|
148
155
|
expect(customModel?.model).toBe("custom-gpt");
|
|
149
156
|
expect(customModel?.description).toBe("Custom model");
|
|
150
|
-
expect(customModel?.
|
|
157
|
+
expect(customModel?.provider).toBe("openai");
|
|
151
158
|
expect(customModel?.roles).toEqual([]);
|
|
152
|
-
expect(customModel?.
|
|
159
|
+
expect(customModel?.capabilities).toEqual([]);
|
|
153
160
|
});
|
|
154
161
|
|
|
155
162
|
it("should filter models based on displayed models", () => {
|
|
@@ -309,7 +316,10 @@ describe("AiModelRegistry", () => {
|
|
|
309
316
|
|
|
310
317
|
expect(multiModelInOpenai).toBeDefined();
|
|
311
318
|
expect(multiModelInAnthropic).toBeDefined();
|
|
312
|
-
|
|
319
|
+
// Same model id, but each entry belongs to its own provider.
|
|
320
|
+
expect(multiModelInOpenai?.provider).toBe("openai");
|
|
321
|
+
expect(multiModelInAnthropic?.provider).toBe("anthropic");
|
|
322
|
+
expect(multiModelInOpenai?.name).toBe(multiModelInAnthropic?.name);
|
|
313
323
|
});
|
|
314
324
|
|
|
315
325
|
it("should handle displayed models filter with non-existent models", () => {
|
|
@@ -339,20 +349,20 @@ describe("AiModelRegistry", () => {
|
|
|
339
349
|
expect(model).toHaveProperty("name");
|
|
340
350
|
expect(model).toHaveProperty("model");
|
|
341
351
|
expect(model).toHaveProperty("description");
|
|
342
|
-
expect(model).toHaveProperty("
|
|
352
|
+
expect(model).toHaveProperty("provider");
|
|
343
353
|
expect(model).toHaveProperty("roles");
|
|
344
|
-
expect(model).toHaveProperty("
|
|
354
|
+
expect(model).toHaveProperty("capabilities");
|
|
345
355
|
expect(model).toHaveProperty("custom");
|
|
346
356
|
|
|
347
357
|
expect(typeof model.name).toBe("string");
|
|
348
358
|
expect(typeof model.model).toBe("string");
|
|
349
359
|
expect(typeof model.description).toBe("string");
|
|
350
|
-
expect(
|
|
360
|
+
expect(typeof model.provider).toBe("string");
|
|
351
361
|
expect(Array.isArray(model.roles)).toBe(true);
|
|
352
|
-
expect(
|
|
362
|
+
expect(Array.isArray(model.capabilities)).toBe(true);
|
|
353
363
|
expect(typeof model.custom).toBe("boolean");
|
|
354
364
|
|
|
355
|
-
expect(model.
|
|
365
|
+
expect(model.provider).toBe(provider);
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
368
|
});
|
|
@@ -367,31 +377,33 @@ describe("AiModelRegistry", () => {
|
|
|
367
377
|
|
|
368
378
|
expect(customModel).toMatchInlineSnapshot(`
|
|
369
379
|
{
|
|
380
|
+
"capabilities": [],
|
|
370
381
|
"custom": true,
|
|
371
382
|
"description": "Custom model",
|
|
383
|
+
"input_types": [],
|
|
372
384
|
"model": "custom-gpt",
|
|
373
385
|
"name": "custom-gpt",
|
|
374
|
-
"
|
|
375
|
-
|
|
376
|
-
|
|
386
|
+
"output_types": [],
|
|
387
|
+
"provider": "openai",
|
|
388
|
+
"release_date": "1970-01-01",
|
|
377
389
|
"roles": [],
|
|
378
|
-
"thinking": false,
|
|
379
390
|
}
|
|
380
391
|
`);
|
|
381
392
|
expect(defaultModel).toMatchInlineSnapshot(`
|
|
382
393
|
{
|
|
394
|
+
"capabilities": [],
|
|
383
395
|
"custom": false,
|
|
384
396
|
"description": "OpenAI GPT-4 model",
|
|
397
|
+
"input_types": [],
|
|
385
398
|
"model": "gpt-4",
|
|
386
399
|
"name": "GPT-4",
|
|
387
|
-
"
|
|
388
|
-
|
|
389
|
-
|
|
400
|
+
"output_types": [],
|
|
401
|
+
"provider": "openai",
|
|
402
|
+
"release_date": "1970-01-01",
|
|
390
403
|
"roles": [
|
|
391
404
|
"chat",
|
|
392
405
|
"edit",
|
|
393
406
|
],
|
|
394
|
-
"thinking": false,
|
|
395
407
|
}
|
|
396
408
|
`);
|
|
397
409
|
});
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Role,
|
|
7
|
-
} from "@marimo-team/llm-info";
|
|
8
|
-
import { models } from "@marimo-team/llm-info/models.json";
|
|
9
|
-
import { providers } from "@marimo-team/llm-info/providers.json";
|
|
3
|
+
import type { AiModel as AiModelType, AiProvider } from "@marimo-team/llm-info";
|
|
4
|
+
import { models as modelsJson } from "@marimo-team/llm-info/models.json";
|
|
5
|
+
import { providers as providersJson } from "@marimo-team/llm-info/providers.json";
|
|
10
6
|
import { Logger } from "@/utils/Logger";
|
|
11
7
|
import { MultiMap } from "@/utils/multi-map";
|
|
12
8
|
import { once } from "@/utils/once";
|
|
@@ -14,13 +10,19 @@ import type { ProviderId } from "./ids/ids";
|
|
|
14
10
|
import { AiModelId, type QualifiedModelId, type ShortModelId } from "./ids/ids";
|
|
15
11
|
|
|
16
12
|
export interface AiModel extends AiModelType {
|
|
17
|
-
roles: Role[];
|
|
18
13
|
model: ShortModelId;
|
|
19
|
-
|
|
14
|
+
/** The provider this entry belongs to. */
|
|
15
|
+
provider: ProviderId;
|
|
20
16
|
/** Whether this is a custom model. */
|
|
21
17
|
custom: boolean;
|
|
22
18
|
}
|
|
23
19
|
|
|
20
|
+
// JSON shape matches the `AiModel` schema (Zod-validated at codegen time).
|
|
21
|
+
const models = modelsJson as unknown as Partial<
|
|
22
|
+
Record<ProviderId, AiModelType[]>
|
|
23
|
+
>;
|
|
24
|
+
const providers = providersJson as unknown as readonly AiProvider[];
|
|
25
|
+
|
|
24
26
|
interface KnownModelMaps {
|
|
25
27
|
/** Map of qualified model ID to model info */
|
|
26
28
|
modelMap: ReadonlyMap<QualifiedModelId, AiModel>;
|
|
@@ -32,24 +34,25 @@ export const getKnownModelMaps = once((): KnownModelMaps => {
|
|
|
32
34
|
const modelMap = new Map<QualifiedModelId, AiModel>();
|
|
33
35
|
const defaultModelByProvider = new Map<ProviderId, QualifiedModelId>();
|
|
34
36
|
|
|
35
|
-
for (const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
for (const [providerKey, providerModels] of Object.entries(models)) {
|
|
38
|
+
if (!providerModels) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const provider = providerKey as ProviderId;
|
|
42
|
+
for (const raw of providerModels) {
|
|
43
|
+
const modelId = raw.model as ShortModelId;
|
|
44
|
+
const modelInfo: AiModel = {
|
|
45
|
+
...raw,
|
|
46
|
+
model: modelId,
|
|
47
|
+
provider,
|
|
48
|
+
custom: false,
|
|
49
|
+
};
|
|
47
50
|
|
|
48
|
-
for (const provider of modelInfo.providers) {
|
|
49
51
|
const qualifiedModelId: QualifiedModelId = `${provider}/${modelId}`;
|
|
50
52
|
modelMap.set(qualifiedModelId, modelInfo);
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
const supportsChatOrEdit =
|
|
55
|
+
modelInfo.roles.includes("chat") || modelInfo.roles.includes("edit");
|
|
53
56
|
if (supportsChatOrEdit && !defaultModelByProvider.has(provider)) {
|
|
54
57
|
defaultModelByProvider.set(provider, qualifiedModelId);
|
|
55
58
|
}
|
|
@@ -67,9 +70,8 @@ const getProviderMap = once(
|
|
|
67
70
|
const providerMap = new Map<ProviderId, AiProvider>();
|
|
68
71
|
const providerToOrderIdx = new Map<ProviderId, number>();
|
|
69
72
|
providers.forEach((provider, idx) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
providerToOrderIdx.set(providerId, idx);
|
|
73
|
+
providerMap.set(provider.id, provider);
|
|
74
|
+
providerToOrderIdx.set(provider.id, idx);
|
|
73
75
|
});
|
|
74
76
|
return { providerMap, providerToOrderIdx };
|
|
75
77
|
},
|
|
@@ -158,9 +160,12 @@ export class AiModelRegistry {
|
|
|
158
160
|
name: modelId.shortModelId,
|
|
159
161
|
model: modelId.shortModelId,
|
|
160
162
|
description: "Custom model",
|
|
161
|
-
|
|
163
|
+
provider: modelId.providerId,
|
|
162
164
|
roles: [],
|
|
163
|
-
|
|
165
|
+
capabilities: [],
|
|
166
|
+
input_types: [],
|
|
167
|
+
output_types: [],
|
|
168
|
+
release_date: "1970-01-01",
|
|
164
169
|
custom: true,
|
|
165
170
|
};
|
|
166
171
|
customModelsMap.set(model, modelInfo);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { MockNotebook } from "@/__mocks__/notebook";
|
|
5
|
+
import { scrollAndHighlightCell } from "@/components/editor/links/cell-link";
|
|
6
|
+
import { notebookAtom } from "@/core/cells/cells";
|
|
7
|
+
import type { CellId } from "@/core/cells/ids";
|
|
8
|
+
import { createCellRuntimeState } from "@/core/cells/types";
|
|
9
|
+
import { store } from "@/core/state/jotai";
|
|
10
|
+
import { notebookScrollToRunning } from "../actions";
|
|
11
|
+
|
|
12
|
+
vi.mock("@/components/editor/links/cell-link", () => ({
|
|
13
|
+
scrollAndHighlightCell: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
describe("notebookScrollToRunning", () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
vi.clearAllMocks();
|
|
19
|
+
store.set(notebookAtom, MockNotebook.notebookState({ cellData: {} }));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("scrolls to the first running cell in notebook order", () => {
|
|
23
|
+
const runtimeOnlyCellId = "runtime-only" as CellId;
|
|
24
|
+
const idleCellId = "idle-cell" as CellId;
|
|
25
|
+
const runningCellId = "running-cell" as CellId;
|
|
26
|
+
|
|
27
|
+
const notebook = MockNotebook.notebookState({
|
|
28
|
+
cellData: {
|
|
29
|
+
[idleCellId]: {},
|
|
30
|
+
[runningCellId]: {},
|
|
31
|
+
},
|
|
32
|
+
cellRuntime: {
|
|
33
|
+
[idleCellId]: { status: "idle" },
|
|
34
|
+
[runningCellId]: { status: "running" },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
notebook.cellRuntime = {
|
|
38
|
+
[runtimeOnlyCellId]: createCellRuntimeState({ status: "running" }),
|
|
39
|
+
...notebook.cellRuntime,
|
|
40
|
+
};
|
|
41
|
+
store.set(notebookAtom, notebook);
|
|
42
|
+
|
|
43
|
+
notebookScrollToRunning();
|
|
44
|
+
|
|
45
|
+
expect(scrollAndHighlightCell).toHaveBeenCalledOnce();
|
|
46
|
+
expect(scrollAndHighlightCell).toHaveBeenCalledWith(runningCellId, "focus");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { scrollAndHighlightCell } from "@/components/editor/links/cell-link";
|
|
4
|
-
import { Objects } from "@/utils/objects";
|
|
5
4
|
import { store } from "../state/jotai";
|
|
6
5
|
import { notebookAtom } from "./cells";
|
|
7
6
|
|
|
@@ -10,12 +9,12 @@ import { notebookAtom } from "./cells";
|
|
|
10
9
|
*/
|
|
11
10
|
export function notebookScrollToRunning() {
|
|
12
11
|
// find cell that is currently in "running" state
|
|
13
|
-
const { cellRuntime } = store.get(notebookAtom);
|
|
14
|
-
const
|
|
15
|
-
(
|
|
12
|
+
const { cellIds, cellRuntime } = store.get(notebookAtom);
|
|
13
|
+
const cellId = cellIds.inOrderIds.find(
|
|
14
|
+
(id) => cellRuntime[id]?.status === "running",
|
|
16
15
|
);
|
|
17
|
-
if (!
|
|
16
|
+
if (!cellId) {
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
|
-
scrollAndHighlightCell(
|
|
19
|
+
scrollAndHighlightCell(cellId, "focus");
|
|
21
20
|
}
|
|
@@ -134,6 +134,35 @@ describe("snapshot all duplicate keymaps", () => {
|
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
+
test("auto_close_pairs: false removes closeBrackets keymaps", () => {
|
|
138
|
+
const withAutoClose = EditorState.create({
|
|
139
|
+
extensions: setup(),
|
|
140
|
+
});
|
|
141
|
+
const withoutAutoClose = EditorState.create({
|
|
142
|
+
extensions: setup({
|
|
143
|
+
completionConfig: {
|
|
144
|
+
...getOpts().completionConfig,
|
|
145
|
+
auto_close_pairs: false,
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const keysWith = withAutoClose.facet(keymap).flat();
|
|
151
|
+
const keysWithout = withoutAutoClose.facet(keymap).flat();
|
|
152
|
+
|
|
153
|
+
// closeBracketsKeymap contributes Backspace and Enter handlers
|
|
154
|
+
expect(keysWith.length).toBeGreaterThan(keysWithout.length);
|
|
155
|
+
|
|
156
|
+
const hasBracketPairHandler = (state: EditorState) =>
|
|
157
|
+
state
|
|
158
|
+
.facet(keymap)
|
|
159
|
+
.flat()
|
|
160
|
+
.some((k) => k.run?.name === "deleteBracketPair");
|
|
161
|
+
|
|
162
|
+
expect(hasBracketPairHandler(withAutoClose)).toBe(true);
|
|
163
|
+
expect(hasBracketPairHandler(withoutAutoClose)).toBe(false);
|
|
164
|
+
});
|
|
165
|
+
|
|
137
166
|
test("placeholder adds another extension", () => {
|
|
138
167
|
const opts = getOpts();
|
|
139
168
|
const withAI = new PythonLanguageAdapter()
|