@marimo-team/islands 0.25.3-dev388 → 0.25.3-dev391
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ErrorBoundary-_mFP3LkM.js → ErrorBoundary-DNRG0xHi.js} +1 -1
- package/dist/{chat-ui-BKSYhGMh.js → chat-ui-CWVNPm2l.js} +769 -769
- package/dist/{code-visibility-DkMNjdNe.js → code-visibility-Ca8sDptK.js} +10 -10
- package/dist/{common-Ces9ooG_.js → common-B3NYpak4.js} +4910 -4902
- package/dist/{data-grid-overlay-editor-uNMslVKY.js → data-grid-overlay-editor-Cz7uMmtm.js} +1 -1
- package/dist/{error-entries-rtPWQkJk.js → error-entries-CnXf4kpP.js} +821 -686
- package/dist/{feedback-button-i960qUnq.js → feedback-button-BQbnZsf5.js} +7 -7
- package/dist/{glide-data-editor-_EEhlGzS.js → glide-data-editor-Bxc30klU.js} +3 -3
- package/dist/{globals-DKkjIolp.js → globals-CDatnx0Y.js} +1 -1
- package/dist/{html-to-image-B5nTOeMI.js → html-to-image-Bu_-vH_Y.js} +4782 -4765
- package/dist/main.js +6233 -6172
- package/dist/{number-overlay-editor-D5U7jbrh.js → number-overlay-editor-ChGu5C-s.js} +1 -1
- package/dist/{process-output-DNxpsd4n.js → process-output-Rbqr1aYD.js} +2 -2
- package/dist/{reveal-component-BM9TozVQ.js → reveal-component-CSxWJFAP.js} +32 -32
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +48 -8
- package/src/__mocks__/notebook.ts +20 -42
- package/src/components/app-config/__tests__/add-model-discovery.test.tsx +255 -0
- package/src/components/app-config/__tests__/model-discovery.test.tsx +183 -0
- package/src/components/app-config/ai-config.tsx +20 -24
- package/src/components/app-config/model-discovery.tsx +118 -184
- package/src/components/app-config/model-provider-config.ts +25 -0
- package/src/components/editor/Output.tsx +5 -4
- package/src/components/editor/__tests__/data-attributes.test.tsx +1 -6
- package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
- package/src/components/editor/__tests__/output-persistence.test.tsx +6 -24
- package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +6 -8
- package/src/components/editor/actions/useSetOutputsExpanded.ts +12 -4
- package/src/components/editor/cell/cell-context-menu.tsx +3 -2
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +89 -72
- package/src/components/editor/notebook-cell.tsx +15 -10
- package/src/components/editor/output/console/process-output.ts +4 -2
- package/src/components/editor/renderers/cells-renderer.tsx +3 -1
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +5 -11
- package/src/components/editor/renderers/grid-layout/grid-layout.tsx +9 -8
- package/src/components/editor/renderers/types.ts +2 -2
- package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +5 -8
- package/src/components/scratchpad/scratchpad.tsx +6 -2
- package/src/components/slides/__tests__/cell-output-block.test.tsx +7 -8
- package/src/components/slides/__tests__/minimap-actions.test.tsx +3 -3
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +1 -0
- package/src/components/slides/slide-cell-view.tsx +1 -3
- package/src/components/slides/slide.tsx +3 -3
- package/src/core/ai/context/__tests__/registry.test.ts +7 -11
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +113 -35
- package/src/core/ai/context/providers/__tests__/error.test.ts +74 -191
- package/src/core/ai/context/providers/cell-output.ts +11 -6
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +8 -103
- package/src/core/cells/__tests__/cells.test.ts +40 -292
- package/src/core/cells/__tests__/clear-outputs.test.ts +151 -0
- package/src/core/cells/__tests__/harness.ts +14 -12
- package/src/core/cells/__tests__/layout.test.ts +20 -26
- package/src/core/cells/__tests__/notebook-outline.test.ts +49 -43
- package/src/core/cells/__tests__/session.test.ts +26 -146
- package/src/core/cells/actions.ts +49 -9
- package/src/core/cells/cell.ts +0 -13
- package/src/core/cells/cells.ts +53 -62
- package/src/core/cells/focus.ts +6 -1
- package/src/core/cells/layout.ts +2 -3
- package/src/core/cells/outputs.ts +2 -2
- package/src/core/cells/session.ts +3 -38
- package/src/core/cells/types.ts +6 -8
- package/src/core/cells/utils.ts +4 -3
- package/src/core/codemirror/ai/__tests__/resources.test.ts +7 -11
- package/src/core/errors/__tests__/error-entries.test.ts +52 -18
- package/src/core/errors/error-entries.ts +21 -11
- package/src/core/executions/__tests__/freshness.test.ts +7 -4
- package/src/core/executions/__tests__/hooks.test.tsx +5 -1
- package/src/core/executions/__tests__/interrupt.test.ts +2 -0
- package/src/core/executions/__tests__/output-lifecycle.test.ts +201 -0
- package/src/core/executions/__tests__/output.test.ts +87 -3
- package/src/core/executions/__tests__/select.test.ts +17 -10
- package/src/core/executions/atoms.ts +73 -15
- package/src/core/executions/freshness.ts +1 -1
- package/src/core/executions/hooks.ts +18 -8
- package/src/core/executions/index.ts +6 -0
- package/src/core/executions/output.ts +122 -38
- package/src/core/executions/select.ts +2 -2
- package/src/core/export/__tests__/hooks.test.ts +20 -29
- package/src/core/export/hooks.ts +7 -9
- package/src/core/islands/__tests__/iframe-resizer.test.ts +91 -0
- package/src/core/islands/__tests__/main.test.ts +17 -0
- package/src/core/islands/components/__tests__/web-components.test.tsx +13 -15
- package/src/core/islands/components/output-wrapper.tsx +15 -20
- package/src/core/islands/iframe-resizer.ts +38 -0
- package/src/core/islands/main.ts +3 -0
- package/src/core/lifecycle/render-policy.ts +7 -4
- package/src/core/network/__tests__/ai.test.ts +41 -0
- package/src/core/network/ai.ts +12 -0
- package/src/core/notebook/document/__tests__/codemirror.test.ts +2 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +19 -0
- package/src/core/notebook/replica/__tests__/results.test.ts +45 -16
- package/src/core/notebook/replica/index.ts +1 -1
- package/src/core/notebook/replica/replica.ts +19 -4
- package/src/core/notebook/replica/resources/executions.ts +100 -9
- package/src/core/notebook/replica/resources/results.ts +46 -31
- package/src/core/transports/__tests__/static.test.ts +5 -3
- package/src/stories/cell.stories.tsx +40 -30
- package/src/stories/layout/vertical/one-column.stories.tsx +15 -7
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
5
|
-
import type {
|
|
5
|
+
import type { CellOutput } from "@/core/executions";
|
|
6
6
|
import { outputExpansionConfigs } from "../useSetOutputsExpanded";
|
|
7
7
|
|
|
8
|
-
const output:
|
|
8
|
+
const output: CellOutput = {
|
|
9
9
|
channel: "output",
|
|
10
10
|
mimetype: "text/plain",
|
|
11
11
|
data: "hello",
|
|
@@ -22,20 +22,18 @@ describe("outputExpansionConfigs", () => {
|
|
|
22
22
|
[expanded]: { config: { expand_output: true } },
|
|
23
23
|
[expandedWithoutOutput]: { config: { expand_output: true } },
|
|
24
24
|
},
|
|
25
|
-
cellRuntime: {
|
|
26
|
-
[withOutput]: { output },
|
|
27
|
-
[expanded]: { output },
|
|
28
|
-
},
|
|
29
25
|
});
|
|
26
|
+
const outputOf = (cellId: string) =>
|
|
27
|
+
cellId === withOutput || cellId === expanded ? output : null;
|
|
30
28
|
|
|
31
29
|
it("expands clamped cells with output and skips cells without output", () => {
|
|
32
|
-
expect(outputExpansionConfigs(notebook, true)).toEqual({
|
|
30
|
+
expect(outputExpansionConfigs(notebook, outputOf, true)).toEqual({
|
|
33
31
|
[withOutput]: { expand_output: true },
|
|
34
32
|
});
|
|
35
33
|
});
|
|
36
34
|
|
|
37
35
|
it("clamps all expanded cells, including those without current output", () => {
|
|
38
|
-
expect(outputExpansionConfigs(notebook, false)).toEqual({
|
|
36
|
+
expect(outputExpansionConfigs(notebook, outputOf, false)).toEqual({
|
|
39
37
|
[expanded]: { expand_output: false },
|
|
40
38
|
[expandedWithoutOutput]: { expand_output: false },
|
|
41
39
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { useStore } from "jotai";
|
|
3
4
|
import { useCallback } from "react";
|
|
4
5
|
import { getNotebook, type NotebookState } from "@/core/cells/cells";
|
|
5
6
|
import type { CellId } from "@/core/cells/ids";
|
|
6
7
|
import { isOutputEmpty } from "@/core/cells/outputs";
|
|
8
|
+
import { type CellOutput, cellOutputAtom } from "@/core/executions";
|
|
7
9
|
import { useNotebookDocumentEdit } from "@/core/notebook/document";
|
|
8
10
|
import type { CellConfig } from "@/core/network/types";
|
|
9
11
|
import { Objects } from "@/utils/objects";
|
|
@@ -12,7 +14,8 @@ import { Objects } from "@/utils/objects";
|
|
|
12
14
|
* The `expand_output` config changes needed to expand or clamp every output.
|
|
13
15
|
*/
|
|
14
16
|
export function outputExpansionConfigs(
|
|
15
|
-
notebook: NotebookState,
|
|
17
|
+
notebook: Pick<NotebookState, "cellIds" | "cellData">,
|
|
18
|
+
outputOf: (cellId: CellId) => CellOutput | null,
|
|
16
19
|
expanded: boolean,
|
|
17
20
|
): Record<CellId, Partial<CellConfig>> {
|
|
18
21
|
const configs: Record<CellId, Partial<CellConfig>> = {};
|
|
@@ -24,7 +27,7 @@ export function outputExpansionConfigs(
|
|
|
24
27
|
) {
|
|
25
28
|
continue;
|
|
26
29
|
}
|
|
27
|
-
if (expanded && isOutputEmpty(
|
|
30
|
+
if (expanded && isOutputEmpty(outputOf(cellId))) {
|
|
28
31
|
continue;
|
|
29
32
|
}
|
|
30
33
|
configs[cellId] = { expand_output: expanded };
|
|
@@ -38,11 +41,16 @@ export function outputExpansionConfigs(
|
|
|
38
41
|
*/
|
|
39
42
|
export const useSetOutputsExpanded = () => {
|
|
40
43
|
const edit = useNotebookDocumentEdit();
|
|
44
|
+
const store = useStore();
|
|
41
45
|
|
|
42
46
|
return useCallback(
|
|
43
47
|
(expanded: boolean) => {
|
|
44
48
|
const entries = Objects.entries(
|
|
45
|
-
outputExpansionConfigs(
|
|
49
|
+
outputExpansionConfigs(
|
|
50
|
+
getNotebook(),
|
|
51
|
+
(cellId) => store.get(cellOutputAtom(cellId)),
|
|
52
|
+
expanded,
|
|
53
|
+
),
|
|
46
54
|
);
|
|
47
55
|
if (entries.length === 0) {
|
|
48
56
|
return;
|
|
@@ -54,6 +62,6 @@ export const useSetOutputsExpanded = () => {
|
|
|
54
62
|
}
|
|
55
63
|
});
|
|
56
64
|
},
|
|
57
|
-
[edit],
|
|
65
|
+
[edit, store],
|
|
58
66
|
);
|
|
59
67
|
};
|
|
@@ -24,7 +24,7 @@ import { useRestoreFocus } from "@/components/ui/use-restore-focus";
|
|
|
24
24
|
import { useCellData, useCellRuntime } from "@/core/cells/cells";
|
|
25
25
|
import { CellOutputId } from "@/core/cells/ids";
|
|
26
26
|
import { isOutputEmpty } from "@/core/cells/outputs";
|
|
27
|
-
import { useCellExecution } from "@/core/executions";
|
|
27
|
+
import { useCellExecution, useCellOutput } from "@/core/executions";
|
|
28
28
|
import { goToDefinitionWithLspFallback } from "@/core/codemirror/go-to-definition/utils";
|
|
29
29
|
import { sendToPanelManager } from "@/core/vscode/vscode-bindings";
|
|
30
30
|
import { copyImageToClipboard, copyToClipboard } from "@/utils/copy";
|
|
@@ -57,6 +57,7 @@ export const CellActionsContextMenu = ({
|
|
|
57
57
|
const cellData = useCellData(cellId);
|
|
58
58
|
const cellRuntime = useCellRuntime(cellId);
|
|
59
59
|
const execution = useCellExecution(cellId);
|
|
60
|
+
const output = useCellOutput(cellId);
|
|
60
61
|
const actions = useCellActionButtons({
|
|
61
62
|
cell: {
|
|
62
63
|
cellId: cellId,
|
|
@@ -64,7 +65,7 @@ export const CellActionsContextMenu = ({
|
|
|
64
65
|
config: cellData.config,
|
|
65
66
|
status: execution.status,
|
|
66
67
|
blocked: execution.blocked,
|
|
67
|
-
hasOutput: !isOutputEmpty(
|
|
68
|
+
hasOutput: !isOutputEmpty(output),
|
|
68
69
|
hasConsoleOutput: cellRuntime.consoleOutputs.length > 0,
|
|
69
70
|
getEditorView,
|
|
70
71
|
},
|
|
@@ -8,16 +8,17 @@ import {
|
|
|
8
8
|
screen,
|
|
9
9
|
waitFor,
|
|
10
10
|
} from "@testing-library/react";
|
|
11
|
-
import { atom, createStore, Provider
|
|
11
|
+
import { atom, createStore, Provider } from "jotai";
|
|
12
12
|
import type React from "react";
|
|
13
13
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
14
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
14
15
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
15
16
|
import { cellId } from "@/__tests__/branded";
|
|
16
17
|
import { PAIR_CONFIG } from "@/__tests__/fixtures/pair-config";
|
|
17
18
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
18
19
|
import { toast } from "@/components/ui/use-toast";
|
|
19
20
|
import type { Attachment } from "@/core/notebook/attachments";
|
|
20
|
-
import {
|
|
21
|
+
import { notebookAtom } from "@/core/cells/cells";
|
|
21
22
|
import {
|
|
22
23
|
type CellOutputMessage,
|
|
23
24
|
type ErrorMessageOutput,
|
|
@@ -25,7 +26,13 @@ import {
|
|
|
25
26
|
} from "@/core/cells/error-report";
|
|
26
27
|
import { pairConfigAtom } from "@/core/config/pair";
|
|
27
28
|
import { readExport } from "@/core/cells/session";
|
|
28
|
-
import
|
|
29
|
+
import { cellOutputView, useCellOutput } from "@/core/executions";
|
|
30
|
+
import {
|
|
31
|
+
cell,
|
|
32
|
+
document as documentOf,
|
|
33
|
+
withCells,
|
|
34
|
+
} from "@/core/notebook/document/__tests__/fixtures";
|
|
35
|
+
import type { MarimoError } from "@/core/kernel/messages";
|
|
29
36
|
import {
|
|
30
37
|
type StableSessionId,
|
|
31
38
|
stableSessionIdAtom,
|
|
@@ -48,10 +55,15 @@ vi.mock("@/components/editor/chrome/wrapper/useOpenAiAssistant", () => ({
|
|
|
48
55
|
|
|
49
56
|
const CELL_ID = cellId("test-cell");
|
|
50
57
|
const STABLE_ID = "stable/test" as StableSessionId;
|
|
51
|
-
|
|
58
|
+
// Hoisted with the module mock below, which reads it as modules load.
|
|
59
|
+
const { attachmentsAtom } = await vi.hoisted(async () => {
|
|
60
|
+
const { atom } = await import("jotai");
|
|
61
|
+
return { attachmentsAtom: atom<Attachment[]>([]) };
|
|
62
|
+
});
|
|
52
63
|
vi.mock("@/core/session/active-notebook", async (importOriginal) => ({
|
|
53
64
|
...(await importOriginal<typeof import("@/core/session/active-notebook")>()),
|
|
54
|
-
|
|
65
|
+
// Writable, so the execution mock can give the replica results.
|
|
66
|
+
activeNotebookReplicaAtom: atom({ attachmentsAtom }),
|
|
55
67
|
}));
|
|
56
68
|
|
|
57
69
|
const AGENT: Attachment = {
|
|
@@ -257,17 +269,14 @@ describe("SendErrorReportButton", () => {
|
|
|
257
269
|
notebookAtom,
|
|
258
270
|
MockNotebook.notebookState({
|
|
259
271
|
cellData: { [CELL_ID]: { code: "later edit" } },
|
|
260
|
-
cellRuntime: {
|
|
261
|
-
[CELL_ID]: {
|
|
262
|
-
output: {
|
|
263
|
-
channel: "output",
|
|
264
|
-
mimetype: "text/plain",
|
|
265
|
-
data: "<Broken formatter>",
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
272
|
}),
|
|
270
273
|
);
|
|
274
|
+
MockExecutions.seed(store, [
|
|
275
|
+
MockExecutions.shown(CELL_ID, {
|
|
276
|
+
mimetype: "text/plain",
|
|
277
|
+
data: "<Broken formatter>",
|
|
278
|
+
}),
|
|
279
|
+
]);
|
|
271
280
|
send();
|
|
272
281
|
await waitFor(() =>
|
|
273
282
|
expect(API.post).toHaveBeenCalledWith(ROUTE, {
|
|
@@ -317,14 +326,14 @@ describe("SendErrorReportButton", () => {
|
|
|
317
326
|
});
|
|
318
327
|
|
|
319
328
|
it("sends the restored exception type and complete traceback", async () => {
|
|
320
|
-
const {
|
|
329
|
+
const { snapshot } = readExport({
|
|
321
330
|
session: {
|
|
322
331
|
version: "1",
|
|
323
332
|
metadata: { marimo_version: "1", script_metadata_hash: null },
|
|
324
333
|
cells: [
|
|
325
334
|
{
|
|
326
335
|
id: CELL_ID,
|
|
327
|
-
code_hash:
|
|
336
|
+
code_hash: "h",
|
|
328
337
|
console: [],
|
|
329
338
|
outputs: [
|
|
330
339
|
{
|
|
@@ -342,12 +351,25 @@ describe("SendErrorReportButton", () => {
|
|
|
342
351
|
},
|
|
343
352
|
],
|
|
344
353
|
},
|
|
345
|
-
notebook:
|
|
354
|
+
notebook: {
|
|
355
|
+
version: "1",
|
|
356
|
+
metadata: { marimo_version: "1" },
|
|
357
|
+
cells: [
|
|
358
|
+
{ id: CELL_ID, code: CODE, code_hash: "h", name: null, config: {} },
|
|
359
|
+
],
|
|
360
|
+
},
|
|
346
361
|
filename: null,
|
|
347
362
|
appConfig: {},
|
|
348
363
|
});
|
|
349
|
-
const message =
|
|
350
|
-
|
|
364
|
+
const message = cellOutputView(
|
|
365
|
+
{
|
|
366
|
+
...MockExecutions.inputs(snapshot?.results ?? []),
|
|
367
|
+
cleared: new Map(),
|
|
368
|
+
cells: new Map(snapshot?.cells.map((cell) => [cell.id, cell])),
|
|
369
|
+
},
|
|
370
|
+
CELL_ID,
|
|
371
|
+
);
|
|
372
|
+
expect(message).not.toBeNull();
|
|
351
373
|
renderButton({
|
|
352
374
|
content: message && <OutputRenderer cellId={CELL_ID} message={message} />,
|
|
353
375
|
});
|
|
@@ -392,59 +414,54 @@ describe("SendErrorReportButton", () => {
|
|
|
392
414
|
await waitFor(() => expect(API.post).toHaveBeenCalledWith(ROUTE, content));
|
|
393
415
|
});
|
|
394
416
|
|
|
395
|
-
it
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
});
|
|
444
|
-
send();
|
|
445
|
-
await waitFor(() => expect(API.post).toHaveBeenCalledWith(ROUTE, REPORT));
|
|
446
|
-
},
|
|
447
|
-
);
|
|
417
|
+
it("sends the source that raised while the host still has it", async () => {
|
|
418
|
+
const confirmed = (fingerprint: string) =>
|
|
419
|
+
withCells(
|
|
420
|
+
documentOf(),
|
|
421
|
+
{
|
|
422
|
+
c1: null,
|
|
423
|
+
c2: null,
|
|
424
|
+
[CELL_ID]: cell(CELL_ID, CODE, { code_fingerprint: fingerprint }),
|
|
425
|
+
},
|
|
426
|
+
[CELL_ID],
|
|
427
|
+
);
|
|
428
|
+
// Render from the store so the host's changes reach the button.
|
|
429
|
+
const StoreOutput = () => {
|
|
430
|
+
const message = useCellOutput(CELL_ID);
|
|
431
|
+
return message ? (
|
|
432
|
+
<OutputRenderer cellId={CELL_ID} message={message} />
|
|
433
|
+
) : null;
|
|
434
|
+
};
|
|
435
|
+
const { store, rerender } = renderButton({ content: <div /> });
|
|
436
|
+
const replica = MockExecutions.seed(
|
|
437
|
+
store,
|
|
438
|
+
[
|
|
439
|
+
MockExecutions.failed(
|
|
440
|
+
CELL_ID,
|
|
441
|
+
{ name: "NameError", message: MESSAGE },
|
|
442
|
+
{ code_fingerprint: "ran" },
|
|
443
|
+
),
|
|
444
|
+
],
|
|
445
|
+
null,
|
|
446
|
+
confirmed("ran"),
|
|
447
|
+
);
|
|
448
|
+
rerender(<StoreOutput />);
|
|
449
|
+
send();
|
|
450
|
+
await waitFor(() => expect(API.post).toHaveBeenCalledWith(ROUTE, REPORT));
|
|
451
|
+
|
|
452
|
+
// Once an edit is confirmed, the source that raised is gone.
|
|
453
|
+
vi.mocked(API.post).mockClear();
|
|
454
|
+
act(() => {
|
|
455
|
+
store.set(replica.documentAtom, confirmed("edited"));
|
|
456
|
+
});
|
|
457
|
+
send();
|
|
458
|
+
await waitFor(() =>
|
|
459
|
+
expect(API.post).toHaveBeenCalledWith(ROUTE, {
|
|
460
|
+
...REPORT,
|
|
461
|
+
code: undefined,
|
|
462
|
+
}),
|
|
463
|
+
);
|
|
464
|
+
});
|
|
448
465
|
|
|
449
466
|
it("does not borrow an old console traceback for a cancelled descendant", async () => {
|
|
450
467
|
const cancelled: MarimoError[] = [
|
|
@@ -47,6 +47,8 @@ import {
|
|
|
47
47
|
replyInput,
|
|
48
48
|
useCellExecution,
|
|
49
49
|
useCellFreshness,
|
|
50
|
+
useCellOutline,
|
|
51
|
+
useCellOutput,
|
|
50
52
|
} from "@/core/executions";
|
|
51
53
|
import type { WithResponse } from "@/core/cells/types";
|
|
52
54
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
@@ -350,7 +352,7 @@ const ReadonlyCellComponent = forwardRef(
|
|
|
350
352
|
(props: { cellId: CellId }, ref: React.ForwardedRef<HTMLDivElement>) => {
|
|
351
353
|
const { cellId } = props;
|
|
352
354
|
const cellData = useCellData(cellId);
|
|
353
|
-
const
|
|
355
|
+
const output = useCellOutput(cellId);
|
|
354
356
|
const execution = useCellExecution(cellId);
|
|
355
357
|
const freshness = useCellFreshness(cellId);
|
|
356
358
|
const errored = execution.outcome === "error";
|
|
@@ -366,7 +368,7 @@ const ReadonlyCellComponent = forwardRef(
|
|
|
366
368
|
errored,
|
|
367
369
|
interrupted,
|
|
368
370
|
stopped,
|
|
369
|
-
output
|
|
371
|
+
output,
|
|
370
372
|
showErrorTracebacks: false,
|
|
371
373
|
});
|
|
372
374
|
|
|
@@ -386,7 +388,7 @@ const ReadonlyCellComponent = forwardRef(
|
|
|
386
388
|
forceExpand={true}
|
|
387
389
|
className={CSSClasses.outputArea}
|
|
388
390
|
cellId={cellId}
|
|
389
|
-
output={
|
|
391
|
+
output={output}
|
|
390
392
|
stale={outputIsStale(execution, freshness, true)}
|
|
391
393
|
loading={outputIsLoading(execution.status)}
|
|
392
394
|
/>
|
|
@@ -415,6 +417,8 @@ const EditableCellComponent = ({
|
|
|
415
417
|
const cellRef = useRef<HTMLDivElement>(null);
|
|
416
418
|
const cellData = useCellData(cellId);
|
|
417
419
|
const cellRuntime = useCellRuntime(cellId);
|
|
420
|
+
const output = useCellOutput(cellId);
|
|
421
|
+
const outline = useCellOutline(cellId);
|
|
418
422
|
const execution = useCellExecution(cellId);
|
|
419
423
|
const freshness = useCellFreshness(cellId);
|
|
420
424
|
const errored = execution.outcome === "error";
|
|
@@ -456,7 +460,7 @@ const EditableCellComponent = ({
|
|
|
456
460
|
errored,
|
|
457
461
|
interrupted,
|
|
458
462
|
stopped,
|
|
459
|
-
output
|
|
463
|
+
output,
|
|
460
464
|
showErrorTracebacks: userConfig.runtime.show_tracebacks ?? false,
|
|
461
465
|
});
|
|
462
466
|
|
|
@@ -502,8 +506,8 @@ const EditableCellComponent = ({
|
|
|
502
506
|
editorView,
|
|
503
507
|
cellActionDropdownRef,
|
|
504
508
|
});
|
|
505
|
-
const canCollapse = canCollapseOutline(
|
|
506
|
-
const hasOutput = !isOutputEmpty(
|
|
509
|
+
const canCollapse = canCollapseOutline(outline);
|
|
510
|
+
const hasOutput = !isOutputEmpty(output);
|
|
507
511
|
// While presenting, pending edits do not dim the output as stale,
|
|
508
512
|
// matching the read view.
|
|
509
513
|
const isStaleCell = outputIsStale(execution, freshness, !isPresenting);
|
|
@@ -598,7 +602,7 @@ const EditableCellComponent = ({
|
|
|
598
602
|
forceExpand={isMarkdownCodeHidden || isPresenting}
|
|
599
603
|
className={CSSClasses.outputArea}
|
|
600
604
|
cellId={cellId}
|
|
601
|
-
output={
|
|
605
|
+
output={output}
|
|
602
606
|
stale={isStaleCell}
|
|
603
607
|
loading={outputIsLoading(execution.status)}
|
|
604
608
|
/>
|
|
@@ -1068,6 +1072,7 @@ const SetupCellComponent = ({
|
|
|
1068
1072
|
const cellRef = useRef<HTMLDivElement>(null);
|
|
1069
1073
|
const cellData = useCellData(cellId);
|
|
1070
1074
|
const cellRuntime = useCellRuntime(cellId);
|
|
1075
|
+
const output = useCellOutput(cellId);
|
|
1071
1076
|
const execution = useCellExecution(cellId);
|
|
1072
1077
|
const freshness = useCellFreshness(cellId);
|
|
1073
1078
|
const errored = execution.outcome === "error";
|
|
@@ -1123,9 +1128,9 @@ const SetupCellComponent = ({
|
|
|
1123
1128
|
editorView,
|
|
1124
1129
|
cellActionDropdownRef,
|
|
1125
1130
|
});
|
|
1126
|
-
const hasOutput = !isOutputEmpty(
|
|
1131
|
+
const hasOutput = !isOutputEmpty(output);
|
|
1127
1132
|
const hasConsoleOutput = cellRuntime.consoleOutputs.length > 0;
|
|
1128
|
-
const isErrorOutput = isErrorMime(
|
|
1133
|
+
const isErrorOutput = isErrorMime(output?.mimetype);
|
|
1129
1134
|
|
|
1130
1135
|
const className = clsx("marimo-cell", "hover-actions-parent z-10", {
|
|
1131
1136
|
interactive: true,
|
|
@@ -1294,7 +1299,7 @@ const SetupCellComponent = ({
|
|
|
1294
1299
|
forceExpand={true}
|
|
1295
1300
|
className={CSSClasses.outputArea}
|
|
1296
1301
|
cellId={cellId}
|
|
1297
|
-
output={
|
|
1302
|
+
output={output}
|
|
1298
1303
|
stale={false}
|
|
1299
1304
|
loading={loading}
|
|
1300
1305
|
/>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import type {
|
|
2
|
+
import type { CellOutput } from "@/core/executions";
|
|
3
3
|
import { ansiToPlainText, parseHtmlContent } from "@/utils/dom";
|
|
4
4
|
import { Strings } from "@/utils/strings";
|
|
5
5
|
|
|
6
6
|
/** Convert cell or console output to a string, while handling html and ansi codes */
|
|
7
|
-
export function processOutput(
|
|
7
|
+
export function processOutput(
|
|
8
|
+
output: Pick<CellOutput, "mimetype" | "data">,
|
|
9
|
+
): string {
|
|
8
10
|
if (
|
|
9
11
|
output.mimetype.startsWith("application/vnd.marimo") ||
|
|
10
12
|
output.mimetype === "text/html"
|
|
@@ -5,6 +5,7 @@ import type React from "react";
|
|
|
5
5
|
import { memo, type PropsWithChildren } from "react";
|
|
6
6
|
import { flattenTopLevelNotebookCells, useNotebook } from "@/core/cells/cells";
|
|
7
7
|
import type { AppConfig } from "@/core/config/config-schema";
|
|
8
|
+
import { cellOutputsAtom } from "@/core/executions";
|
|
8
9
|
import { resolveLayoutData } from "@/core/layout/layout";
|
|
9
10
|
import {
|
|
10
11
|
resolveLayoutType,
|
|
@@ -70,8 +71,9 @@ export const PluginCellRenderer = (props: PluginCellRendererProps) => {
|
|
|
70
71
|
const { appConfig, mode, plugin } = props;
|
|
71
72
|
const layoutState = useLayoutState();
|
|
72
73
|
const notebook = useNotebook();
|
|
74
|
+
const outputs = useAtomValue(cellOutputsAtom);
|
|
73
75
|
const { setCurrentLayoutData } = useLayoutActions();
|
|
74
|
-
const cells = flattenTopLevelNotebookCells(notebook);
|
|
76
|
+
const cells = flattenTopLevelNotebookCells(notebook, outputs);
|
|
75
77
|
const layout = resolveLayoutData({ state: layoutState, plugin, cells });
|
|
76
78
|
|
|
77
79
|
const Renderer = plugin.Component;
|
|
@@ -23,16 +23,6 @@ function renderErroredCell(cells: GridLayout["cells"]) {
|
|
|
23
23
|
MockExecutions.seed(store, [MockExecutions.errored(ERRORED)]);
|
|
24
24
|
const notebook = MockNotebook.notebookState({
|
|
25
25
|
cellData: { [ERRORED]: { code: "raise ValueError('boom')" } },
|
|
26
|
-
cellRuntime: {
|
|
27
|
-
[ERRORED]: {
|
|
28
|
-
output: {
|
|
29
|
-
channel: "marimo-error",
|
|
30
|
-
mimetype: "application/vnd.marimo+error",
|
|
31
|
-
data: [MockNotebook.errors.exception("boom")],
|
|
32
|
-
timestamp: 1,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
26
|
});
|
|
37
27
|
render(
|
|
38
28
|
<Provider store={store}>
|
|
@@ -48,7 +38,11 @@ function renderErroredCell(cells: GridLayout["cells"]) {
|
|
|
48
38
|
}}
|
|
49
39
|
setLayout={vi.fn()}
|
|
50
40
|
cells={[
|
|
51
|
-
{
|
|
41
|
+
{
|
|
42
|
+
...notebook.cellData[ERRORED],
|
|
43
|
+
...notebook.cellRuntime[ERRORED],
|
|
44
|
+
output: null,
|
|
45
|
+
},
|
|
52
46
|
]}
|
|
53
47
|
/>
|
|
54
48
|
</Provider>,
|
|
@@ -8,7 +8,7 @@ import React, {
|
|
|
8
8
|
} from "react";
|
|
9
9
|
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
10
10
|
import { OutputArea } from "@/components/editor/Output";
|
|
11
|
-
import type {
|
|
11
|
+
import type { RuntimeCell } from "@/core/cells/types";
|
|
12
12
|
import type { ICellRendererProps } from "../types";
|
|
13
13
|
import type { GridLayout, GridLayoutCellSide } from "./types";
|
|
14
14
|
|
|
@@ -37,7 +37,11 @@ import { NumberField } from "@/components/ui/number-field";
|
|
|
37
37
|
import { Switch } from "@/components/ui/switch";
|
|
38
38
|
import { outputIsLoading, outputIsStale } from "@/core/cells/cell";
|
|
39
39
|
import type { CellId } from "@/core/cells/ids";
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
useCellExecution,
|
|
42
|
+
useCellFreshness,
|
|
43
|
+
useCellOutput,
|
|
44
|
+
} from "@/core/executions";
|
|
41
45
|
import type { AppMode } from "@/core/mode";
|
|
42
46
|
import { useIsDragging } from "@/hooks/useIsDragging";
|
|
43
47
|
import { cn } from "@/utils/cn";
|
|
@@ -227,7 +231,6 @@ export const GridLayoutRenderer: React.FC<Props> = ({
|
|
|
227
231
|
code={cell.code}
|
|
228
232
|
mode={mode}
|
|
229
233
|
cellId={cell.id}
|
|
230
|
-
output={cell.output}
|
|
231
234
|
hideWithoutValue={true}
|
|
232
235
|
isScrollable={isScrollable}
|
|
233
236
|
side={side}
|
|
@@ -292,7 +295,6 @@ export const GridLayoutRenderer: React.FC<Props> = ({
|
|
|
292
295
|
code={cell.code}
|
|
293
296
|
mode={mode}
|
|
294
297
|
cellId={cell.id}
|
|
295
|
-
output={cell.output}
|
|
296
298
|
hideWithoutValue={false}
|
|
297
299
|
isScrollable={false}
|
|
298
300
|
/>
|
|
@@ -360,7 +362,6 @@ export const GridLayoutRenderer: React.FC<Props> = ({
|
|
|
360
362
|
className="select-none pointer-events-none"
|
|
361
363
|
mode={mode}
|
|
362
364
|
cellId={cell.id}
|
|
363
|
-
output={cell.output}
|
|
364
365
|
hideWithoutValue={false}
|
|
365
366
|
isScrollable={false}
|
|
366
367
|
/>
|
|
@@ -372,7 +373,7 @@ export const GridLayoutRenderer: React.FC<Props> = ({
|
|
|
372
373
|
);
|
|
373
374
|
};
|
|
374
375
|
|
|
375
|
-
interface GridCellProps
|
|
376
|
+
interface GridCellProps {
|
|
376
377
|
className?: string;
|
|
377
378
|
code: string;
|
|
378
379
|
cellId: CellId;
|
|
@@ -385,7 +386,6 @@ interface GridCellProps extends Pick<CellRuntimeState, "output"> {
|
|
|
385
386
|
|
|
386
387
|
const GridCell = memo(
|
|
387
388
|
({
|
|
388
|
-
output,
|
|
389
389
|
cellId,
|
|
390
390
|
mode,
|
|
391
391
|
code,
|
|
@@ -394,6 +394,7 @@ const GridCell = memo(
|
|
|
394
394
|
side,
|
|
395
395
|
className,
|
|
396
396
|
}: GridCellProps) => {
|
|
397
|
+
const output = useCellOutput(cellId);
|
|
397
398
|
const execution = useCellExecution(cellId);
|
|
398
399
|
const freshness = useCellFreshness(cellId);
|
|
399
400
|
const loading = outputIsLoading(execution.status);
|
|
@@ -683,7 +684,7 @@ const GridHoverActions: React.FC<GridHoverActionsProps> = ({
|
|
|
683
684
|
);
|
|
684
685
|
};
|
|
685
686
|
|
|
686
|
-
function isSidebarCell(cell:
|
|
687
|
+
function isSidebarCell(cell: RuntimeCell) {
|
|
687
688
|
// False-positives are ok here because we rendering these cells in a hidden div
|
|
688
689
|
return (
|
|
689
690
|
typeof cell.output?.data === "string" &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import type { ZodType } from "zod";
|
|
4
|
-
import type { CellData,
|
|
4
|
+
import type { CellData, RuntimeCell } from "@/core/cells/types";
|
|
5
5
|
import type { AppConfig } from "@/core/config/config-schema";
|
|
6
6
|
import type { AppMode } from "@/core/mode";
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ export interface ICellRendererProps<L> {
|
|
|
17
17
|
/**
|
|
18
18
|
* The cells to render.
|
|
19
19
|
*/
|
|
20
|
-
cells:
|
|
20
|
+
cells: RuntimeCell[];
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* The layout configuration.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { isOutputEmpty } from "@/core/cells/outputs";
|
|
4
|
-
import type {
|
|
4
|
+
import type { RuntimeCell } from "@/core/cells/types";
|
|
5
5
|
import { MarkdownLanguageAdapter } from "@/core/codemirror/language/languages/markdown";
|
|
6
6
|
import { KnownQueryParams } from "@/core/constants";
|
|
7
7
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
@@ -42,10 +42,10 @@ export function updateShowCodeQueryParam(showCode: boolean): void {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function groupCellsByColumn(
|
|
45
|
-
cells:
|
|
46
|
-
): [number,
|
|
45
|
+
cells: RuntimeCell[],
|
|
46
|
+
): [number, RuntimeCell[]][] {
|
|
47
47
|
// Group cells by column
|
|
48
|
-
const cellsByColumn = new Map<number,
|
|
48
|
+
const cellsByColumn = new Map<number, RuntimeCell[]>();
|
|
49
49
|
let lastSeenColumn = 0;
|
|
50
50
|
cells.forEach((cell) => {
|
|
51
51
|
const column = cell.config.column ?? lastSeenColumn;
|