@marimo-team/islands 0.25.3-dev437 → 0.25.3-dev438

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 (91) hide show
  1. package/dist/{ConnectedDataExplorerComponent-CoEU9snz.js → ConnectedDataExplorerComponent-LA5OtjAG.js} +11 -11
  2. package/dist/{ErrorBoundary-LQpWaaaj.js → ErrorBoundary-Bvtsf3zB.js} +18 -18
  3. package/dist/{abnfDiagram-VCTEODGH-RbfxpmIE.js → abnfDiagram-VCTEODGH-CBntFgCZ.js} +2 -2
  4. package/dist/{any-language-editor-Cw4VtZvb.js → any-language-editor-gzDRWdCH.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-DzzNVRo4.js → architectureDiagram-5GKGNRK7-Bz6ouXl-.js} +1 -1
  6. package/dist/{assertNever-ChGm2jYv.js → assertNever-DOTNJ2Y4.js} +2 -2
  7. package/dist/{chat-ui-BEMyRpmS.js → chat-ui-ZGXdN6Vr.js} +45 -45
  8. package/dist/{check-BHRB6N0I.js → check-CApwK1fD.js} +1 -1
  9. package/dist/{chunk-IMKFNOWR-1Zy6M_oP.js → chunk-IMKFNOWR-DK_M66Dt.js} +1 -1
  10. package/dist/{chunk-SHT3W25Y-yAttqZEk.js → chunk-SHT3W25Y-C7Cg6zGL.js} +1 -1
  11. package/dist/{chunk-SVP7TREG-MKJpuJHR.js → chunk-SVP7TREG-K0lWia53.js} +1 -1
  12. package/dist/{chunk-TICWLB2K-BOC0OebH.js → chunk-TICWLB2K-DiKpryGp.js} +1 -1
  13. package/dist/{classDiagram-ZZMXUADV-BOlD7kH9.js → classDiagram-ZZMXUADV-CXX5eaxi.js} +2 -2
  14. package/dist/{classDiagram-v2-VYDZK3BY-C3p3seuT.js → classDiagram-v2-VYDZK3BY-Bjyy4iKL.js} +2 -2
  15. package/dist/{code-visibility-Cl2Z5Y2R.js → code-visibility-CmfNaZAX.js} +17 -17
  16. package/dist/{common-DVxtA3e0.js → common-i_ykKLxU.js} +4881 -4842
  17. package/dist/{config-EJnOxh0i.js → config-C8TXSDmC.js} +18 -18
  18. package/dist/{copy-icon-Bv5SAA0w.js → copy-icon-CDvvlY90.js} +2 -2
  19. package/dist/{createReducer-BJJ0K5Tu.js → createReducer-CXqSak4H.js} +1 -1
  20. package/dist/{cynefinDiagram-5FMLGOSQ-BKnxm64C.js → cynefinDiagram-5FMLGOSQ-C-MlCYj4.js} +1 -1
  21. package/dist/{dagre-GXQ25YYZ-COBTexAI.js → dagre-GXQ25YYZ-C6e9vEKZ.js} +1 -1
  22. package/dist/{data-grid-overlay-editor-FI3lYcm3.js → data-grid-overlay-editor-kj617zpx.js} +1 -1
  23. package/dist/{diagram-S7CK7UJ4-Dyt3J6ek.js → diagram-S7CK7UJ4-DgXNq_At.js} +1 -1
  24. package/dist/{diagram-UQ7AKVKN-CJCsT4fA.js → diagram-UQ7AKVKN-BG5NExCt.js} +1 -1
  25. package/dist/{diagram-VX7I27RA-BboxCtbh.js → diagram-VX7I27RA-Da7VYCfC.js} +1 -1
  26. package/dist/{diagram-Z3DM3KII-DfRWWQ5t.js → diagram-Z3DM3KII-DHk6GaR5.js} +1 -1
  27. package/dist/{dialog-B8vU2hHC.js → dialog-rgayPemF.js} +20 -20
  28. package/dist/{dropdown-menu-DzhAnAhr.js → dropdown-menu-B12Nf3Zf.js} +703 -703
  29. package/dist/{ebnfDiagram-PWID7BFC-DYxwv-nl.js → ebnfDiagram-PWID7BFC-DdSjinXr.js} +2 -2
  30. package/dist/{erDiagram-RLTQ6QDP-D9e5WUw7.js → erDiagram-RLTQ6QDP-BgcwfZct.js} +1 -1
  31. package/dist/{error-banner-BRkKwvku.js → error-banner-DXHIN-63.js} +58 -58
  32. package/dist/{error-entries-BbxtqUQ4.js → error-entries-DMgIKuK1.js} +380 -380
  33. package/dist/{feedback-button-1MiN6gfS.js → feedback-button-CGAe5hFZ.js} +7 -7
  34. package/dist/{flowDiagram-HODETNUW-tt7EepxX.js → flowDiagram-HODETNUW-CVwzkmUF.js} +2 -2
  35. package/dist/{formats-HRSqKdFt.js → formats-BWuAsLfw.js} +1 -1
  36. package/dist/{glide-data-editor-Kt7kYQLq.js → glide-data-editor-BiU_hF9A.js} +11 -11
  37. package/dist/{glide-utils-BzjESEmr.js → glide-utils-D1McS0Pn.js} +2 -2
  38. package/dist/{globals-BjpSYd8i.js → globals-jz3DTWzC.js} +3 -3
  39. package/dist/{html-to-image-DuNAF8H5.js → html-to-image-Dopvv40j.js} +774 -774
  40. package/dist/{infoDiagram-27XIBGKW-CpQH_joy.js → infoDiagram-27XIBGKW-CHkU2P-8.js} +1 -1
  41. package/dist/{ishikawaDiagram-5VMMS53U-d-it4xqm.js → ishikawaDiagram-5VMMS53U-B0k5UyY5.js} +1 -1
  42. package/dist/{kanban-definition-UXKFOSKX-DItpqTFY.js → kanban-definition-UXKFOSKX-DwQvOV0x.js} +1 -1
  43. package/dist/main.js +4913 -4936
  44. package/dist/{mermaid-BugOVfeH.js → mermaid-Bqy6f_NU.js} +34 -34
  45. package/dist/{mindmap-definition-YA3MSWOX-D6IpF-_J.js → mindmap-definition-YA3MSWOX-CqvvAm8I.js} +1 -1
  46. package/dist/{number-overlay-editor-BG707U9t.js → number-overlay-editor-D3OSLsDB.js} +1 -1
  47. package/dist/{pegDiagram-XKGWAZYB-CXUu3QwE.js → pegDiagram-XKGWAZYB-Befnx4Ry.js} +2 -2
  48. package/dist/{pencil-DWRFEz2B.js → pencil-BC7pOv9g.js} +1 -1
  49. package/dist/{pieDiagram-E7YTZNPT-DoUJF0yj.js → pieDiagram-E7YTZNPT-6rYFbF7p.js} +1 -1
  50. package/dist/{process-output-Cl97_Reh.js → process-output-BidrKebE.js} +4 -4
  51. package/dist/{railroadDiagram-O6MQD6OU-BsGDhtLL.js → railroadDiagram-O6MQD6OU-SSniwYC8.js} +2 -2
  52. package/dist/{requirementDiagram-BXWQKSXE-BHW0qW2Z.js → requirementDiagram-BXWQKSXE-3L_xNfQr.js} +1 -1
  53. package/dist/{reveal-component-C8L9okWw.js → reveal-component-CnyvRvqy.js} +900 -900
  54. package/dist/{select-Brvb-RwP.js → select-PQHWLm64.js} +99 -99
  55. package/dist/{sequenceDiagram-WJ2MYXX4-DpgYJzLl.js → sequenceDiagram-WJ2MYXX4-DvzIRlWu.js} +1 -1
  56. package/dist/{spec-BWpscSQi.js → spec-6shN7lEe.js} +4 -4
  57. package/dist/{stateDiagram-D77RDMKH-Btf1jiYb.js → stateDiagram-D77RDMKH-VsHup-Ig.js} +2 -2
  58. package/dist/{stateDiagram-v2-MP3YSRHH-DN9FyEf3.js → stateDiagram-v2-MP3YSRHH-BwIIR8nk.js} +2 -2
  59. package/dist/{static-state-BhCfPRoz.js → static-state-CWXd6dYX.js} +9 -9
  60. package/dist/{swimlanes-42K2YHIH-2l_tR9qL.js → swimlanes-42K2YHIH-DhSDCIWI.js} +1 -1
  61. package/dist/{swimlanesDiagram-VR7AAH4N-BAkmv8kE.js → swimlanesDiagram-VR7AAH4N-C2WGVm-W.js} +2 -2
  62. package/dist/{timeline-definition-24CTP7MA-AxSxEOhx.js → timeline-definition-24CTP7MA-DhUhNinO.js} +1 -1
  63. package/dist/{toast-DOWc3HtU.js → toast-BGvv7tKS.js} +153 -153
  64. package/dist/{tooltip-DsQZP310.js → tooltip-CiJ919pg.js} +62 -62
  65. package/dist/{use-restore-focus-CTa7IRP6.js → use-restore-focus-BLj45Ibw.js} +75 -75
  66. package/dist/{useDateFormatter-CRuBYwR6.js → useDateFormatter-C659lkax.js} +2 -2
  67. package/dist/{useDeepCompareMemoize-B2RNcTmn.js → useDeepCompareMemoize-CDhinwm7.js} +1 -1
  68. package/dist/{useLifecycle-Bw0JtmoB.js → useLifecycle-mKiMNa4V.js} +1 -1
  69. package/dist/{vega-component-BV9sYHhU.js → vega-component-CWvQ7wBJ.js} +6 -6
  70. package/dist/{vennDiagram-4TSXK5OY-oHztO7MH.js → vennDiagram-4TSXK5OY-exvBF8P5.js} +1 -1
  71. package/dist/{wardleyDiagram-VM6X3IG4-DWeEjZSc.js → wardleyDiagram-VM6X3IG4-BFhJmnXo.js} +1 -1
  72. package/dist/{xychartDiagram-S5SC5T6Z-ESBlsY9i.js → xychartDiagram-S5SC5T6Z-D_xAdG6u.js} +1 -1
  73. package/package.json +1 -1
  74. package/src/components/editor/controls/Controls.tsx +5 -2
  75. package/src/components/editor/notebook-cell.tsx +7 -21
  76. package/src/components/editor/renderers/grid-layout/grid-layout.tsx +2 -7
  77. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +2 -4
  78. package/src/components/slides/minimap.tsx +2 -3
  79. package/src/components/slides/reveal-component.tsx +2 -3
  80. package/src/components/slides/slide-cell-view.tsx +5 -12
  81. package/src/core/cells/__tests__/cell.test.ts +8 -51
  82. package/src/core/cells/__tests__/utils.test.ts +27 -18
  83. package/src/core/cells/cell.ts +6 -12
  84. package/src/core/cells/cells.ts +5 -3
  85. package/src/core/cells/utils.ts +61 -55
  86. package/src/core/config/config.ts +4 -0
  87. package/src/core/executions/__tests__/hooks.test.tsx +48 -2
  88. package/src/core/executions/__tests__/select.test.ts +0 -17
  89. package/src/core/executions/hooks.ts +24 -0
  90. package/src/core/executions/index.ts +2 -0
  91. package/src/core/executions/select.ts +0 -5
