@marimo-team/frontend 0.24.3-dev0 → 0.24.3-dev10

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.
Files changed (149) hide show
  1. package/dist/assets/{CellStatus-LoTwk7fR.js → CellStatus-DXkwkuL9.js} +1 -1
  2. package/dist/assets/{ConnectedDataExplorerComponent-DW6cJ-Lr.js → ConnectedDataExplorerComponent-DiXd-oqU.js} +1 -1
  3. package/dist/assets/JsonOutput-izmGhjov.js +50 -0
  4. package/dist/assets/LazyAnyLanguageCodeMirror-C_cwGmDg.js +2 -0
  5. package/dist/assets/{MarimoErrorOutput-DqpoYOvw.js → MarimoErrorOutput-CdmP3ZHL.js} +2 -2
  6. package/dist/assets/{RenderHTML-DwhMAd9l.js → RenderHTML-DlYXvh8D.js} +1 -1
  7. package/dist/assets/{RunButton-BlpbweyH.js → RunButton-Bieadi9w.js} +1 -1
  8. package/dist/assets/add-cell-with-ai-ZpV9L4qe.js +76 -0
  9. package/dist/assets/{add-connection-dialog-BGfpw5lC.js → add-connection-dialog-a8mkIeXa.js} +73 -73
  10. package/dist/assets/agent-panel-rVtDSi07.js +286 -0
  11. package/dist/assets/ai-model-dropdown-C8IztRe2.js +3 -0
  12. package/dist/assets/{any-language-editor-DflLjPSQ.js → any-language-editor-pGZDaSqz.js} +1 -1
  13. package/dist/assets/app-config-button-DLr-6jwI.js +1 -0
  14. package/dist/assets/{blob-B2d_dHwI.js → blob-B2Qs47Zi.js} +1 -1
  15. package/dist/assets/cell-editor-3VpJI5EQ.js +21 -0
  16. package/dist/assets/cell-link-DEXHmwy1.js +1 -0
  17. package/dist/assets/{cells-Cp-G34Rz.js → cells--Hh9voS5.js} +25 -25
  18. package/dist/assets/chat-display-DtQ0tOGK.js +1 -0
  19. package/dist/assets/{chat-panel-BlUwNY5j.js → chat-panel-DLgUUTdo.js} +2 -2
  20. package/dist/assets/{chat-ui-DGiVDzNh.js → chat-ui-DIXDoCsM.js} +4 -4
  21. package/dist/assets/{column-preview-riSXbYe_.js → column-preview-H8rmRiii.js} +1 -1
  22. package/dist/assets/{command-palette-CCVzJcyf.js → command-palette-Pmg3QxZ0.js} +1 -1
  23. package/dist/assets/{common-CHR7w7aQ.js → common-CrhvbKbI.js} +1 -1
  24. package/dist/assets/components-DWwMSfV5.js +1 -0
  25. package/dist/assets/components-rCVlCccf.js +1 -0
  26. package/dist/assets/{config-BlNM0caL.js → config-BuGkUPaK.js} +1 -1
  27. package/dist/assets/{copy-icon-z8fuTE3w.js → copy-icon-BUOcnUgJ.js} +1 -1
  28. package/dist/assets/{datasource-DrODSIs0.js → datasource-DgkQfSw3.js} +2 -2
  29. package/dist/assets/{dependency-graph-panel-AY5BEVH2.js → dependency-graph-panel-D1BZdQJH.js} +3 -3
  30. package/dist/assets/dist-0lSCnrrf.js +1 -0
  31. package/dist/assets/dist-CLXTUtr2.js +1 -0
  32. package/dist/assets/{documentation-panel-CaJF7e-j.js → documentation-panel-DzNGB1Zx.js} +1 -1
  33. package/dist/assets/{download-DMxOzI7b.js → download-DtQweFN1.js} +1 -1
  34. package/dist/assets/dropdown-menu-DnvwbPho.js +1 -0
  35. package/dist/assets/edit-page-fb5fV9UA.js +9 -0
  36. package/dist/assets/{error-entries-Cv2m1yhc.js → error-entries-CMsalXvZ.js} +1 -1
  37. package/dist/assets/{error-panel-Bhlvt6_H.js → error-panel-D6kqFA9f.js} +1 -1
  38. package/dist/assets/file-explorer-panel-D3APtOiy.js +1 -0
  39. package/dist/assets/file-icons-wArFRwmS.js +1 -0
  40. package/dist/assets/{file-name-input-K4MKESI_.js → file-name-input-CdDGwb85.js} +3 -3
  41. package/dist/assets/{floating-outline-DaUHnl_e.js → floating-outline-D2WpILR-.js} +1 -1
  42. package/dist/assets/gallery-page-B39w2KuX.js +1 -0
  43. package/dist/assets/{glide-data-editor-sICUMEhk.js → glide-data-editor-BufxOYjB.js} +1 -1
  44. package/dist/assets/home-page-BXgJYrZ5.js +4 -0
  45. package/dist/assets/index-B4Fq20-p.js +29 -0
  46. package/dist/assets/{kiosk-mode-mxgb5lWf.js → kiosk-mode-m6yKu6eh.js} +1 -1
  47. package/dist/assets/{layout-DWnrxIo2.js → layout-VgriO3Ll.js} +5 -5
  48. package/dist/assets/logs-panel-DsbX3K3h.js +1 -0
  49. package/dist/assets/{markdown-renderer-BZKlbm2Q.js → markdown-renderer-DD7ui8RW.js} +1 -1
  50. package/dist/assets/{name-cell-input-BMCdK-el.js → name-cell-input-EjA-eGvA.js} +1 -1
  51. package/dist/assets/{outline-panel-Dr5u73V6.js → outline-panel-DeDFCw9s.js} +1 -1
  52. package/dist/assets/packages-panel-B__MaP9u.js +1 -0
  53. package/dist/assets/{pair-with-agent-modal-CbUFKJHP.js → pair-with-agent-modal-DYvcjx3q.js} +1 -1
  54. package/dist/assets/panel-accordion-state-CwLKISCL.js +1 -0
  55. package/dist/assets/panels-c3iYYVuV.js +4 -0
  56. package/dist/assets/{pathUtils-Cryrlpma.js → pathUtils-D7lk2rYQ.js} +1 -1
  57. package/dist/assets/paths-ClYq6Exe.js +1 -0
  58. package/dist/assets/process-output-DQoLxPra.js +1 -0
  59. package/dist/assets/readonly-code-display-DuFy8860.js +1 -0
  60. package/dist/assets/{readonly-python-code-DpIyjHqY.js → readonly-python-code-yR65TOiM.js} +1 -1
  61. package/dist/assets/{renderShortcut-X-CJUSM8.js → renderShortcut-BE8QI9Yi.js} +1 -1
  62. package/dist/assets/{reveal-component-nZIAapoD.js → reveal-component-CgskYNVn.js} +2 -2
  63. package/dist/assets/rotate-cw-CESctpLh.js +1 -0
  64. package/dist/assets/run-page-C_mciAdT.js +1 -0
  65. package/dist/assets/{scratchpad-panel-BleGt2KM.js → scratchpad-panel-Bj4yxnuS.js} +1 -1
  66. package/dist/assets/{secrets-panel-D3BpDIgg.js → secrets-panel-Cf-U5wY0.js} +1 -1
  67. package/dist/assets/select-C1IYgK48.js +1 -0
  68. package/dist/assets/session-panel-NQyDQouJ.js +1 -0
  69. package/dist/assets/share-BZW3tzEX.js +1 -0
  70. package/dist/assets/{skeleton-BKeh8hf3.js → skeleton-CUFHwpIk.js} +1 -1
  71. package/dist/assets/{snippets-panel-D5yy7kj0.js → snippets-panel-Bx2wFck8.js} +1 -1
  72. package/dist/assets/{state-B6AklCzD.js → state-CdjswcRf.js} +1 -1
  73. package/dist/assets/state-CiPrV156.js +3 -0
  74. package/dist/assets/switch-DhPDzMo3.js +1 -0
  75. package/dist/assets/{terminal-CQAFGBfN.js → terminal-DH54UV0y.js} +2 -2
  76. package/dist/assets/tooltip-BvU0ko_d.js +1 -0
  77. package/dist/assets/tracing-Qjfb3Qm1.js +1 -0
  78. package/dist/assets/tracing-panel-Cj_-LD2X.js +2 -0
  79. package/dist/assets/{tree-actions-CG5g7aUQ.js → tree-actions-CmY9PFuu.js} +1 -1
  80. package/dist/assets/{useAddCell-DdB_uBif.js → useAddCell-Bvb-C_H5.js} +1 -1
  81. package/dist/assets/{useBoolean-BXC4CItZ.js → useBoolean-zcg-oxnj.js} +1 -1
  82. package/dist/assets/useCellActionButton-Df4qSnWR.js +1 -0
  83. package/dist/assets/{useDeleteCell-Bz49_cFj.js → useDeleteCell-eNMTvg8D.js} +1 -1
  84. package/dist/assets/useDependencyPanelTab-BusYWoB8.js +1 -0
  85. package/dist/assets/useInstallPackage-ClaR_nYb.js +1 -0
  86. package/dist/assets/useNotebookActions-bWJW4dS_.js +10 -0
  87. package/dist/assets/{useRunCells-CX7oW5zy.js → useRunCells-D8B7UNsg.js} +1 -1
  88. package/dist/assets/{useSplitCell-Dy2_DmJR.js → useSplitCell-Cy7fCcQW.js} +1 -1
  89. package/dist/assets/{vega-component-C7TCzyaU.js → vega-component-Z8mt9AUF.js} +1 -1
  90. package/dist/assets/{write-secret-modal-D6zoZgLY.js → write-secret-modal-CSWlDX_Z.js} +1 -1
  91. package/dist/index.html +36 -35
  92. package/package.json +1 -1
  93. package/src/__mocks__/requests.ts +7 -2
  94. package/src/components/data-table/column-visibility-dropdown.tsx +9 -3
  95. package/src/components/datasources/components.tsx +4 -2
  96. package/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx +143 -0
  97. package/src/components/editor/chrome/panels/packages-panel.tsx +145 -51
  98. package/src/components/editor/package-alert.tsx +25 -1
  99. package/src/components/home/components.tsx +17 -0
  100. package/src/components/pages/gallery-page.tsx +2 -4
  101. package/src/components/pages/home-page.tsx +2 -4
  102. package/src/components/terminal/terminal.tsx +4 -4
  103. package/src/core/__tests__/mode.test.ts +8 -1
  104. package/src/core/islands/__tests__/parse.test.ts +140 -7
  105. package/src/core/islands/parse.ts +20 -0
  106. package/src/core/packages/__tests__/useInstallPackage.test.tsx +47 -1
  107. package/src/core/packages/toast-components.tsx +26 -0
  108. package/src/core/packages/useInstallPackage.ts +7 -2
  109. package/src/core/runtime/__tests__/runtime.test.ts +11 -0
  110. package/src/core/runtime/runtime.ts +7 -2
  111. package/src/core/wasm/bridge.ts +1 -0
  112. package/dist/assets/JsonOutput-CzIGPEZQ.js +0 -50
  113. package/dist/assets/LazyAnyLanguageCodeMirror-LboTfNDv.js +0 -2
  114. package/dist/assets/add-cell-with-ai-R-3DS79K.js +0 -76
  115. package/dist/assets/agent-panel-Cgt_K0tD.js +0 -286
  116. package/dist/assets/ai-model-dropdown-DCmiuk7x.js +0 -3
  117. package/dist/assets/app-config-button-DUJC6b6x.js +0 -1
  118. package/dist/assets/cell-editor-Dw09J9yD.js +0 -21
  119. package/dist/assets/cell-link-6burT2XF.js +0 -1
  120. package/dist/assets/chat-display-Bu405iyc.js +0 -1
  121. package/dist/assets/components-C7mWrmXr.js +0 -1
  122. package/dist/assets/dist-DzCQtGkt.js +0 -1
  123. package/dist/assets/dropdown-menu-C40jM9o4.js +0 -1
  124. package/dist/assets/edit-page-xlMlcLnI.js +0 -9
  125. package/dist/assets/file-explorer-panel-s0ohSG_L.js +0 -1
  126. package/dist/assets/file-icons-DdGYuADJ.js +0 -1
  127. package/dist/assets/gallery-page-C3pBpHlY.js +0 -1
  128. package/dist/assets/home-page-BLd6rnbk.js +0 -4
  129. package/dist/assets/index-4n22QjCD.js +0 -29
  130. package/dist/assets/logs-panel-BGS2v3ba.js +0 -1
  131. package/dist/assets/packages-panel-BdpRg9tX.js +0 -1
  132. package/dist/assets/panel-accordion-state-DjUTN7i5.js +0 -1
  133. package/dist/assets/panels-CWn0Yh1D.js +0 -4
  134. package/dist/assets/paths-zcL04qUW.js +0 -1
  135. package/dist/assets/process-output-Ck7-P_xp.js +0 -1
  136. package/dist/assets/readonly-code-display--S2daDa6.js +0 -1
  137. package/dist/assets/run-page-9pl8qhQR.js +0 -1
  138. package/dist/assets/select-nLt2y0Sw.js +0 -1
  139. package/dist/assets/session-panel-DRGPlL5J.js +0 -1
  140. package/dist/assets/share-CPtBiNgr.js +0 -1
  141. package/dist/assets/state-Di9TbuV9.js +0 -3
  142. package/dist/assets/switch-DjXr9Y9D.js +0 -1
  143. package/dist/assets/tooltip-BUtPzKB4.js +0 -1
  144. package/dist/assets/tracing-DNk3gmWv.js +0 -1
  145. package/dist/assets/tracing-panel-Yqazr6w_.js +0 -2
  146. package/dist/assets/useCellActionButton-B31neI3m.js +0 -1
  147. package/dist/assets/useDependencyPanelTab-C_ps0r--.js +0 -1
  148. package/dist/assets/useInstallPackage-DsD08SLK.js +0 -1
  149. package/dist/assets/useNotebookActions-CQtbk9CB.js +0 -10
