@marimo-team/frontend 0.24.3-dev80 → 0.24.3-dev81
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/assets/{ConnectedDataExplorerComponent-S61Cojer.js → ConnectedDataExplorerComponent-DkTZ7AvX.js} +1 -1
- package/dist/assets/{ErrorBoundary-rFJTQttC.js → ErrorBoundary-DTpbqvzY.js} +2 -2
- package/dist/assets/{LazyAnyLanguageCodeMirror-DJWWnUeJ.js → LazyAnyLanguageCodeMirror-DYsZfkSk.js} +2 -2
- package/dist/assets/{RunButton-DfEJQMZn.js → RunButton-IMtEkRXV.js} +2 -2
- package/dist/assets/{abnfDiagram-VCTEODGH-Cp9dE6jg.js → abnfDiagram-VCTEODGH-pTFf_XLR.js} +1 -1
- package/dist/assets/{add-cell-with-ai-CY4gzrAg.js → add-cell-with-ai-CSNC0MIy.js} +1 -1
- package/dist/assets/{agent-panel-C3RY3rVh.js → agent-panel-DxU4qgxk.js} +1 -1
- package/dist/assets/{ai-model-dropdown-Bq7LNfwO.js → ai-model-dropdown-Ct4CTWKe.js} +1 -1
- package/dist/assets/{any-language-editor-DyDLZyTa.js → any-language-editor-DBp5CC3w.js} +1 -1
- package/dist/assets/{app-config-button-BEUe2niv.js → app-config-button-BjxXAmKd.js} +1 -1
- package/dist/assets/{architectureDiagram-5GKGNRK7-Bp0xYQON.js → architectureDiagram-5GKGNRK7-C7t0AR-N.js} +1 -1
- package/dist/assets/{blockDiagram-I7D4REHJ-CTdYGlif.js → blockDiagram-I7D4REHJ-DZgXohrV.js} +1 -1
- package/dist/assets/{cache-panel-BsWmIJNw.js → cache-panel-DDlfv8BP.js} +1 -1
- package/dist/assets/{cells-BY2lhea7.js → cells-C0itXtA7.js} +2 -2
- package/dist/assets/{chat-display-CHx8XIBv.js → chat-display-CHxh_MGC.js} +1 -1
- package/dist/assets/{chat-panel-akoUJ8qX.js → chat-panel-Ca6yjxkg.js} +1 -1
- package/dist/assets/{chat-ui-DZoDkcnO.js → chat-ui-D5zW1hYM.js} +1 -1
- package/dist/assets/{chunk-IMKFNOWR-BDUxpkzp.js → chunk-IMKFNOWR-CAmhQu-F.js} +1 -1
- package/dist/assets/{chunk-SHT3W25Y-BY2fwZu6.js → chunk-SHT3W25Y-BqEFXoRq.js} +1 -1
- package/dist/assets/{chunk-SVP7TREG-BMAK1dM1.js → chunk-SVP7TREG-Dxu0eRzD.js} +1 -1
- package/dist/assets/{chunk-TICWLB2K-DYvCP0dC.js → chunk-TICWLB2K-gHNMAWa9.js} +1 -1
- package/dist/assets/{classDiagram-ZZMXUADV-DInDmLPP.js → classDiagram-ZZMXUADV-DE3i3SzX.js} +1 -1
- package/dist/assets/{classDiagram-v2-VYDZK3BY-DInDmLPP.js → classDiagram-v2-VYDZK3BY-DE3i3SzX.js} +1 -1
- package/dist/assets/{code-visibility-C7jb6w0_.js → code-visibility-kUtIY_sH.js} +1 -1
- package/dist/assets/{command-palette-3rMZly6z.js → command-palette-BZJRR34P.js} +1 -1
- package/dist/assets/{common-Bg00voiB.js → common-DtiDLSXB.js} +1 -1
- package/dist/assets/{components-DF5RfdrX.js → components-CHh1MGbL.js} +1 -1
- package/dist/assets/{components-Djpop-6Y.js → components-DScgyZ8j.js} +1 -1
- package/dist/assets/{cynefinDiagram-5FMLGOSQ-DjGWNvBA.js → cynefinDiagram-5FMLGOSQ-C8RK-PLH.js} +1 -1
- package/dist/assets/{dagre-BdadXra2.js → dagre-Be6hV3Qt.js} +1 -1
- package/dist/assets/{dagre-GXQ25YYZ-4WrRwKjj.js → dagre-GXQ25YYZ-DZ6JGcBM.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-CdyFyGHp.js → data-grid-overlay-editor-BkZfO-uG.js} +1 -1
- package/dist/assets/{dependency-graph-panel-HTfghWvl.js → dependency-graph-panel-DhGTFsO9.js} +1 -1
- package/dist/assets/{diagram-S7CK7UJ4-BhNxBPOh.js → diagram-S7CK7UJ4-BN77DDKM.js} +1 -1
- package/dist/assets/{diagram-UQ7AKVKN-CpXP5J8O.js → diagram-UQ7AKVKN-BZthP0T4.js} +1 -1
- package/dist/assets/{diagram-VX7I27RA-8joParfV.js → diagram-VX7I27RA-D3GF3lRq.js} +1 -1
- package/dist/assets/{diagram-Z3DM3KII-Dj4QE7kS.js → diagram-Z3DM3KII-DnsKITpy.js} +1 -1
- package/dist/assets/{documentation-panel-BATWKMxI.js → documentation-panel-D8fz9UDV.js} +1 -1
- package/dist/assets/{ebnfDiagram-PWID7BFC-bg9GAIDY.js → ebnfDiagram-PWID7BFC-CHqqdhbQ.js} +1 -1
- package/dist/assets/{edit-page-Bw_9cD6X.js → edit-page-Cw1A5Rhq.js} +4 -4
- package/dist/assets/{erDiagram-RLTQ6QDP-B7AAtDAB.js → erDiagram-RLTQ6QDP-ChDyfc3w.js} +1 -1
- package/dist/assets/{error-entries-BGsjaQkq.js → error-entries-Dy7E9tUS.js} +1 -1
- package/dist/assets/{error-panel-gEXILkC3.js → error-panel-FYd4Tvsc.js} +1 -1
- package/dist/assets/{feedback-button-C_vk_D6i.js → feedback-button-Zjt-Mi38.js} +1 -1
- package/dist/assets/{file-explorer-panel-IuDHKOoY.js → file-explorer-panel-BpklXFSu.js} +1 -1
- package/dist/assets/{file-name-input-BOEaxkNs.js → file-name-input-DifonhZ7.js} +1 -1
- package/dist/assets/{flowDiagram-HODETNUW-CMeIUHlj.js → flowDiagram-HODETNUW-CelwDl0Y.js} +1 -1
- package/dist/assets/{gallery-page-CK1bqVLD.js → gallery-page-C0T1oyzr.js} +1 -1
- package/dist/assets/{glide-data-editor-DdFVvDaa.js → glide-data-editor-Dqd-if6R.js} +4 -4
- package/dist/assets/{graphlib-Czf9KyA4.js → graphlib-6_f7N0YM.js} +1 -1
- package/dist/assets/has-D5vyh6J_.js +1 -0
- package/dist/assets/{home-page-Da9V4OZH.js → home-page-CN05bwXu.js} +1 -1
- package/dist/assets/index-CcaMC2ZX.js +62 -0
- package/dist/assets/{infoDiagram-27XIBGKW-CIQ-BWOI.js → infoDiagram-27XIBGKW-Dh0ztpYZ.js} +1 -1
- package/dist/assets/{ishikawaDiagram-5VMMS53U-Dv_nv5Nd.js → ishikawaDiagram-5VMMS53U-Yy11Lj-8.js} +1 -1
- package/dist/assets/{kanban-definition-UXKFOSKX-XKnaVIBU.js → kanban-definition-UXKFOSKX-_hCm9ITM.js} +1 -1
- package/dist/assets/{logs-panel-De3Aixdf.js → logs-panel-D_Ki0PRi.js} +1 -1
- package/dist/assets/{mermaid-DxmgGQBY.js → mermaid-DUZOkwYg.js} +4 -4
- package/dist/assets/{mindmap-definition-YA3MSWOX-CaE8R-61.js → mindmap-definition-YA3MSWOX-CqKVab9Z.js} +1 -1
- package/dist/assets/{number-overlay-editor-DzvkzNgP.js → number-overlay-editor-BFwgibS5.js} +1 -1
- package/dist/assets/{outline-panel-C95qN5yF.js → outline-panel-BVLrHsJa.js} +1 -1
- package/dist/assets/{packages-panel-sY9qWXae.js → packages-panel-cq-qnvM5.js} +1 -1
- package/dist/assets/{panels-CCUm-UiE.js → panels-DwxpnIFf.js} +3 -3
- package/dist/assets/{pegDiagram-XKGWAZYB-CciXs9oJ.js → pegDiagram-XKGWAZYB-Cq-QrQFc.js} +1 -1
- package/dist/assets/{pieDiagram-E7YTZNPT-BbYR1uGC.js → pieDiagram-E7YTZNPT-DXU0ndOt.js} +1 -1
- package/dist/assets/{process-output-CGPaOEF_.js → process-output-B76bPsnA.js} +1 -1
- package/dist/assets/{railroadDiagram-O6MQD6OU-CcMt9sHo.js → railroadDiagram-O6MQD6OU-CFI_pgSK.js} +1 -1
- package/dist/assets/{requirementDiagram-BXWQKSXE-BCxwwt1G.js → requirementDiagram-BXWQKSXE-DgdygEWz.js} +1 -1
- package/dist/assets/{reveal-component-CkEkHMf-.js → reveal-component-BqiZOsW3.js} +1 -1
- package/dist/assets/{run-page-DuB25jlR.js → run-page-DVqnr-8x.js} +1 -1
- package/dist/assets/{scratchpad-panel-Dotdyqj2.js → scratchpad-panel-BT2lF-Gs.js} +1 -1
- package/dist/assets/{secrets-panel-1h46YXtq.js → secrets-panel-CeovmJAu.js} +1 -1
- package/dist/assets/{sequenceDiagram-WJ2MYXX4-BDiLUY65.js → sequenceDiagram-WJ2MYXX4-Cq7P3SPg.js} +1 -1
- package/dist/assets/{session-panel-C5KxX76R.js → session-panel-CGddxX8c.js} +1 -1
- package/dist/assets/{snippets-panel-C4akeu4G.js → snippets-panel-UawnfExC.js} +1 -1
- package/dist/assets/{stateDiagram-D77RDMKH-CDTKGawS.js → stateDiagram-D77RDMKH-CO8GuJdh.js} +1 -1
- package/dist/assets/{stateDiagram-v2-MP3YSRHH-DoZ64xoP.js → stateDiagram-v2-MP3YSRHH-DA7CflqT.js} +1 -1
- package/dist/assets/{swimlanes-42K2YHIH-CTH1Amtr.js → swimlanes-42K2YHIH-Bkf4BWja.js} +1 -1
- package/dist/assets/{swimlanesDiagram-VR7AAH4N-BeyRxUpX.js → swimlanesDiagram-VR7AAH4N-Bf0FHwi-.js} +1 -1
- package/dist/assets/{swiper-component-CUC6e6Nx.js → swiper-component-Dcb47cI1.js} +1 -1
- package/dist/assets/{terminal-C0R4btMV.js → terminal-bvd8BLSi.js} +1 -1
- package/dist/assets/{timeline-definition-24CTP7MA-BcRe5OGG.js → timeline-definition-24CTP7MA-CWdT681e.js} +1 -1
- package/dist/assets/{tracing-DiHWzXpM.js → tracing-BbV840Cl.js} +1 -1
- package/dist/assets/{tracing-panel-DNwBoqbU.js → tracing-panel-AQUl8b58.js} +2 -2
- package/dist/assets/{useCellActionButton-CSzUH7xJ.js → useCellActionButton-DIiKKxoN.js} +1 -1
- package/dist/assets/{vega-component-C3dqV-HG.js → vega-component-C5LY21OO.js} +1 -1
- package/dist/assets/{vega-embed-container-NsunuIaD.js → vega-embed-container-C6Hr9CZj.js} +1 -1
- package/dist/assets/{vennDiagram-4TSXK5OY-DT15w8Xq.js → vennDiagram-4TSXK5OY-B3uJF3gV.js} +1 -1
- package/dist/assets/{wardleyDiagram-VM6X3IG4-BTCnC8gB.js → wardleyDiagram-VM6X3IG4-DGmcLh5J.js} +1 -1
- package/dist/assets/{xychartDiagram-S5SC5T6Z-BtV9PLMA.js → xychartDiagram-S5SC5T6Z-kFxqIAk2.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/src/__mocks__/notebook.ts +1 -0
- package/src/components/editor/navigation/clipboard.ts +1 -0
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +37 -0
- package/src/core/cells/__tests__/apply-transaction.test.ts +34 -0
- package/src/core/cells/__tests__/cells.test.ts +1 -0
- package/src/core/cells/__tests__/document-changes.test.ts +39 -1
- package/src/core/cells/__tests__/outputs.test.tsx +117 -0
- package/src/core/cells/__tests__/session.test.ts +7 -0
- package/src/core/cells/cells.ts +6 -1
- package/src/core/cells/document-changes.ts +11 -1
- package/src/core/cells/outputs.ts +66 -9
- package/src/core/cells/session.ts +2 -0
- package/src/core/cells/types.ts +2 -0
- package/dist/assets/has-Bpddg3XQ.js +0 -1
- package/dist/assets/index-BtFkx6qT.js +0 -62
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { act, renderHook } from "@testing-library/react";
|
|
4
|
+
import { createStore, Provider } from "jotai";
|
|
5
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { MockNotebook } from "@/__mocks__/notebook";
|
|
7
|
+
import { notebookAtom } from "@/core/cells/cells";
|
|
8
|
+
import { CellId } from "@/core/cells/ids";
|
|
9
|
+
import { type AppMode, viewStateAtom } from "@/core/mode";
|
|
10
|
+
import { useExpandedConsoleOutput, useExpandedOutput } from "../outputs";
|
|
11
|
+
|
|
12
|
+
const saveCellConfig = vi.fn().mockResolvedValue(null);
|
|
13
|
+
|
|
14
|
+
vi.mock("@/core/network/requests", () => ({
|
|
15
|
+
getRequestClient: () => ({ saveCellConfig }),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
function setup(opts: { mode: AppMode; expandOutput?: boolean }) {
|
|
19
|
+
const cellId = CellId.create();
|
|
20
|
+
const store = createStore();
|
|
21
|
+
store.set(
|
|
22
|
+
notebookAtom,
|
|
23
|
+
MockNotebook.notebookState({
|
|
24
|
+
cellData: {
|
|
25
|
+
[cellId]: { config: { expand_output: opts.expandOutput ?? false } },
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
store.set(viewStateAtom, { mode: opts.mode, cellAnchor: null });
|
|
30
|
+
|
|
31
|
+
const { result } = renderHook(() => useExpandedOutput(cellId), {
|
|
32
|
+
wrapper: ({ children }) => <Provider store={store}>{children}</Provider>,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return { cellId, store, result };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const configOf = (store: ReturnType<typeof createStore>, cellId: CellId) =>
|
|
39
|
+
store.get(notebookAtom).cellData[cellId].config;
|
|
40
|
+
|
|
41
|
+
describe("useExpandedOutput", () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
vi.clearAllMocks();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("reads the initial state from the cell's expand_output config", () => {
|
|
47
|
+
expect(setup({ mode: "edit" }).result.current[0]).toBe(false);
|
|
48
|
+
expect(setup({ mode: "edit", expandOutput: true }).result.current[0]).toBe(
|
|
49
|
+
true,
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("persists the toggle to the cell's config in edit mode", () => {
|
|
54
|
+
const { cellId, store, result } = setup({ mode: "edit" });
|
|
55
|
+
|
|
56
|
+
act(() => result.current[1](true));
|
|
57
|
+
|
|
58
|
+
expect(result.current[0]).toBe(true);
|
|
59
|
+
expect(configOf(store, cellId).expand_output).toBe(true);
|
|
60
|
+
expect(saveCellConfig).toHaveBeenCalledWith({
|
|
61
|
+
configs: { [cellId]: { expand_output: true } },
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("collapses by clearing the config", () => {
|
|
66
|
+
const { cellId, store, result } = setup({
|
|
67
|
+
mode: "edit",
|
|
68
|
+
expandOutput: true,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
act(() => result.current[1](false));
|
|
72
|
+
|
|
73
|
+
expect(result.current[0]).toBe(false);
|
|
74
|
+
expect(configOf(store, cellId).expand_output).toBe(false);
|
|
75
|
+
expect(saveCellConfig).toHaveBeenCalledWith({
|
|
76
|
+
configs: { [cellId]: { expand_output: false } },
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("keeps the toggle in memory outside of edit mode", () => {
|
|
81
|
+
const { cellId, store, result } = setup({ mode: "read" });
|
|
82
|
+
|
|
83
|
+
act(() => result.current[1](true));
|
|
84
|
+
|
|
85
|
+
expect(result.current[0]).toBe(true);
|
|
86
|
+
// Cell configs are read-only outside of edit mode.
|
|
87
|
+
expect(configOf(store, cellId).expand_output).toBe(false);
|
|
88
|
+
expect(saveCellConfig).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("still honors expand_output outside of edit mode", () => {
|
|
92
|
+
const { result } = setup({ mode: "read", expandOutput: true });
|
|
93
|
+
expect(result.current[0]).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// `expand_output` covers the cell's output area only. Console output is
|
|
97
|
+
// clamped independently and stays an in-memory, per-session toggle.
|
|
98
|
+
it("does not touch the config when console output is expanded", () => {
|
|
99
|
+
const cellId = CellId.create();
|
|
100
|
+
const store = createStore();
|
|
101
|
+
store.set(
|
|
102
|
+
notebookAtom,
|
|
103
|
+
MockNotebook.notebookState({ cellData: { [cellId]: {} } }),
|
|
104
|
+
);
|
|
105
|
+
store.set(viewStateAtom, { mode: "edit", cellAnchor: null });
|
|
106
|
+
|
|
107
|
+
const { result } = renderHook(() => useExpandedConsoleOutput(cellId), {
|
|
108
|
+
wrapper: ({ children }) => <Provider store={store}>{children}</Provider>,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
act(() => result.current[1](true));
|
|
112
|
+
|
|
113
|
+
expect(result.current[0]).toBe(true);
|
|
114
|
+
expect(configOf(store, cellId).expand_output).toBe(false);
|
|
115
|
+
expect(saveCellConfig).not.toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -59,6 +59,7 @@ describe("notebookStateFromSession", () => {
|
|
|
59
59
|
column: config?.column ?? null,
|
|
60
60
|
disabled: config?.disabled ?? null,
|
|
61
61
|
hide_code: config?.hide_code ?? null,
|
|
62
|
+
expand_output: config?.expand_output ?? null,
|
|
62
63
|
},
|
|
63
64
|
});
|
|
64
65
|
|
|
@@ -298,6 +299,7 @@ describe("notebookStateFromSession", () => {
|
|
|
298
299
|
hide_code: false,
|
|
299
300
|
disabled: false,
|
|
300
301
|
column: null,
|
|
302
|
+
expand_output: false,
|
|
301
303
|
},
|
|
302
304
|
serializedEditorState: null,
|
|
303
305
|
});
|
|
@@ -309,6 +311,7 @@ describe("notebookStateFromSession", () => {
|
|
|
309
311
|
hide_code: true,
|
|
310
312
|
disabled: true,
|
|
311
313
|
column: 1,
|
|
314
|
+
expand_output: true,
|
|
312
315
|
}),
|
|
313
316
|
]);
|
|
314
317
|
const result = notebookStateFromSession(null, notebook);
|
|
@@ -319,6 +322,7 @@ describe("notebookStateFromSession", () => {
|
|
|
319
322
|
hide_code: true,
|
|
320
323
|
disabled: true,
|
|
321
324
|
column: 1,
|
|
325
|
+
expand_output: true,
|
|
322
326
|
});
|
|
323
327
|
});
|
|
324
328
|
|
|
@@ -350,6 +354,7 @@ describe("notebookStateFromSession", () => {
|
|
|
350
354
|
hide_code: false,
|
|
351
355
|
disabled: false,
|
|
352
356
|
column: null,
|
|
357
|
+
expand_output: false,
|
|
353
358
|
},
|
|
354
359
|
serializedEditorState: null,
|
|
355
360
|
});
|
|
@@ -386,6 +391,7 @@ describe("notebookStateFromSession", () => {
|
|
|
386
391
|
hide_code: false,
|
|
387
392
|
disabled: false,
|
|
388
393
|
column: null,
|
|
394
|
+
expand_output: false,
|
|
389
395
|
},
|
|
390
396
|
serializedEditorState: null,
|
|
391
397
|
});
|
|
@@ -426,6 +432,7 @@ describe("notebookStateFromSession", () => {
|
|
|
426
432
|
hide_code: false,
|
|
427
433
|
disabled: false,
|
|
428
434
|
column: null,
|
|
435
|
+
expand_output: false,
|
|
429
436
|
},
|
|
430
437
|
serializedEditorState: null,
|
|
431
438
|
});
|
package/src/core/cells/cells.ts
CHANGED
|
@@ -125,7 +125,12 @@ export interface NotebookState {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
function withScratchCell(notebookState: NotebookState): NotebookState {
|
|
128
|
-
const config = {
|
|
128
|
+
const config = {
|
|
129
|
+
column: 0,
|
|
130
|
+
hide_code: false,
|
|
131
|
+
disabled: false,
|
|
132
|
+
expand_output: false,
|
|
133
|
+
};
|
|
129
134
|
return {
|
|
130
135
|
...notebookState,
|
|
131
136
|
cellData: {
|
|
@@ -164,6 +164,7 @@ function columnChanges(
|
|
|
164
164
|
column: newCol,
|
|
165
165
|
disabled: cell?.config.disabled ?? false,
|
|
166
166
|
hideCode: cell?.config.hide_code ?? false,
|
|
167
|
+
expandOutput: cell?.config.expand_output ?? false,
|
|
167
168
|
});
|
|
168
169
|
}
|
|
169
170
|
}
|
|
@@ -277,6 +278,7 @@ export function toDocumentChanges(
|
|
|
277
278
|
column: cell.config.column ?? null,
|
|
278
279
|
disabled: cell.config.disabled ?? false,
|
|
279
280
|
hideCode: cell.config.hide_code ?? false,
|
|
281
|
+
expandOutput: cell.config.expand_output ?? false,
|
|
280
282
|
},
|
|
281
283
|
];
|
|
282
284
|
}
|
|
@@ -452,7 +454,11 @@ export function fromDocumentChanges(
|
|
|
452
454
|
payload: { cellId: change.cellId, name: change.name },
|
|
453
455
|
});
|
|
454
456
|
}
|
|
455
|
-
if (
|
|
457
|
+
if (
|
|
458
|
+
change.config?.disabled != null ||
|
|
459
|
+
change.config?.column != null ||
|
|
460
|
+
change.config?.expand_output != null
|
|
461
|
+
) {
|
|
456
462
|
actions.push({
|
|
457
463
|
type: "updateCellConfig",
|
|
458
464
|
payload: {
|
|
@@ -464,6 +470,9 @@ export function fromDocumentChanges(
|
|
|
464
470
|
...(change.config.column != null && {
|
|
465
471
|
column: change.config.column,
|
|
466
472
|
}),
|
|
473
|
+
...(change.config.expand_output != null && {
|
|
474
|
+
expand_output: change.config.expand_output,
|
|
475
|
+
}),
|
|
467
476
|
},
|
|
468
477
|
},
|
|
469
478
|
});
|
|
@@ -560,6 +569,7 @@ export function fromDocumentChanges(
|
|
|
560
569
|
column: change.column,
|
|
561
570
|
disabled: change.disabled,
|
|
562
571
|
hide_code: change.hideCode,
|
|
572
|
+
expand_output: change.expandOutput,
|
|
563
573
|
},
|
|
564
574
|
},
|
|
565
575
|
});
|
|
@@ -1,34 +1,91 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useAtomValue } from "jotai";
|
|
4
|
+
import { selectAtom } from "jotai/utils";
|
|
5
|
+
import { useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { useEvent } from "@/hooks/useEvent";
|
|
7
|
+
import { Logger } from "@/utils/Logger";
|
|
4
8
|
import type { OutputMessage } from "../kernel/messages";
|
|
9
|
+
import { viewStateAtom } from "../mode";
|
|
10
|
+
import { getRequestClient } from "../network/requests";
|
|
11
|
+
import { cellDataAtom, useCellActions } from "./cells";
|
|
5
12
|
import type { CellId } from "./ids";
|
|
6
13
|
|
|
7
14
|
// This does not need to be overcomplicated. We can just store the expanded
|
|
8
15
|
// state in a global map instead of Jotai since state is not shared between cells.
|
|
16
|
+
// The output area only falls back to its map where the `expand_output` config
|
|
17
|
+
// cannot be edited; see `useExpandedOutput`.
|
|
9
18
|
const expandedOutputs: Record<CellId, boolean> = {};
|
|
10
19
|
const expandedConsoleOutputs: Record<CellId, boolean> = {};
|
|
11
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Whether a cell's output is shown in full, instead of clamped to a fixed
|
|
23
|
+
* height. Covers the cell's output area only; console output is clamped
|
|
24
|
+
* independently, via `useExpandedConsoleOutput`.
|
|
25
|
+
*
|
|
26
|
+
* In edit mode, we toggle the cell's `expand_output` config, so the choice is persisted.
|
|
27
|
+
*/
|
|
12
28
|
export function useExpandedOutput(cellId: CellId) {
|
|
13
|
-
const
|
|
29
|
+
const { mode } = useAtomValue(viewStateAtom);
|
|
30
|
+
const { updateCellConfig } = useCellActions();
|
|
31
|
+
// Select just the flag: every output would otherwise re-render on each
|
|
32
|
+
// keystroke in its cell.
|
|
33
|
+
const isConfigExpanded = useAtomValue(
|
|
34
|
+
useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
selectAtom(
|
|
37
|
+
cellDataAtom(cellId),
|
|
38
|
+
(data) => data?.config.expand_output ?? false,
|
|
39
|
+
Object.is,
|
|
40
|
+
),
|
|
41
|
+
[cellId],
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
const [isSessionExpanded, setIsSessionExpanded] = useState(
|
|
45
|
+
() => expandedOutputs[cellId] ?? isConfigExpanded,
|
|
46
|
+
);
|
|
14
47
|
|
|
15
48
|
// Sync state to external storage
|
|
16
49
|
useEffect(() => {
|
|
17
|
-
expandedOutputs[cellId] =
|
|
18
|
-
}, [cellId,
|
|
50
|
+
expandedOutputs[cellId] = isSessionExpanded;
|
|
51
|
+
}, [cellId, isSessionExpanded]);
|
|
19
52
|
|
|
20
|
-
|
|
53
|
+
const isEditable = mode === "edit";
|
|
54
|
+
const isExpanded = isEditable ? isConfigExpanded : isSessionExpanded;
|
|
55
|
+
|
|
56
|
+
const setIsExpanded = useEvent((expanded: boolean) => {
|
|
57
|
+
setIsSessionExpanded(expanded);
|
|
58
|
+
if (!isEditable) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const config = { expand_output: expanded };
|
|
62
|
+
updateCellConfig({ cellId, config });
|
|
63
|
+
getRequestClient()
|
|
64
|
+
.saveCellConfig({ configs: { [cellId]: config } })
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
Logger.error("Failed to save expand_output config", error);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return [isExpanded, setIsExpanded] as const;
|
|
21
71
|
}
|
|
22
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Whether a cell's console output is shown in full. Deliberately not backed by
|
|
75
|
+
* `expand_output`: that config covers the cell's output area only, so console
|
|
76
|
+
* output stays a per-session, in-memory toggle.
|
|
77
|
+
*/
|
|
23
78
|
export function useExpandedConsoleOutput(cellId: CellId) {
|
|
24
|
-
const [
|
|
79
|
+
const [isExpanded, setIsExpanded] = useState(
|
|
80
|
+
expandedConsoleOutputs[cellId] ?? false,
|
|
81
|
+
);
|
|
25
82
|
|
|
26
83
|
// Sync state to external storage
|
|
27
84
|
useEffect(() => {
|
|
28
|
-
expandedConsoleOutputs[cellId] =
|
|
29
|
-
}, [cellId,
|
|
85
|
+
expandedConsoleOutputs[cellId] = isExpanded;
|
|
86
|
+
}, [cellId, isExpanded]);
|
|
30
87
|
|
|
31
|
-
return [
|
|
88
|
+
return [isExpanded, setIsExpanded] as const;
|
|
32
89
|
}
|
|
33
90
|
|
|
34
91
|
export function isOutputEmpty(
|
|
@@ -149,6 +149,7 @@ function createEmptyNotebookCell(): NotebookCell {
|
|
|
149
149
|
column: null,
|
|
150
150
|
disabled: false,
|
|
151
151
|
hide_code: false,
|
|
152
|
+
expand_output: false,
|
|
152
153
|
},
|
|
153
154
|
};
|
|
154
155
|
}
|
|
@@ -177,6 +178,7 @@ function createCellDataFromNotebook(
|
|
|
177
178
|
column: notebookCell.config?.column ?? null,
|
|
178
179
|
disabled: notebookCell.config?.disabled ?? false,
|
|
179
180
|
hide_code: notebookCell.config?.hide_code ?? false,
|
|
181
|
+
expand_output: notebookCell.config?.expand_output ?? false,
|
|
180
182
|
},
|
|
181
183
|
serializedEditorState: null,
|
|
182
184
|
};
|
package/src/core/cells/types.ts
CHANGED
|
@@ -27,6 +27,7 @@ export function createCell({
|
|
|
27
27
|
hide_code: false,
|
|
28
28
|
disabled: false,
|
|
29
29
|
column: null,
|
|
30
|
+
expand_output: false,
|
|
30
31
|
},
|
|
31
32
|
name: name,
|
|
32
33
|
code: code,
|
|
@@ -42,6 +43,7 @@ export function createCellConfig(config?: Partial<CellConfig>): CellConfig {
|
|
|
42
43
|
hide_code: false,
|
|
43
44
|
disabled: false,
|
|
44
45
|
column: null,
|
|
46
|
+
expand_output: false,
|
|
45
47
|
...config,
|
|
46
48
|
};
|
|
47
49
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ka as e}from"./index-BtFkx6qT.js";var t=Object.prototype.hasOwnProperty;function n(e,n){return e!=null&&t.call(e,n)}function r(t,r){return t!=null&&e(t,r,n)}export{r as t};
|