@marimo-team/islands 0.25.3-dev388 → 0.25.3-dev391
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/{ErrorBoundary-_mFP3LkM.js → ErrorBoundary-DNRG0xHi.js} +1 -1
- package/dist/{chat-ui-BKSYhGMh.js → chat-ui-CWVNPm2l.js} +769 -769
- package/dist/{code-visibility-DkMNjdNe.js → code-visibility-Ca8sDptK.js} +10 -10
- package/dist/{common-Ces9ooG_.js → common-B3NYpak4.js} +4910 -4902
- package/dist/{data-grid-overlay-editor-uNMslVKY.js → data-grid-overlay-editor-Cz7uMmtm.js} +1 -1
- package/dist/{error-entries-rtPWQkJk.js → error-entries-CnXf4kpP.js} +821 -686
- package/dist/{feedback-button-i960qUnq.js → feedback-button-BQbnZsf5.js} +7 -7
- package/dist/{glide-data-editor-_EEhlGzS.js → glide-data-editor-Bxc30klU.js} +3 -3
- package/dist/{globals-DKkjIolp.js → globals-CDatnx0Y.js} +1 -1
- package/dist/{html-to-image-B5nTOeMI.js → html-to-image-Bu_-vH_Y.js} +4782 -4765
- package/dist/main.js +6233 -6172
- package/dist/{number-overlay-editor-D5U7jbrh.js → number-overlay-editor-ChGu5C-s.js} +1 -1
- package/dist/{process-output-DNxpsd4n.js → process-output-Rbqr1aYD.js} +2 -2
- package/dist/{reveal-component-BM9TozVQ.js → reveal-component-CSxWJFAP.js} +32 -32
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +48 -8
- package/src/__mocks__/notebook.ts +20 -42
- package/src/components/app-config/__tests__/add-model-discovery.test.tsx +255 -0
- package/src/components/app-config/__tests__/model-discovery.test.tsx +183 -0
- package/src/components/app-config/ai-config.tsx +20 -24
- package/src/components/app-config/model-discovery.tsx +118 -184
- package/src/components/app-config/model-provider-config.ts +25 -0
- package/src/components/editor/Output.tsx +5 -4
- package/src/components/editor/__tests__/data-attributes.test.tsx +1 -6
- package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
- package/src/components/editor/__tests__/output-persistence.test.tsx +6 -24
- package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +6 -8
- package/src/components/editor/actions/useSetOutputsExpanded.ts +12 -4
- package/src/components/editor/cell/cell-context-menu.tsx +3 -2
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +89 -72
- package/src/components/editor/notebook-cell.tsx +15 -10
- package/src/components/editor/output/console/process-output.ts +4 -2
- package/src/components/editor/renderers/cells-renderer.tsx +3 -1
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +5 -11
- package/src/components/editor/renderers/grid-layout/grid-layout.tsx +9 -8
- package/src/components/editor/renderers/types.ts +2 -2
- package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +5 -8
- package/src/components/scratchpad/scratchpad.tsx +6 -2
- package/src/components/slides/__tests__/cell-output-block.test.tsx +7 -8
- package/src/components/slides/__tests__/minimap-actions.test.tsx +3 -3
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +1 -0
- package/src/components/slides/slide-cell-view.tsx +1 -3
- package/src/components/slides/slide.tsx +3 -3
- package/src/core/ai/context/__tests__/registry.test.ts +7 -11
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +113 -35
- package/src/core/ai/context/providers/__tests__/error.test.ts +74 -191
- package/src/core/ai/context/providers/cell-output.ts +11 -6
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +8 -103
- package/src/core/cells/__tests__/cells.test.ts +40 -292
- package/src/core/cells/__tests__/clear-outputs.test.ts +151 -0
- package/src/core/cells/__tests__/harness.ts +14 -12
- package/src/core/cells/__tests__/layout.test.ts +20 -26
- package/src/core/cells/__tests__/notebook-outline.test.ts +49 -43
- package/src/core/cells/__tests__/session.test.ts +26 -146
- package/src/core/cells/actions.ts +49 -9
- package/src/core/cells/cell.ts +0 -13
- package/src/core/cells/cells.ts +53 -62
- package/src/core/cells/focus.ts +6 -1
- package/src/core/cells/layout.ts +2 -3
- package/src/core/cells/outputs.ts +2 -2
- package/src/core/cells/session.ts +3 -38
- package/src/core/cells/types.ts +6 -8
- package/src/core/cells/utils.ts +4 -3
- package/src/core/codemirror/ai/__tests__/resources.test.ts +7 -11
- package/src/core/errors/__tests__/error-entries.test.ts +52 -18
- package/src/core/errors/error-entries.ts +21 -11
- package/src/core/executions/__tests__/freshness.test.ts +7 -4
- package/src/core/executions/__tests__/hooks.test.tsx +5 -1
- package/src/core/executions/__tests__/interrupt.test.ts +2 -0
- package/src/core/executions/__tests__/output-lifecycle.test.ts +201 -0
- package/src/core/executions/__tests__/output.test.ts +87 -3
- package/src/core/executions/__tests__/select.test.ts +17 -10
- package/src/core/executions/atoms.ts +73 -15
- package/src/core/executions/freshness.ts +1 -1
- package/src/core/executions/hooks.ts +18 -8
- package/src/core/executions/index.ts +6 -0
- package/src/core/executions/output.ts +122 -38
- package/src/core/executions/select.ts +2 -2
- package/src/core/export/__tests__/hooks.test.ts +20 -29
- package/src/core/export/hooks.ts +7 -9
- package/src/core/islands/__tests__/iframe-resizer.test.ts +91 -0
- package/src/core/islands/__tests__/main.test.ts +17 -0
- package/src/core/islands/components/__tests__/web-components.test.tsx +13 -15
- package/src/core/islands/components/output-wrapper.tsx +15 -20
- package/src/core/islands/iframe-resizer.ts +38 -0
- package/src/core/islands/main.ts +3 -0
- package/src/core/lifecycle/render-policy.ts +7 -4
- package/src/core/network/__tests__/ai.test.ts +41 -0
- package/src/core/network/ai.ts +12 -0
- package/src/core/notebook/document/__tests__/codemirror.test.ts +2 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +19 -0
- package/src/core/notebook/replica/__tests__/results.test.ts +45 -16
- package/src/core/notebook/replica/index.ts +1 -1
- package/src/core/notebook/replica/replica.ts +19 -4
- package/src/core/notebook/replica/resources/executions.ts +100 -9
- package/src/core/notebook/replica/resources/results.ts +46 -31
- package/src/core/transports/__tests__/static.test.ts +5 -3
- package/src/stories/cell.stories.tsx +40 -30
- package/src/stories/layout/vertical/one-column.stories.tsx +15 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { dequal } from "dequal";
|
|
3
4
|
import { useAtom, useAtomValue } from "jotai";
|
|
4
5
|
import {
|
|
5
6
|
BotIcon,
|
|
@@ -85,6 +86,7 @@ import { Tooltip } from "../ui/tooltip";
|
|
|
85
86
|
import { formItemClasses, SettingSubtitle } from "./common";
|
|
86
87
|
import { AWS_REGIONS } from "./constants";
|
|
87
88
|
import { ModelDiscovery } from "./model-discovery";
|
|
89
|
+
import { getModelProviderConfig } from "./model-provider-config";
|
|
88
90
|
import { IncorrectModelId } from "./incorrect-model-id";
|
|
89
91
|
import {
|
|
90
92
|
IsOverridden,
|
|
@@ -1689,14 +1691,13 @@ export const AddModelForm: React.FC<{
|
|
|
1689
1691
|
!!providerName &&
|
|
1690
1692
|
(providerName === "openrouter" ||
|
|
1691
1693
|
customProviderNames.includes(providerName));
|
|
1692
|
-
const
|
|
1693
|
-
const
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
const configurationKey = JSON.stringify(savedProviderConfig ?? null);
|
|
1694
|
+
const draftAi = useWatch({ control: form.control, name: "ai" });
|
|
1695
|
+
const effectiveAi = useAtomValue(resolvedMarimoConfigAtom).ai;
|
|
1696
|
+
const savedProvider = getModelProviderConfig(config.ai, providerName);
|
|
1697
|
+
const draftProvider = getModelProviderConfig(draftAi, providerName);
|
|
1698
|
+
const effectiveProvider = getModelProviderConfig(effectiveAi, providerName);
|
|
1699
|
+
const isSaving = useAtomValue(pendingConfigSavesAtom) > 0;
|
|
1700
|
+
const hasUnsavedChanges = !dequal(savedProvider, draftProvider);
|
|
1700
1701
|
const hasValidValues = providerName?.trim() && modelName?.trim();
|
|
1701
1702
|
|
|
1702
1703
|
const resetForm = () => {
|
|
@@ -1833,10 +1834,7 @@ export const AddModelForm: React.FC<{
|
|
|
1833
1834
|
|
|
1834
1835
|
const modelInput = (
|
|
1835
1836
|
<div
|
|
1836
|
-
className={cn(
|
|
1837
|
-
"flex items-center gap-2",
|
|
1838
|
-
isCustomProvider && "self-start",
|
|
1839
|
-
)}
|
|
1837
|
+
className={cn("flex items-start gap-2", isCustomProvider && "self-start")}
|
|
1840
1838
|
>
|
|
1841
1839
|
<Label
|
|
1842
1840
|
htmlFor={modelNameInputId}
|
|
@@ -1846,11 +1844,10 @@ export const AddModelForm: React.FC<{
|
|
|
1846
1844
|
</Label>
|
|
1847
1845
|
{canDiscoverModels && providerName ? (
|
|
1848
1846
|
<ModelDiscovery
|
|
1849
|
-
key={providerName}
|
|
1850
1847
|
provider={providerName}
|
|
1848
|
+
configuration={effectiveProvider}
|
|
1851
1849
|
label="Model"
|
|
1852
|
-
|
|
1853
|
-
configurationPending={configurationPending}
|
|
1850
|
+
disabled={isSaving || hasUnsavedChanges}
|
|
1854
1851
|
inputId={modelNameInputId}
|
|
1855
1852
|
inputClassName="text-xs mb-0"
|
|
1856
1853
|
value={modelName}
|
|
@@ -1869,22 +1866,21 @@ export const AddModelForm: React.FC<{
|
|
|
1869
1866
|
);
|
|
1870
1867
|
|
|
1871
1868
|
const inputForm = (
|
|
1872
|
-
<div
|
|
1873
|
-
className={cn(
|
|
1874
|
-
"flex items-center gap-3 p-3 border border-border rounded-md",
|
|
1875
|
-
canDiscoverModels &&
|
|
1876
|
-
"relative pb-12 [&_[data-testid^='model-discovery-']>button]:absolute [&_[data-testid^='model-discovery-']>button]:right-3 [&_[data-testid^='model-discovery-']>button]:bottom-3",
|
|
1877
|
-
)}
|
|
1878
|
-
>
|
|
1869
|
+
<div className="flex flex-wrap items-start gap-3 p-3 border border-border rounded-md">
|
|
1879
1870
|
{providerSelect}
|
|
1880
1871
|
{modelInput}
|
|
1881
1872
|
<div
|
|
1882
1873
|
className={cn("flex gap-1.5 ml-auto", isCustomProvider && "self-end")}
|
|
1883
1874
|
>
|
|
1884
|
-
<Button
|
|
1875
|
+
<Button
|
|
1876
|
+
type="button"
|
|
1877
|
+
onClick={handleAddModel}
|
|
1878
|
+
disabled={!hasValidValues}
|
|
1879
|
+
size="xs"
|
|
1880
|
+
>
|
|
1885
1881
|
Add
|
|
1886
1882
|
</Button>
|
|
1887
|
-
<Button variant="outline" onClick={resetForm} size="xs">
|
|
1883
|
+
<Button type="button" variant="outline" onClick={resetForm} size="xs">
|
|
1888
1884
|
Cancel
|
|
1889
1885
|
</Button>
|
|
1890
1886
|
</div>
|
|
@@ -1,220 +1,154 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { getRuntimeManager } from "@/core/runtime/config";
|
|
3
|
+
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { listProviderModels } from "@/core/network/ai";
|
|
7
6
|
import { isWasm } from "@/core/wasm/utils";
|
|
7
|
+
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
8
|
+
import { useDeepCompareMemoize } from "@/hooks/useDeepCompareMemoize";
|
|
9
|
+
import { prettyError } from "@/utils/errors";
|
|
8
10
|
import { Button } from "../ui/button";
|
|
9
11
|
import { Input } from "../ui/input";
|
|
10
|
-
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
11
12
|
import { Popover, PopoverContent } from "../ui/popover";
|
|
12
|
-
|
|
13
|
-
const CatalogSchema = z.object({
|
|
14
|
-
models: z.array(z.object({ id: z.string().min(1), name: z.string() })),
|
|
15
|
-
});
|
|
13
|
+
import type { ModelProviderConfig } from "./model-provider-config";
|
|
16
14
|
|
|
17
15
|
interface ModelDiscoveryProps {
|
|
18
16
|
provider: string;
|
|
17
|
+
configuration: ModelProviderConfig;
|
|
19
18
|
label: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
value?: string;
|
|
25
|
-
onValueChange?: (value: string) => void;
|
|
26
|
-
inputId?: string;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
value: string;
|
|
21
|
+
onValueChange: (value: string) => void;
|
|
22
|
+
inputId: string;
|
|
27
23
|
inputClassName?: string;
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
export function ModelDiscovery({
|
|
31
27
|
provider,
|
|
28
|
+
configuration,
|
|
32
29
|
label,
|
|
33
|
-
|
|
34
|
-
configurationPending,
|
|
35
|
-
onSelect,
|
|
36
|
-
disabled = false,
|
|
30
|
+
disabled,
|
|
37
31
|
value,
|
|
38
32
|
onValueChange,
|
|
39
33
|
inputId,
|
|
40
34
|
inputClassName,
|
|
41
35
|
}: ModelDiscoveryProps) {
|
|
42
|
-
const
|
|
43
|
-
|
|
36
|
+
const query = useDeepCompareMemoize({ provider, configuration });
|
|
37
|
+
const [requestedQuery, setRequestedQuery] = useState<typeof query | null>(
|
|
38
|
+
null,
|
|
44
39
|
);
|
|
45
|
-
const
|
|
46
|
-
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
47
|
-
const [loading, setLoading] = useState(false);
|
|
48
|
-
const [loaded, setLoaded] = useState(false);
|
|
49
|
-
const [error, setError] = useState("");
|
|
40
|
+
const requested = requestedQuery === query;
|
|
50
41
|
const [open, setOpen] = useState(false);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return () => requestRef.current?.abort();
|
|
62
|
-
}, [provider, configurationKey]);
|
|
42
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
43
|
+
const optionsRef = useRef<HTMLDivElement>(null);
|
|
44
|
+
const focusOptionsOnOpen = useRef(false);
|
|
45
|
+
const { data, error, isFetching, refetch } = useAsyncData(async () => {
|
|
46
|
+
if (!requested || disabled) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const catalog = await listProviderModels(provider);
|
|
50
|
+
return { query, ...catalog };
|
|
51
|
+
}, [query, requested, disabled]);
|
|
63
52
|
|
|
64
|
-
const
|
|
65
|
-
const
|
|
53
|
+
const catalog = requested && data?.query === query ? data : undefined;
|
|
54
|
+
const catalogError = requested ? error : undefined;
|
|
55
|
+
const loading = requested && !disabled && isFetching;
|
|
56
|
+
const search = value.trim().toLowerCase();
|
|
57
|
+
const filtered = catalog?.models.filter((model) =>
|
|
66
58
|
`${model.name} ${model.id}`.toLowerCase().includes(search),
|
|
67
59
|
);
|
|
68
60
|
|
|
69
|
-
const load = async () => {
|
|
70
|
-
requestRef.current?.abort();
|
|
71
|
-
const controller = new AbortController();
|
|
72
|
-
requestRef.current = controller;
|
|
73
|
-
setLoading(true);
|
|
74
|
-
setError("");
|
|
75
|
-
try {
|
|
76
|
-
const url = getRuntimeManager().httpURL;
|
|
77
|
-
url.search = "";
|
|
78
|
-
url.hash = "";
|
|
79
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}/api/ai/models/${encodeURIComponent(provider)}`;
|
|
80
|
-
const response = await fetch(url.toString(), {
|
|
81
|
-
headers: API.headers(),
|
|
82
|
-
signal: controller.signal,
|
|
83
|
-
});
|
|
84
|
-
if (!response.ok) {
|
|
85
|
-
const raw = await response.text();
|
|
86
|
-
let detail = "";
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const parsed = z
|
|
90
|
-
.object({ detail: z.string() })
|
|
91
|
-
.safeParse(JSON.parse(raw));
|
|
92
|
-
|
|
93
|
-
detail = parsed.success ? parsed.data.detail : "";
|
|
94
|
-
} catch {
|
|
95
|
-
// The backend may return a non-JSON error response.
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (!controller.signal.aborted) {
|
|
99
|
-
setError(
|
|
100
|
-
detail ||
|
|
101
|
-
"Unable to load the provider model catalog. Check the connection and retry.",
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const catalog = CatalogSchema.parse(await response.json());
|
|
108
|
-
if (controller.signal.aborted) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
setModels(catalog.models);
|
|
112
|
-
setLoaded(true);
|
|
113
|
-
setOpen(true);
|
|
114
|
-
} catch {
|
|
115
|
-
if (!controller.signal.aborted) {
|
|
116
|
-
setError(
|
|
117
|
-
"Unable to load a valid catalog. Check the connection and retry.",
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
} finally {
|
|
121
|
-
if (!controller.signal.aborted) {
|
|
122
|
-
setLoading(false);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
61
|
return (
|
|
128
|
-
<div
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
62
|
+
<div className="flex min-w-0 flex-col gap-2">
|
|
63
|
+
<Popover open={open && !!catalog && !disabled} onOpenChange={setOpen}>
|
|
64
|
+
<PopoverPrimitive.Anchor asChild={true}>
|
|
65
|
+
<div>
|
|
66
|
+
<Input
|
|
67
|
+
ref={inputRef}
|
|
68
|
+
id={inputId}
|
|
69
|
+
className={inputClassName}
|
|
70
|
+
aria-label={label}
|
|
71
|
+
aria-haspopup="dialog"
|
|
72
|
+
aria-expanded={open && !!catalog && !disabled}
|
|
73
|
+
placeholder="Type a model ID or search…"
|
|
74
|
+
value={value}
|
|
75
|
+
onChange={(event) => {
|
|
76
|
+
onValueChange(event.target.value);
|
|
77
|
+
setOpen(true);
|
|
78
|
+
}}
|
|
79
|
+
onFocus={() => setOpen(true)}
|
|
80
|
+
onKeyDown={(event) => {
|
|
81
|
+
if (event.key === "Escape") {
|
|
82
|
+
setOpen(false);
|
|
83
|
+
}
|
|
84
|
+
if (event.key === "Enter") {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
}
|
|
87
|
+
if (event.key === "ArrowDown" && catalog) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
focusOptionsOnOpen.current = !open;
|
|
148
90
|
setOpen(true);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
setOpen(false);
|
|
197
|
-
}}
|
|
198
|
-
>
|
|
199
|
-
{model.name} — {model.id}
|
|
200
|
-
</button>
|
|
201
|
-
))
|
|
202
|
-
)}
|
|
203
|
-
</PopoverContent>
|
|
204
|
-
</Popover>
|
|
205
|
-
{error && (
|
|
206
|
-
<p role="alert" className="mt-1 text-sm text-destructive">
|
|
207
|
-
{error}
|
|
208
|
-
</p>
|
|
209
|
-
)}
|
|
210
|
-
</div>
|
|
91
|
+
optionsRef.current?.querySelector("button")?.focus();
|
|
92
|
+
}
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</PopoverPrimitive.Anchor>
|
|
97
|
+
<PopoverContent
|
|
98
|
+
ref={optionsRef}
|
|
99
|
+
align="start"
|
|
100
|
+
className="w-[var(--radix-popover-trigger-width)] min-w-64 max-w-[calc(100vw-2rem)] max-h-72 overflow-y-auto p-1 text-sm"
|
|
101
|
+
onOpenAutoFocus={(event) => {
|
|
102
|
+
if (!focusOptionsOnOpen.current) {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
}
|
|
105
|
+
focusOptionsOnOpen.current = false;
|
|
106
|
+
}}
|
|
107
|
+
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
108
|
+
onInteractOutside={(event) => {
|
|
109
|
+
if (event.target === inputRef.current) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{filtered?.length === 0 && (
|
|
115
|
+
<p className="px-2 py-1">No models found</p>
|
|
116
|
+
)}
|
|
117
|
+
{filtered?.map((model) => (
|
|
118
|
+
<button
|
|
119
|
+
type="button"
|
|
120
|
+
key={model.id}
|
|
121
|
+
className="block w-full cursor-pointer rounded-sm px-2 py-1 text-left hover:bg-accent focus:bg-accent focus:outline-hidden"
|
|
122
|
+
onClick={() => {
|
|
123
|
+
onValueChange(model.id);
|
|
124
|
+
inputRef.current?.focus();
|
|
125
|
+
setOpen(false);
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
{model.name} — {model.id}
|
|
129
|
+
</button>
|
|
130
|
+
))}
|
|
131
|
+
</PopoverContent>
|
|
132
|
+
</Popover>
|
|
133
|
+
{catalogError && (
|
|
134
|
+
<p role="alert" className="text-sm text-destructive">
|
|
135
|
+
{prettyError(catalogError)}
|
|
136
|
+
</p>
|
|
137
|
+
)}
|
|
211
138
|
<Button
|
|
212
139
|
type="button"
|
|
213
140
|
variant="outline"
|
|
214
141
|
size="xs"
|
|
215
|
-
className="self-start
|
|
216
|
-
disabled={disabled || loading ||
|
|
217
|
-
onClick={
|
|
142
|
+
className="self-start"
|
|
143
|
+
disabled={disabled || loading || isWasm()}
|
|
144
|
+
onClick={() => {
|
|
145
|
+
setOpen(true);
|
|
146
|
+
if (requested) {
|
|
147
|
+
refetch();
|
|
148
|
+
} else {
|
|
149
|
+
setRequestedQuery(query);
|
|
150
|
+
}
|
|
151
|
+
}}
|
|
218
152
|
>
|
|
219
153
|
{loading ? "Loading models…" : "Search available models"}
|
|
220
154
|
</Button>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { omit } from "lodash-es";
|
|
4
|
+
import type { UserConfig } from "@/core/config/config-schema";
|
|
5
|
+
|
|
6
|
+
type AiConfig = NonNullable<UserConfig["ai"]>;
|
|
7
|
+
export type ModelProviderConfig = NonNullable<AiConfig["openrouter"]>;
|
|
8
|
+
|
|
9
|
+
export function getModelProviderConfig(
|
|
10
|
+
ai: UserConfig["ai"],
|
|
11
|
+
providerName: string | null,
|
|
12
|
+
): ModelProviderConfig {
|
|
13
|
+
let selected = providerName
|
|
14
|
+
? ai?.custom_providers?.[providerName]
|
|
15
|
+
: undefined;
|
|
16
|
+
if (!selected && providerName === "openrouter") {
|
|
17
|
+
selected = ai?.openrouter;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const config = selected ?? {};
|
|
21
|
+
const unsetKeys = Object.entries(config)
|
|
22
|
+
.filter(([, value]) => value === undefined)
|
|
23
|
+
.map(([key]) => key);
|
|
24
|
+
return omit(config, unsetKeys);
|
|
25
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import React, { memo, Suspense, useMemo, useRef } from "react";
|
|
3
3
|
import { type CellId, CellOutputId } from "@/core/cells/ids";
|
|
4
|
-
import type { CellOutput
|
|
4
|
+
import type { CellOutput } from "@/core/executions";
|
|
5
|
+
import type { OutputMessage } from "@/core/kernel/messages";
|
|
5
6
|
import { cn } from "@/utils/cn";
|
|
6
7
|
import { logNever } from "../../utils/assertNever";
|
|
7
8
|
import { ErrorBoundary } from "./boundary/ErrorBoundary";
|
|
@@ -67,7 +68,7 @@ export type OnRefactorWithAI = (opts: {
|
|
|
67
68
|
*/
|
|
68
69
|
export const OutputRenderer: React.FC<{
|
|
69
70
|
message: Pick<
|
|
70
|
-
|
|
71
|
+
CellOutput,
|
|
71
72
|
"channel" | "data" | "mimetype" | "code" | "traceback_format"
|
|
72
73
|
>;
|
|
73
74
|
cellId?: CellId;
|
|
@@ -280,7 +281,7 @@ const MimeBundleOutputRenderer: React.FC<{
|
|
|
280
281
|
// Filter out metadata from the mime entries and type narrow
|
|
281
282
|
const rawEntries = Objects.entries(mimebundle as Record<string, unknown>)
|
|
282
283
|
.filter(([key]) => key !== METADATA_KEY)
|
|
283
|
-
.map(([mime, data]) => [mime, data] as [MimeType,
|
|
284
|
+
.map(([mime, data]) => [mime, data] as [MimeType, OutputMessage["data"]]);
|
|
284
285
|
|
|
285
286
|
// Apply precedence ordering and hiding rules
|
|
286
287
|
const { entries: mimeEntries } = processMimeBundle(rawEntries);
|
|
@@ -351,7 +352,7 @@ const MimeBundleOutputRenderer: React.FC<{
|
|
|
351
352
|
MimeBundleOutputRenderer.displayName = "MimeBundleOutputRenderer";
|
|
352
353
|
|
|
353
354
|
interface OutputAreaProps {
|
|
354
|
-
output:
|
|
355
|
+
output: CellOutput | null;
|
|
355
356
|
cellId: CellId;
|
|
356
357
|
stale: boolean;
|
|
357
358
|
loading: boolean;
|
|
@@ -109,12 +109,7 @@ describe("Cell data attributes", () => {
|
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
notebook.cellRuntime[cid] = createCellRuntimeState(
|
|
113
|
-
output: null,
|
|
114
|
-
consoleOutputs: [],
|
|
115
|
-
debuggerActive: false,
|
|
116
|
-
outline: null,
|
|
117
|
-
});
|
|
112
|
+
notebook.cellRuntime[cid] = createCellRuntimeState();
|
|
118
113
|
|
|
119
114
|
store.set(notebookAtom, notebook);
|
|
120
115
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
9
|
import { Provider, createStore } from "jotai";
|
|
10
10
|
import type { ReactNode } from "react";
|
|
11
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
11
12
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
12
13
|
import { cellId } from "@/__tests__/branded";
|
|
13
14
|
import { notebookAtom } from "@/core/cells/cells";
|
|
@@ -25,16 +26,13 @@ describe("DynamicFavicon", () => {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function setErrors() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
]),
|
|
37
|
-
);
|
|
29
|
+
MockNotebook.withErrors(store, [
|
|
30
|
+
{
|
|
31
|
+
cellId: id,
|
|
32
|
+
cellName: "cell",
|
|
33
|
+
error: { kind: "invalid-syntax", message: "Invalid syntax" },
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
beforeEach(() => {
|
|
@@ -211,12 +209,9 @@ describe("DynamicFavicon", () => {
|
|
|
211
209
|
act(() => setErrors());
|
|
212
210
|
await waitFor(() => expect(favicon.href).toContain("circle-x.ico"));
|
|
213
211
|
|
|
214
|
-
act(() =>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
MockNotebook.notebookState({ cellData: { [id]: {} } }),
|
|
218
|
-
),
|
|
219
|
-
);
|
|
212
|
+
act(() => {
|
|
213
|
+
MockExecutions.seed(store, []);
|
|
214
|
+
});
|
|
220
215
|
await waitFor(() => expect(favicon.href).toContain("circle-check.ico"));
|
|
221
216
|
});
|
|
222
217
|
|
|
@@ -16,14 +16,13 @@ import {
|
|
|
16
16
|
document as documentOf,
|
|
17
17
|
withCells,
|
|
18
18
|
} from "@/core/notebook/document/__tests__/fixtures";
|
|
19
|
-
import type { CellRuntimeState } from "@/core/cells/types";
|
|
20
|
-
import { createCellRuntimeState } from "@/core/cells/types";
|
|
21
19
|
import { defaultUserConfig } from "@/core/config/config-schema";
|
|
22
20
|
import type { AppMode } from "@/core/mode";
|
|
23
21
|
import { requestClientAtom } from "@/core/network/requests";
|
|
24
22
|
import { Cell } from "../notebook-cell";
|
|
25
23
|
|
|
26
24
|
const cid = cellId("test");
|
|
25
|
+
const PERSIST = { mimetype: "text/html", data: "<span>persist me</span>" };
|
|
27
26
|
|
|
28
27
|
function createTestWrapper() {
|
|
29
28
|
const store = createStore();
|
|
@@ -37,10 +36,7 @@ function createTestWrapper() {
|
|
|
37
36
|
return { wrapper, store };
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
function seedNotebook(
|
|
41
|
-
store: ReturnType<typeof createStore>,
|
|
42
|
-
runtimeOverrides: Partial<CellRuntimeState> = {},
|
|
43
|
-
) {
|
|
39
|
+
function seedNotebook(store: ReturnType<typeof createStore>) {
|
|
44
40
|
const notebook = MockNotebook.notebookState({
|
|
45
41
|
cellData: {
|
|
46
42
|
[cid]: {
|
|
@@ -54,15 +50,6 @@ function seedNotebook(
|
|
|
54
50
|
},
|
|
55
51
|
},
|
|
56
52
|
});
|
|
57
|
-
notebook.cellRuntime[cid] = createCellRuntimeState({
|
|
58
|
-
output: {
|
|
59
|
-
channel: "output",
|
|
60
|
-
mimetype: "text/html",
|
|
61
|
-
data: "<span>persist me</span>",
|
|
62
|
-
timestamp: 0,
|
|
63
|
-
},
|
|
64
|
-
...runtimeOverrides,
|
|
65
|
-
});
|
|
66
53
|
store.set(notebookAtom, notebook);
|
|
67
54
|
}
|
|
68
55
|
|
|
@@ -94,6 +81,7 @@ beforeAll(() => {
|
|
|
94
81
|
describe("output persistence across mode changes", () => {
|
|
95
82
|
it("preserves the output DOM node when toggling edit <-> present", () => {
|
|
96
83
|
const { store, wrapper } = createTestWrapper();
|
|
84
|
+
MockExecutions.seed(store, [MockExecutions.shown(cid, PERSIST)]);
|
|
97
85
|
seedNotebook(store);
|
|
98
86
|
|
|
99
87
|
const { container, rerender } = render(renderCell("edit"), { wrapper });
|
|
@@ -144,6 +132,7 @@ describe("output persistence across mode changes", () => {
|
|
|
144
132
|
|
|
145
133
|
it("hides all edit chrome while presenting", () => {
|
|
146
134
|
const { store, wrapper } = createTestWrapper();
|
|
135
|
+
MockExecutions.seed(store, [MockExecutions.shown(cid, PERSIST)]);
|
|
147
136
|
seedNotebook(store);
|
|
148
137
|
|
|
149
138
|
const { container, rerender } = render(renderCell("edit"), { wrapper });
|
|
@@ -195,7 +184,7 @@ describe("output persistence across mode changes", () => {
|
|
|
195
184
|
// The host holds newer source than the cell last ran with
|
|
196
185
|
MockExecutions.seed(
|
|
197
186
|
store,
|
|
198
|
-
[MockExecutions.
|
|
187
|
+
[MockExecutions.shown(cid, PERSIST, { code_fingerprint: "ran" })],
|
|
199
188
|
null,
|
|
200
189
|
withCells(
|
|
201
190
|
documentOf(),
|
|
@@ -223,14 +212,7 @@ describe("output persistence across mode changes", () => {
|
|
|
223
212
|
it("hides errored cells while presenting without unmounting them", () => {
|
|
224
213
|
const { store, wrapper } = createTestWrapper();
|
|
225
214
|
MockExecutions.seed(store, [MockExecutions.errored(cid)]);
|
|
226
|
-
seedNotebook(store
|
|
227
|
-
output: {
|
|
228
|
-
channel: "marimo-error",
|
|
229
|
-
mimetype: "application/vnd.marimo+error",
|
|
230
|
-
data: [{ type: "exception", exception_type: "ValueError", msg: "!" }],
|
|
231
|
-
timestamp: 0,
|
|
232
|
-
},
|
|
233
|
-
});
|
|
215
|
+
seedNotebook(store);
|
|
234
216
|
|
|
235
217
|
const { container, rerender } = render(renderCell("edit"), { wrapper });
|
|
236
218
|
|