@marimo-team/islands 0.25.3-dev485 → 0.25.3-dev487

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 (89) hide show
  1. package/dist/{ConnectedDataExplorerComponent-LA5OtjAG.js → ConnectedDataExplorerComponent-BV2GFVYn.js} +9 -9
  2. package/dist/{ErrorBoundary-CodLzVG5.js → ErrorBoundary-CKgl5BPB.js} +6 -6
  3. package/dist/{abnfDiagram-VCTEODGH-CBntFgCZ.js → abnfDiagram-VCTEODGH-1AWrWE-o.js} +2 -2
  4. package/dist/{any-language-editor-gzDRWdCH.js → any-language-editor-Dqpg95i0.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-Bz6ouXl-.js → architectureDiagram-5GKGNRK7-D0zM5fGn.js} +1 -1
  6. package/dist/{assertNever-DOTNJ2Y4.js → assertNever-BQEDS5Ew.js} +2 -2
  7. package/dist/{chat-ui-Covffkhg.js → chat-ui-Blvl4-Kd.js} +12 -12
  8. package/dist/{check-CApwK1fD.js → check-BTnCP_6g.js} +1 -1
  9. package/dist/{chunk-IMKFNOWR-DK_M66Dt.js → chunk-IMKFNOWR-CTe-GyEo.js} +1 -1
  10. package/dist/{chunk-SHT3W25Y-C7Cg6zGL.js → chunk-SHT3W25Y-mDvz0_Bb.js} +1 -1
  11. package/dist/{chunk-SVP7TREG-K0lWia53.js → chunk-SVP7TREG-TQe5CTi-.js} +1 -1
  12. package/dist/{chunk-TICWLB2K-DiKpryGp.js → chunk-TICWLB2K-DueGZcaL.js} +1 -1
  13. package/dist/{classDiagram-ZZMXUADV-CXX5eaxi.js → classDiagram-ZZMXUADV-C80WtbRl.js} +2 -2
  14. package/dist/{classDiagram-v2-VYDZK3BY-Bjyy4iKL.js → classDiagram-v2-VYDZK3BY-BGUFGXB1.js} +2 -2
  15. package/dist/{code-visibility-BauZWifR.js → code-visibility-CCSRGVdJ.js} +5 -5
  16. package/dist/{common-DeBx86ld.js → common-DJZmfqr8.js} +19 -19
  17. package/dist/{config-C8TXSDmC.js → config-DbjezUyA.js} +3 -3
  18. package/dist/{copy-icon-CDvvlY90.js → copy-icon-7bY-OuK1.js} +2 -2
  19. package/dist/{createReducer-CXqSak4H.js → createReducer-BTiEYD5d.js} +1 -1
  20. package/dist/{cynefinDiagram-5FMLGOSQ-C-MlCYj4.js → cynefinDiagram-5FMLGOSQ-B1FxtX7q.js} +1 -1
  21. package/dist/{dagre-GXQ25YYZ-C6e9vEKZ.js → dagre-GXQ25YYZ-DsaxsLKR.js} +1 -1
  22. package/dist/{data-grid-overlay-editor-BzEmIb3z.js → data-grid-overlay-editor-CoCQnhxw.js} +1 -1
  23. package/dist/{diagram-S7CK7UJ4-DgXNq_At.js → diagram-S7CK7UJ4-0_x8Q-Gz.js} +1 -1
  24. package/dist/{diagram-UQ7AKVKN-BG5NExCt.js → diagram-UQ7AKVKN-nvR7yqd-.js} +1 -1
  25. package/dist/{diagram-VX7I27RA-Da7VYCfC.js → diagram-VX7I27RA-BnEUU78X.js} +1 -1
  26. package/dist/{diagram-Z3DM3KII-DHk6GaR5.js → diagram-Z3DM3KII-BHX2x9ql.js} +1 -1
  27. package/dist/{dialog-rgayPemF.js → dialog-CBKdXrw9.js} +2 -2
  28. package/dist/{dropdown-menu-B12Nf3Zf.js → dropdown-menu-218IIk7S.js} +5 -5
  29. package/dist/{ebnfDiagram-PWID7BFC-DdSjinXr.js → ebnfDiagram-PWID7BFC-DYZD7-aw.js} +2 -2
  30. package/dist/{erDiagram-RLTQ6QDP-BgcwfZct.js → erDiagram-RLTQ6QDP-Bv-0tHzX.js} +1 -1
  31. package/dist/{error-banner-DXHIN-63.js → error-banner-cub3qDum.js} +1 -1
  32. package/dist/{error-entries-C4OopOce.js → error-entries-MZLN-feW.js} +11 -25
  33. package/dist/{feedback-button-BTYGJiow.js → feedback-button-BH8UID5_.js} +7 -7
  34. package/dist/{flowDiagram-HODETNUW-CVwzkmUF.js → flowDiagram-HODETNUW-BV2Dug--.js} +2 -2
  35. package/dist/{formats-BWuAsLfw.js → formats-CBWqzCiR.js} +1 -1
  36. package/dist/{glide-data-editor-Bcy2IE3H.js → glide-data-editor-D3HQ_xaE.js} +11 -11
  37. package/dist/{glide-utils-D1McS0Pn.js → glide-utils-DlglW_uh.js} +2 -2
  38. package/dist/{globals-9AyCoAnh.js → globals-DfUGFJr_.js} +3 -3
  39. package/dist/{html-to-image-95V1hWZu.js → html-to-image-D6h4lzXj.js} +48 -48
  40. package/dist/{infoDiagram-27XIBGKW-CHkU2P-8.js → infoDiagram-27XIBGKW-xekhSKlY.js} +1 -1
  41. package/dist/{ishikawaDiagram-5VMMS53U-B0k5UyY5.js → ishikawaDiagram-5VMMS53U-Coe7mUqv.js} +1 -1
  42. package/dist/{kanban-definition-UXKFOSKX-DwQvOV0x.js → kanban-definition-UXKFOSKX-Znywqtyi.js} +1 -1
  43. package/dist/main.js +8222 -8216
  44. package/dist/{mermaid-Bqy6f_NU.js → mermaid-DRT7MewO.js} +34 -34
  45. package/dist/{mindmap-definition-YA3MSWOX-CqvvAm8I.js → mindmap-definition-YA3MSWOX-Do_NrRXE.js} +1 -1
  46. package/dist/{number-overlay-editor-aEdDUAzH.js → number-overlay-editor-BzPKuji4.js} +1 -1
  47. package/dist/{pegDiagram-XKGWAZYB-Befnx4Ry.js → pegDiagram-XKGWAZYB-CTuwofVH.js} +2 -2
  48. package/dist/{pencil-BC7pOv9g.js → pencil-qedVMD6q.js} +1 -1
  49. package/dist/{pieDiagram-E7YTZNPT-6rYFbF7p.js → pieDiagram-E7YTZNPT-CFHRBvha.js} +1 -1
  50. package/dist/{process-output-DPHxrq7D.js → process-output-MYh-Vr__.js} +4 -4
  51. package/dist/{railroadDiagram-O6MQD6OU-SSniwYC8.js → railroadDiagram-O6MQD6OU-BJBqS4A3.js} +2 -2
  52. package/dist/{requirementDiagram-BXWQKSXE-3L_xNfQr.js → requirementDiagram-BXWQKSXE-CoMoIh3b.js} +1 -1
  53. package/dist/{reveal-component-_1Vpg1lV.js → reveal-component-cvMIqV4P.js} +7 -7
  54. package/dist/{select-PQHWLm64.js → select-BcEi9lad.js} +4 -4
  55. package/dist/{sequenceDiagram-WJ2MYXX4-DvzIRlWu.js → sequenceDiagram-WJ2MYXX4-Cu7Mpp-z.js} +1 -1
  56. package/dist/{spec-6shN7lEe.js → spec-AxyC1vc5.js} +4 -4
  57. package/dist/{stateDiagram-D77RDMKH-VsHup-Ig.js → stateDiagram-D77RDMKH-DX7_Rnib.js} +2 -2
  58. package/dist/{stateDiagram-v2-MP3YSRHH-BwIIR8nk.js → stateDiagram-v2-MP3YSRHH-oFXVbGoo.js} +2 -2
  59. package/dist/{static-state-CWXd6dYX.js → static-state-CqzVppxA.js} +1 -1
  60. package/dist/{swimlanes-42K2YHIH-DhSDCIWI.js → swimlanes-42K2YHIH-CxzCGtVZ.js} +1 -1
  61. package/dist/{swimlanesDiagram-VR7AAH4N-C2WGVm-W.js → swimlanesDiagram-VR7AAH4N-1a1GRLNf.js} +2 -2
  62. package/dist/{timeline-definition-24CTP7MA-DhUhNinO.js → timeline-definition-24CTP7MA-Pfn2awsU.js} +1 -1
  63. package/dist/{toast-BGvv7tKS.js → toast-aYa8V5tR.js} +3 -3
  64. package/dist/{tooltip-CiJ919pg.js → tooltip-CwQmweEz.js} +1 -1
  65. package/dist/{use-restore-focus-BLj45Ibw.js → use-restore-focus-DlX1CSiq.js} +6 -1
  66. package/dist/{useDateFormatter-C659lkax.js → useDateFormatter-BAckjdIS.js} +2 -2
  67. package/dist/{useDeepCompareMemoize-CDhinwm7.js → useDeepCompareMemoize-C6mte0N8.js} +1 -1
  68. package/dist/{useLifecycle-mKiMNa4V.js → useLifecycle-XZ5KJAFU.js} +1 -1
  69. package/dist/{vega-component-CWvQ7wBJ.js → vega-component-_We1FoNw.js} +6 -6
  70. package/dist/{vennDiagram-4TSXK5OY-exvBF8P5.js → vennDiagram-4TSXK5OY-DrIqDugg.js} +1 -1
  71. package/dist/{wardleyDiagram-VM6X3IG4-BFhJmnXo.js → wardleyDiagram-VM6X3IG4-DBPVNfc3.js} +1 -1
  72. package/dist/{xychartDiagram-S5SC5T6Z-D_xAdG6u.js → xychartDiagram-S5SC5T6Z-64Isocef.js} +1 -1
  73. package/package.json +1 -1
  74. package/src/components/dependency-graph/__tests__/elements.test.ts +20 -11
  75. package/src/components/dependency-graph/dependency-graph-tree.tsx +17 -3
  76. package/src/components/dependency-graph/elements.ts +12 -25
  77. package/src/components/editor/cell/ReusableDefinitionBadge.tsx +62 -0
  78. package/src/components/editor/notebook-cell.tsx +7 -66
  79. package/src/core/cells/__tests__/cells.test.ts +0 -3
  80. package/src/core/cells/actions.ts +0 -1
  81. package/src/core/cells/cells.ts +0 -12
  82. package/src/core/cells/execution-console.ts +0 -2
  83. package/src/core/cells/reusable-definition.ts +25 -0
  84. package/src/core/cells/types.ts +1 -6
  85. package/src/core/executions/__tests__/select.test.ts +2 -2
  86. package/src/core/islands/bootstrap.ts +0 -8
  87. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +1 -1
  88. package/src/core/session/active-notebook.ts +6 -0
  89. package/src/core/session/useNotebookSession.tsx +0 -9
