@marimo-team/islands 0.25.3-dev365 → 0.25.3-dev368
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-C1Juomzz.js → ErrorBoundary-DpkCKHtr.js} +1 -1
- package/dist/{code-visibility-DYeldTAJ.js → code-visibility-tzmc1eIh.js} +1 -1
- package/dist/{common-By96qaG7.js → common-D923JCoX.js} +1 -1
- package/dist/{data-grid-overlay-editor-kINvpNJa.js → data-grid-overlay-editor-9X7heXSB.js} +1 -1
- package/dist/{feedback-button-Bc2IzTgC.js → feedback-button-D7wpuiTw.js} +2 -2
- package/dist/{glide-data-editor-C6wxFBGz.js → glide-data-editor-DDgCfsr2.js} +3 -3
- package/dist/{globals-BdA92Wgi.js → globals-D46oCNJC.js} +1 -1
- package/dist/main.js +6 -6
- package/dist/{number-overlay-editor-s2Ge4Uwy.js → number-overlay-editor-CH0jdmO6.js} +1 -1
- package/dist/{reveal-component-Kfgc1ojj.js → reveal-component-CNzBUIYg.js} +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/app-config/ai-config.tsx +50 -11
- package/src/components/app-config/model-discovery.tsx +223 -0
- package/src/components/app-config/state.ts +2 -0
- package/src/components/app-config/user-config-form.tsx +12 -1
package/package.json
CHANGED
|
@@ -84,6 +84,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs";
|
|
|
84
84
|
import { Tooltip } from "../ui/tooltip";
|
|
85
85
|
import { formItemClasses, SettingSubtitle } from "./common";
|
|
86
86
|
import { AWS_REGIONS } from "./constants";
|
|
87
|
+
import { ModelDiscovery } from "./model-discovery";
|
|
87
88
|
import { IncorrectModelId } from "./incorrect-model-id";
|
|
88
89
|
import {
|
|
89
90
|
IsOverridden,
|
|
@@ -91,7 +92,7 @@ import {
|
|
|
91
92
|
useConfigOverride,
|
|
92
93
|
} from "./is-overridden";
|
|
93
94
|
import { MCPConfig } from "./mcp-config";
|
|
94
|
-
import { aiSettingsSubTabAtom } from "./state";
|
|
95
|
+
import { aiSettingsSubTabAtom, pendingConfigSavesAtom } from "./state";
|
|
95
96
|
|
|
96
97
|
interface AiConfigProps {
|
|
97
98
|
form: UseFormReturn<UserConfig>;
|
|
@@ -1534,6 +1535,7 @@ const ProviderTreeItem: React.FC<ProviderTreeItemProps> = ({
|
|
|
1534
1535
|
|
|
1535
1536
|
export const AiModelDisplayConfig: React.FC<AiConfigProps> = ({
|
|
1536
1537
|
form,
|
|
1538
|
+
config,
|
|
1537
1539
|
onSubmit,
|
|
1538
1540
|
}) => {
|
|
1539
1541
|
const resolvedAi = useAtomValue(resolvedMarimoConfigAtom).ai;
|
|
@@ -1655,6 +1657,7 @@ export const AiModelDisplayConfig: React.FC<AiConfigProps> = ({
|
|
|
1655
1657
|
</div>
|
|
1656
1658
|
<AddModelForm
|
|
1657
1659
|
form={form}
|
|
1660
|
+
config={config}
|
|
1658
1661
|
customModels={customModels}
|
|
1659
1662
|
customProviderNames={customProviderNames}
|
|
1660
1663
|
onSubmit={onSubmit}
|
|
@@ -1665,10 +1668,11 @@ export const AiModelDisplayConfig: React.FC<AiConfigProps> = ({
|
|
|
1665
1668
|
|
|
1666
1669
|
export const AddModelForm: React.FC<{
|
|
1667
1670
|
form: UseFormReturn<UserConfig>;
|
|
1671
|
+
config: UserConfig;
|
|
1668
1672
|
customModels: QualifiedModelId[];
|
|
1669
1673
|
customProviderNames: string[];
|
|
1670
1674
|
onSubmit: (values: UserConfig) => void;
|
|
1671
|
-
}> = ({ form, customModels, customProviderNames, onSubmit }) => {
|
|
1675
|
+
}> = ({ form, config, customModels, customProviderNames, onSubmit }) => {
|
|
1672
1676
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
|
1673
1677
|
const [modelAdded, setModelAdded] = useState(false);
|
|
1674
1678
|
const [provider, setProvider] = useState<ProviderId | "custom" | null>(null);
|
|
@@ -1681,6 +1685,18 @@ export const AddModelForm: React.FC<{
|
|
|
1681
1685
|
|
|
1682
1686
|
const isCustomProvider = provider === "custom";
|
|
1683
1687
|
const providerName = isCustomProvider ? customProviderName : provider;
|
|
1688
|
+
const canDiscoverModels =
|
|
1689
|
+
!!providerName &&
|
|
1690
|
+
(providerName === "openrouter" ||
|
|
1691
|
+
customProviderNames.includes(providerName));
|
|
1692
|
+
const configurationPending = useAtomValue(pendingConfigSavesAtom) > 0;
|
|
1693
|
+
const savedProviderConfig =
|
|
1694
|
+
providerName === "openrouter"
|
|
1695
|
+
? config.ai?.openrouter
|
|
1696
|
+
: providerName
|
|
1697
|
+
? config.ai?.custom_providers?.[providerName]
|
|
1698
|
+
: undefined;
|
|
1699
|
+
const configurationKey = JSON.stringify(savedProviderConfig ?? null);
|
|
1684
1700
|
const hasValidValues = providerName?.trim() && modelName?.trim();
|
|
1685
1701
|
|
|
1686
1702
|
const resetForm = () => {
|
|
@@ -1728,7 +1744,10 @@ export const AddModelForm: React.FC<{
|
|
|
1728
1744
|
</Label>
|
|
1729
1745
|
<Select
|
|
1730
1746
|
value={provider || ""}
|
|
1731
|
-
onValueChange={(v) =>
|
|
1747
|
+
onValueChange={(v) => {
|
|
1748
|
+
setProvider(v as ProviderId | "custom");
|
|
1749
|
+
setModelName("");
|
|
1750
|
+
}}
|
|
1732
1751
|
>
|
|
1733
1752
|
<SelectTrigger id={providerSelectId} className={providerClassName}>
|
|
1734
1753
|
{provider ? (
|
|
@@ -1825,18 +1844,38 @@ export const AddModelForm: React.FC<{
|
|
|
1825
1844
|
>
|
|
1826
1845
|
Model
|
|
1827
1846
|
</Label>
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1847
|
+
{canDiscoverModels && providerName ? (
|
|
1848
|
+
<ModelDiscovery
|
|
1849
|
+
key={providerName}
|
|
1850
|
+
provider={providerName}
|
|
1851
|
+
label="Model"
|
|
1852
|
+
configurationKey={configurationKey}
|
|
1853
|
+
configurationPending={configurationPending}
|
|
1854
|
+
inputId={modelNameInputId}
|
|
1855
|
+
inputClassName="text-xs mb-0"
|
|
1856
|
+
value={modelName}
|
|
1857
|
+
onValueChange={setModelName}
|
|
1858
|
+
/>
|
|
1859
|
+
) : (
|
|
1860
|
+
<Input
|
|
1861
|
+
id={modelNameInputId}
|
|
1862
|
+
value={modelName}
|
|
1863
|
+
onChange={(e) => setModelName(e.target.value)}
|
|
1864
|
+
placeholder="gpt-5.6-sol"
|
|
1865
|
+
className="text-xs mb-0"
|
|
1866
|
+
/>
|
|
1867
|
+
)}
|
|
1835
1868
|
</div>
|
|
1836
1869
|
);
|
|
1837
1870
|
|
|
1838
1871
|
const inputForm = (
|
|
1839
|
-
<div
|
|
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
|
+
>
|
|
1840
1879
|
{providerSelect}
|
|
1841
1880
|
{modelInput}
|
|
1842
1881
|
<div
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { API } from "@/core/network/api";
|
|
6
|
+
import { getRuntimeManager } from "@/core/runtime/config";
|
|
7
|
+
import { isWasm } from "@/core/wasm/utils";
|
|
8
|
+
import { Button } from "../ui/button";
|
|
9
|
+
import { Input } from "../ui/input";
|
|
10
|
+
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
11
|
+
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
|
+
});
|
|
16
|
+
|
|
17
|
+
interface ModelDiscoveryProps {
|
|
18
|
+
provider: string;
|
|
19
|
+
label: string;
|
|
20
|
+
configurationKey: string;
|
|
21
|
+
configurationPending: boolean;
|
|
22
|
+
onSelect?: (modelId: string) => void;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
value?: string;
|
|
25
|
+
onValueChange?: (value: string) => void;
|
|
26
|
+
inputId?: string;
|
|
27
|
+
inputClassName?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function ModelDiscovery({
|
|
31
|
+
provider,
|
|
32
|
+
label,
|
|
33
|
+
configurationKey,
|
|
34
|
+
configurationPending,
|
|
35
|
+
onSelect,
|
|
36
|
+
disabled = false,
|
|
37
|
+
value,
|
|
38
|
+
onValueChange,
|
|
39
|
+
inputId,
|
|
40
|
+
inputClassName,
|
|
41
|
+
}: ModelDiscoveryProps) {
|
|
42
|
+
const [models, setModels] = useState<z.infer<typeof CatalogSchema>["models"]>(
|
|
43
|
+
[],
|
|
44
|
+
);
|
|
45
|
+
const [query, setQuery] = useState("");
|
|
46
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
47
|
+
const [loading, setLoading] = useState(false);
|
|
48
|
+
const [loaded, setLoaded] = useState(false);
|
|
49
|
+
const [error, setError] = useState("");
|
|
50
|
+
const [open, setOpen] = useState(false);
|
|
51
|
+
const requestRef = useRef<AbortController | null>(null);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
requestRef.current?.abort();
|
|
55
|
+
setModels([]);
|
|
56
|
+
setQuery("");
|
|
57
|
+
setOpen(false);
|
|
58
|
+
setLoaded(false);
|
|
59
|
+
setLoading(false);
|
|
60
|
+
setError("");
|
|
61
|
+
return () => requestRef.current?.abort();
|
|
62
|
+
}, [provider, configurationKey]);
|
|
63
|
+
|
|
64
|
+
const search = (value ?? query).trim().toLowerCase();
|
|
65
|
+
const filtered = models.filter((model) =>
|
|
66
|
+
`${model.name} ${model.id}`.toLowerCase().includes(search),
|
|
67
|
+
);
|
|
68
|
+
|
|
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
|
+
return (
|
|
128
|
+
<div
|
|
129
|
+
className="flex flex-col gap-2 sm:flex-row sm:items-end sm:gap-4"
|
|
130
|
+
data-testid={`model-discovery-${provider}`}
|
|
131
|
+
>
|
|
132
|
+
<div className="relative min-w-0 flex-1">
|
|
133
|
+
<Popover open={open && loaded} onOpenChange={setOpen}>
|
|
134
|
+
<PopoverPrimitive.Anchor asChild>
|
|
135
|
+
<div>
|
|
136
|
+
<Input
|
|
137
|
+
ref={inputRef}
|
|
138
|
+
id={inputId}
|
|
139
|
+
className={inputClassName ?? "w-full"}
|
|
140
|
+
aria-label={label}
|
|
141
|
+
aria-haspopup="dialog"
|
|
142
|
+
aria-expanded={open && loaded}
|
|
143
|
+
placeholder="Type a model ID or search…"
|
|
144
|
+
value={value ?? query}
|
|
145
|
+
onChange={(event) => {
|
|
146
|
+
setQuery(event.target.value);
|
|
147
|
+
onValueChange?.(event.target.value);
|
|
148
|
+
setOpen(true);
|
|
149
|
+
}}
|
|
150
|
+
onFocus={() => setOpen(true)}
|
|
151
|
+
onKeyDown={(event) => {
|
|
152
|
+
if (event.key === "Escape") {
|
|
153
|
+
setOpen(false);
|
|
154
|
+
}
|
|
155
|
+
if (event.key === "Enter") {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
}
|
|
158
|
+
if (event.key === "ArrowDown" && loaded) {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
setOpen(true);
|
|
161
|
+
}
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
</PopoverPrimitive.Anchor>
|
|
166
|
+
<PopoverContent
|
|
167
|
+
align="start"
|
|
168
|
+
className="w-[var(--radix-popover-trigger-width)] min-w-64 max-w-[calc(100vw-2rem)] p-1 text-sm"
|
|
169
|
+
style={{
|
|
170
|
+
maxHeight:
|
|
171
|
+
"min(18rem, var(--radix-popover-content-available-height))",
|
|
172
|
+
overflowY: "auto",
|
|
173
|
+
}}
|
|
174
|
+
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
175
|
+
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
176
|
+
onInteractOutside={(event) => {
|
|
177
|
+
if (event.target === inputRef.current) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
}
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
{filtered.length === 0 ? (
|
|
183
|
+
<p className="px-2 py-1">No models found</p>
|
|
184
|
+
) : (
|
|
185
|
+
filtered.map((model) => (
|
|
186
|
+
<button
|
|
187
|
+
type="button"
|
|
188
|
+
key={model.id}
|
|
189
|
+
className="block w-full cursor-pointer rounded-sm px-2 py-1 text-left hover:bg-accent focus:bg-accent focus:outline-hidden"
|
|
190
|
+
onClick={() => {
|
|
191
|
+
setQuery(model.id);
|
|
192
|
+
onValueChange?.(model.id);
|
|
193
|
+
setOpen(false);
|
|
194
|
+
onSelect?.(model.id);
|
|
195
|
+
inputRef.current?.focus();
|
|
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>
|
|
211
|
+
<Button
|
|
212
|
+
type="button"
|
|
213
|
+
variant="outline"
|
|
214
|
+
size="xs"
|
|
215
|
+
className="self-start sm:self-end"
|
|
216
|
+
disabled={disabled || loading || configurationPending || isWasm()}
|
|
217
|
+
onClick={load}
|
|
218
|
+
>
|
|
219
|
+
{loading ? "Loading models…" : "Search available models"}
|
|
220
|
+
</Button>
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
@@ -10,6 +10,8 @@ export const aiSettingsSubTabAtom = atom<AiSettingsSubTab>("ai-features");
|
|
|
10
10
|
|
|
11
11
|
export const settingDialogAtom = atom<boolean>(false);
|
|
12
12
|
|
|
13
|
+
export const pendingConfigSavesAtom = atom<number>(0);
|
|
14
|
+
|
|
13
15
|
export function useOpenSettingsToTab() {
|
|
14
16
|
const setActiveCategory = useSetAtom(activeUserConfigCategoryAtom);
|
|
15
17
|
const setSettingsDialog = useSetAtom(settingDialogAtom);
|
|
@@ -48,6 +48,7 @@ import { Badge } from "../ui/badge";
|
|
|
48
48
|
import { ExternalLink } from "../ui/links";
|
|
49
49
|
import { Tooltip } from "../ui/tooltip";
|
|
50
50
|
import { AiConfig } from "./ai-config";
|
|
51
|
+
import { pendingConfigSavesAtom } from "./state";
|
|
51
52
|
import { formItemClasses, SettingGroup } from "./common";
|
|
52
53
|
import { DataForm } from "./data-form";
|
|
53
54
|
import { applyManualInjections, getDirtyValues } from "./get-dirty-values";
|
|
@@ -127,6 +128,7 @@ export const UserConfigForm: React.FC = () => {
|
|
|
127
128
|
const marimoVersion = useAtomValue(marimoVersionAtom);
|
|
128
129
|
const { locale } = useLocale();
|
|
129
130
|
const { saveUserConfig } = useRequestClient();
|
|
131
|
+
const setPendingConfigSaves = useSetAtom(pendingConfigSavesAtom);
|
|
130
132
|
|
|
131
133
|
// Create form
|
|
132
134
|
const form = useForm({
|
|
@@ -184,7 +186,16 @@ export const UserConfigForm: React.FC = () => {
|
|
|
184
186
|
// overwriting newer config changes.
|
|
185
187
|
setConfig((prev) => mergeConfig(prev, dirtyValues));
|
|
186
188
|
};
|
|
187
|
-
const onSubmit = useDebouncedCallback(
|
|
189
|
+
const onSubmit = useDebouncedCallback((values: UserConfig) => {
|
|
190
|
+
const save = onSubmitNotDebounced(values);
|
|
191
|
+
|
|
192
|
+
setPendingConfigSaves((count) => count + 1);
|
|
193
|
+
void save
|
|
194
|
+
.finally(() => {
|
|
195
|
+
setPendingConfigSaves((count) => Math.max(0, count - 1));
|
|
196
|
+
})
|
|
197
|
+
.catch(() => undefined);
|
|
198
|
+
}, FORM_DEBOUNCE);
|
|
188
199
|
|
|
189
200
|
const isWasmRuntime = isWasm();
|
|
190
201
|
const getOverride = useConfigOverride();
|