Skip to content

Commit 6f10e14

Browse files
committed
Trust plugin data: URIs in the VS Code renderer
Fixes #490 marimo 0.23.2 (marimo-team/marimo#9196) re-allows plugins to load base64 `data:` URIs, but only once `hasRunAnyCellAtom` is `true`,and that atom only flips inside marimo's `useRunCells` hook, which our renderer never calls (cells run through VS Code's NotebookController). Seed it at `initialize()` so holoviews/bokeh and anywidget-backed outputs like polars tables stop failing with "Refusing to load … from untrusted URL". Workspace trust and extension ownership of the kernel are used as the signal the atom is standing in for.
1 parent f6753fa commit 6f10e14

9 files changed

Lines changed: 37 additions & 15 deletions

File tree

.marimo-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.23.1
1+
0.23.2

extension/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const LanguageId = {
5555
export const MINIMUM_MARIMO_KERNEL_VERSION = {
5656
major: 0,
5757
minor: 23,
58-
patch: 1,
58+
patch: 2,
5959
} as const;
6060

6161
export type MarimoContextKey =

extension/src/python/__tests__/EnvironmentValidator.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ it.layer(EnvironmentValidatorLive)("EnvironmentValidator", (it) => {
120120
"requiredVersion": {
121121
"major": 0,
122122
"minor": 23,
123-
"patch": 1,
123+
"patch": 2,
124124
},
125125
},
126126
]

extension/src/renderer/marimo-frontend-untyped.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
* a clear boundary between typed and untyped code.
3838
*/
3939

40+
// TODO(marimo-team/marimo#TODO): move `hasRunAnyCellAtom` and the anywidget
41+
// model re-exports back into `marimo-frontend.ts` once marimo extracts the
42+
// atom into a leaf module. They're forced through this bridge because
43+
// `plugins/core/trusted-url.ts` (reached via `anywidget/widget-binding.ts`)
44+
// imports from `useRunCells.ts`, whose transitive closure blows up tsc.
45+
export { hasRunAnyCellAtom } from "@marimo-team/frontend/unstable_internal/components/editor/cell/useRunCells.ts";
46+
export {
47+
handleWidgetMessage,
48+
MODEL_MANAGER,
49+
} from "@marimo-team/frontend/unstable_internal/plugins/impl/anywidget/model.ts";
50+
4051
export { OutputRenderer } from "@marimo-team/frontend/unstable_internal/components/editor/Output.tsx";
4152
export { ConsoleOutput } from "@marimo-team/frontend/unstable_internal/components/editor/output/console/ConsoleOutput.tsx";
4253
export { TooltipProvider } from "@marimo-team/frontend/unstable_internal/components/ui/tooltip.tsx";

extension/src/renderer/marimo-frontend.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ import type {
2222
RunRequests,
2323
} from "@marimo-team/frontend/unstable_internal/core/network/types.ts";
2424
import { store } from "@marimo-team/frontend/unstable_internal/core/state/jotai.ts";
25-
import {
26-
handleWidgetMessage,
27-
MODEL_MANAGER,
28-
} from "@marimo-team/frontend/unstable_internal/plugins/impl/anywidget/model.ts";
2925
import { safeExtractSetUIElementMessageBuffers } from "@marimo-team/frontend/unstable_internal/utils/json/base64.ts";
3026

3127
import type { NotificationOf, CellRuntimeState } from "../types.ts";
@@ -53,6 +49,16 @@ export type { CellRuntimeState, CellId };
5349
export function initialize(client: RequestClient) {
5450
store.set(initialModeAtom, "edit");
5551
store.set(requestClientAtom, client);
52+
// Trust data: URIs from plugins without waiting for a run through marimo's
53+
// React UI — VS Code gates notebook open on workspace trust, and cell runs
54+
// flow through the extension's NotebookController (bypassing useRunCells),
55+
// so the atom would otherwise stay false forever.
56+
//
57+
// TODO: route through the untyped bridge because marimo 0.23.2 defines this
58+
// atom in `components/editor/cell/useRunCells.ts`, whose transitive closure
59+
// (CodeMirror, cells state, data-table UI, etc.) blows up tsc. Once the atom
60+
// moves to a leaf file upstream (marimo-team/marimo#TODO), import directly.
61+
store.set(untyped.hasRunAnyCellAtom, true);
5662

5763
untyped.initializePlugins();
5864
// Start the RuntimeState to listen for UI element value changes
@@ -74,7 +80,11 @@ export function handleSendUiElementMessage(
7480
}
7581

7682
export function handleModelLifecycle(msg: NotificationOf<"model-lifecycle">) {
77-
void handleWidgetMessage(MODEL_MANAGER, msg);
83+
// TODO: route through the untyped bridge because
84+
// `plugins/impl/anywidget/model.ts` transitively imports `trusted-url.ts`,
85+
// which in marimo 0.23.2 pulls in `useRunCells.ts` and its heavy closure.
86+
// Drop once the upstream atom move lands (marimo-team/marimo#TODO).
87+
void untyped.handleWidgetMessage(untyped.MODEL_MANAGER, msg);
7888
}
7989

8090
export function handleFunctionCallResult(

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [{ name = "Trevor Manz", email = "trevor.j.manz@gmail.com" }]
88
dependencies = [
99
"jupytext==1.19.1",
1010
"lsprotocol==2025.0.0",
11-
"marimo==0.23.1",
11+
"marimo==0.23.2",
1212
"pygls==2.1.1",
1313
]
1414

@@ -37,7 +37,7 @@ build-backend = "uv_build"
3737
# the update-marimo-version cron), while the value below is the compatibility
3838
# floor we claim to support for user kernels and is bumped manually when we
3939
# intentionally drop support for an older release.
40-
minimum-kernel-version = "0.23.1"
40+
minimum-kernel-version = "0.23.2"
4141

4242
[tool.ty.src]
4343
exclude = ["extension/**"]

src/marimo_lsp/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ async def export_as_ipynb(
355355
session_data = serialize_session_view(
356356
session.session_view,
357357
cell_ids=session.app_file_manager.app.cell_manager.cell_ids(),
358+
drop_virtual_file_outputs=True,
358359
)
359360
ipynb.setdefault("metadata", {}).setdefault("marimo", {})["session"] = session_data
360361
return json.dumps(ipynb)

src/marimo_lsp/kernel_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(
114114
app_config=app_file_manager.app.config,
115115
),
116116
redirect_console_to_browser=True,
117-
virtual_files_supported=False,
117+
virtual_file_storage=None,
118118
)
119119
self.executable = executable
120120
self.connection_info = connection_info

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)