@@ -2,7 +2,7 @@ import { i as e } from "./chunk-75Z2AOVW-76L6My3P.js";
2
2
  import { n as t } from "./src-D5uZaZib.js";
3
3
  import { n } from "./chunk-Y2CYZVJY-DKKS1VyV.js";
4
4
  import { D as r, H as i, K as a, U as o, a as s, b as c, c as l, v as u, w as d, x as f, y as p } from "./chunk-DU6HZSFF-4SDIhUTY.js";
5
- import { p as m } from "./mermaid-Bqy6f_NU.js";
5
+ import { p as m } from "./mermaid-DRT7MewO.js";
6
6
  import { n as h } from "./mermaid-parser.core-DtOnl7m4.js";
7
7
  import { t as g } from "./chunk-JWPE2WC7-DJvv1t8U.js";
8
8
  //#region ../node_modules/.pnpm/mermaid@11.17.2/node_modules/mermaid/dist/chunks/mermaid.core/wardleyDiagram-VM6X3IG4.mjs
@@ -9,7 +9,7 @@ import { n as s } from "./chunk-Y2CYZVJY-DKKS1VyV.js";
9
9
  import { D as c, H as l, K as u, U as d, a as f, b as p, c as m, f as h, v as g, w as _, y as v, z as y } from "./chunk-DU6HZSFF-4SDIhUTY.js";