@@ -19,6 +19,13 @@ import {
19
19
  } from "../parse";
20
20
  import { createMockIslandElement, createMockIslands } from "./test-utils.tsx";
21
21
 
22
+ function islandSnapshotPath(filename: string): string {
23
+ return new URL(
24
+ `../../../../../tests/_islands/snapshots/${filename}`,
25
+ import.meta.url,
26
+ ).pathname.replace(/^\/@fs/, "");
27
+ }
28
+
22
29
  function createPayloadCell(
23
30
  overrides: Partial<{
24
31
  cellId: string;
@@ -47,6 +54,7 @@ function appendPayload(
47
54
  payload: {
48
55
  schemaVersion: number;
49
56
  appId: string;
57
+ dependencies?: unknown;
50
58
  cells: ReturnType<typeof createPayloadCell>[];
51
59
  },
52
60
  ) {
@@ -58,6 +66,33 @@ function appendPayload(
58
66
  }
59
67
 
60
68
  describe("createMarimoFile", () => {
69
+ it("should serialize dependencies as top-level script metadata", () => {
70
+ const file = createMarimoFile({
71
+ dependencies: ['cowsay==6.1; sys_platform == "emscripten"'],
72
+ cells: [{ code: "import cowsay" }],
73
+ });
74
+ expect(file).toBe(
75
+ [
76
+ "# /// script",
77
+ '# dependencies = ["cowsay==6.1; sys_platform == \\"emscripten\\""]',
78
+ "# ///",
79
+ "import marimo",
80
+ "app = marimo.App()",
81
+ "@app.cell",
82
+ "def __():",
83
+ " import cowsay",
84
+ " return",
85
+ ].join("\n"),
86
+ );
87
+ });
88
+
89
+ it("should omit metadata for empty dependencies", () => {
90
+ const cells = [{ code: "import cowsay" }];
91
+ expect(createMarimoFile({ cells, dependencies: [] })).toBe(
92
+ createMarimoFile({ cells }),
93
+ );
94
+ });
95
+
61
96
  it("should return a string", () => {
62
97
  const app = {
63
98
  cells: [
@@ -736,13 +771,7 @@ describe("parseMarimoIslandApps", () => {
736
771
  });
737
772
 
738
773
  it("should parse Python-generated island payload snapshots", () => {
739
- const html = readFileSync(
740
- new URL(
741
- "../../../../../tests/_islands/snapshots/html-payload.txt",
742
- import.meta.url,
743
- ).pathname.replace(/^\/@fs/, ""),
744
- "utf8",
745
- );
774
+ const html = readFileSync(islandSnapshotPath("html-payload.txt"), "utf8");
746
775
  container.innerHTML = html;
747
776
 
748
777
  const result = parseMarimoIslandApps(container);
@@ -775,6 +804,108 @@ describe("parseMarimoIslandApps", () => {
775
804
  expect(islands[2].getAttribute(ISLAND_DATA_ATTRIBUTES.CELL_IDX)).toBe("1");
776
805
  });
777
806
 
807
+ it("should restore metadata from a Python-generated dependency payload", () => {
808
+ container.innerHTML = readFileSync(
809
+ islandSnapshotPath("body-dependencies.txt"),
810
+ "utf8",
811
+ );
812
+
813
+ const probed = parseMarimoIslandApps(container, { materialize: false });
814
+ const apps = parseMarimoIslandApps(container);
815
+
816
+ expect(probed).toEqual(apps);
817
+ expect(apps).toEqual([
818
+ {
819
+ id: "main",
820
+ payloadBacked: true,
821
+ dependencies: [
822
+ 'cowsay==6.1; sys_platform == "emscripten"',
823
+ "rich[jupyter]>=13",
824
+ "desktop; sys_platform != 'emscripten'",
825
+ "older-python; python_version < '3.13'",
826
+ "newer-python; python_version >= '3.13'",
827
+ ],
828
+ cells: [{ cellId: "Hbol", code: "import cowsay", output: "", idx: 0 }],
829
+ },
830
+ ]);
831
+ // The Python Pyodide test reads this file with the real metadata parser.
832
+ expect(createMarimoFile(apps[0])).toBe(
833
+ readFileSync(islandSnapshotPath("notebook-dependencies.txt"), "utf8"),
834
+ );
835
+ });
836
+
837
+ it("should carry dependencies from payloads into each generated notebook", () => {
838
+ for (const [appId, dependencies] of [
839
+ ["app1", ["cowsay==6.1"]],
840
+ ["app2", ["rich[jupyter]>=13"]],
841
+ ] as const) {
842
+ container.appendChild(
843
+ createMockIslandElement({ appId, cellId: "cell-1" }),
844
+ );
845
+ appendPayload(container, {
846
+ schemaVersion: 1,
847
+ appId,
848
+ dependencies,
849
+ cells: [createPayloadCell()],
850
+ });
851
+ }
852
+
853
+ const apps = parseMarimoIslandApps(container);
854
+ expect(apps.map((app) => [app.id, app.dependencies])).toEqual([
855
+ ["app1", ["cowsay==6.1"]],
856
+ ["app2", ["rich[jupyter]>=13"]],
857
+ ]);
858
+ expect(createMarimoFile(apps[0])).toContain(
859
+ '# /// script\n# dependencies = ["cowsay==6.1"]\n# ///\n',
860
+ );
861
+ });
862
+
863
+ it.each([null, "cowsay", [123], ["cowsay", null]])(
864
+ "should ignore payloads with malformed dependencies: %j",
865
+ (dependencies) => {
866
+ const island = createMockIslandElement({
867
+ appId: "app1",
868
+ cellId: "cell-1",
869
+ code: "import cowsay",
870
+ innerHTML: "<div>dom</div>",
871
+ });
872
+ island.setAttribute(ISLAND_DATA_ATTRIBUTES.REACTIVE, "true");
873
+ container.appendChild(island);
874
+ appendPayload(container, {
875
+ schemaVersion: 1,
876
+ appId: "app1",
877
+ dependencies,
878
+ cells: [createPayloadCell()],
879
+ });
880
+
881
+ expect(parseMarimoIslandApps(container)).toEqual([
882
+ {
883
+ id: "app1",
884
+ cells: [{ code: "import cowsay", output: "<div>dom</div>", idx: 0 }],
885
+ },
886
+ ]);
887
+ },
888
+ );
889
+
890
+ it("should merge dependencies from payloads belonging to the same app", () => {
891
+ for (const [cellId, dependencies] of [
892
+ ["cell-1", ["cowsay"]],
893
+ ["cell-2", ["cowsay", "rich"]],
894
+ ] as const) {
895
+ container.appendChild(createMockIslandElement({ appId: "app1", cellId }));
896
+ appendPayload(container, {
897
+ schemaVersion: 1,
898
+ appId: "app1",
899
+ dependencies,
900
+ cells: [createPayloadCell({ cellId })],
901
+ });
902
+ }
903
+
904
+ expect(
905
+ parseMarimoIslandApps(container).map((app) => app.dependencies),
906
+ ).toEqual([["cowsay", "rich"]]);
907
+ });
908
+
778
909
  it("should fall back to DOM islands for unsupported payload versions", () => {
779
910
  const island = createMockIslandElement({
780
911
  appId: "app1",
@@ -990,6 +1121,7 @@ describe("parseMarimoIslandApps", () => {
990
1121
  outputHtml: "<div>payload only</div>",
991
1122
  }),
992
1123
  ],
1124
+ dependencies: ["cowsay"],
993
1125
  });
994
1126
 
995
1127
  const result = parseMarimoIslandApps(container);
@@ -1076,6 +1208,7 @@ describe("parseMarimoIslandApps", () => {
1076
1208
  reactive: false,
1077
1209
  }),
1078
1210
  ],
1211
+ dependencies: ["cowsay"],
1079
1212
  });
1080
1213
 
1081
1214
  const result = parseMarimoIslandApps(container);
@@ -30,6 +30,8 @@ export interface MarimoIslandApp {
30
30
  * Whether cells came from a supported JSON payload instead of DOM parsing.
31
31
  */
32
32
  payloadBacked?: boolean;
33
+ /** Explicit notebook dependencies to install before starting the app. */
34
+ dependencies?: string[];
33
35
  /**
34
36
  * Cells in the app.
35
37
  */
@@ -62,6 +64,7 @@ interface MarimoIslandCell {
62
64
  interface MarimoIslandPayload {
63
65
  schemaVersion: 1;
64
66
  appId: string;
67
+ dependencies?: string[];
65
68
  cells: MarimoIslandPayloadCell[];
66
69
  }
67
70
 
@@ -235,6 +238,12 @@ function parsePayloadBackedApps({
235
238
  embed?.setAttribute(ISLAND_DATA_ATTRIBUTES.CELL_IDX, idx.toString());
236
239
  }
237
240
  }
241
+ const app = apps.get(payload.appId);
242
+ if (app && payload.dependencies?.length) {
243
+ app.dependencies = [
244
+ ...new Set([...(app.dependencies ?? []), ...payload.dependencies]),
245
+ ];
246
+ }
238
247
  }
239
248
 
240
249
  // A supported payload is the runtime source for its app. Extra same-app DOM
@@ -371,6 +380,7 @@ export function parseIslandElement(
371
380
 
372
381
  export function createMarimoFile(app: {
373
382
  cells: { code: string; disabled?: boolean }[];
383
+ dependencies?: string[];
374
384
  }): string {
375
385
  const lines = [
376
386
  "import marimo",
@@ -402,6 +412,13 @@ export function createMarimoFile(app: {
402
412
  .join("\n"),
403
413
  ];
404
414
 
415
+ if (app.dependencies?.length) {
416
+ lines.unshift(
417
+ "# /// script",
418
+ `# dependencies = ${JSON.stringify(app.dependencies)}`,
419
+ "# ///",
420
+ );
421
+ }
405
422
  return lines.join("\n");
406
423
  }
407
424
 
@@ -507,6 +524,9 @@ function isMarimoIslandPayload(
507
524
  return (
508
525
  payload.schemaVersion === 1 &&
509
526
  typeof payload.appId === "string" &&
527
+ (payload.dependencies === undefined ||
528
+ (Array.isArray(payload.dependencies) &&
529
+ payload.dependencies.every((dep) => typeof dep === "string"))) &&
510
530
  Array.isArray(payload.cells) &&
511
531
  payload.cells.every(isMarimoIslandPayloadCell)
512
532
  );
@@ -1,10 +1,22 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
- import { act, renderHook } from "@testing-library/react";
2
+ import {
3
+ act,
4
+ fireEvent,
5
+ render,
6
+ renderHook,
7
+ screen,
8
+ } from "@testing-library/react";
3
9
  import { beforeEach, describe, expect, it, vi } from "vitest";
4
10
  import { useInstallPackages } from "../useInstallPackage";
11
+ import { Toast, ToastProvider, ToastViewport } from "@/components/ui/toast";
5
12
 
6
13
  const toast = vi.fn();
7
14
  const addPackage = vi.fn();
15
+ const restartKernel = vi.fn();
16
+
17
+ vi.mock("@/components/editor/actions/useRestartKernel", () => ({
18
+ useRestartKernel: () => restartKernel,
19
+ }));
8
20
 
9
21
  vi.mock("@/components/ui/use-toast", () => ({
10
22
  toast: (...args: unknown[]) => toast(...args),
@@ -20,6 +32,7 @@ describe("useInstallPackages", () => {
20
32
  beforeEach(() => {
21
33
  toast.mockClear();
22
34
  addPackage.mockClear();
35
+ restartKernel.mockClear();
23
36
  });
24
37
 
25
38
  it("batches all packages into a single install call", async () => {
@@ -109,6 +122,39 @@ describe("useInstallPackages", () => {
109
122
  );
110
123
  });
111
124
 
125
+ it("reports saved changes requiring restart without claiming installation", async () => {
126
+ addPackage.mockResolvedValue({
127
+ success: false,
128
+ error: null,
129
+ restartRequired: true,
130
+ });
131
+ const { result } = renderHook(() => useInstallPackages());
132
+ await act(async () => {
133
+ await result.current.handleInstallPackages(["boltons", "six"]);
134
+ });
135
+ expect(toast).toHaveBeenCalledTimes(1);
136
+ expect(toast).toHaveBeenCalledWith(
137
+ expect.objectContaining({
138
+ title: "Changes saved — restart required",
139
+ description: expect.stringContaining(
140
+ "Restarting clears in-memory variables",
141
+ ),
142
+ duration: Infinity,
143
+ action: expect.anything(),
144
+ }),
145
+ );
146
+ expect(toast.mock.calls[0][0].variant).not.toBe("danger");
147
+ render(
148
+ <ToastProvider>
149
+ <Toast>{toast.mock.calls[0][0].action}</Toast>
150
+ <ToastViewport />
151
+ </ToastProvider>,
152
+ );
153
+ expect(restartKernel).not.toHaveBeenCalled();
154
+ fireEvent.click(screen.getByRole("button", { name: "Restart Kernel" }));
155
+ expect(restartKernel).toHaveBeenCalledTimes(1);
156
+ });
157
+
112
158
  it("calls onSuccess after a successful install", async () => {
113
159
  addPackage.mockResolvedValue({ success: true, error: null });
114
160
  const onSuccess = vi.fn();
@@ -1,8 +1,34 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
+ import { useRestartKernel } from "@/components/editor/actions/useRestartKernel";
3
4
  import { Kbd } from "@/components/ui/kbd";
5
+ import { ToastAction } from "@/components/ui/toast";
4
6
  import { toast } from "@/components/ui/use-toast";
5
7
 
8
+ export const RESTART_REQUIRED_DESCRIPTION =
9
+ "Your dependency changes are saved. Restart the kernel to use the updated environment. Restarting clears in-memory variables.";
10
+
11
+ const RestartKernelAction = () => {
12
+ const restartKernel = useRestartKernel();
13
+ return (
14
+ <ToastAction
15
+ altText="Restart the kernel to use the updated dependencies"
16
+ onClick={restartKernel}
17
+ >
18
+ Restart Kernel
19
+ </ToastAction>
20
+ );
21
+ };
22
+
23
+ export const showPackageRestartToast = () => {
24
+ toast({
25
+ title: "Changes saved — restart required",
26
+ description: RESTART_REQUIRED_DESCRIPTION,
27
+ duration: Infinity,
28
+ action: <RestartKernelAction />,
29
+ });
30
+ };
31
+
6
32
  export const showAddPackageToast = (
7
33
  packageName: string | string[],
8
34
  error?: string | null,
@@ -3,7 +3,10 @@
3
3
  import { useState } from "react";
4
4
  import { Logger } from "@/utils/Logger";
5
5
  import { useRequestClient } from "../network/requests";
6
- import { showAddPackageToast } from "./toast-components";
6
+ import {
7
+ showAddPackageToast,
8
+ showPackageRestartToast,
9
+ } from "./toast-components";
7
10
 
8
11
  export function useInstallPackages(): {
9
12
  handleInstallPackages: (
@@ -30,7 +33,9 @@ export function useInstallPackages(): {
30
33
  // response only carries an aggregate success/error. Report a single
31
34
  // toast covering all requested packages rather than implying a
32
35
  // per-package outcome we don't actually have.
33
- if (response.success) {
36
+ if (response.restartRequired) {
37
+ showPackageRestartToast();
38
+ } else if (response.success) {
34
39
  showAddPackageToast(packages);
35
40
  } else {
36
41
  showAddPackageToast(packages, response.error);
@@ -276,6 +276,17 @@ describe("RuntimeManager", () => {
276
276
  });
277
277
 
278
278
  describe("getTerminalWsURL", () => {
279
+ it("should include dimensions in the terminal handshake", () => {
280
+ const runtime = new RuntimeManager(mockConfig);
281
+ const url = runtime.getTerminalWsURL({ rows: 30, cols: 140 });
282
+
283
+ expect(Object.fromEntries(url.searchParams)).toEqual({
284
+ access_token: "test-token",
285
+ rows: "30",
286
+ cols: "140",
287
+ });
288
+ });
289
+
279
290
  it("should return terminal WebSocket URL", () => {
280
291
  const runtime = new RuntimeManager(mockConfig);
281
292
  const url = runtime.getTerminalWsURL();
@@ -183,8 +183,13 @@ export class RuntimeManager {
183
183
  /**
184
184
  * The WebSocket URL of the terminal.
185
185
  */
186
- getTerminalWsURL(): URL {
187
- return this.formatWsURL("/terminal/ws");
186
+ getTerminalWsURL(size?: { rows: number; cols: number }): URL {
187
+ const url = this.formatWsURL("/terminal/ws");
188
+ if (size) {
189
+ url.searchParams.set("rows", String(size.rows));
190
+ url.searchParams.set("cols", String(size.cols));
191
+ }
192
+ return url;
188
193
  }
189
194
 
190
195
  /**
@@ -649,6 +649,7 @@ export class PyodideBridge implements RunRequests, EditRequests {
649
649
  tags: [],
650
650
  version: null,
651
651
  },
652
+ context: { kind: "package-manager", name: "micropip" },
652
653
  };
653
654
  };
654
655