@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
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "@/components/ui/dropdown-menu";
|
|
28
28
|
import { outputIsLoading, outputIsStale } from "@/core/cells/cell";
|
|
29
29
|
import type { CellId } from "@/core/cells/ids";
|
|
30
|
-
import type {
|
|
30
|
+
import type { CellRuntimeState, RuntimeCell } from "@/core/cells/types";
|
|
31
31
|
import { getReadonlyCodeDisplay } from "@/core/cells/readonly-code-display";
|
|
32
32
|
import { MarkdownLanguageAdapter } from "@/core/codemirror/language/languages/markdown";
|
|
33
33
|
import { useResolvedMarimoConfig } from "@/core/config/config";
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
runtimeStatusAtom,
|
|
37
37
|
useCellExecution,
|
|
38
38
|
useCellFreshness,
|
|
39
|
+
useCellOutput,
|
|
39
40
|
} from "@/core/executions";
|
|
40
41
|
import { useNotebookCodeAvailable } from "@/core/meta/code-visibility";
|
|
41
42
|
import { showCodeInRunModeAtom } from "@/core/meta/state";
|
|
@@ -95,12 +96,11 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({
|
|
|
95
96
|
});
|
|
96
97
|
};
|
|
97
98
|
|
|
98
|
-
const renderCell = (cell:
|
|
99
|
+
const renderCell = (cell: RuntimeCell) => {
|
|
99
100
|
return (
|
|
100
101
|
<VerticalCell
|
|
101
102
|
key={cell.id}
|
|
102
103
|
cellId={cell.id}
|
|
103
|
-
output={cell.output}
|
|
104
104
|
consoleOutputs={cell.consoleOutputs}
|
|
105
105
|
code={cell.code}
|
|
106
106
|
config={cell.config}
|
|
@@ -301,10 +301,7 @@ const ActionButtons: React.FC<{
|
|
|
301
301
|
);
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
interface VerticalCellProps extends Pick<
|
|
305
|
-
CellRuntimeState,
|
|
306
|
-
"output" | "consoleOutputs"
|
|
307
|
-
> {
|
|
304
|
+
interface VerticalCellProps extends Pick<CellRuntimeState, "consoleOutputs"> {
|
|
308
305
|
cellOutputArea: "above" | "below";
|
|
309
306
|
cellId: CellId;
|
|
310
307
|
config: CellConfig;
|
|
@@ -318,7 +315,6 @@ interface VerticalCellProps extends Pick<
|
|
|
318
315
|
|
|
319
316
|
const VerticalCell = memo(
|
|
320
317
|
({
|
|
321
|
-
output,
|
|
322
318
|
consoleOutputs,
|
|
323
319
|
cellOutputArea,
|
|
324
320
|
cellId,
|
|
@@ -331,6 +327,7 @@ const VerticalCell = memo(
|
|
|
331
327
|
showErrorTracebacks,
|
|
332
328
|
}: VerticalCellProps) => {
|
|
333
329
|
const cellRef = useRef<HTMLDivElement>(null);
|
|
330
|
+
const output = useCellOutput(cellId);
|
|
334
331
|
const execution = useCellExecution(cellId);
|
|
335
332
|
const freshness = useCellFreshness(cellId);
|
|
336
333
|
const errored = execution.outcome === "error";
|
|
@@ -23,7 +23,11 @@ import { prepareCellCodeUpdate } from "@/core/codemirror/language/cell-code";
|
|
|
23
23
|
import { getEditorCodeAsPython } from "@/core/codemirror/language/utils";
|
|
24
24
|
import { useResolvedMarimoConfig } from "@/core/config/config";
|
|
25
25
|
import { CSSClasses } from "@/core/constants";
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
cellExecutionInputsAtom,
|
|
28
|
+
scratchStatus,
|
|
29
|
+
useScratchOutput,
|
|
30
|
+
} from "@/core/executions";
|
|
27
31
|
import { useRequestClient } from "@/core/network/requests";
|
|
28
32
|
import type { CellConfig } from "@/core/network/types";
|
|
29
33
|
import { LazyAnyLanguageCodeMirror } from "@/plugins/impl/code/LazyAnyLanguageCodeMirror";
|
|
@@ -67,7 +71,7 @@ export const ScratchPad: React.FC = () => {
|
|
|
67
71
|
|
|
68
72
|
const cellId = SCRATCH_CELL_ID;
|
|
69
73
|
const cellRuntime = notebookState.cellRuntime[cellId];
|
|
70
|
-
const output =
|
|
74
|
+
const output = useScratchOutput();
|
|
71
75
|
const status = scratchStatus(
|
|
72
76
|
useAtomValue(cellExecutionInputsAtom).executions,
|
|
73
77
|
);
|
|
@@ -13,14 +13,13 @@ describe("CellOutputBlock", () => {
|
|
|
13
13
|
const id = cellId("test");
|
|
14
14
|
const cell = {
|
|
15
15
|
...createCell({ id, name: "title" }),
|
|
16
|
-
...createCellRuntimeState(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}),
|
|
16
|
+
...createCellRuntimeState(),
|
|
17
|
+
output: {
|
|
18
|
+
channel: "output" as const,
|
|
19
|
+
mimetype: "text/plain" as const,
|
|
20
|
+
data: "hello",
|
|
21
|
+
timestamp: 0,
|
|
22
|
+
},
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
const { container } = render(
|
|
@@ -5,7 +5,7 @@ import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
|
5
5
|
import { cellId } from "@/__tests__/branded";
|
|
6
6
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
7
7
|
import type { CellId } from "@/core/cells/ids";
|
|
8
|
-
import type {
|
|
8
|
+
import type { RuntimeCell } from "@/core/cells/types";
|
|
9
9
|
import type { CellColumnId } from "@/core/cells/layout";
|
|
10
10
|
import { SlidesMinimap } from "../minimap";
|
|
11
11
|
|
|
@@ -77,13 +77,13 @@ beforeAll(() => {
|
|
|
77
77
|
|
|
78
78
|
// The minimap only reads `id`/`code`/`status`/`output`, so a minimal stub is
|
|
79
79
|
// enough; the cast is confined to this helper.
|
|
80
|
-
function makeCell(id: CellId):
|
|
80
|
+
function makeCell(id: CellId): RuntimeCell {
|
|
81
81
|
return {
|
|
82
82
|
id,
|
|
83
83
|
code: `print("${id}")`,
|
|
84
84
|
output: null,
|
|
85
85
|
status: "idle",
|
|
86
|
-
} as unknown as
|
|
86
|
+
} as unknown as RuntimeCell;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function renderMinimap() {
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
cellStatusClasses,
|
|
22
22
|
isUninstantiated,
|
|
23
23
|
} from "@/core/cells/utils";
|
|
24
|
-
import type {
|
|
24
|
+
import type { RuntimeCell } from "@/core/cells/types";
|
|
25
25
|
import type { LanguageAdapterType } from "@/core/codemirror/language/types";
|
|
26
26
|
import { useCellExecution, useCellFreshness } from "@/core/executions";
|
|
27
27
|
import { connectionAtom } from "@/core/network/connection";
|
|
@@ -30,8 +30,6 @@ import { cn } from "@/utils/cn";
|
|
|
30
30
|
import { ReadonlyCode } from "../editor/code/readonly-python-code";
|
|
31
31
|
import { getReadonlyCodeDisplay } from "@/core/cells/readonly-code-display";
|
|
32
32
|
|
|
33
|
-
type RuntimeCell = CellRuntimeState & CellData;
|
|
34
|
-
|
|
35
33
|
/**
|
|
36
34
|
* Renders a single cell in the slides view as an editable CodeMirror editor
|
|
37
35
|
* stacked with its output, mirroring the notebook layout. Editing and
|
|
@@ -4,10 +4,10 @@ import { outputIsLoading } from "@/core/cells/cell";
|
|
|
4
4
|
import { OutputArea } from "../editor/Output";
|
|
5
5
|
import { memo } from "react";
|
|
6
6
|
import type { CellId } from "@/core/cells/ids";
|
|
7
|
-
import type {
|
|
8
|
-
import type { CellRunStatus } from "@/core/executions";
|
|
7
|
+
import type { CellOutput, CellRunStatus } from "@/core/executions";
|
|
9
8
|
|
|
10
|
-
interface SlideContentProps
|
|
9
|
+
interface SlideContentProps {
|
|
10
|
+
output: CellOutput | null;
|
|
11
11
|
cellId: CellId;
|
|
12
12
|
status: CellRunStatus;
|
|
13
13
|
stale: boolean;
|
|
@@ -5,7 +5,6 @@ import type { FileUIPart } from "ai";
|
|
|
5
5
|
import { createStore } from "jotai";
|
|
6
6
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
7
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
8
|
-
import { notebookAtom } from "@/core/cells/cells";
|
|
9
8
|
import { CellId as CellIdClass } from "@/core/cells/ids";
|
|
10
9
|
import {
|
|
11
10
|
type ErrorContextItem,
|
|
@@ -725,23 +724,21 @@ describe("AIContextRegistry", () => {
|
|
|
725
724
|
const cellId1 = CellIdClass.create();
|
|
726
725
|
const cellId2 = CellIdClass.create();
|
|
727
726
|
|
|
728
|
-
|
|
727
|
+
MockNotebook.withErrors(store, [
|
|
729
728
|
{
|
|
730
729
|
cellId: cellId1,
|
|
731
730
|
cellName: "Cell 1",
|
|
732
|
-
|
|
733
|
-
MockNotebook.errors.syntax("Invalid syntax"),
|
|
734
|
-
MockNotebook.errors.exception("Runtime error"),
|
|
735
|
-
],
|
|
731
|
+
error: { kind: "invalid-syntax", message: "Invalid syntax" },
|
|
736
732
|
},
|
|
737
733
|
{
|
|
738
734
|
cellId: cellId2,
|
|
739
735
|
cellName: "Cell 2",
|
|
740
|
-
|
|
736
|
+
error: {
|
|
737
|
+
kind: "cycle-dependencies",
|
|
738
|
+
message: "This cell is in a cycle",
|
|
739
|
+
},
|
|
741
740
|
},
|
|
742
741
|
]);
|
|
743
|
-
|
|
744
|
-
store.set(notebookAtom, notebookState);
|
|
745
742
|
errorProvider = new ErrorContextProvider(store);
|
|
746
743
|
registry = new AIContextRegistry<ErrorContextItem>().register(
|
|
747
744
|
errorProvider,
|
|
@@ -797,8 +794,7 @@ describe("AIContextRegistry", () => {
|
|
|
797
794
|
it("should handle empty errors gracefully", () => {
|
|
798
795
|
// Create store with no errors using MockNotebook
|
|
799
796
|
const emptyStore = createStore();
|
|
800
|
-
|
|
801
|
-
emptyStore.set(notebookAtom, emptyNotebookState);
|
|
797
|
+
MockNotebook.withErrors(emptyStore, []);
|
|
802
798
|
|
|
803
799
|
const emptyErrorProvider = new ErrorContextProvider(emptyStore);
|
|
804
800
|
const emptyRegistry = new AIContextRegistry().register(
|
|
@@ -13,23 +13,52 @@ vi.mock("@/utils/Logger", () => ({
|
|
|
13
13
|
Logger: Mocks.quietLogger(),
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import { createStore } from "jotai";
|
|
17
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
18
|
+
import { type NotebookState, notebookAtom } from "@/core/cells/cells";
|
|
19
|
+
import type { CellOutput } from "@/core/executions";
|
|
17
20
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
18
21
|
import type { JotaiStore } from "@/core/state/jotai";
|
|
19
22
|
import { CellOutputContextProvider, getCellContextData } from "../cell-output";
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/** A notebook fixture whose runtime entries also state what the host shows. */
|
|
25
|
+
type NotebookFixture = NotebookState & {
|
|
26
|
+
cellRuntime: Record<string, { output?: CellOutput | null }>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** What the fixture shows for `cellId`. */
|
|
30
|
+
function outputOf(
|
|
31
|
+
notebook: NotebookFixture,
|
|
32
|
+
cellId: string,
|
|
33
|
+
): CellOutput | null {
|
|
34
|
+
return notebook.cellRuntime[cellId]?.output ?? null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A store holding the fixture, with each cell's output as a host result. */
|
|
38
|
+
function createMockStore(notebook: NotebookFixture): JotaiStore {
|
|
39
|
+
const store = createStore();
|
|
40
|
+
store.set(notebookAtom, notebook);
|
|
41
|
+
MockExecutions.seed(
|
|
42
|
+
store,
|
|
43
|
+
notebook.cellIds.flatMap((cellId) => {
|
|
44
|
+
const output = outputOf(notebook, cellId);
|
|
45
|
+
return output === null
|
|
46
|
+
? []
|
|
47
|
+
: [
|
|
48
|
+
MockExecutions.shown(cellId, {
|
|
49
|
+
mimetype: output.mimetype,
|
|
50
|
+
data: String(output.data),
|
|
51
|
+
}),
|
|
52
|
+
];
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
26
55
|
return store;
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
describe("CellOutputContextProvider", () => {
|
|
30
59
|
let provider: CellOutputContextProvider;
|
|
31
60
|
let mockStore: JotaiStore;
|
|
32
|
-
let mockNotebook:
|
|
61
|
+
let mockNotebook: NotebookFixture;
|
|
33
62
|
|
|
34
63
|
beforeEach(() => {
|
|
35
64
|
// Create a basic mock notebook state
|
|
@@ -69,7 +98,7 @@ describe("CellOutputContextProvider", () => {
|
|
|
69
98
|
output: null,
|
|
70
99
|
},
|
|
71
100
|
},
|
|
72
|
-
} as unknown as
|
|
101
|
+
} as unknown as NotebookFixture;
|
|
73
102
|
|
|
74
103
|
mockStore = createMockStore(mockNotebook);
|
|
75
104
|
provider = new CellOutputContextProvider(mockStore);
|
|
@@ -208,7 +237,7 @@ describe("Cell output utility functions", () => {
|
|
|
208
237
|
cellIds: [],
|
|
209
238
|
cellData: {},
|
|
210
239
|
cellRuntime: {},
|
|
211
|
-
} as unknown as
|
|
240
|
+
} as unknown as NotebookFixture;
|
|
212
241
|
|
|
213
242
|
mockStore = createMockStore(mockNotebook);
|
|
214
243
|
provider = new CellOutputContextProvider(mockStore);
|
|
@@ -339,7 +368,7 @@ describe("Cell output utility functions", () => {
|
|
|
339
368
|
cellIds: [],
|
|
340
369
|
cellData: {},
|
|
341
370
|
cellRuntime: {},
|
|
342
|
-
} as unknown as
|
|
371
|
+
} as unknown as NotebookFixture;
|
|
343
372
|
|
|
344
373
|
mockStore = createMockStore(mockNotebook);
|
|
345
374
|
provider = new CellOutputContextProvider(mockStore);
|
|
@@ -389,7 +418,7 @@ describe("Cell output utility functions", () => {
|
|
|
389
418
|
});
|
|
390
419
|
|
|
391
420
|
describe("getCellContextData", () => {
|
|
392
|
-
let mockNotebook:
|
|
421
|
+
let mockNotebook: NotebookFixture;
|
|
393
422
|
|
|
394
423
|
beforeEach(() => {
|
|
395
424
|
mockNotebook = {
|
|
@@ -424,11 +453,15 @@ describe("Cell output utility functions", () => {
|
|
|
424
453
|
],
|
|
425
454
|
},
|
|
426
455
|
},
|
|
427
|
-
} as unknown as
|
|
456
|
+
} as unknown as NotebookFixture;
|
|
428
457
|
});
|
|
429
458
|
|
|
430
459
|
it("should extract basic cell data", () => {
|
|
431
|
-
const result = getCellContextData(
|
|
460
|
+
const result = getCellContextData(
|
|
461
|
+
cellId("cell1"),
|
|
462
|
+
mockNotebook,
|
|
463
|
+
outputOf(mockNotebook, "cell1"),
|
|
464
|
+
);
|
|
432
465
|
|
|
433
466
|
expect(result.cellId).toBe("cell1");
|
|
434
467
|
expect(result.cellName).toBe("My Named Cell");
|
|
@@ -436,13 +469,21 @@ describe("Cell output utility functions", () => {
|
|
|
436
469
|
});
|
|
437
470
|
|
|
438
471
|
it("should generate cell name for unnamed cells", () => {
|
|
439
|
-
const result = getCellContextData(
|
|
472
|
+
const result = getCellContextData(
|
|
473
|
+
cellId("cell2"),
|
|
474
|
+
mockNotebook,
|
|
475
|
+
outputOf(mockNotebook, "cell2"),
|
|
476
|
+
);
|
|
440
477
|
|
|
441
478
|
expect(result.cellName).toBe("cell-1"); // 0-indexed, so cell2 is at index 1
|
|
442
479
|
});
|
|
443
480
|
|
|
444
481
|
it("should include cell output when present", () => {
|
|
445
|
-
const result = getCellContextData(
|
|
482
|
+
const result = getCellContextData(
|
|
483
|
+
cellId("cell1"),
|
|
484
|
+
mockNotebook,
|
|
485
|
+
outputOf(mockNotebook, "cell1"),
|
|
486
|
+
);
|
|
446
487
|
|
|
447
488
|
expect(result.cellOutput).toBeDefined();
|
|
448
489
|
expect(result.cellOutput?.outputType).toBe("text");
|
|
@@ -450,21 +491,34 @@ describe("Cell output utility functions", () => {
|
|
|
450
491
|
});
|
|
451
492
|
|
|
452
493
|
it("should not include cell output when not present", () => {
|
|
453
|
-
const result = getCellContextData(
|
|
494
|
+
const result = getCellContextData(
|
|
495
|
+
cellId("cell2"),
|
|
496
|
+
mockNotebook,
|
|
497
|
+
outputOf(mockNotebook, "cell2"),
|
|
498
|
+
);
|
|
454
499
|
|
|
455
500
|
expect(result.cellOutput).toBeUndefined();
|
|
456
501
|
});
|
|
457
502
|
|
|
458
503
|
it("should not include console outputs by default", () => {
|
|
459
|
-
const result = getCellContextData(
|
|
504
|
+
const result = getCellContextData(
|
|
505
|
+
cellId("cell2"),
|
|
506
|
+
mockNotebook,
|
|
507
|
+
outputOf(mockNotebook, "cell2"),
|
|
508
|
+
);
|
|
460
509
|
|
|
461
510
|
expect(result.consoleOutputs).toBeUndefined();
|
|
462
511
|
});
|
|
463
512
|
|
|
464
513
|
it("should include console outputs when opted in", () => {
|
|
465
|
-
const result = getCellContextData(
|
|
466
|
-
|
|
467
|
-
|
|
514
|
+
const result = getCellContextData(
|
|
515
|
+
cellId("cell2"),
|
|
516
|
+
mockNotebook,
|
|
517
|
+
outputOf(mockNotebook, "cell2"),
|
|
518
|
+
{
|
|
519
|
+
includeConsoleOutput: true,
|
|
520
|
+
},
|
|
521
|
+
);
|
|
468
522
|
|
|
469
523
|
expect(result.consoleOutputs).toBeDefined();
|
|
470
524
|
expect(result.consoleOutputs).toHaveLength(1);
|
|
@@ -488,9 +542,14 @@ describe("Cell output utility functions", () => {
|
|
|
488
542
|
];
|
|
489
543
|
}
|
|
490
544
|
|
|
491
|
-
const result = getCellContextData(
|
|
492
|
-
|
|
493
|
-
|
|
545
|
+
const result = getCellContextData(
|
|
546
|
+
cellId("cell2"),
|
|
547
|
+
mockNotebook,
|
|
548
|
+
outputOf(mockNotebook, "cell2"),
|
|
549
|
+
{
|
|
550
|
+
includeConsoleOutput: true,
|
|
551
|
+
},
|
|
552
|
+
);
|
|
494
553
|
|
|
495
554
|
expect(result.consoleOutputs).toHaveLength(1);
|
|
496
555
|
expect(result.consoleOutputs?.[0]?.processedContent).toBe("valid output");
|
|
@@ -507,9 +566,14 @@ describe("Cell output utility functions", () => {
|
|
|
507
566
|
];
|
|
508
567
|
}
|
|
509
568
|
|
|
510
|
-
const result = getCellContextData(
|
|
511
|
-
|
|
512
|
-
|
|
569
|
+
const result = getCellContextData(
|
|
570
|
+
cellId("cell1"),
|
|
571
|
+
mockNotebook,
|
|
572
|
+
outputOf(mockNotebook, "cell1"),
|
|
573
|
+
{
|
|
574
|
+
includeConsoleOutput: true,
|
|
575
|
+
},
|
|
576
|
+
);
|
|
513
577
|
|
|
514
578
|
expect(result.cellOutput).toBeDefined();
|
|
515
579
|
expect(result.cellOutput?.processedContent).toBe("42");
|
|
@@ -520,23 +584,32 @@ describe("Cell output utility functions", () => {
|
|
|
520
584
|
});
|
|
521
585
|
|
|
522
586
|
it("should handle empty console outputs array", () => {
|
|
523
|
-
const result = getCellContextData(
|
|
524
|
-
|
|
525
|
-
|
|
587
|
+
const result = getCellContextData(
|
|
588
|
+
cellId("cell1"),
|
|
589
|
+
mockNotebook,
|
|
590
|
+
outputOf(mockNotebook, "cell1"),
|
|
591
|
+
{
|
|
592
|
+
includeConsoleOutput: true,
|
|
593
|
+
},
|
|
594
|
+
);
|
|
526
595
|
|
|
527
596
|
expect(result.consoleOutputs).toEqual([]);
|
|
528
597
|
});
|
|
529
598
|
|
|
530
599
|
it("should handle media outputs in cell output", () => {
|
|
531
|
-
const cell1Runtime = mockNotebook.cellRuntime
|
|
600
|
+
const cell1Runtime = mockNotebook.cellRuntime.cell1;
|
|
532
601
|
if (cell1Runtime) {
|
|
533
|
-
|
|
602
|
+
cell1Runtime.output = {
|
|
534
603
|
mimetype: "image/png",
|
|
535
604
|
data: "data:image/png;base64,test",
|
|
536
605
|
} as OutputMessage;
|
|
537
606
|
}
|
|
538
607
|
|
|
539
|
-
const result = getCellContextData(
|
|
608
|
+
const result = getCellContextData(
|
|
609
|
+
cellId("cell1"),
|
|
610
|
+
mockNotebook,
|
|
611
|
+
outputOf(mockNotebook, "cell1"),
|
|
612
|
+
);
|
|
540
613
|
|
|
541
614
|
expect(result.cellOutput).toBeDefined();
|
|
542
615
|
expect(result.cellOutput?.outputType).toBe("media");
|
|
@@ -554,9 +627,14 @@ describe("Cell output utility functions", () => {
|
|
|
554
627
|
];
|
|
555
628
|
}
|
|
556
629
|
|
|
557
|
-
const result = getCellContextData(
|
|
558
|
-
|
|
559
|
-
|
|
630
|
+
const result = getCellContextData(
|
|
631
|
+
cellId("cell2"),
|
|
632
|
+
mockNotebook,
|
|
633
|
+
outputOf(mockNotebook, "cell2"),
|
|
634
|
+
{
|
|
635
|
+
includeConsoleOutput: true,
|
|
636
|
+
},
|
|
637
|
+
);
|
|
560
638
|
|
|
561
639
|
expect(result.consoleOutputs).toHaveLength(1);
|
|
562
640
|
expect(result.consoleOutputs?.[0]?.outputType).toBe("media");
|