10
10
  import "./chunk-PWAF6VOD-CRu_RGP2.js";
11
11
  import { t as b } from "./chunk-GMAD6QVW-BJGF8QZL.js";
12
- import { p as x } from "./mermaid-Bqy6f_NU.js";
12
+ import { p as x } from "./mermaid-DRT7MewO.js";
13
13
  //#region ../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/band.js
14
14
  function S() {
15
15
  var e = t().unknown(void 0), r = e.domain, i = e.range, o = 0, s = 1, c, l, u = !1, d = 0, f = 0, p = .5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.25.3-dev485",
3
+ "version": "0.25.3-dev487",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -3,7 +3,7 @@
3
3
  import { describe, expect, it } from "vitest";
4
4
  import type { CellId } from "@/core/cells/ids";
5
5
  import type { Variable, VariableName, Variables } from "@/core/variables/types";
6
- import { createCellRuntimeState } from "@/core/cells/types";
6
+ import type { CellDiagnostic } from "@marimo-team/client/protocol";
7
7
  import {
8
8
  collapsedNodeWidth,
9
9
  computeDefsByCell,
@@ -136,16 +136,25 @@ describe("reusableCellIds", () => {
136
136
  const c2 = "c2" as CellId;
137
137
  const c3 = "c3" as CellId;
138
138
 
139
- it("collects cells whose serialization hint is valid, case-insensitively", () => {
140
- const runtime = {
141
- [c1]: createCellRuntimeState({ serialization: "Valid" }),
142
- [c2]: createCellRuntimeState({ serialization: "Unparsable" }),
143
- [c3]: createCellRuntimeState(),
139
+ it("hides only reusable definitions reported by marimo", () => {
140
+ const valid: CellDiagnostic = {
141
+ source: "marimo",
142
+ kind: "reusable-definition",
143
+ severity: "information",
144
+ message: "Importable when saved as Python.",
145
+ range: null,
146
+ related: [],
144
147
  };
145
- expect(reusableCellIds([c1, c2, c3], runtime)).toEqual(new Set([c1]));
146
- });
147
-
148
- it("ignores cells with no runtime entry", () => {
149
- expect(reusableCellIds([c1], {})).toEqual(new Set());
148
+ const cell = { defs: [], refs: [], diagnostics: [valid] };
149
+ const cells = {
150
+ [c1]: cell,
151
+ [c2]: {
152
+ ...cell,
153
+ diagnostics: [{ ...valid, kind: "non-reusable-definition" }],
154
+ },
155
+ [c3]: { ...cell, diagnostics: [{ ...valid, source: "other" }] },
156
+ };
157
+ expect(reusableCellIds([c1, c2, c3], cells)).toEqual(new Set([c1]));
158
+ expect(reusableCellIds([c1], undefined)).toEqual(new Set());
150
159
  });
151
160
  });
@@ -28,12 +28,14 @@ import {
28
28
  import { lastFocusedCellIdAtom } from "@/core/cells/focus";
29
29
  import type { CellId } from "@/core/cells/ids";
30
30
  import type { CellData } from "@/core/cells/types";
31
+ import { notebookAnalysisAtom } from "@/core/session/active-notebook";
31
32
  import { store } from "@/core/state/jotai";
32
33
  import type { Variables } from "@/core/variables/types";
33
34
  import { Events } from "@/utils/events";
34
35
  import { Tooltip } from "../ui/tooltip";
35
36
  import {
36
37
  computeDefsByCell,
38
+ reusableCellIds,
37
39
  type NodeData,
38
40
  nodeDimensions,
39
41
  TreeElementsBuilder,
@@ -80,6 +82,18 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
80
82
  layoutDirection,
81
83
  settings,
82
84
  }) => {
85
+ const hiddenReusable = useAtomValue(
86
+ useMemo(
87
+ () =>
88
+ atom((get) =>
89
+ settings.hideReusableFunctions
90
+ ? reusableCellIds(cellIds, get(notebookAnalysisAtom)?.cells)
91
+ : new Set<CellId>(),
92
+ ),
93
+ [cellIds, settings.hideReusableFunctions],
94
+ ),
95
+ );
96
+
83
97
  // Cells whose node is expanded to show its full code (toggled by double-click).
84
98
  const [expandedIds, setExpandedIds] = useState<Set<CellId>>(() => new Set());
85
99
 
@@ -90,7 +104,7 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
90
104
  cellAtoms,
91
105
  variables,
92
106
  hidePureMarkdown: settings.hidePureMarkdown,
93
- hideReusableFunctions: settings.hideReusableFunctions,
107
+ hiddenReusable,
94
108
  });
95
109
  return layoutElements({
96
110
  nodes: withExpansion(elements.nodes, expandedIds),
@@ -168,7 +182,7 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
168
182
  cellAtoms,
169
183
  variables,
170
184
  hidePureMarkdown: settings.hidePureMarkdown,
171
- hideReusableFunctions: settings.hideReusableFunctions,
185
+ hiddenReusable,
172
186
  });
173
187
  syncChanges({
174
188
  nodes: withExpansion(elements.nodes, expandedIds),
@@ -180,7 +194,7 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
180
194
  cellAtoms,
181
195
  syncChanges,
182
196
  settings.hidePureMarkdown,
183
- settings.hideReusableFunctions,
197
+ hiddenReusable,
184
198
  expandedIds,
185
199
  sizeSignature,
186
200
  ]);
@@ -2,9 +2,10 @@
2
2
 
3
3
  import type { Atom } from "jotai";
4
4
  import { type Edge, MarkerType, type Node, type NodeProps } from "reactflow";
5
- import { getNotebook } from "@/core/cells/cells";
5
+ import type { Analysis } from "@marimo-team/client/protocol";
6
+ import { reusableDefinition } from "@/core/cells/reusable-definition";
6
7
  import type { CellId } from "@/core/cells/ids";
7
- import type { CellData, CellRuntimeState } from "@/core/cells/types";
8
+ import type { CellData } from "@/core/cells/types";
8
9
  import { store } from "@/core/state/jotai";
9
10
  import type { Variable, VariableName, Variables } from "@/core/variables/types";
10
11
  import { Arrays } from "@/utils/arrays";
@@ -47,7 +48,7 @@ interface CreateElementsOptions {
47
48
  cellAtoms: Atom<CellData>[];
48
49
  variables: Variables;
49
50
  hidePureMarkdown: boolean;
50
- hideReusableFunctions: boolean;
51
+ hiddenReusable: ReadonlySet<CellId>;
51
52
  }
52
53
 
53
54
  const LINE_HEIGHT = 11; // matches TinyCode.css
@@ -151,21 +152,15 @@ export function nodeDimensions(data: NodeData): {
151
152
  export const OUTPUTS_HANDLE_ID = "outputs";
152
153
  export const INPUTS_HANDLE_ID = "inputs";
153
154
 
154
- /**
155
- * Cells hidden by the reusable-functions filter: those the kernel marked as
156
- * valid top-level definitions (serialization hint `Valid`).
157
- */
158
155
  export function reusableCellIds(
159
- cellIds: CellId[],
160
- cellRuntime: Record<CellId, CellRuntimeState>,
156
+ cellIds: readonly CellId[],
157
+ cells: Analysis["cells"] | undefined,
161
158
  ): Set<CellId> {
162
- const reusable = new Set<CellId>();
163
- for (const cellId of cellIds) {
164
- if (cellRuntime[cellId]?.serialization?.toLowerCase() === "valid") {
165
- reusable.add(cellId);
166
- }
167
- }
168
- return reusable;
159
+ return new Set(
160
+ cellIds.filter(
161
+ (id) => reusableDefinition(cells?.[id])?.kind === "reusable-definition",
162
+ ),
163
+ );
169
164
  }
170
165
 
171
166
  /** Map each cell to the names of the variables it declares. */
@@ -319,18 +314,10 @@ export class TreeElementsBuilder implements ElementsBuilder {
319
314
  cellAtoms,
320
315
  variables,
321
316
  hidePureMarkdown,
322
- hideReusableFunctions,
317
+ hiddenReusable,
323
318
  }: CreateElementsOptions) {
324
319
  const nodes: Node<NodeData>[] = [];
325
320
 
326
- const cellRuntime = getNotebook().cellRuntime;
327
- // Hidden reusable cells are dropped along with their edges — a reusable
328
- // function is nearly always referenced somewhere, so gating on "no edges"
329
- // would make the filter a no-op.
330
- const hiddenReusable = hideReusableFunctions
331
- ? reusableCellIds(cellIds, cellRuntime)
332
- : new Set<CellId>();
333
-
334
321
  const nodesWithEdges = new Set<CellId>();
335
322
  // Dedupe cell→cell edges, aggregating every variable that crosses them so a
336
323
  // single edge can carry multiple refs and flag whether any is a state flow.
@@ -0,0 +1,62 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import type { CellDiagnostic } from "@marimo-team/client/protocol";
4
+ import { HelpCircleIcon, SquareFunctionIcon } from "lucide-react";
5
+ import { Tooltip } from "@/components/ui/tooltip";
6
+
7
+ const LEARN_MORE = "https://links.marimo.app/reusable-definitions";
8
+
9
+ /** Whether a lone function or class is saved at module scope, and why not. */
10
+ export const ReusableDefinitionBadge = ({
11
+ finding,
12
+ }: {
13
+ finding: CellDiagnostic;
14
+ }) => {
15
+ const reusable = finding.kind === "reusable-definition";
16
+ const Icon = reusable ? SquareFunctionIcon : HelpCircleIcon;
17
+ return (
18
+ <div className="py-1 px-2 flex items-center justify-end gap-2 last:rounded-b">
19
+ {reusable && (
20
+ <a
21
+ href={LEARN_MORE}
22
+ target="_blank"
23
+ className="hover:underline text-muted-foreground text-xs font-bold"
24
+ rel="noreferrer"
25
+ >
26
+ reusable
27
+ </a>
28
+ )}
29
+ <Tooltip
30
+ content={
31
+ <span className="max-w-16 text-xs">
32
+ {reusable ? (
33
+ finding.message
34
+ ) : (
35
+ <>
36
+ This definition can't be reused in other Python modules:
37
+ <br />
38
+ <br />
39
+ <pre>{finding.message}</pre>
40
+ <br />
41
+ Click this icon to learn more.
42
+ </>
43
+ )}
44
+ </span>
45
+ }
46
+ >
47
+ <a
48
+ href={LEARN_MORE}
49
+ target="_blank"
50
+ rel="noreferrer"
51
+ aria-label="Learn about reusable definitions"
52
+ >
53
+ <Icon
54
+ size={16}
55
+ strokeWidth={1.5}
56
+ className="rounded-lg text-muted-foreground"
57
+ />
58
+ </a>
59
+ </Tooltip>
60
+ </div>
61
+ );
62
+ };
@@ -3,11 +3,7 @@ import { closeCompletion, completionStatus } from "@codemirror/autocomplete";
3
3
  import type { EditorView } from "@codemirror/view";
4
4
  import clsx from "clsx";
5
5
  import { useAtomValue, useSetAtom } from "jotai";
6
- import {
7
- HelpCircleIcon,
8
- MoreHorizontalIcon,
9
- SquareFunctionIcon,
10
- } from "lucide-react";
6
+ import { HelpCircleIcon, MoreHorizontalIcon } from "lucide-react";
11
7
  import {
12
8
  type FocusEvent,
13
9
  forwardRef,
@@ -30,6 +26,7 @@ import {
30
26
  outputIsLoading,
31
27
  outputIsStale,
32
28
  } from "@/core/cells/cell";
29
+ import { useReusableDefinition } from "@/core/cells/reusable-definition";
33
30
  import { isOutputEmpty } from "@/core/cells/outputs";
34
31
  import { useIsPendingCut } from "@/core/cells/pending-cut-service";
35
32
  import { autocompletionKeymap } from "@/core/codemirror/cm";
@@ -79,6 +76,7 @@ import { Logger } from "../../utils/Logger";
79
76
  import { renderShortcut } from "../shortcuts/renderShortcut";
80
77
  import { CellStatusComponent } from "./cell/CellStatus";
81
78
  import { CreateCellButton } from "./cell/CreateCellButton";
79
+ import { ReusableDefinitionBadge } from "./cell/ReusableDefinitionBadge";
82
80
  import {
83
81
  CellActionsDropdown,
84
82
  type CellActionsDropdownHandle,
@@ -389,6 +387,7 @@ const EditableCellComponent = ({
389
387
  const cellRef = useRef<HTMLDivElement>(null);
390
388
  const cellData = useCellData(cellId);
391
389
  const cellRuntime = useCellRuntime(cellId);
390
+ const reusable = useReusableDefinition(cellId);
392
391
  const output = useCellOutput(cellId);
393
392
  const outline = useCellOutline(cellId);
394
393
  const { execution, freshness } = useCellPresentation(cellId);
@@ -625,8 +624,6 @@ const EditableCellComponent = ({
625
624
  return undefined;
626
625
  };
627
626
 
628
- const isToplevel = cellRuntime.serialization?.toLowerCase() === "valid";
629
-
630
627
  return (
631
628
  <TooltipProvider>
632
629
  <CellActionsContextMenu
@@ -747,70 +744,14 @@ const EditableCellComponent = ({
747
744
  />
748
745
  )}
749
746
  {cellOutput === "below" && (outputArea || emptyMarkdownPlaceholder)}
750
- {!isPresenting && cellRuntime.serialization && (
751
- <div className="py-1 px-2 flex items-center justify-end gap-2 last:rounded-b">
752
- {isToplevel && (
753
- <a
754
- href="https://links.marimo.app/reusable-definitions"
755
- target="_blank"
756
- className="hover:underline text-muted-foreground text-xs font-bold"
757
- rel="noreferrer"
758
- >
759
- reusable
760
- </a>
761
- )}
762
- <Tooltip
763
- content={
764
- <span className="max-w-16 text-xs">
765
- {(isToplevel &&
766
- "This function or class can be imported into other Python notebooks or modules.") || (
767
- <>
768
- This definition can't be reused in other Python
769
- modules:
770
- <br />
771
- <br />
772
- <pre>{cellRuntime.serialization}</pre>
773
- <br />
774
- Click this icon to learn more.
775
- </>
776
- )}
777
- </span>
778
- }
779
- >
780
- {isToplevel ? (
781
- <a
782
- href="https://links.marimo.app/reusable-definitions"
783
- target="_blank"
784
- rel="noreferrer"
785
- >
786
- <SquareFunctionIcon
787
- size={16}
788
- strokeWidth={1.5}
789
- className="rounded-lg text-muted-foreground"
790
- />
791
- </a>
792
- ) : (
793
- <a
794
- href="https://links.marimo.app/reusable-definitions"
795
- target="_blank"
796
- rel="noreferrer"
797
- >
798
- <HelpCircleIcon
799
- size={16}
800
- strokeWidth={1.5}
801
- className="rounded-lg text-muted-foreground"
802
- />
803
- </a>
804
- )}
805
- </Tooltip>
806
- </div>
747
+ {!isPresenting && reusable && (
748
+ <ReusableDefinitionBadge finding={reusable} />
807
749
  )}
808
750
  {!isPresenting && (
809
751
  <ConsoleOutput
810
752
  consoleOutputs={cellRuntime.consoleOutputs}
811
753
  stale={consoleOutputStale}
812
- // Empty name if serialization triggered
813
- cellName={cellRuntime.serialization ? "_" : cellData.name}
754
+ cellName={reusable ? "_" : cellData.name}
814
755
  onRefactorWithAI={handleRefactorWithAI}
815
756
  onClear={() => {
816
757
  actions.clearCellConsoleOutput({ cellId });
@@ -421,7 +421,6 @@ describe("kernel-ready", () => {
421
421
  [CELL_B]: { id: CELL_B, code: "2" },
422
422
  },
423
423
  cellRuntime: {
424
- [CELL_A]: { serialization: "Valid" },
425
424
  [CELL_B]: {
426
425
  embeddedConsole: [
427
426
  {
@@ -441,7 +440,6 @@ describe("kernel-ready", () => {
441
440
  payload: undefined,
442
441
  });
443
442
 
444
- expect(next.cellRuntime[CELL_A].serialization).toBeUndefined();
445
443
  expect(next.cellRuntime[CELL_B].embeddedConsole).toEqual([]);
446
444
  });
447
445
 
@@ -486,7 +484,6 @@ describe("kernel-ready", () => {
486
484
  payload: undefined,
487
485
  });
488
486
 
489
- expect(next.cellRuntime[CELL_A].serialization).toBeUndefined();
490
487
  expect(next.cellRuntime[CELL_B].embeddedConsole[0]).toMatchObject({
491
488
  data: "hydrated-B-stdout",
492
489
  });
@@ -656,7 +656,6 @@ export function useCellActions() {
656
656
  // The session feeds the kernel's messages and the document into the
657
657
  // notebook through `useReducerActions`; components get the operations.
658
658
  const {
659
- setCellReusability: _setCellReusability,
660
659
  addLogs: _addLogs,
661
660
  reconcileDocument: _reconcileDocument,
662
661
  resetCellRuntimes: _resetCellRuntimes,
@@ -168,18 +168,6 @@ const {
168
168
  useActions,
169
169
  valueAtom: notebookAtom,
170
170
  } = createReducerAndAtoms(initialNotebookState, {
171
- setCellReusability: (
172
- state,
173
- message: { cell_id: CellId; serialization: string | null },
174
- ) =>
175
- updateCellRuntimeState({
176
- state,
177
- cellId: message.cell_id,
178
- cellReducer: (cell) => ({
179
- ...cell,
180
- serialization: message.serialization,
181
- }),
182
- }),
183
171
  startCellConsole: (state, { cellId }: { cellId: CellId }) =>
184
172
  updateCellRuntimeState({
185
173
  state,
@@ -203,7 +203,6 @@ export function consoleView(
203
203
  return {
204
204
  ...inputs,
205
205
  rendered: {
206
- serialization: local.serialization,
207
206
  consoleOutputs: added ? collapseConsoleOutputs([...rows, added]) : rows,
208
207
  },
209
208
  };
@@ -231,7 +230,6 @@ export function consoleView(
231
230
  return {
232
231
  ...inputs,
233
232
  rendered: {
234
- serialization: local.serialization,
235
233
  consoleOutputs: collapseConsoleBatch(entries),
236
234
  },
237
235
  };
@@ -0,0 +1,25 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import type { CellAnalysis } from "@marimo-team/client/protocol";
4
+ import { atom, useAtomValue } from "jotai";
5
+ import { useMemo } from "react";
6
+ import { notebookAnalysisAtom } from "../session/active-notebook";
7
+ import type { CellId } from "./ids";
8
+
9
+ export function reusableDefinition(cell: CellAnalysis | undefined) {
10
+ return cell?.diagnostics.find(
11
+ ({ source, kind }) =>
12
+ source === "marimo" &&
13
+ (kind === "reusable-definition" || kind === "non-reusable-definition"),
14
+ );
15
+ }
16
+
17
+ export function useReusableDefinition(id: CellId) {
18
+ return useAtomValue(
19
+ useMemo(
20
+ () =>
21
+ atom((get) => reusableDefinition(get(notebookAnalysisAtom)?.cells[id])),
22
+ [id],
23
+ ),
24
+ );
25
+ }
@@ -78,15 +78,10 @@ export interface CellRuntimeState {
78
78
  seq: number;
79
79
  prompts: ReadonlySet<string>;
80
80
  };
81
- /** serialization message. TODO(MO-8414) */
82
- serialization?: string | null;
83
81
  }
84
82
 
85
83
  /** The cell runtime fields available to renderers. */
86
- export interface CellRuntimeView extends Pick<
87
- CellRuntimeState,
88
- "serialization"
89
- > {
84
+ export interface CellRuntimeView {
90
85
  consoleOutputs: ConsoleOutputMessage[];
91
86
  }
92
87
 
@@ -19,8 +19,8 @@ it("counts only distinct disabled ancestors in a cycle", () => {
19
19
  notebook_id: "n1",
20
20
  document_etag: "v1",
21
21
  cells: {
22
- a: { defs: [], refs: [], parents: ["b"], errors: [] },
23
- b: { defs: [], refs: [], parents: ["a"], errors: [] },
22
+ a: { defs: [], refs: [], parents: ["b"], diagnostics: [] },
23
+ b: { defs: [], refs: [], parents: ["a"], diagnostics: [] },
24
24
  },
25
25
  };
26
26
  const disabled = (id: string) =>
@@ -259,14 +259,6 @@ function handleNotification(
259
259
  inputIds: msg.input_ids,
260
260
  });
261
261
  return;
262
- case "cell-op":
263
- if (msg.serialization !== undefined) {
264
- actions.setCellReusability({
265
- cell_id: msg.cell_id,
266
- serialization: msg.serialization,
267
- });
268
- }
269
- return;
270
262
  case "callback-output":
271
263
  VirtualFileTracker.INSTANCE.trackCallbackOutput(msg);
272
264
  actions.showCommandOutput(msg);
@@ -398,7 +398,7 @@ describe("useNotebookSession messages", () => {
398
398
  {
399
399
  defs: [],
400
400
  refs: [],
401
- errors: [],
401
+ diagnostics: [],
402
402
  ...(parents && { parents: parents[id] }),
403
403
  },
404
404
  ]),
@@ -7,6 +7,12 @@ import type { NotebookReplica } from "../notebook/replica";
7
7
  /** The replica owned by the mounted notebook session. */
8
8
  export const activeNotebookReplicaAtom = atom<NotebookReplica | null>(null);
9
9
 
10
+ /** The last analysis, kept while the host analyzes a newer revision. */
11
+ export const notebookAnalysisAtom = atom((get) => {
12
+ const replica = get(activeNotebookReplicaAtom);
13
+ return (replica && get(replica.analysisAtom)?.analysis) ?? null;
14
+ });
15
+
10
16
  /** The document model owned by the mounted notebook session. */
11
17
  export const activeDocumentModelAtom = atom<DocumentModel | null>(null);
12
18
 
@@ -90,7 +90,6 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
90
90
  const store = useStore();
91
91
 
92
92
  const {
93
- setCellReusability,
94
93
  showCommandOutput,
95
94
  hideConsoleInputs,
96
95
  clearDebuggerOutput,
@@ -223,14 +222,6 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
223
222
  inputIds: msg.data.input_ids,
224
223
  });
225
224
  return;
226
- case "cell-op":
227
- if (msg.data.serialization !== undefined) {
228
- setCellReusability({
229
- cell_id: msg.data.cell_id,
230
- serialization: msg.data.serialization,
231
- });
232
- }
233
- return;
234
225
  case "callback-output":
235
226
  VirtualFileTracker.INSTANCE.trackCallbackOutput(msg.data);
236
227
  showCommandOutput(msg.data);