@marimo-team/islands 0.23.15-dev5 → 0.23.15-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-CU4fZJzG.js → ConnectedDataExplorerComponent-Cmq_9LVS.js} +4 -4
- package/dist/{ErrorBoundary-DE6tzZf-.js → ErrorBoundary-CnMJ8jR9.js} +1 -1
- package/dist/{ImageComparisonComponent-CHrI72em.js → ImageComparisonComponent-1i5IBhon.js} +173 -129
- package/dist/assets/__vite-browser-external-CjNAy01L.js +1 -0
- package/dist/assets/worker-B3XPCb6y.js +98 -0
- package/dist/{chat-ui-DinOvbWu.js → chat-ui-Dy0arY8E.js} +3111 -3111
- package/dist/{code-visibility-DBuB5MVY.js → code-visibility-B5xe1Xp2.js} +946 -864
- package/dist/{constants-T20xxyNf.js → debounce-BOD3DbfP.js} +1 -24
- package/dist/{formats-Dzx4J_z1.js → formats-CdvkxTS6.js} +1 -1
- package/dist/{glide-data-editor-CjTu7ukN.js → glide-data-editor-D5w23DvC.js} +3 -3
- package/dist/{html-to-image-_wGfk8V-.js → html-to-image-f-kPEnn0.js} +2291 -2250
- package/dist/{input-DtsN7xm-.js → input-CF5Sgjba.js} +2 -2
- package/dist/main.js +1302 -1202
- package/dist/{mermaid-BYqXy_NE.js → mermaid-BaZJ2mds.js} +2 -2
- package/dist/{process-output-Mh4UrjwM.js → process-output-O9FeFAVM.js} +1 -1
- package/dist/{reveal-component-DfOZrkd6.js → reveal-component-BkZp_qsV.js} +618 -605
- package/dist/{spec-Cz-Bj1JI.js → spec-DxIove3q.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{toDate-CWNNlFEX.js → toDate-CEOdz9nC.js} +14 -5
- package/dist/{useAsyncData-KfHB8wQR.js → useAsyncData-Cs0mpJTy.js} +1 -1
- package/dist/{useDeepCompareMemoize-nJMtxhm4.js → useDeepCompareMemoize-DoOZicGb.js} +1 -1
- package/dist/{useLifecycle-DegSo0lV.js → useLifecycle-DR_F1d7F.js} +1 -1
- package/dist/{useTheme-6eZ3GOTS.js → useTheme-BA-8MM7N.js} +63 -27
- package/dist/{vega-component-DzyyM9fc.js → vega-component-BN0fz-QA.js} +6 -6
- package/package.json +1 -1
- package/src/__mocks__/requests.ts +3 -0
- package/src/components/chat/__tests__/chat-utils.test.ts +244 -1
- package/src/components/chat/__tests__/message-queue.test.tsx +121 -0
- package/src/components/chat/chat-panel.tsx +196 -67
- package/src/components/chat/chat-utils.ts +111 -2
- package/src/components/editor/SortableCell.tsx +6 -2
- package/src/components/editor/__tests__/output-persistence.test.tsx +241 -0
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +153 -0
- package/src/components/editor/actions/pair-with-agent-commands.ts +109 -0
- package/src/components/editor/actions/pair-with-agent-modal.tsx +20 -64
- package/src/components/editor/actions/useNotebookActions.tsx +8 -0
- package/src/components/editor/ai/add-cell-with-ai.tsx +14 -5
- package/src/components/editor/ai/ai-completion-editor.tsx +4 -1
- package/src/components/editor/cell/cell-context-menu.tsx +7 -0
- package/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx +221 -0
- package/src/components/editor/chrome/components/feedback-button.tsx +308 -77
- package/src/components/editor/chrome/panels/packages-panel.tsx +11 -1
- package/src/components/editor/columns/__tests__/cell-column.test.tsx +105 -0
- package/src/components/editor/columns/cell-column.tsx +34 -4
- package/src/components/editor/columns/sortable-column.tsx +24 -4
- package/src/components/editor/file-tree/download.ts +46 -0
- package/src/components/editor/file-tree/file-explorer.tsx +3 -21
- package/src/components/editor/file-tree/file-viewer.tsx +4 -27
- package/src/components/editor/navigation/__tests__/navigation.test.ts +33 -0
- package/src/components/editor/navigation/navigation.ts +8 -1
- package/src/components/editor/notebook-cell.tsx +203 -106
- package/src/components/editor/renderers/__tests__/cells-renderer.test.tsx +66 -0
- package/src/components/editor/renderers/cell-array.tsx +26 -13
- package/src/components/editor/renderers/cells-renderer.tsx +8 -2
- package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +29 -0
- package/src/components/editor/renderers/slides-layout/types.ts +4 -0
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +19 -19
- package/src/components/slides/reveal-component.tsx +37 -4
- package/src/components/slides/slide-form.tsx +72 -0
- package/src/components/ui/toast.tsx +11 -3
- package/src/components/ui/toaster.tsx +65 -9
- package/src/core/ai/context/providers/error.ts +6 -158
- package/src/core/cells/__tests__/utils.test.ts +59 -0
- package/src/core/cells/utils.ts +51 -0
- package/src/core/codemirror/completion/__tests__/signature-hint.test.ts +97 -3
- package/src/core/codemirror/completion/signature-hint.ts +78 -11
- package/src/core/constants.ts +8 -0
- package/src/core/diagnostics/__tests__/issue-details.test.ts +173 -0
- package/src/core/diagnostics/issue-details.ts +139 -0
- package/src/core/errors/__tests__/error-entries.test.ts +25 -0
- package/src/core/errors/error-entries.ts +176 -0
- package/src/core/islands/__tests__/bridge.test.ts +341 -46
- package/src/core/islands/__tests__/main.test.ts +176 -0
- package/src/core/islands/__tests__/parse.test.ts +105 -0
- package/src/core/islands/bootstrap.ts +8 -3
- package/src/core/islands/bridge.ts +117 -23
- package/src/core/islands/components/__tests__/web-components.test.tsx +214 -0
- package/src/core/islands/components/web-components.tsx +76 -15
- package/src/core/islands/constants.ts +1 -0
- package/src/core/islands/main.ts +69 -3
- package/src/core/islands/parse.ts +70 -23
- package/src/core/islands/worker/__tests__/controller.test.ts +173 -0
- package/src/core/islands/worker/worker.tsx +145 -57
- package/src/core/network/__tests__/requests-lazy.test.ts +18 -0
- package/src/core/network/__tests__/requests-network.test.ts +7 -0
- package/src/core/network/requests-lazy.ts +13 -1
- package/src/core/network/requests-network.ts +3 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +3 -0
- package/src/core/runtime/__tests__/runtime.test.ts +64 -0
- package/src/core/runtime/runtime.ts +30 -10
- package/src/core/wasm/bridge.ts +8 -0
- package/src/core/wasm/worker/bootstrap.ts +113 -20
- package/src/core/wasm/worker/types.ts +2 -0
- package/src/css/app/Cell.css +10 -0
- package/src/hooks/__tests__/useHotkey.test.tsx +88 -0
- package/src/hooks/useHotkey.ts +29 -4
- package/src/plugins/impl/anywidget/__tests__/host.test.ts +6 -9
- package/src/plugins/impl/anywidget/__tests__/registry.test.ts +3 -1
- package/src/plugins/impl/anywidget/__tests__/widget-binding.test.ts +32 -61
- package/src/plugins/impl/anywidget/model-proxy.ts +0 -13
- package/src/plugins/impl/anywidget/runtime.ts +1 -0
- package/src/plugins/impl/anywidget/widget-binding.ts +8 -34
- package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +53 -2
- package/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx +71 -0
- package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +71 -3
- package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +1 -0
- package/src/theme/__tests__/useTheme.test.ts +68 -0
- package/src/theme/useTheme.ts +16 -1
- package/dist/assets/__vite-browser-external-BQCLNwri.js +0 -1
- package/dist/assets/worker-DAWRHcPq.js +0 -73
package/src/core/cells/utils.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type { EditorView } from "@codemirror/view";
|
|
4
4
|
import { Objects } from "@/utils/objects";
|
|
5
|
+
import type { MarimoError, OutputMessage } from "../kernel/messages";
|
|
6
|
+
import { isErrorMime } from "../mime";
|
|
5
7
|
import type { RuntimeState } from "../network/types";
|
|
6
8
|
import type { NotebookState } from "./cells";
|
|
7
9
|
import type { CellId } from "./ids";
|
|
@@ -196,3 +198,52 @@ export function cellStatusClasses({
|
|
|
196
198
|
stale: status === "disabled-transitively",
|
|
197
199
|
};
|
|
198
200
|
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Status classes for a published cell (read or present mode, output only).
|
|
204
|
+
*/
|
|
205
|
+
export function publishedCellClasses({
|
|
206
|
+
errored,
|
|
207
|
+
stopped,
|
|
208
|
+
}: {
|
|
209
|
+
errored: boolean;
|
|
210
|
+
stopped: boolean;
|
|
211
|
+
}) {
|
|
212
|
+
return {
|
|
213
|
+
published: true,
|
|
214
|
+
"has-error": errored,
|
|
215
|
+
stopped: stopped,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Whether a published cell (read or present mode) should be hidden.
|
|
221
|
+
*
|
|
222
|
+
* Errored, interrupted, and stopped cells (and error outputs) are hidden in
|
|
223
|
+
* published views, unless `show_tracebacks` is enabled and the output carries
|
|
224
|
+
* an exception traceback to display inline.
|
|
225
|
+
*/
|
|
226
|
+
export function shouldHidePublishedCell({
|
|
227
|
+
errored,
|
|
228
|
+
interrupted,
|
|
229
|
+
stopped,
|
|
230
|
+
output,
|
|
231
|
+
showErrorTracebacks,
|
|
232
|
+
}: {
|
|
233
|
+
errored: boolean;
|
|
234
|
+
interrupted: boolean;
|
|
235
|
+
stopped: boolean;
|
|
236
|
+
output: OutputMessage | null;
|
|
237
|
+
showErrorTracebacks: boolean;
|
|
238
|
+
}): boolean {
|
|
239
|
+
const outputIsError = isErrorMime(output?.mimetype);
|
|
240
|
+
const hasTraceback =
|
|
241
|
+
showErrorTracebacks &&
|
|
242
|
+
outputIsError &&
|
|
243
|
+
Array.isArray(output?.data) &&
|
|
244
|
+
output.data.some(
|
|
245
|
+
(e: MarimoError) =>
|
|
246
|
+
e.type === "exception" && "traceback" in e && e.traceback,
|
|
247
|
+
);
|
|
248
|
+
return (errored || interrupted || stopped || outputIsError) && !hasTraceback;
|
|
249
|
+
}
|
|
@@ -5,6 +5,7 @@ import { EditorView, type Tooltip } from "@codemirror/view";
|
|
|
5
5
|
import { describe, expect, it } from "vitest";
|
|
6
6
|
import {
|
|
7
7
|
asSignatureHint,
|
|
8
|
+
closeSignatureHint,
|
|
8
9
|
setSignatureHintEffect,
|
|
9
10
|
signatureHintField,
|
|
10
11
|
} from "../signature-hint";
|
|
@@ -51,12 +52,79 @@ describe("signatureHintField", () => {
|
|
|
51
52
|
expect(state.field(signatureHintField)).toBeNull();
|
|
52
53
|
});
|
|
53
54
|
|
|
54
|
-
it("keeps and re-anchors the tooltip across edits", () => {
|
|
55
|
+
it("keeps and re-anchors the tooltip across edits inside the call", () => {
|
|
55
56
|
let state = stateWithHint("plt.plot(", 9);
|
|
56
|
-
// Insert before the tooltip position
|
|
57
|
-
|
|
57
|
+
// Insert before the tooltip position while the cursor stays inside the
|
|
58
|
+
// call; the anchor should shift but the hint should remain.
|
|
59
|
+
state = state.update({
|
|
60
|
+
changes: { from: 0, insert: "xy" },
|
|
61
|
+
selection: { anchor: 11 },
|
|
62
|
+
}).state;
|
|
58
63
|
expect(state.field(signatureHintField)?.pos).toBe(11);
|
|
59
64
|
});
|
|
65
|
+
|
|
66
|
+
it("dismisses the tooltip when the closing paren is typed", () => {
|
|
67
|
+
let state = stateWithHint("plt.plot(", 9);
|
|
68
|
+
// Type the closing paren; the cursor is now outside the call.
|
|
69
|
+
state = state.update({
|
|
70
|
+
changes: { from: 9, insert: ")" },
|
|
71
|
+
selection: { anchor: 10 },
|
|
72
|
+
}).state;
|
|
73
|
+
expect(state.field(signatureHintField)).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("dismisses the tooltip when the anchored call closes inside grouping parens", () => {
|
|
77
|
+
// Regression for the `(plt.plot())` case: the outer grouping paren must not
|
|
78
|
+
// keep the (now-closed) plt.plot hint alive.
|
|
79
|
+
let state = stateWithHint("(plt.plot(", 10);
|
|
80
|
+
// Close plt.plot's call; the outer `(` is still open but we've left the
|
|
81
|
+
// anchored call.
|
|
82
|
+
state = state.update({
|
|
83
|
+
changes: { from: 10, insert: ")" },
|
|
84
|
+
selection: { anchor: 11 },
|
|
85
|
+
}).state;
|
|
86
|
+
expect(state.field(signatureHintField)).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("keeps the tooltip while typing a nested call inside the anchored call", () => {
|
|
90
|
+
// Cursor inside the anchored call of `f(g(<cursor>`; opening/typing a nested
|
|
91
|
+
// call stays inside the anchored call, so the hint should remain.
|
|
92
|
+
let state = stateWithHint("f(g(", 4);
|
|
93
|
+
state = state.update({
|
|
94
|
+
changes: { from: 4, insert: "x(" },
|
|
95
|
+
selection: { anchor: 6 },
|
|
96
|
+
}).state;
|
|
97
|
+
expect(state.field(signatureHintField)?.pos).toBe(4);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("keeps the tooltip when a nested call closes inside the anchored call", () => {
|
|
101
|
+
const anchor = "f(".length;
|
|
102
|
+
let state = stateWithHint("f(g(x", anchor);
|
|
103
|
+
state = state.update({
|
|
104
|
+
changes: { from: 5, insert: ")" },
|
|
105
|
+
selection: { anchor: 6 },
|
|
106
|
+
}).state;
|
|
107
|
+
expect(state.field(signatureHintField)?.pos).toBe(anchor);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("dismisses the tooltip when the closing paren is typed in a large multi-line call", () => {
|
|
111
|
+
const anchor = "f(".length;
|
|
112
|
+
const prefix = `f(\n${" x,\n".repeat(25)}`;
|
|
113
|
+
let state = EditorState.create({
|
|
114
|
+
doc: prefix,
|
|
115
|
+
selection: { anchor: prefix.length },
|
|
116
|
+
extensions: [signatureHintField],
|
|
117
|
+
});
|
|
118
|
+
state = state.update({
|
|
119
|
+
effects: setSignatureHintEffect.of(fakeTooltip(anchor)),
|
|
120
|
+
}).state;
|
|
121
|
+
const head = prefix.length;
|
|
122
|
+
state = state.update({
|
|
123
|
+
changes: { from: head, insert: ")" },
|
|
124
|
+
selection: { anchor: head + 1 },
|
|
125
|
+
}).state;
|
|
126
|
+
expect(state.field(signatureHintField)).toBeNull();
|
|
127
|
+
});
|
|
60
128
|
});
|
|
61
129
|
|
|
62
130
|
describe("asSignatureHint", () => {
|
|
@@ -92,3 +160,29 @@ describe("asSignatureHint", () => {
|
|
|
92
160
|
expect(wrapped.above).toBe(true);
|
|
93
161
|
});
|
|
94
162
|
});
|
|
163
|
+
|
|
164
|
+
describe("closeSignatureHint", () => {
|
|
165
|
+
it("returns false when no hint is showing", () => {
|
|
166
|
+
const view = new EditorView({
|
|
167
|
+
state: EditorState.create({ extensions: [signatureHintField] }),
|
|
168
|
+
});
|
|
169
|
+
expect(closeSignatureHint(view)).toBe(false);
|
|
170
|
+
expect(view.state.field(signatureHintField)).toBeNull();
|
|
171
|
+
view.destroy();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("dismisses the hint and returns true when one is showing", () => {
|
|
175
|
+
const view = new EditorView({
|
|
176
|
+
state: EditorState.create({
|
|
177
|
+
doc: "plt.plot(",
|
|
178
|
+
extensions: [signatureHintField],
|
|
179
|
+
}),
|
|
180
|
+
});
|
|
181
|
+
view.dispatch({ effects: setSignatureHintEffect.of(fakeTooltip(9)) });
|
|
182
|
+
expect(view.state.field(signatureHintField)?.pos).toBe(9);
|
|
183
|
+
|
|
184
|
+
expect(closeSignatureHint(view)).toBe(true);
|
|
185
|
+
expect(view.state.field(signatureHintField)).toBeNull();
|
|
186
|
+
view.destroy();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
@@ -1,12 +1,61 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import type { EditorState } from "@codemirror/state";
|
|
2
3
|
import { StateEffect, StateField } from "@codemirror/state";
|
|
3
|
-
import { showTooltip, type Tooltip } from "@codemirror/view";
|
|
4
|
+
import { type EditorView, showTooltip, type Tooltip } from "@codemirror/view";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Effect to set (or clear, with `null`) the floating signature hint.
|
|
7
8
|
*/
|
|
8
9
|
export const setSignatureHintEffect = StateEffect.define<Tooltip | null>();
|
|
9
10
|
|
|
11
|
+
// Bound the scan so large cells stay cheap on every keystroke.
|
|
12
|
+
const MAX_LINES_BACK = 20;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether the cursor is still inside the anchored call (just inside its `(`).
|
|
16
|
+
*
|
|
17
|
+
* Anchor-relative paren scan, bounded to {@link MAX_LINES_BACK} lines.
|
|
18
|
+
* Good enough for hint dismissal — not a full parse (ignores strings/comments).
|
|
19
|
+
*/
|
|
20
|
+
function isCursorInsideAnchoredCall(options: {
|
|
21
|
+
state: EditorState;
|
|
22
|
+
anchor: number;
|
|
23
|
+
head: number;
|
|
24
|
+
}): boolean {
|
|
25
|
+
const { state, anchor, head } = options;
|
|
26
|
+
if (head < anchor) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const headLine = state.doc.lineAt(head).number;
|
|
31
|
+
const anchorLine = state.doc.lineAt(anchor).number;
|
|
32
|
+
const startLine = Math.max(anchorLine, headLine - MAX_LINES_BACK + 1);
|
|
33
|
+
const from = Math.max(anchor, state.doc.line(startLine).from);
|
|
34
|
+
|
|
35
|
+
// If the anchor is outside the bounded window, assume its `(` is still open.
|
|
36
|
+
const assumedOpen = from > anchor;
|
|
37
|
+
let balance = assumedOpen ? 1 : 0;
|
|
38
|
+
const iter = state.doc.iterRange(from, head);
|
|
39
|
+
for (;;) {
|
|
40
|
+
const { value, done } = iter.next();
|
|
41
|
+
if (done) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
for (const char of value) {
|
|
45
|
+
if (char === "(") {
|
|
46
|
+
balance++;
|
|
47
|
+
} else if (char === ")") {
|
|
48
|
+
balance--;
|
|
49
|
+
const closed = assumedOpen ? balance <= 0 : balance < 0;
|
|
50
|
+
if (closed) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
10
59
|
/**
|
|
11
60
|
* Wrap a tooltip so it renders like the completion popup's info box.
|
|
12
61
|
*
|
|
@@ -34,13 +83,7 @@ export function asSignatureHint(tooltip: Tooltip): Tooltip {
|
|
|
34
83
|
* Holds the floating "signature hint" shown after typing `(` or `,` inside a
|
|
35
84
|
* call on the non-LSP (Jedi) completion path.
|
|
36
85
|
*
|
|
37
|
-
* The LSP path has its own signature help; this fills the gap for users
|
|
38
|
-
* without a language server. The completion source (`pythonCompletionSource`)
|
|
39
|
-
* drives it: it dispatches `setSignatureHintEffect` with the tooltip when the
|
|
40
|
-
* backend returns a signature and with `null` otherwise. The hint is also
|
|
41
|
-
* cleared when the cursor moves via a selection-only change (e.g. clicking
|
|
42
|
-
* away or arrowing out of the call), and kept anchored across edits so it
|
|
43
|
-
* doesn't flicker while a fresh result is in flight.
|
|
86
|
+
* The LSP path has its own signature help; this fills the gap for users without a language server.
|
|
44
87
|
*/
|
|
45
88
|
export const signatureHintField = StateField.define<Tooltip | null>({
|
|
46
89
|
create: () => null,
|
|
@@ -57,12 +100,36 @@ export const signatureHintField = StateField.define<Tooltip | null>({
|
|
|
57
100
|
if (tr.selection && !tr.docChanged) {
|
|
58
101
|
return null;
|
|
59
102
|
}
|
|
60
|
-
//
|
|
61
|
-
//
|
|
103
|
+
// Dismiss once the cursor leaves the anchored call (e.g. the closing paren
|
|
104
|
+
// is typed). Otherwise keep the hint anchored across edits so it doesn't
|
|
105
|
+
// flicker while a fresh result is in flight; the completion source refreshes
|
|
106
|
+
// or clears it as results arrive.
|
|
62
107
|
if (tr.docChanged) {
|
|
63
|
-
|
|
108
|
+
const anchor = tr.changes.mapPos(tooltip.pos);
|
|
109
|
+
if (
|
|
110
|
+
!isCursorInsideAnchoredCall({
|
|
111
|
+
state: tr.state,
|
|
112
|
+
anchor,
|
|
113
|
+
head: tr.state.selection.main.head,
|
|
114
|
+
})
|
|
115
|
+
) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return { ...tooltip, pos: anchor };
|
|
64
119
|
}
|
|
65
120
|
return tooltip;
|
|
66
121
|
},
|
|
67
122
|
provide: (field) => showTooltip.from(field),
|
|
68
123
|
});
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Dismiss the floating signature hint if one is showing.
|
|
127
|
+
* Returns `true` if a hint was dismissed.
|
|
128
|
+
*/
|
|
129
|
+
export function closeSignatureHint(view: EditorView): boolean {
|
|
130
|
+
if (view.state.field(signatureHintField, false)) {
|
|
131
|
+
view.dispatch({ effects: setSignatureHintEffect.of(null) });
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
package/src/core/constants.ts
CHANGED
|
@@ -3,6 +3,8 @@ export const Constants = {
|
|
|
3
3
|
githubPage: "https://github.com/marimo-team/marimo",
|
|
4
4
|
releasesPage: "https://github.com/marimo-team/marimo/releases",
|
|
5
5
|
issuesPage: "https://github.com/marimo-team/marimo/issues",
|
|
6
|
+
bugReportUrl:
|
|
7
|
+
"https://github.com/marimo-team/marimo/issues/new?template=bug_report.yaml",
|
|
6
8
|
feedbackForm: "https://marimo.io/feedback",
|
|
7
9
|
discordLink: "https://marimo.io/discord?ref=notebook",
|
|
8
10
|
docsPage: "https://docs.marimo.io",
|
|
@@ -50,6 +52,12 @@ export const KnownQueryParams = {
|
|
|
50
52
|
* If false, the chrome will be hidden.
|
|
51
53
|
*/
|
|
52
54
|
showChrome: "show-chrome",
|
|
55
|
+
/**
|
|
56
|
+
* Override the display theme: `light`, `dark`, or `system`.
|
|
57
|
+
* Takes precedence over the notebook's saved `display.theme`.
|
|
58
|
+
* Ignored for embedded islands, which infer the theme from their host page.
|
|
59
|
+
*/
|
|
60
|
+
theme: "theme",
|
|
53
61
|
};
|
|
54
62
|
|
|
55
63
|
/**
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { cellId } from "@/__tests__/branded";
|
|
5
|
+
import type { CellErrorEntry } from "@/core/errors/error-entries";
|
|
6
|
+
import type { EnvironmentInfo } from "@/core/network/types";
|
|
7
|
+
import {
|
|
8
|
+
buildBugReportUrl,
|
|
9
|
+
buildIssueDetails,
|
|
10
|
+
createPartialEnvironment,
|
|
11
|
+
enrichEnvironment,
|
|
12
|
+
markdownCodeFence,
|
|
13
|
+
MAX_PREFILL_URL_LENGTH,
|
|
14
|
+
} from "../issue-details";
|
|
15
|
+
|
|
16
|
+
const environment: EnvironmentInfo = {
|
|
17
|
+
marimo: "1.2.3",
|
|
18
|
+
editable: false,
|
|
19
|
+
location: "~/.venv/site-packages/marimo",
|
|
20
|
+
OS: "Darwin",
|
|
21
|
+
"OS Version": "25.0",
|
|
22
|
+
Processor: "arm",
|
|
23
|
+
"Python Version": "3.12.9",
|
|
24
|
+
Locale: "en_US",
|
|
25
|
+
Binaries: { Browser: "chrome 140", Node: "v22", uv: "0.11" },
|
|
26
|
+
Dependencies: { click: "8.4.2" },
|
|
27
|
+
"Optional Dependencies": { pandas: "3.0.0" },
|
|
28
|
+
"Experimental Flags": {},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe("enrichEnvironment", () => {
|
|
32
|
+
it("replaces server Chrome detection with the active browser", () => {
|
|
33
|
+
const result = enrichEnvironment(environment, "Firefox/140");
|
|
34
|
+
expect(result.Binaries.Browser).toBe("Firefox/140");
|
|
35
|
+
expect(result.Binaries.Node).toBe("v22");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("does not mutate the input", () => {
|
|
39
|
+
enrichEnvironment(environment, "Firefox/140");
|
|
40
|
+
expect(environment.Binaries.Browser).toBe("chrome 140");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("createPartialEnvironment", () => {
|
|
45
|
+
it("records the collection error and keeps the active browser", () => {
|
|
46
|
+
const partial = createPartialEnvironment(
|
|
47
|
+
"1.2.3",
|
|
48
|
+
"Firefox/140",
|
|
49
|
+
"en_US",
|
|
50
|
+
"Server environment information unavailable",
|
|
51
|
+
);
|
|
52
|
+
expect(partial.marimo).toBe("1.2.3");
|
|
53
|
+
expect(partial.Binaries?.Browser).toBe("Firefox/140");
|
|
54
|
+
expect(partial.Locale).toBe("en_US");
|
|
55
|
+
expect(partial["Environment Collection Error"]).toBe(
|
|
56
|
+
"Server environment information unavailable",
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("omits empty fields rather than filling placeholders", () => {
|
|
61
|
+
const partial = createPartialEnvironment(
|
|
62
|
+
"1.2.3",
|
|
63
|
+
"Firefox/140",
|
|
64
|
+
"",
|
|
65
|
+
"boom",
|
|
66
|
+
);
|
|
67
|
+
expect(partial.Locale).toBeUndefined();
|
|
68
|
+
expect(partial.location).toBeUndefined();
|
|
69
|
+
expect(partial.OS).toBeUndefined();
|
|
70
|
+
expect(partial.Dependencies).toBeUndefined();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("markdownCodeFence", () => {
|
|
75
|
+
it("uses a fence longer than any backtick run in the content", () => {
|
|
76
|
+
const block = markdownCodeFence("python", 'text = "```"');
|
|
77
|
+
expect(block.startsWith("````python\n")).toBe(true);
|
|
78
|
+
expect(block.endsWith("\n````")).toBe(true);
|
|
79
|
+
expect(block).toContain('text = "```"');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("uses a minimum fence of three backticks", () => {
|
|
83
|
+
const block = markdownCodeFence("json", "{}");
|
|
84
|
+
expect(block.startsWith("```json\n")).toBe(true);
|
|
85
|
+
expect(block.endsWith("\n```")).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("buildIssueDetails", () => {
|
|
90
|
+
it("includes the environment and omits notebook source unless provided", () => {
|
|
91
|
+
const markdown = buildIssueDetails({
|
|
92
|
+
environment,
|
|
93
|
+
errors: [],
|
|
94
|
+
notebook: undefined,
|
|
95
|
+
});
|
|
96
|
+
expect(markdown).toContain("<summary>Environment</summary>");
|
|
97
|
+
expect(markdown).toContain('"marimo": "1.2.3"');
|
|
98
|
+
expect(markdown).not.toContain("Notebook source");
|
|
99
|
+
expect(markdown).not.toContain("Current errors");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("includes current errors as plain text without notebook source", () => {
|
|
103
|
+
const errors: CellErrorEntry[] = [
|
|
104
|
+
{
|
|
105
|
+
cellId: cellId("cell-1"),
|
|
106
|
+
cellName: "Cell 1",
|
|
107
|
+
cellCode: "password = 'private'",
|
|
108
|
+
errorData: [],
|
|
109
|
+
tracebackHtml:
|
|
110
|
+
'<span class="gr">ValueError</span>: <span class="n">bad value</span>',
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
const markdown = buildIssueDetails({ environment, errors });
|
|
114
|
+
expect(markdown).toContain("<summary>Current errors</summary>");
|
|
115
|
+
expect(markdown).toContain("ValueError: bad value");
|
|
116
|
+
expect(markdown).not.toContain("password");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("includes notebook source under its basename when provided", () => {
|
|
120
|
+
const markdown = buildIssueDetails({
|
|
121
|
+
environment,
|
|
122
|
+
errors: [],
|
|
123
|
+
notebook: {
|
|
124
|
+
filename: "/project/example.py",
|
|
125
|
+
contents: "x = 1",
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
expect(markdown).toContain(
|
|
129
|
+
"<summary>Notebook source: example.py</summary>",
|
|
130
|
+
);
|
|
131
|
+
expect(markdown).toContain("x = 1");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("escapes the summary label as text", () => {
|
|
135
|
+
const markdown = buildIssueDetails({
|
|
136
|
+
environment,
|
|
137
|
+
errors: [],
|
|
138
|
+
notebook: {
|
|
139
|
+
filename: "/project/<script>.py",
|
|
140
|
+
contents: "x = 1",
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
expect(markdown).toContain("<script>.py");
|
|
144
|
+
expect(markdown).not.toContain("<script>.py");
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe("buildBugReportUrl", () => {
|
|
149
|
+
const baseUrl =
|
|
150
|
+
"https://github.com/marimo-team/marimo/issues/new?template=bug_report.yaml";
|
|
151
|
+
|
|
152
|
+
it("prefills the env field with the encoded issue details", () => {
|
|
153
|
+
const url = buildBugReportUrl(baseUrl, "hello world");
|
|
154
|
+
expect(url).toBe(`${baseUrl}&env=hello%20world`);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("appends env with a query separator when the base URL has none", () => {
|
|
158
|
+
const url = buildBugReportUrl("https://example.com/new", "x");
|
|
159
|
+
expect(url).toBe("https://example.com/new?env=x");
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("encodes markdown so it survives as a single query param", () => {
|
|
163
|
+
const details = buildIssueDetails({ environment, errors: [] });
|
|
164
|
+
const url = buildBugReportUrl(baseUrl, details);
|
|
165
|
+
expect(url).toContain("&env=");
|
|
166
|
+
expect(new URL(url).searchParams.get("env")).toBe(details);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("falls back to the plain base URL when the prefill exceeds the cap", () => {
|
|
170
|
+
const huge = "x".repeat(MAX_PREFILL_URL_LENGTH);
|
|
171
|
+
expect(buildBugReportUrl(baseUrl, huge)).toBe(baseUrl);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type CellErrorEntry,
|
|
5
|
+
formatCellError,
|
|
6
|
+
} from "@/core/errors/error-entries";
|
|
7
|
+
import type { EnvironmentInfo } from "@/core/network/types";
|
|
8
|
+
import { Paths } from "@/utils/paths";
|
|
9
|
+
import { Strings } from "@/utils/strings";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Environment information augmented with a client-side collection error, used
|
|
13
|
+
* when the server environment request fails and only partial data is available.
|
|
14
|
+
* Fields are optional because a partial environment only carries what the
|
|
15
|
+
* client could determine without the server.
|
|
16
|
+
*/
|
|
17
|
+
export type EnvironmentDiagnostics = Partial<EnvironmentInfo> & {
|
|
18
|
+
"Environment Collection Error"?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export interface NotebookSource {
|
|
22
|
+
filename: string;
|
|
23
|
+
contents: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IssueDetailsInput {
|
|
27
|
+
environment: EnvironmentDiagnostics;
|
|
28
|
+
errors: CellErrorEntry[];
|
|
29
|
+
notebook?: NotebookSource;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Replace the server-detected browser with the active browser's user agent.
|
|
34
|
+
*
|
|
35
|
+
* The server cannot know which browser is driving the UI, so diagnostics
|
|
36
|
+
* generated from the modal reflect the live `navigator.userAgent` instead.
|
|
37
|
+
*/
|
|
38
|
+
export function enrichEnvironment(
|
|
39
|
+
environment: EnvironmentInfo,
|
|
40
|
+
userAgent: string,
|
|
41
|
+
): EnvironmentInfo {
|
|
42
|
+
return {
|
|
43
|
+
...environment,
|
|
44
|
+
Binaries: {
|
|
45
|
+
...environment.Binaries,
|
|
46
|
+
Browser: userAgent,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function createPartialEnvironment(
|
|
52
|
+
marimoVersion: string,
|
|
53
|
+
userAgent: string,
|
|
54
|
+
locale: string,
|
|
55
|
+
message: string,
|
|
56
|
+
): EnvironmentDiagnostics {
|
|
57
|
+
return {
|
|
58
|
+
marimo: marimoVersion,
|
|
59
|
+
Locale: locale || undefined,
|
|
60
|
+
Binaries: { Browser: userAgent },
|
|
61
|
+
"Environment Collection Error": message,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Wrap `contents` in a Markdown code fence long enough to survive backtick runs
|
|
67
|
+
* inside it, so pasted diagnostics render as a single block on GitHub.
|
|
68
|
+
*/
|
|
69
|
+
export function markdownCodeFence(language: string, contents: string): string {
|
|
70
|
+
const longest = Math.max(
|
|
71
|
+
2,
|
|
72
|
+
...Array.from(contents.matchAll(/`+/g), (match) => match[0].length),
|
|
73
|
+
);
|
|
74
|
+
const fence = "`".repeat(longest + 1);
|
|
75
|
+
return `${fence}${language}\n${contents}\n${fence}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* GitHub returns HTTP 414 for issue-form URLs beyond roughly 8 KB, so prefill is
|
|
80
|
+
* skipped once the encoded body would push the URL past this conservative cap.
|
|
81
|
+
*/
|
|
82
|
+
export const MAX_PREFILL_URL_LENGTH = 6000;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Build a bug-report URL with `issueDetails` prefilled into the form's `env`
|
|
86
|
+
* field. Falls back to `baseUrl` unchanged when the prefilled URL would exceed
|
|
87
|
+
* `MAX_PREFILL_URL_LENGTH`.
|
|
88
|
+
*/
|
|
89
|
+
export function buildBugReportUrl(
|
|
90
|
+
baseUrl: string,
|
|
91
|
+
issueDetails: string,
|
|
92
|
+
): string {
|
|
93
|
+
const separator = baseUrl.includes("?") ? "&" : "?";
|
|
94
|
+
const prefilled = `${baseUrl}${separator}env=${encodeURIComponent(issueDetails)}`;
|
|
95
|
+
return prefilled.length > MAX_PREFILL_URL_LENGTH ? baseUrl : prefilled;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function detailsSection(summary: string, body: string): string {
|
|
99
|
+
return [
|
|
100
|
+
"<details>",
|
|
101
|
+
`<summary>${Strings.htmlEscape(summary) ?? ""}</summary>`,
|
|
102
|
+
"",
|
|
103
|
+
body,
|
|
104
|
+
"",
|
|
105
|
+
"</details>",
|
|
106
|
+
].join("\n");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function buildIssueDetails(input: IssueDetailsInput): string {
|
|
110
|
+
const sections = [
|
|
111
|
+
detailsSection(
|
|
112
|
+
"Environment",
|
|
113
|
+
markdownCodeFence("json", JSON.stringify(input.environment, null, 2)),
|
|
114
|
+
),
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
if (input.errors.length > 0) {
|
|
118
|
+
sections.push(
|
|
119
|
+
detailsSection(
|
|
120
|
+
"Current errors",
|
|
121
|
+
markdownCodeFence(
|
|
122
|
+
"text",
|
|
123
|
+
input.errors.map(formatCellError).join("\n\n---\n\n"),
|
|
124
|
+
),
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (input.notebook) {
|
|
130
|
+
sections.push(
|
|
131
|
+
detailsSection(
|
|
132
|
+
`Notebook source: ${Paths.basename(input.notebook.filename)}`,
|
|
133
|
+
markdownCodeFence("python", input.notebook.contents),
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return sections.join("\n\n");
|
|
139
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { cellId } from "@/__tests__/branded";
|
|
5
|
+
import { type CellErrorEntry, formatCellError } from "../error-entries";
|
|
6
|
+
|
|
7
|
+
describe("formatCellError", () => {
|
|
8
|
+
it("formats current tracebacks without notebook source", () => {
|
|
9
|
+
const entry: CellErrorEntry = {
|
|
10
|
+
cellId: cellId("cell-1"),
|
|
11
|
+
cellName: "Cell 1",
|
|
12
|
+
cellCode: "password = 'private'",
|
|
13
|
+
errorData: [],
|
|
14
|
+
tracebackHtml:
|
|
15
|
+
'<span class="gr">ValueError</span>: <span class="n">bad value</span>',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const text = formatCellError(entry);
|
|
19
|
+
|
|
20
|
+
expect(text).toContain("Cell 1");
|
|
21
|
+
expect(text).toContain("ValueError: bad value");
|
|
22
|
+
expect(text).not.toContain("password");
|
|
23
|
+
expect(text).not.toContain("<span");
|
|
24
|
+
});
|
|
25
|
+
});
|