@@ -15,14 +15,7 @@ import { Objects } from "@/utils/objects";
15
15
  import { isErrorMime } from "../mime";
16
16
  import type { NotebookState } from "./cells";
17
17
  import type { CellId } from "./ids";
18
-
19
- export function notebookNeedsRun(
20
- state: NotebookState,
21
- executions: CellExecutionInputs,
22
- freshness: CellFreshnessLookup,
23
- ) {
24
- return staleCellIds(state, executions, freshness).length > 0;
25
- }
18
+ import type { CellData } from "./types";
26
19
 
27
20
  export function notebookCells(state: NotebookState) {
28
21
  return state.cellIds.map((cellId) => state.cellData[cellId]);
@@ -103,35 +96,72 @@ export function getDescendantsStatus(
103
96
  };
104
97
  }
105
98
 
106
- /**
107
- * Cells that are stale and can be run.
108
- */
99
+ type RunReason = "not-run" | "source" | "inputs" | "interrupted";
100
+
101
+ export function cellRunReason(
102
+ execution: Pick<CellExecutionView, "status" | "live" | "outcome" | "blocked">,
103
+ freshness: CellFreshness,
104
+ cell: Pick<CellData, "code" | "config">,
105
+ ): RunReason | null {
106
+ if (execution.status !== "idle") {
107
+ return null;
108
+ }
109
+ if (isUninstantiated(execution) && cell.code.trim()) {
110
+ return "not-run";
111
+ }
112
+ if (freshness.sourceChanged) {
113
+ return "source";
114
+ }
115
+ if (execution.outcome === "interrupted") {
116
+ return "interrupted";
117
+ }
118
+ return freshness.inputsChanged && !cell.config.disabled && !execution.blocked
119
+ ? "inputs"
120
+ : null;
121
+ }
122
+
123
+ function* cellsNeedingRun(
124
+ state: NotebookState,
125
+ executions: CellExecutionInputs,
126
+ freshness: CellFreshnessLookup,
127
+ ): Generator<[CellId, RunReason]> {
128
+ for (const id of state.cellIds) {
129
+ const view = cellExecutionView(executions, id);
130
+ const changes = freshness(id);
131
+ const reason = cellRunReason(view, changes, state.cellData[id]);
132
+ if (reason !== null) {
133
+ yield [id, reason];
134
+ } else if (changes.sourceChanged && inFlight(executions.executions, id)) {
135
+ // The run action can submit an edit made after the host planned this cell.
136
+ yield [id, "source"];
137
+ }
138
+ }
139
+ }
140
+
109
141
  export function staleCellIds(
110
142
  state: NotebookState,
111
143
  executions: CellExecutionInputs,
112
144
  freshness: CellFreshnessLookup,
113
145
  ) {
114
- const { cellIds, cellData } = state;
115
- return cellIds.filter((cellId) => {
116
- const execution = cellExecutionView(executions, cellId);
117
- if (execution.status !== "idle") {
118
- // A run in progress covers the source it was asked for. Only an edit
119
- // since then, visible once the host has planned the run, needs another.
120
- return (
121
- inFlight(executions.executions, cellId) &&
122
- freshness(cellId).sourceChanged
123
- );
146
+ return Array.from(
147
+ cellsNeedingRun(state, executions, freshness),
148
+ ([id]) => id,
149
+ );
150
+ }
151
+
152
+ export function notebookRunReason(
153
+ state: NotebookState,
154
+ executions: CellExecutionInputs,
155
+ freshness: CellFreshnessLookup,
156
+ ): RunReason | null {
157
+ let reason: RunReason | null = null;
158
+ for (const [, pending] of cellsNeedingRun(state, executions, freshness)) {
159
+ if (pending !== "inputs") {
160
+ return pending;
124
161
  }
125
- return (
126
- isUninstantiated(execution) ||
127
- cellNeedsRun({
128
- freshness: freshness(cellId),
129
- interrupted: execution.outcome === "interrupted",
130
- disabled: cellData[cellId].config.disabled,
131
- blocked: execution.blocked,
132
- })
133
- );
134
- });
162
+ reason = pending;
163
+ }
164
+ return reason;
135
165
  }
136
166
 
137
167
  /** Whether the host holds a planned or started execution of the cell that has not completed. */
@@ -158,30 +188,6 @@ export function isUninstantiated({
158
188
  );
159
189
  }
160
190
 
161
- /**
162
- * Whether a cell needs to be run: its source changed, its last run was
163
- * interrupted, or an input changed and the cell can run. A disabled cell,
164
- * or one blocked by a disabled ancestor, is not flagged for changed inputs
165
- * until it can run again.
166
- */
167
- export function cellNeedsRun({
168
- freshness,
169
- interrupted,
170
- disabled,
171
- blocked,
172
- }: {
173
- freshness: CellFreshness;
174
- interrupted: boolean;
175
- disabled: boolean | undefined;
176
- blocked: boolean;
177
- }): boolean {
178
- return (
179
- freshness.sourceChanged ||
180
- interrupted ||
181
- (freshness.inputsChanged && !(disabled || blocked))
182
- );
183
- }
184
-
185
191
  export function cellStatusClasses({
186
192
  needsRun,
187
193
  errored,
@@ -71,6 +71,10 @@ export const resolvedMarimoConfigAtom = atom<UserConfig>((get) => {
71
71
  return mergeConfig(userConfig, overrides);
72
72
  });
73
73
 
74
+ export const autoRunOnChangeAtom = atom(
75
+ (get) => get(resolvedMarimoConfigAtom).runtime.on_cell_change === "autorun",
76
+ );
77
+
74
78
  export const autoInstantiateAtom = atom((get) => {
75
79
  return get(resolvedMarimoConfigAtom).runtime.auto_instantiate;
76
80
  });
@@ -3,8 +3,9 @@
3
3
  import { act, renderHook } from "@testing-library/react";
4
4
  import { createStore, Provider } from "jotai";
5
5
  import type { ReactNode } from "react";
6
- import { describe, expect, it } from "vitest";
6
+ import { describe, expect, it, vi } from "vitest";
7
7
  import { MockExecutions } from "@/__mocks__/executions";
8
+ import { configOverridesAtom } from "@/core/config/config";
8
9
  import { cellId } from "@/__tests__/branded";
9
10
  import {
10
11
  cell,
@@ -12,7 +13,11 @@ import {
12
13
  withCells,
13
14
  } from "@/core/notebook/document/__tests__/fixtures";
14
15
  import { clearCellOutputs } from "../atoms";
15
- import { useCellFreshness, useCellOutput } from "../hooks";
16
+ import {
17
+ useCellFreshness,
18
+ useCellOutput,
19
+ useShowChangedInputs,
20
+ } from "../hooks";
16
21
 
17
22
  const C1 = cellId("c1");
18
23
  const C2 = cellId("c2");
@@ -106,6 +111,47 @@ describe("useCellFreshness", () => {
106
111
  });
107
112
  });
108
113
 
114
+ describe("input-change warnings", () => {
115
+ it("gives autorun time to queue a reader, but exposes an unhandled change", () => {
116
+ vi.useFakeTimers();
117
+ try {
118
+ const { wrapper, store } = setup([]);
119
+ const { result, rerender } = renderHook(
120
+ (changed: boolean) => useShowChangedInputs(changed),
121
+ {
122
+ wrapper,
123
+ initialProps: false,
124
+ },
125
+ );
126
+ rerender(true);
127
+ expect(result.current).toBe(false);
128
+ // Queued before the warning appeared.
129
+ rerender(false);
130
+ act(() => vi.runAllTimers());
131
+ expect(result.current).toBe(false);
132
+ rerender(true);
133
+ act(() => vi.runAllTimers());
134
+ expect(result.current).toBe(true);
135
+ rerender(false);
136
+ expect(result.current).toBe(false);
137
+ act(() => vi.advanceTimersByTime(50));
138
+ rerender(true);
139
+ act(() => vi.advanceTimersByTime(199));
140
+ expect(result.current).toBe(false);
141
+ act(() => vi.advanceTimersByTime(1));
142
+ expect(result.current).toBe(true);
143
+ rerender(false);
144
+ act(() =>
145
+ store.set(configOverridesAtom, { runtime: { on_cell_change: "lazy" } }),
146
+ );
147
+ rerender(true);
148
+ expect(result.current).toBe(true);
149
+ } finally {
150
+ vi.useRealTimers();
151
+ }
152
+ });
153
+ });
154
+
109
155
  describe("useCellOutput", () => {
110
156
  const shown = (id: string) =>
111
157
  MockExecutions.completed(id, {
@@ -110,7 +110,6 @@ describe("cellExecutionView", () => {
110
110
  outcome: null,
111
111
  startedAt: null,
112
112
  duration: null,
113
- rendered: false,
114
113
  live: true,
115
114
  });
116
115
  });
@@ -146,25 +145,10 @@ describe("cellExecutionView", () => {
146
145
  outcome: null,
147
146
  startedAt: Date.parse(T2),
148
147
  duration: null,
149
- rendered: false,
150
148
  live: true,
151
149
  });
152
150
  });
153
151
 
154
- it("notes when a running execution has shown a value so far", () => {
155
- const showing = inputs({
156
- executions: [
157
- execution({
158
- id: "e1",
159
- status: "running",
160
- outcome: { kind: "value", display: null },
161
- completed_at: null,
162
- }),
163
- ],
164
- });
165
- expect(cellExecutionView(showing, "c1").rendered).toBe(true);
166
- });
167
-
168
152
  it("says whether the notebook's runtime produced the cell's result", () => {
169
153
  const result = execution({ id: "e1" });
170
154
  const produced = (runtimeId: string | null) =>
@@ -205,7 +189,6 @@ describe("cellExecutionView", () => {
205
189
  outcome: "value",
206
190
  startedAt: Date.parse(T0),
207
191
  duration: 1500,
208
- rendered: false,
209
192
  live: true,
210
193
  });
211
194
  const error = (kind: string): Protocol.Outcome => ({
@@ -5,6 +5,8 @@ import { dequal } from "dequal";
5
5
  import { useAtomValue } from "jotai";
6
6
  import { selectAtom } from "jotai/utils";
7
7
  import { useMemo } from "react";
8
+ import { autoRunOnChangeAtom } from "@/core/config/config";
9
+ import { useDelayElapsed } from "@/hooks/useDelayElapsed";
8
10
  import type { CellId } from "@/core/cells/ids";
9
11
  import type { Outline } from "@/core/cells/outline";
10
12
  import {
@@ -54,6 +56,28 @@ export function useCellFreshness(id: Protocol.CellId): CellFreshness {
54
56
  return useAtomValue(cellAtom);
55
57
  }
56
58
 
59
+ /** A variable revision can arrive just before the host queues its readers. */
60
+ export function useShowChangedInputs(changed: boolean): boolean {
61
+ const autorun = useAtomValue(autoRunOnChangeAtom);
62
+ const delayElapsed = useDelayElapsed(autorun && changed ? 200 : 0);
63
+ return changed && delayElapsed;
64
+ }
65
+
66
+ export function useCellPresentation(id: Protocol.CellId) {
67
+ const execution = useCellExecution(id);
68
+ const actual = useCellFreshness(id);
69
+ const inputsChanged = useShowChangedInputs(
70
+ actual.inputsChanged && execution.status === "idle",
71
+ );
72
+ return {
73
+ execution,
74
+ freshness:
75
+ inputsChanged === actual.inputsChanged
76
+ ? actual
77
+ : { ...actual, inputsChanged },
78
+ };
79
+ }
80
+
57
81
  /** What the cell shows: its running value so far, else its result's outcome. */
58
82
  export function useCellOutput(id: CellId): CellOutput | null {
59
83
  return useAtomValue(cellOutputAtom(id));
@@ -34,6 +34,8 @@ export {
34
34
  useCellHasResult,
35
35
  useCellOutline,
36
36
  useCellOutput,
37
+ useCellPresentation,
38
+ useShowChangedInputs,
37
39
  useScratchOutput,
38
40
  } from "./hooks";
39
41
  export {
@@ -31,8 +31,6 @@ export interface CellExecutionView {
31
31
  readonly startedAt: Milliseconds | null;
32
32
  /** How long the last completed execution took, null while the cell runs again. */
33
33
  readonly duration: Milliseconds | null;
34
- /** Whether the running execution has shown a value so far. TODO(MO-8404) */
35
- readonly rendered: boolean;
36
34
  }
37
35
 
38
36
  /** What a cell's view is derived from. */
@@ -128,11 +126,9 @@ export function cellExecutionView(
128
126
  const result = inputs.results.get(id)?.record ?? null;
129
127
  let status: CellRunStatus = "idle";
130
128
  let startedAt = result === null ? null : millis(result.started_at);
131
- let rendered = false;
132
129
  if (latest !== null && latest.record.status !== "completed") {
133
130
  status = latest.record.status;
134
131
  startedAt = millis(latest.record.started_at) ?? startedAt;
135
- rendered = latest.record.outcome !== null;
136
132
  } else if (awaited(inputs, id)) {
137
133
  status = "queued";
138
134
  }
@@ -154,7 +150,6 @@ export function cellExecutionView(
154
150
  result.runtime_id === inputs.runtimeId,
155
151
  startedAt,
156
152
  duration,
157
- rendered,
158
153
  };
159
154
  }
160
155