@marimo-team/islands 0.23.16-dev5 → 0.23.16-dev50
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-CJaUI-S-.js → ConnectedDataExplorerComponent-f9vLjQiF.js} +13 -13
- package/dist/{ErrorBoundary-DXlxsrTF.js → ErrorBoundary-DhLqwSWA.js} +3 -3
- package/dist/{any-language-editor-P9tjkj4n.js → any-language-editor-DifE-fl7.js} +5 -5
- package/dist/{button-BcSml68y.js → button-BSm8IXRU.js} +2 -4
- package/dist/{capabilities-BYLFYTYv.js → capabilities-C6OQ5YBO.js} +1 -1
- package/dist/{chat-ui-BdSDiVjk.js → chat-ui-1e7PcW56.js} +3117 -3120
- package/dist/{check-Cs-KV5XY.js → check-DP7U0H0G.js} +1 -1
- package/dist/{code-visibility-C4wLKnSb.js → common-BcbT1FqC.js} +1046 -1014
- package/dist/{copy-Cs3yt6Vt.js → copy-DNq8q3zw.js} +2 -2
- package/dist/{dist-B96tMAst.js → dist-DIlxLFXG.js} +2 -2
- package/dist/{error-banner-DR7o3CbX.js → error-banner-B_GQfxxD.js} +2 -2
- package/dist/{esm-k8PIvuZW.js → esm-DzZVaNH4.js} +1 -1
- package/dist/{extends-Cq2JYHKy.js → extends-w2_S44bV.js} +4 -4
- package/dist/{formats-BFhkZJwd.js → formats-Dwq1THhr.js} +3 -3
- package/dist/{glide-data-editor--CaN-f27.js → glide-data-editor-B9K6-MJe.js} +9 -9
- package/dist/{html-to-image-DDENewl2.js → html-to-image-3w0AakWW.js} +7164 -6240
- package/dist/{input-DStQIuqD.js → input-C5K4VBvB.js} +7 -7
- package/dist/{label-DIk0QoFe.js → label-DjoYwqmj.js} +2 -2
- package/dist/{loader-CTHCI-qe.js → loader-DX-IDS7n.js} +1 -1
- package/dist/main.js +1010 -1019
- package/dist/{mermaid-CdSvixW2.js → mermaid-hv6IckVw.js} +5 -5
- package/dist/{node-sql-parser-DLl_zNw0.js → node-sql-parser-v1Vi-Fft.js} +16867 -16665
- package/dist/{process-output-2QPcgBQg.js → process-output-BRwR4QGs.js} +32 -28
- package/dist/{reveal-component-BSD4w8YU.js → reveal-component-D7xmRQQ_.js} +725 -643
- package/dist/{spec-CnaxwDqy.js → spec-CQKL_D3i.js} +4 -4
- package/dist/{strings-BYAhZnQi.js → strings-DIy9NAmg.js} +4 -4
- package/dist/style.css +1 -1
- package/dist/{swiper-component-DE94711u.js → swiper-component-CEdAYjb7.js} +2 -2
- package/dist/toDate-CqhBWjvO.js +713 -0
- package/dist/{tooltip-B-qh7UPB.js → tooltip-f-qR0iUx.js} +3 -3
- package/dist/{types-DQl7jVYK.js → types-DicH9Oi0.js} +1 -1
- package/dist/{useAsyncData-CvO8WUy3.js → useAsyncData-CYOQb1EW.js} +1 -1
- package/dist/{useDateFormatter-BSoGim-G.js → useDateFormatter-Bt2qr_XS.js} +2 -2
- package/dist/{useDeepCompareMemoize-J3MKRdA4.js → useDeepCompareMemoize-CSHQeQEI.js} +1 -1
- package/dist/{useIframeCapabilities-POcFXHbw.js → useIframeCapabilities-kA09ykNq.js} +1 -1
- package/dist/{useLifecycle-DqPxHgAN.js → useLifecycle-CMJGqBaY.js} +3 -3
- package/dist/{useTheme-XMq9mNf_.js → useTheme-DYfby65G.js} +2 -2
- package/dist/{vega-component-CrFoZT1S.js → vega-component-C7nO5zcf.js} +10 -10
- package/dist/{zod-D0yOqoGe.js → zod-BUcyXSdR.js} +1 -1
- package/package.json +3 -4
- package/src/__mocks__/requests.ts +45 -4
- package/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap +174 -21
- package/src/components/data-table/__tests__/chart-spec-model.test.ts +102 -1
- package/src/components/data-table/column-summary/chart-spec-model.tsx +163 -103
- package/src/components/data-table/column-summary/legacy-chart-spec.ts +15 -7
- package/src/components/data-table/column-summary/utils.ts +26 -7
- package/src/components/data-table/types.ts +1 -1
- package/src/components/editor/__tests__/viewer-banner.test.tsx +14 -0
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +99 -18
- package/src/components/editor/actions/__tests__/pdf-export.test.ts +32 -13
- package/src/components/editor/actions/pair-with-agent-commands.ts +21 -10
- package/src/components/editor/actions/pair-with-agent-modal.tsx +2 -2
- package/src/components/editor/actions/pdf-export.ts +11 -14
- package/src/components/editor/actions/useNotebookActions.tsx +18 -18
- package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
- package/src/components/editor/cell/code/cell-editor.tsx +13 -7
- package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +25 -0
- package/src/components/editor/chrome/panels/logs-panel.tsx +12 -2
- package/src/components/editor/chrome/panels/write-secret-modal.tsx +40 -12
- package/src/components/editor/connections/__tests__/json-credentials.test.ts +114 -0
- package/src/components/editor/connections/__tests__/paths.test.ts +39 -0
- package/src/components/editor/connections/components.tsx +6 -2
- package/src/components/editor/connections/database/__tests__/__snapshots__/as-code.test.ts.snap +21 -5
- package/src/components/editor/connections/database/__tests__/as-code.test.ts +17 -0
- package/src/components/editor/connections/database/as-code.ts +16 -2
- package/src/components/editor/connections/database/schemas.ts +6 -5
- package/src/components/editor/connections/form-renderers.tsx +99 -1
- package/src/components/editor/connections/json-credentials.ts +57 -0
- package/src/components/editor/connections/paths.ts +21 -0
- package/src/components/editor/connections/secret-combobox.tsx +41 -20
- package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +88 -2
- package/src/components/editor/connections/storage/__tests__/as-code.test.ts +128 -8
- package/src/components/editor/connections/storage/as-code.ts +79 -36
- package/src/components/editor/connections/storage/schemas.ts +85 -44
- package/src/components/editor/file-tree/__tests__/renderers.test.ts +31 -0
- package/src/components/editor/file-tree/file-viewer.tsx +11 -7
- package/src/components/editor/file-tree/renderers.tsx +21 -0
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +1 -1
- package/src/components/editor/viewer-banner.tsx +4 -1
- package/src/components/forms/options.ts +2 -1
- package/src/components/slides/__tests__/cell-output-block.test.tsx +40 -0
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +33 -0
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +198 -0
- package/src/components/slides/reveal-component.tsx +25 -19
- package/src/components/slides/slide-cell-view.tsx +1 -1
- package/src/components/slides/slide-scroll-hint.tsx +161 -0
- package/src/components/slides/slides.css +4 -2
- package/src/components/static-html/share-modal.tsx +1 -1
- package/src/components/ui/input.tsx +1 -1
- package/src/core/ai/context/providers/file.ts +8 -29
- package/src/core/cells/__tests__/cells.test.ts +12 -2
- package/src/core/cells/__tests__/logs.test.ts +5 -5
- package/src/core/cells/cells.ts +17 -4
- package/src/core/cells/document-changes.ts +1 -0
- package/src/core/cells/logs.ts +14 -4
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +396 -100
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +128 -540
- package/src/core/codemirror/copilot/language-server.ts +182 -70
- package/src/core/codemirror/copilot/transport.ts +15 -207
- package/src/core/codemirror/copilot/types.ts +9 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -30
- package/src/core/codemirror/find-replace/navigate.ts +2 -0
- package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +24 -3
- package/src/core/codemirror/go-to-definition/commands.ts +3 -0
- package/src/core/codemirror/keymaps/__tests__/keymaps.test.ts +31 -2
- package/src/core/codemirror/keymaps/keymaps.ts +12 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +443 -61
- package/src/core/codemirror/language/languages/python.ts +23 -11
- package/src/core/codemirror/language/languages/sql/completion-store.ts +5 -1
- package/src/core/codemirror/language/languages/sql/sql.ts +210 -3
- package/src/core/codemirror/lsp/__tests__/federated-lsp.test.ts +161 -0
- package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +53 -0
- package/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts +25 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +598 -156
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +112 -0
- package/src/core/codemirror/lsp/federated-lsp.ts +76 -23
- package/src/core/codemirror/lsp/log-messages.ts +37 -0
- package/src/core/codemirror/lsp/normalize-markdown-math.ts +8 -4
- package/src/core/codemirror/lsp/notebook-lsp.ts +220 -56
- package/src/core/codemirror/lsp/transports.ts +8 -1
- package/src/core/codemirror/lsp/types.ts +68 -8
- package/src/core/codemirror/lsp/utils.ts +14 -0
- package/src/core/codemirror/utils.ts +28 -0
- package/src/core/edit-app.tsx +1 -2
- package/src/core/export/__tests__/hooks.test.ts +2 -4
- package/src/core/export/hooks.ts +4 -3
- package/src/core/hotkeys/hotkeys.ts +0 -2
- package/src/core/islands/__tests__/bridge.test.ts +107 -0
- package/src/core/islands/bridge.ts +16 -0
- package/src/core/lsp/__tests__/transport.test.ts +509 -337
- package/src/core/lsp/transport.ts +304 -132
- package/src/core/mode.ts +10 -0
- package/src/core/network/__tests__/api.test.ts +42 -0
- package/src/core/network/__tests__/connection.test.ts +45 -0
- package/src/core/network/__tests__/requests-lazy.test.ts +32 -1
- package/src/core/network/__tests__/requests-network.test.ts +21 -0
- package/src/core/network/api.ts +27 -0
- package/src/core/network/connection.ts +15 -0
- package/src/core/network/requests-lazy.ts +1 -0
- package/src/core/network/requests-network.ts +14 -8
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +22 -6
- package/src/core/rtc/state.ts +9 -0
- package/src/core/static/download-html.ts +5 -14
- package/src/core/wasm/bridge.ts +4 -2
- package/src/core/wasm/worker/types.ts +5 -2
- package/src/css/app/codemirror.css +16 -2
- package/src/plugins/impl/FormPlugin.tsx +1 -1
- package/src/plugins/impl/__tests__/FormPlugin.test.tsx +162 -0
- package/src/stories/log-viewer.stories.tsx +12 -6
- package/src/utils/__tests__/blob.test.ts +27 -1
- package/src/utils/__tests__/download.test.tsx +44 -4
- package/src/utils/blob.ts +24 -1
- package/src/utils/download.ts +14 -15
- package/dist/toDate-B3IRfHhw.js +0 -692
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Simulates React Activity's effect teardown when mode switches to "hidden":
|
|
5
|
+
* all useEffect cleanups run. On "visible", setups re-run (cleanups do not run
|
|
6
|
+
* again). Component state and DOM are preserved — only effects cycle.
|
|
7
|
+
*
|
|
8
|
+
* Registration order matches cell-editor.tsx: mount effect runs before destroy
|
|
9
|
+
* effect setup. With async editor creation (editorMountScheduler), destroy
|
|
10
|
+
* captures null initially; with sync creation it captures the live editor.
|
|
11
|
+
*/
|
|
12
|
+
import { EditorState } from "@codemirror/state";
|
|
13
|
+
import { EditorView } from "@codemirror/view";
|
|
14
|
+
import { describe, expect, it } from "vitest";
|
|
15
|
+
import { Functions } from "@/utils/functions";
|
|
16
|
+
|
|
17
|
+
interface EffectRegistration {
|
|
18
|
+
cleanup: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function createActivitySimulator() {
|
|
22
|
+
const effects: EffectRegistration[] = [];
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
/** Register effects in order — each setup runs synchronously, like React. */
|
|
26
|
+
useEffect(setup: () => (() => void) | undefined) {
|
|
27
|
+
const cleanup = setup() ?? Functions.NOOP;
|
|
28
|
+
effects.push({ cleanup });
|
|
29
|
+
},
|
|
30
|
+
hide() {
|
|
31
|
+
for (const effect of effects) {
|
|
32
|
+
effect.cleanup();
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
show() {
|
|
36
|
+
effects.length = 0;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function createEditor(doc = "hello") {
|
|
42
|
+
return new EditorView({
|
|
43
|
+
state: EditorState.create({ doc }),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface RegisterCellEditorEffectsOptions {
|
|
48
|
+
activity: ReturnType<typeof createActivitySimulator>;
|
|
49
|
+
editorViewRef: { current: EditorView | null };
|
|
50
|
+
destroyPattern: "old" | "pr";
|
|
51
|
+
onDestroy?: () => void;
|
|
52
|
+
/** When true, editor creation is deferred like editorMountScheduler.request */
|
|
53
|
+
asyncMount?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function registerCellEditorEffects({
|
|
57
|
+
activity,
|
|
58
|
+
editorViewRef,
|
|
59
|
+
destroyPattern,
|
|
60
|
+
onDestroy,
|
|
61
|
+
asyncMount = false,
|
|
62
|
+
}: RegisterCellEditorEffectsOptions) {
|
|
63
|
+
activity.useEffect(() => {
|
|
64
|
+
if (editorViewRef.current !== null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let cancelled = false;
|
|
68
|
+
const mount = () => {
|
|
69
|
+
if (!cancelled && editorViewRef.current === null) {
|
|
70
|
+
editorViewRef.current = createEditor();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
if (asyncMount) {
|
|
74
|
+
const id = setTimeout(mount, 0);
|
|
75
|
+
return () => {
|
|
76
|
+
cancelled = true;
|
|
77
|
+
clearTimeout(id);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
mount();
|
|
81
|
+
return () => {
|
|
82
|
+
cancelled = true;
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (destroyPattern === "old") {
|
|
87
|
+
activity.useEffect(() => {
|
|
88
|
+
const ev = editorViewRef.current;
|
|
89
|
+
return () => {
|
|
90
|
+
if (ev) {
|
|
91
|
+
ev.destroy();
|
|
92
|
+
onDestroy?.();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
activity.useEffect(() => {
|
|
98
|
+
return () => {
|
|
99
|
+
if (editorViewRef.current) {
|
|
100
|
+
editorViewRef.current.destroy();
|
|
101
|
+
onDestroy?.();
|
|
102
|
+
}
|
|
103
|
+
editorViewRef.current = null;
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
describe("CellEditor Activity lifecycle (simulated)", () => {
|
|
110
|
+
it("old destroy pattern (sync mount): first hide/show leaves stale ref", () => {
|
|
111
|
+
const editorViewRef = { current: null as EditorView | null };
|
|
112
|
+
let destroyCount = 0;
|
|
113
|
+
const activity = createActivitySimulator();
|
|
114
|
+
|
|
115
|
+
registerCellEditorEffects({
|
|
116
|
+
activity,
|
|
117
|
+
editorViewRef,
|
|
118
|
+
destroyPattern: "old",
|
|
119
|
+
onDestroy: () => {
|
|
120
|
+
destroyCount++;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
const liveEditor = editorViewRef.current;
|
|
124
|
+
expect(liveEditor).not.toBeNull();
|
|
125
|
+
|
|
126
|
+
activity.hide();
|
|
127
|
+
expect(destroyCount).toBeGreaterThan(0);
|
|
128
|
+
expect(editorViewRef.current).toBe(liveEditor);
|
|
129
|
+
|
|
130
|
+
activity.show();
|
|
131
|
+
registerCellEditorEffects({
|
|
132
|
+
activity,
|
|
133
|
+
editorViewRef,
|
|
134
|
+
destroyPattern: "old",
|
|
135
|
+
});
|
|
136
|
+
expect(editorViewRef.current).toBe(liveEditor);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("old destroy pattern (async mount): first hide/show preserves editor", async () => {
|
|
140
|
+
const editorViewRef = { current: null as EditorView | null };
|
|
141
|
+
let destroyCount = 0;
|
|
142
|
+
const activity = createActivitySimulator();
|
|
143
|
+
|
|
144
|
+
registerCellEditorEffects({
|
|
145
|
+
activity,
|
|
146
|
+
editorViewRef,
|
|
147
|
+
destroyPattern: "old",
|
|
148
|
+
onDestroy: () => {
|
|
149
|
+
destroyCount++;
|
|
150
|
+
},
|
|
151
|
+
asyncMount: true,
|
|
152
|
+
});
|
|
153
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
154
|
+
const liveEditor = editorViewRef.current;
|
|
155
|
+
expect(liveEditor).not.toBeNull();
|
|
156
|
+
|
|
157
|
+
// Destroy effect captured null at setup (editor created async after effects)
|
|
158
|
+
activity.hide();
|
|
159
|
+
expect(destroyCount).toBe(0);
|
|
160
|
+
expect(editorViewRef.current).toBe(liveEditor);
|
|
161
|
+
|
|
162
|
+
activity.show();
|
|
163
|
+
registerCellEditorEffects({
|
|
164
|
+
activity,
|
|
165
|
+
editorViewRef,
|
|
166
|
+
destroyPattern: "old",
|
|
167
|
+
asyncMount: true,
|
|
168
|
+
});
|
|
169
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
170
|
+
expect(editorViewRef.current).toBe(liveEditor);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("PR destroy pattern (async mount): recreates on first hide/show", async () => {
|
|
174
|
+
const editorViewRef = { current: null as EditorView | null };
|
|
175
|
+
const activity = createActivitySimulator();
|
|
176
|
+
|
|
177
|
+
registerCellEditorEffects({
|
|
178
|
+
activity,
|
|
179
|
+
editorViewRef,
|
|
180
|
+
destroyPattern: "pr",
|
|
181
|
+
asyncMount: true,
|
|
182
|
+
});
|
|
183
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
184
|
+
const firstEditor = editorViewRef.current;
|
|
185
|
+
|
|
186
|
+
activity.hide();
|
|
187
|
+
expect(editorViewRef.current).toBeNull();
|
|
188
|
+
|
|
189
|
+
activity.show();
|
|
190
|
+
registerCellEditorEffects({
|
|
191
|
+
activity,
|
|
192
|
+
editorViewRef,
|
|
193
|
+
destroyPattern: "pr",
|
|
194
|
+
asyncMount: true,
|
|
195
|
+
});
|
|
196
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
197
|
+
expect(editorViewRef.current).not.toBeNull();
|
|
198
|
+
expect(editorViewRef.current).not.toBe(firstEditor);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("PR destroy pattern: nulls ref on hide so mount recreates on show", () => {
|
|
202
|
+
const editorViewRef = { current: null as EditorView | null };
|
|
203
|
+
const activity = createActivitySimulator();
|
|
204
|
+
|
|
205
|
+
registerCellEditorEffects({
|
|
206
|
+
activity,
|
|
207
|
+
editorViewRef,
|
|
208
|
+
destroyPattern: "pr",
|
|
209
|
+
});
|
|
210
|
+
const firstEditor = editorViewRef.current;
|
|
211
|
+
|
|
212
|
+
activity.hide();
|
|
213
|
+
expect(editorViewRef.current).toBeNull();
|
|
214
|
+
|
|
215
|
+
activity.show();
|
|
216
|
+
registerCellEditorEffects({
|
|
217
|
+
activity,
|
|
218
|
+
editorViewRef,
|
|
219
|
+
destroyPattern: "pr",
|
|
220
|
+
});
|
|
221
|
+
expect(editorViewRef.current).not.toBeNull();
|
|
222
|
+
expect(editorViewRef.current).not.toBe(firstEditor);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("PR destroy pattern: stable across repeated hide/show cycles", () => {
|
|
226
|
+
const editorViewRef = { current: null as EditorView | null };
|
|
227
|
+
const activity = createActivitySimulator();
|
|
228
|
+
|
|
229
|
+
for (let i = 0; i < 3; i++) {
|
|
230
|
+
registerCellEditorEffects({
|
|
231
|
+
activity,
|
|
232
|
+
editorViewRef,
|
|
233
|
+
destroyPattern: "pr",
|
|
234
|
+
});
|
|
235
|
+
expect(editorViewRef.current).not.toBeNull();
|
|
236
|
+
|
|
237
|
+
activity.hide();
|
|
238
|
+
expect(editorViewRef.current).toBeNull();
|
|
239
|
+
|
|
240
|
+
activity.show();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
registerCellEditorEffects({
|
|
244
|
+
activity,
|
|
245
|
+
editorViewRef,
|
|
246
|
+
destroyPattern: "pr",
|
|
247
|
+
});
|
|
248
|
+
expect(editorViewRef.current).not.toBeNull();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
@@ -39,7 +39,7 @@ import type { UserConfig } from "@/core/config/config-schema";
|
|
|
39
39
|
import { OverridingHotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
40
40
|
import { connectionAtom } from "@/core/network/connection";
|
|
41
41
|
import { useRequestClient } from "@/core/network/requests";
|
|
42
|
-
import { isRtcEnabled } from "@/core/rtc/state";
|
|
42
|
+
import { canUseRtc, isRtcEnabled } from "@/core/rtc/state";
|
|
43
43
|
import { useSaveNotebook } from "@/core/saving/save-component";
|
|
44
44
|
import { isAppConnecting } from "@/core/websocket/connection-utils";
|
|
45
45
|
import type { Theme } from "@/theme/useTheme";
|
|
@@ -342,7 +342,7 @@ const CellEditorInternal = ({
|
|
|
342
342
|
saveOrNameNotebook,
|
|
343
343
|
]);
|
|
344
344
|
|
|
345
|
-
const rtcEnabled = isRtcEnabled();
|
|
345
|
+
const rtcEnabled = isRtcEnabled() && canUseRtc(cellId);
|
|
346
346
|
const handleInitializeEditor = useEvent(() => {
|
|
347
347
|
// If rtc is enabled, use collaborative editing
|
|
348
348
|
if (rtcEnabled) {
|
|
@@ -451,6 +451,7 @@ const CellEditorInternal = ({
|
|
|
451
451
|
setIsEditorMounted(true);
|
|
452
452
|
return;
|
|
453
453
|
}
|
|
454
|
+
setIsEditorMounted(false);
|
|
454
455
|
if (serializedEditorState !== null) {
|
|
455
456
|
handleDeserializeEditor();
|
|
456
457
|
setIsEditorMounted(true);
|
|
@@ -479,11 +480,12 @@ const CellEditorInternal = ({
|
|
|
479
480
|
handleReconfigureEditor();
|
|
480
481
|
}, [handleReconfigureEditor, extensions, editorViewRef]);
|
|
481
482
|
|
|
482
|
-
// Destroy the editor when the component is unmounted
|
|
483
|
+
// Destroy the editor when the component is unmounted. Read the ref in cleanup
|
|
484
|
+
// (not setup) so Activity hide/show cycles don't leave a stale destroyed view.
|
|
483
485
|
useEffect(() => {
|
|
484
|
-
const ev = editorViewRef.current;
|
|
485
486
|
return () => {
|
|
486
|
-
|
|
487
|
+
editorViewRef.current?.destroy();
|
|
488
|
+
editorViewRef.current = null;
|
|
487
489
|
};
|
|
488
490
|
}, [editorViewRef]);
|
|
489
491
|
|
|
@@ -635,14 +637,18 @@ CellCodeMirrorEditor.displayName = "CellCodeMirrorEditor";
|
|
|
635
637
|
// Wait until the websocket connection is open before rendering the editor
|
|
636
638
|
// This is used for real-time collaboration since the backend needs the connection started
|
|
637
639
|
// before connecting the rtc websockets
|
|
638
|
-
function WithWaitUntilConnected<T extends
|
|
640
|
+
function WithWaitUntilConnected<T extends Pick<CellEditorProps, "id">>(
|
|
639
641
|
Component: React.ComponentType<T>,
|
|
640
642
|
) {
|
|
641
643
|
const WaitUntilConnectedComponent = (props: T) => {
|
|
642
644
|
const connection = useAtomValue(connectionAtom);
|
|
643
645
|
const [rtcDoc, setRtcDoc] = useAtom(connectedDocAtom);
|
|
644
646
|
|
|
645
|
-
if (
|
|
647
|
+
if (
|
|
648
|
+
isRtcEnabled() &&
|
|
649
|
+
canUseRtc(props.id) &&
|
|
650
|
+
(isAppConnecting(connection.state) || rtcDoc === undefined)
|
|
651
|
+
) {
|
|
646
652
|
return (
|
|
647
653
|
<div className="flex h-full w-full items-baseline p-4">
|
|
648
654
|
<DelayMount milliseconds={1000} fallback={null}>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import type { CellLog } from "@/core/cells/logs";
|
|
6
|
+
import { LogViewer } from "../logs-panel";
|
|
7
|
+
|
|
8
|
+
describe("LogViewer", () => {
|
|
9
|
+
it("labels logs that came from a language server instead of a cell", () => {
|
|
10
|
+
const logs: CellLog[] = [
|
|
11
|
+
{
|
|
12
|
+
timestamp: 0,
|
|
13
|
+
level: "stderr",
|
|
14
|
+
message: "pylsp failed to start",
|
|
15
|
+
source: { type: "lsp", name: "pylsp" },
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
render(<LogViewer logs={logs} />);
|
|
20
|
+
|
|
21
|
+
expect(screen.getByText("(lsp:pylsp)")).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByText("pylsp failed to start")).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText("STDERR")).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -4,7 +4,11 @@ import { FileTextIcon } from "lucide-react";
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { ClearButton } from "@/components/buttons/clear-button";
|
|
6
6
|
import { useCellActions, useCellLogs } from "@/core/cells/cells";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
type CellLog,
|
|
9
|
+
formatLogTimestamp,
|
|
10
|
+
logSourceLabel,
|
|
11
|
+
} from "@/core/cells/logs";
|
|
8
12
|
import { cn } from "@/utils/cn";
|
|
9
13
|
import { CellLink } from "../../links/cell-link";
|
|
10
14
|
import { PanelEmptyState } from "./empty-state";
|
|
@@ -84,7 +88,13 @@ function formatLog(log: CellLog) {
|
|
|
84
88
|
</span>
|
|
85
89
|
<span className={cn("shrink-0", color)}>{level}</span>
|
|
86
90
|
<span className="shrink-0 text-(--gray-10)">
|
|
87
|
-
(
|
|
91
|
+
(
|
|
92
|
+
{log.source.type === "cell" ? (
|
|
93
|
+
<CellLink cellId={log.source.cellId} />
|
|
94
|
+
) : (
|
|
95
|
+
logSourceLabel(log.source)
|
|
96
|
+
)}
|
|
97
|
+
)
|
|
88
98
|
</span>
|
|
89
99
|
{log.message}
|
|
90
100
|
</>
|
|
@@ -19,9 +19,11 @@ import {
|
|
|
19
19
|
SelectTrigger,
|
|
20
20
|
SelectValue,
|
|
21
21
|
} from "@/components/ui/select";
|
|
22
|
+
import { Textarea } from "@/components/ui/textarea";
|
|
22
23
|
import { toast } from "@/components/ui/use-toast";
|
|
23
24
|
import { useRequestClient } from "@/core/network/requests";
|
|
24
25
|
import type { ListSecretKeysResponse } from "@/core/network/types";
|
|
26
|
+
import { flattenSecretValue } from "../../connections/json-credentials";
|
|
25
27
|
|
|
26
28
|
// dotenv providers should be at the top
|
|
27
29
|
export function sortProviders(providers: ListSecretKeysResponse["keys"]) {
|
|
@@ -44,10 +46,21 @@ export const WriteSecretModal: React.FC<{
|
|
|
44
46
|
onClose: () => void;
|
|
45
47
|
onSuccess: (secretName: string) => void;
|
|
46
48
|
initialValue?: string;
|
|
47
|
-
|
|
49
|
+
multiline?: boolean;
|
|
50
|
+
}> = ({
|
|
51
|
+
providerNames,
|
|
52
|
+
onClose,
|
|
53
|
+
onSuccess,
|
|
54
|
+
initialValue = "",
|
|
55
|
+
multiline = false,
|
|
56
|
+
}) => {
|
|
48
57
|
const { writeSecret } = useRequestClient();
|
|
49
58
|
const [key, setKey] = React.useState("");
|
|
50
|
-
|
|
59
|
+
// Multiline values are flattened so they fit on a single dotenv line;
|
|
60
|
+
// the textarea still wraps visually for readability.
|
|
61
|
+
const [value, setValue] = React.useState(() =>
|
|
62
|
+
multiline ? flattenSecretValue(initialValue) : initialValue,
|
|
63
|
+
);
|
|
51
64
|
const [location, setLocation] = React.useState<string | undefined>(
|
|
52
65
|
providerNames[0],
|
|
53
66
|
);
|
|
@@ -65,7 +78,9 @@ export const WriteSecretModal: React.FC<{
|
|
|
65
78
|
return;
|
|
66
79
|
}
|
|
67
80
|
|
|
68
|
-
|
|
81
|
+
const secretValue = multiline ? flattenSecretValue(value) : value;
|
|
82
|
+
|
|
83
|
+
if (!key || !secretValue || !location) {
|
|
69
84
|
toast({
|
|
70
85
|
title: "Error",
|
|
71
86
|
description: "Please fill in all fields.",
|
|
@@ -77,7 +92,7 @@ export const WriteSecretModal: React.FC<{
|
|
|
77
92
|
try {
|
|
78
93
|
await writeSecret({
|
|
79
94
|
key,
|
|
80
|
-
value,
|
|
95
|
+
value: secretValue,
|
|
81
96
|
provider,
|
|
82
97
|
name: location,
|
|
83
98
|
});
|
|
@@ -120,14 +135,27 @@ export const WriteSecretModal: React.FC<{
|
|
|
120
135
|
</div>
|
|
121
136
|
<div className="grid gap-2">
|
|
122
137
|
<Label htmlFor="value">Value</Label>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
{multiline ? (
|
|
139
|
+
<Textarea
|
|
140
|
+
id="value"
|
|
141
|
+
value={value}
|
|
142
|
+
onChange={(e) => setValue(flattenSecretValue(e.target.value))}
|
|
143
|
+
required={true}
|
|
144
|
+
className="my-0 font-code text-xs break-all"
|
|
145
|
+
rows={8}
|
|
146
|
+
autoFocus={true}
|
|
147
|
+
autoComplete="off"
|
|
148
|
+
/>
|
|
149
|
+
) : (
|
|
150
|
+
<Input
|
|
151
|
+
id="value"
|
|
152
|
+
type="password"
|
|
153
|
+
value={value}
|
|
154
|
+
onChange={(e) => setValue(e.target.value)}
|
|
155
|
+
required={true}
|
|
156
|
+
autoComplete="off"
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
131
159
|
{/* http is prone to man-in-the-middle */}
|
|
132
160
|
{isHttpUrl() && (
|
|
133
161
|
<FormDescription>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
escapePythonString,
|
|
5
|
+
flattenSecretValue,
|
|
6
|
+
looksLikeJson,
|
|
7
|
+
resolveJsonCredential,
|
|
8
|
+
} from "../json-credentials";
|
|
9
|
+
import { prefixPath } from "../paths";
|
|
10
|
+
import { prefixSecret } from "../secrets";
|
|
11
|
+
|
|
12
|
+
describe("resolveJsonCredential", () => {
|
|
13
|
+
test("resolves a file path", () => {
|
|
14
|
+
expect(
|
|
15
|
+
resolveJsonCredential(prefixPath("/etc/secrets/key.json"), (v) => v),
|
|
16
|
+
).toEqual({ kind: "path", path: "/etc/secrets/key.json" });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("resolves a secret via printSecret", () => {
|
|
20
|
+
expect(
|
|
21
|
+
resolveJsonCredential(prefixSecret("MY_CREDS"), () => "_my_creds"),
|
|
22
|
+
).toEqual({ kind: "json", expr: "json.loads(_my_creds)" });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("resolves a raw JSON literal", () => {
|
|
26
|
+
expect(
|
|
27
|
+
resolveJsonCredential('{"type":"service_account"}', (v) => v),
|
|
28
|
+
).toEqual({
|
|
29
|
+
kind: "json",
|
|
30
|
+
expr: 'json.loads(r"""{"type":"service_account"}""")',
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("uses a raw string so escaped newlines in a private_key survive", () => {
|
|
35
|
+
const credentialsJson =
|
|
36
|
+
'{"private_key":"-----BEGIN PRIVATE KEY-----\\nabc123\\n-----END PRIVATE KEY-----\\n"}';
|
|
37
|
+
const credential = resolveJsonCredential(credentialsJson, (v) => v);
|
|
38
|
+
expect(credential).toEqual({
|
|
39
|
+
kind: "json",
|
|
40
|
+
expr: `json.loads(r"""${credentialsJson}""")`,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("prefers path over secret-looking values", () => {
|
|
45
|
+
// A path-prefixed value wins even if the path text starts with "env:".
|
|
46
|
+
expect(
|
|
47
|
+
resolveJsonCredential(prefixPath("env:not-a-secret"), (v) => v),
|
|
48
|
+
).toEqual({ kind: "path", path: "env:not-a-secret" });
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("looksLikeJson", () => {
|
|
53
|
+
test("detects objects and arrays, including partial paste", () => {
|
|
54
|
+
expect(looksLikeJson('{"type":"service_account"}')).toBe(true);
|
|
55
|
+
expect(looksLikeJson(" {")).toBe(true);
|
|
56
|
+
expect(looksLikeJson("[1, 2]")).toBe(true);
|
|
57
|
+
expect(looksLikeJson("/etc/secrets/key.json")).toBe(false);
|
|
58
|
+
expect(looksLikeJson("MY_SECRET")).toBe(false);
|
|
59
|
+
expect(looksLikeJson("")).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("drives the path vs. create-secret combobox actions exclusively", () => {
|
|
63
|
+
// These mirror how SECRET_TEXTAREA_RENDERER wires allowCustomValue /
|
|
64
|
+
// allowCreateSecret, so a path and a JSON paste never both offer (or
|
|
65
|
+
// both hide) the wrong action.
|
|
66
|
+
const allowCustomValue = (search: string) => !looksLikeJson(search);
|
|
67
|
+
const allowCreateSecret = (search: string) =>
|
|
68
|
+
!search || looksLikeJson(search);
|
|
69
|
+
|
|
70
|
+
expect(allowCustomValue("/etc/secrets/key.json")).toBe(true);
|
|
71
|
+
expect(allowCreateSecret("/etc/secrets/key.json")).toBe(false);
|
|
72
|
+
|
|
73
|
+
expect(allowCustomValue('{"type":"service_account"}')).toBe(false);
|
|
74
|
+
expect(allowCreateSecret('{"type":"service_account"}')).toBe(true);
|
|
75
|
+
|
|
76
|
+
expect(allowCreateSecret("")).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe("flattenSecretValue", () => {
|
|
81
|
+
test("minifies valid JSON", () => {
|
|
82
|
+
expect(
|
|
83
|
+
flattenSecretValue(`{
|
|
84
|
+
"type": "service_account",
|
|
85
|
+
"project_id": "test"
|
|
86
|
+
}`),
|
|
87
|
+
).toBe('{"type":"service_account","project_id":"test"}');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("strips newlines from non-JSON", () => {
|
|
91
|
+
expect(flattenSecretValue("line1\nline2\r\nline3")).toBe("line1line2line3");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("returns empty for blank input", () => {
|
|
95
|
+
expect(flattenSecretValue("")).toBe("");
|
|
96
|
+
expect(flattenSecretValue(" \n ")).toBe("");
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("escapePythonString", () => {
|
|
101
|
+
test("escapes backslashes and quotes", () => {
|
|
102
|
+
expect(escapePythonString('C:\\tmp\\"creds".json')).toBe(
|
|
103
|
+
'C:\\\\tmp\\\\\\"creds\\".json',
|
|
104
|
+
);
|
|
105
|
+
expect(escapePythonString("/etc/secrets/key.json")).toBe(
|
|
106
|
+
"/etc/secrets/key.json",
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("escapes control characters", () => {
|
|
111
|
+
expect(escapePythonString("line1\nline2")).toBe("line1\\nline2");
|
|
112
|
+
expect(escapePythonString("a\tb\rc")).toBe("a\\tb\\rc");
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
isPath,
|
|
5
|
+
prefixPath,
|
|
6
|
+
type PathPlaceholder,
|
|
7
|
+
unprefixPath,
|
|
8
|
+
} from "../paths";
|
|
9
|
+
|
|
10
|
+
describe("paths", () => {
|
|
11
|
+
test("isPath", () => {
|
|
12
|
+
expect(isPath("path:/etc/secrets/key.json")).toBe(true);
|
|
13
|
+
expect(isPath("path:")).toBe(true);
|
|
14
|
+
expect(isPath("/etc/secrets/key.json")).toBe(false);
|
|
15
|
+
expect(isPath("env:MY_SECRET")).toBe(false);
|
|
16
|
+
expect(isPath("")).toBe(false);
|
|
17
|
+
expect(isPath(null)).toBe(false);
|
|
18
|
+
expect(isPath(undefined)).toBe(false);
|
|
19
|
+
expect(isPath(123)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("prefixPath", () => {
|
|
23
|
+
expect(prefixPath("/etc/secrets/key.json")).toBe(
|
|
24
|
+
"path:/etc/secrets/key.json",
|
|
25
|
+
);
|
|
26
|
+
expect(prefixPath("")).toBe("path:");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("unprefixPath", () => {
|
|
30
|
+
expect(unprefixPath("path:/etc/secrets/key.json" as PathPlaceholder)).toBe(
|
|
31
|
+
"/etc/secrets/key.json",
|
|
32
|
+
);
|
|
33
|
+
expect(unprefixPath("path:" as PathPlaceholder)).toBe("");
|
|
34
|
+
// Only strips the leading prefix — path may itself contain "path:".
|
|
35
|
+
expect(unprefixPath("path:/tmp/path:weird.json" as PathPlaceholder)).toBe(
|
|
36
|
+
"/tmp/path:weird.json",
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -21,9 +21,13 @@ import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
|
|
|
21
21
|
import { useCellActions } from "@/core/cells/cells";
|
|
22
22
|
import { useLastFocusedCellId } from "@/core/cells/focus";
|
|
23
23
|
import { autoInstantiateAtom } from "@/core/config/config";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
ENV_RENDERER,
|
|
26
|
+
SECRET_TEXTAREA_RENDERER,
|
|
27
|
+
SecretsProvider,
|
|
28
|
+
} from "./form-renderers";
|
|
25
29
|
|
|
26
|
-
const RENDERERS: FormRenderer[] = [ENV_RENDERER];
|
|
30
|
+
const RENDERERS: FormRenderer[] = [ENV_RENDERER, SECRET_TEXTAREA_RENDERER];
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
33
|
* Grid layout for provider/database selector buttons.
|