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

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 (38) hide show
  1. package/dist/{ErrorBoundary-VEwPi06B.js → ErrorBoundary-CodLzVG5.js} +1 -1
  2. package/dist/assets/__vite-browser-external-DZv_7F5P.js +1 -0
  3. package/dist/assets/{worker-DFvnFhLF.js → worker-cHYZNFD4.js} +2 -2
  4. package/dist/{chat-ui-LeUI9zli.js → chat-ui-Covffkhg.js} +7 -7
  5. package/dist/{code-visibility-D3Fzysn4.js → code-visibility-BauZWifR.js} +11 -11
  6. package/dist/{common-rNx_NjSU.js → common-DeBx86ld.js} +14 -14
  7. package/dist/{data-grid-overlay-editor-JtuxaR3K.js → data-grid-overlay-editor-BzEmIb3z.js} +1 -1
  8. package/dist/{error-entries--YT1ZOUW.js → error-entries-C4OopOce.js} +81 -62
  9. package/dist/{feedback-button-DLq5Sxk0.js → feedback-button-BTYGJiow.js} +135 -135
  10. package/dist/{glide-data-editor-DTvqUeZ9.js → glide-data-editor-Bcy2IE3H.js} +3 -3
  11. package/dist/{globals-DVNWDe7Y.js → globals-9AyCoAnh.js} +1 -1
  12. package/dist/{html-to-image-BMt1erSy.js → html-to-image-95V1hWZu.js} +32 -32
  13. package/dist/main.js +6048 -6020
  14. package/dist/{number-overlay-editor-CZ_t156n.js → number-overlay-editor-aEdDUAzH.js} +1 -1
  15. package/dist/{process-output-CNBGRz3r.js → process-output-DPHxrq7D.js} +2 -2
  16. package/dist/{reveal-component-glqW2Ys5.js → reveal-component-_1Vpg1lV.js} +2 -2
  17. package/package.json +1 -1
  18. package/src/__mocks__/executions.ts +2 -0
  19. package/src/__tests__/CellStatus.test.tsx +3 -3
  20. package/src/components/editor/cell/CellStatus.tsx +23 -38
  21. package/src/components/editor/notebook-cell.tsx +1 -1
  22. package/src/components/slides/slide-cell-view.tsx +1 -1
  23. package/src/core/executions/__tests__/atoms.test.ts +1 -41
  24. package/src/core/executions/__tests__/output-lifecycle.test.ts +1 -5
  25. package/src/core/executions/__tests__/select.test.ts +34 -2
  26. package/src/core/executions/atoms.ts +16 -31
  27. package/src/core/executions/hooks.ts +2 -3
  28. package/src/core/executions/index.ts +0 -1
  29. package/src/core/executions/select.ts +55 -2
  30. package/src/core/islands/bootstrap.ts +0 -8
  31. package/src/core/notebook/replica/replica.ts +50 -3
  32. package/src/core/notebook/replica/resources/analysis.ts +9 -0
  33. package/src/core/session/__tests__/backend.test.ts +3 -12
  34. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +84 -0
  35. package/src/core/session/backend.ts +4 -4
  36. package/src/core/session/useNotebookSession.tsx +0 -8
  37. package/src/stories/cell-status.stories.tsx +6 -6
  38. package/dist/assets/__vite-browser-external-DoIBUY2I.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { t } from "./react-Bgs_wQh3.js";
3
- import { a as n } from "./glide-data-editor-DTvqUeZ9.js";
3
+ import { a as n } from "./glide-data-editor-Bcy2IE3H.js";
4
4
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.1_57c124ac5a994dbbf13fd11838cf9ba9/node_modules/@glideapps/glide-data-grid/dist/esm/internal/data-grid-overlay-editor/private/number-overlay-editor-style.js
5
5
  var r = /* @__PURE__ */ e(t()), i = /*#__PURE__*/ n("div")({
6
6
  name: "NumberOverlayEditorStyle",
@@ -1,6 +1,6 @@
1
- import { T as e } from "./html-to-image-BMt1erSy.js";
1
+ import { T as e } from "./html-to-image-95V1hWZu.js";
2
2
  import { h as t } from "./tooltip-CiJ919pg.js";
3
- import { Tt as n, wt as r } from "./error-entries--YT1ZOUW.js";
3
+ import { Tt as n, wt as r } from "./error-entries-C4OopOce.js";
4
4
  import { r as i } from "./assertNever-DOTNJ2Y4.js";
5
5
  var a = t("file", [["path", {
6
6
  d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
@@ -3,14 +3,14 @@ import { g as t, h as n, i as r, m as i, t as a } from "./button-qQhINE7z.js";
3
3
  import { t as o } from "./react-Bgs_wQh3.js";
4
4
  import { t as s } from "./compiler-runtime-C5KHtL5D.js";
5
5
  import { h as c, t as l } from "./tooltip-CiJ919pg.js";
6
- import { Cn as u, En as d, Sn as f, dn as p, et as m, f as h, i as g, l as _, n as v, nt as y, r as b, t as x, tt as S, u as C } from "./common-rNx_NjSU.js";
6
+ import { Cn as u, En as d, Sn as f, dn as p, et as m, f as h, i as g, l as _, n as v, nt as y, r as b, t as x, tt as S, u as C } from "./common-DeBx86ld.js";
7
7
  import { M as w } from "./select-PQHWLm64.js";
8
8
  import { X as T } from "./dropdown-menu-B12Nf3Zf.js";
9
9
  import { t as E } from "./jsx-runtime-D8btoEHk.js";
10
10
  import { Rt as D, Vt as O, f as k, i as ee } from "./use-restore-focus-BLj45Ibw.js";
11
11
  import { t as A } from "./useEvent-BoN7U38T.js";
12
12
  import { o as te } from "./static-state-CWXd6dYX.js";
13
- import { n as ne, t as re } from "./code-visibility-D3Fzysn4.js";
13
+ import { n as ne, t as re } from "./code-visibility-BauZWifR.js";
14
14
  /* empty css */
15
15
  var j = c("sticky-note", [["path", {
16
16
  d: "M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.25.3-dev481",
3
+ "version": "0.25.3-dev485",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -262,6 +262,7 @@ export const MockExecutions = {
262
262
  ),
263
263
  requested: new Set(),
264
264
  blocked: new Set(),
265
+ shownBlocked: new Set(),
265
266
  runtimeId: null,
266
267
  ...extra,
267
268
  };
@@ -287,6 +288,7 @@ export const MockExecutions = {
287
288
  generationAtom: atom(1),
288
289
  backendAtom: atom<NotebookBackend | null>(null),
289
290
  notebookAtom: atom<Protocol.Notebook | null>(MockExecutions.notebook()),
291
+ analysisAtom: atom(null),
290
292
  documentAtom,
291
293
  shownDocumentAtom: documentAtom,
292
294
  runtimeAtom: atom(runtime),
@@ -77,7 +77,7 @@ describe("CellStatusComponent", () => {
77
77
  interrupted: false,
78
78
  elapsedTime: null,
79
79
  startedAt: null,
80
- blocked: false,
80
+ blocked: null,
81
81
  uninstantiated: false,
82
82
  };
83
83
 
@@ -124,7 +124,7 @@ describe("CellStatusComponent", () => {
124
124
  test("renders disabled transitively state", () => {
125
125
  const props = {
126
126
  ...baseProps,
127
- blocked: true,
127
+ blocked: "current" as const,
128
128
  startedAt: 1_704_096_000_000 as Milliseconds,
129
129
  };
130
130
 
@@ -139,7 +139,7 @@ describe("CellStatusComponent", () => {
139
139
  test("renders stale and disabled transitively state", () => {
140
140
  const props = {
141
141
  ...baseProps,
142
- blocked: true,
142
+ blocked: "current" as const,
143
143
  freshness: { sourceChanged: false, inputsChanged: true } as CellFreshness,
144
144
  startedAt: 1_704_096_000_000 as Milliseconds,
145
145
  };
@@ -7,7 +7,11 @@ import {
7
7
  } from "lucide-react";
8
8
  import { useDateFormatter } from "react-aria";
9
9
  import { MultiIcon } from "@/components/icons/multi-icon";
10
- import type { CellFreshness, CellRunStatus } from "@/core/executions";
10
+ import type {
11
+ CellExecutionView,
12
+ CellFreshness,
13
+ CellRunStatus,
14
+ } from "@/core/executions";
11
15
  import { Logger } from "@/utils/Logger";
12
16
  import { useElapsedTime } from "../../../hooks/useElapsedTime";
13
17
  import { Tooltip } from "../../ui/tooltip";
@@ -20,7 +24,7 @@ export interface CellStatusComponentProps {
20
24
  editing: boolean;
21
25
  disabled: boolean;
22
26
  /** Whether a cell it depends on is disabled. */
23
- blocked: boolean;
27
+ blocked: CellExecutionView["shownBlock"];
24
28
  /** Whether the cell's result is current. */
25
29
  freshness: CellFreshness;
26
30
  status: CellRunStatus;
@@ -109,43 +113,20 @@ export const CellStatusComponent: React.FC<CellStatusComponentProps> = ({
109
113
  );
110
114
  }
111
115
 
112
- // disabled from parent
113
- if (!staleInputs && blocked) {
114
- return (
115
- <Tooltip
116
- content={
117
- <div className="flex flex-col gap-1">
118
- <span>
119
- An ancestor of this cell is disabled, so it can't be run
120
- </span>
121
- {lastRanTime}
122
- </div>
123
- }
124
- usePortal={true}
125
- >
126
- <div
127
- className="cell-status-icon cell-status-stale"
128
- data-testid="cell-status"
129
- data-status="disabled-transitively"
130
- >
131
- <MultiIcon layerTop={true}>
132
- <WorkflowIcon className="h-5 w-5" strokeWidth={1.5} />
133
- <BanIcon className="h-3 w-3" strokeWidth={2.5} />
134
- </MultiIcon>
135
- </div>
136
- </Tooltip>
137
- );
138
- }
139
-
140
- // stale from parent being disabled
141
- if (staleInputs && blocked) {
116
+ // A live run takes precedence over a badge from an earlier revision.
117
+ if (blocked === "current" || (blocked === "stale" && status === "idle")) {
118
+ let message = "An ancestor of this cell is disabled, so it can't be run";
119
+ if (blocked === "stale") {
120
+ message = "Blocked in the last analysis";
121
+ } else if (staleInputs) {
122
+ message =
123
+ "This cell is stale, but an ancestor is disabled so it can't be run";
124
+ }
142
125
  return (
143
126
  <Tooltip
144
127
  content={
145
128
  <div className="flex flex-col gap-1">
146
- <span>
147
- This cell is stale, but an ancestor is disabled so it can't be run
148
- </span>
129
+ <span>{message}</span>
149
130
  {lastRanTime}
150
131
  </div>
151
132
  }
@@ -154,10 +135,14 @@ export const CellStatusComponent: React.FC<CellStatusComponentProps> = ({
154
135
  <div
155
136
  className="cell-status-icon cell-status-stale"
156
137
  data-testid="cell-status"
157
- data-status="stale"
138
+ data-status={staleInputs ? "stale" : "disabled-transitively"}
158
139
  >
159
- <MultiIcon>
160
- <RefreshCwIcon className="h-5 w-5" strokeWidth={1} />
140
+ <MultiIcon layerTop={!staleInputs}>
141
+ {staleInputs ? (
142
+ <RefreshCwIcon className="h-5 w-5" strokeWidth={1} />
143
+ ) : (
144
+ <WorkflowIcon className="h-5 w-5" strokeWidth={1.5} />
145
+ )}
161
146
  <BanIcon className="h-3 w-3" strokeWidth={2.5} />
162
147
  </MultiIcon>
163
148
  </div>
@@ -864,7 +864,7 @@ const CellRightSideActions = memo(
864
864
  disabled={disabled}
865
865
  elapsedTime={execution.duration}
866
866
  startedAt={execution.startedAt}
867
- blocked={execution.blocked}
867
+ blocked={execution.shownBlock}
868
868
  uninstantiated={uninstantiated}
869
869
  />
870
870
  );
@@ -102,7 +102,7 @@ export const SlideCellView = ({ cell }: { cell: RuntimeCell }) => {
102
102
  interrupted={interrupted}
103
103
  elapsedTime={execution.duration}
104
104
  startedAt={execution.startedAt}
105
- blocked={execution.blocked}
105
+ blocked={execution.shownBlock}
106
106
  uninstantiated={uninstantiated}
107
107
  />
108
108
  <LanguageToggles
@@ -14,7 +14,6 @@ import {
14
14
  acceptRun,
15
15
  cellExecutionInputsAtom,
16
16
  notebookQueuedOrRunningCountAtom,
17
- setCellBlocked,
18
17
  requestRun,
19
18
  type RunRequest,
20
19
  withdrawRequest,
@@ -111,53 +110,14 @@ describe("requestRun", () => {
111
110
  expect(store.get(notebookQueuedOrRunningCountAtom)).toBe(0);
112
111
  });
113
112
 
114
- it("forgets requests and blocked cells with the notebook they were made in", () => {
113
+ it("forgets requests when the notebook changes", () => {
115
114
  const { store, replica } = shown();
116
115
  request(store, [C1]);
117
- setCellBlocked(store, C2, true);
118
116
 
119
117
  store.set(replica.notebookAtom, MockExecutions.notebook("n2"));
120
118
 
121
119
  expect(requested(store)).toEqual([]);
122
120
  expect(statusOf(store)).toBe("idle");
123
- expect(store.get(cellExecutionInputsAtom).blocked.size).toBe(0);
124
- });
125
- });
126
-
127
- describe("setCellBlocked", () => {
128
- it("does not show a requested cell as queued once the kernel reports it blocked", () => {
129
- const { store } = shown();
130
- request(store, [C1]);
131
- expect(statusOf(store)).toBe("queued");
132
-
133
- setCellBlocked(store, C1, true);
134
-
135
- const view = cellExecutionView(store.get(cellExecutionInputsAtom), C1);
136
- expect(view.status).toBe("idle");
137
- expect(view.blocked).toBe(true);
138
- expect(store.get(notebookQueuedOrRunningCountAtom)).toBe(0);
139
- });
140
-
141
- it("forgets requests and blocked cells with the replica they were made for", () => {
142
- const { store } = shown();
143
- request(store, [C1]);
144
- setCellBlocked(store, C1, true);
145
-
146
- MockExecutions.seed(store, [], null, documentOf());
147
-
148
- const view = cellExecutionView(store.get(cellExecutionInputsAtom), C1);
149
- expect(view.status).toBe("idle");
150
- expect(view.blocked).toBe(false);
151
- expect(store.get(notebookQueuedOrRunningCountAtom)).toBe(0);
152
- });
153
-
154
- it("keeps a request while the cell is merely queued", () => {
155
- const { store } = shown();
156
- request(store, [C1]);
157
-
158
- setCellBlocked(store, C1, false);
159
-
160
- expect(statusOf(store)).toBe("queued");
161
121
  });
162
122
  });
163
123
 
@@ -20,7 +20,6 @@ import {
20
20
  cellOutputAtom,
21
21
  clearCellOutputs,
22
22
  isCurrent,
23
- setCellBlocked,
24
23
  requestRun,
25
24
  withdrawRequest,
26
25
  } from "../atoms";
@@ -128,9 +127,7 @@ describe("output lifetime", () => {
128
127
  const pending = requestRun(store, [C1])!;
129
128
  acceptRun(store, pending, run);
130
129
  const late = requestRun(store, [C1])!;
131
- setCellBlocked(store, C1, true);
132
130
  clearCellOutputs(store, [C1]);
133
- expect(store.get(cellExecutionInputsAtom).blocked.has(C1)).toBe(true);
134
131
  expect(store.get(cellOutputAtom(C1))).toBeNull();
135
132
 
136
133
  if (recovery !== "in-place reset") {
@@ -141,9 +138,8 @@ describe("output lifetime", () => {
141
138
  } else {
142
139
  message({ event: "ready", id: "120", data: {} });
143
140
  }
144
- const { requested, blocked } = store.get(cellExecutionInputsAtom);
141
+ const { requested } = store.get(cellExecutionInputsAtom);
145
142
  expect([...requested]).toEqual([]);
146
- expect([...blocked]).toEqual([]);
147
143
  expect(store.get(cellOutputAtom(C1))?.data).toBe("A");
148
144
  expect(isCurrent(store, late)).toBe(false);
149
145
 
@@ -2,10 +2,11 @@
2
2
 
3
3
  import type * as Protocol from "@marimo-team/client/protocol";
4
4
  import { describe, expect, it } from "vitest";
5
- import { CONFIG } from "@/core/notebook/document/__tests__/fixtures";
5
+ import { cell, CONFIG } from "@/core/notebook/document/__tests__/fixtures";
6
6
  import type { Execution, Executions, Results } from "@/core/notebook/replica";
7
7
  import {
8
8
  anyRunning,
9
+ blockedDescendants,
9
10
  type CellExecutionInputs,
10
11
  cellExecutionView,
11
12
  onlyScratchRunning,
@@ -13,6 +14,26 @@ import {
13
14
  runningCellIds,
14
15
  } from "../select";
15
16
 
17
+ it("counts only distinct disabled ancestors in a cycle", () => {
18
+ const analysis: Protocol.Analysis = {
19
+ notebook_id: "n1",
20
+ document_etag: "v1",
21
+ cells: {
22
+ a: { defs: [], refs: [], parents: ["b"], errors: [] },
23
+ b: { defs: [], refs: [], parents: ["a"], errors: [] },
24
+ },
25
+ };
26
+ const disabled = (id: string) =>
27
+ cell(id, "", { config: { ...CONFIG, disabled: true } });
28
+ const a = disabled("a");
29
+ expect(blockedDescendants(analysis, [a, cell("b", "")])).toEqual(
30
+ new Set(["b"]),
31
+ );
32
+ expect(blockedDescendants(analysis, [a, disabled("b")])).toEqual(
33
+ new Set(["a", "b"]),
34
+ );
35
+ });
36
+
16
37
  const T0 = "2026-10-01T09:20:11Z";
17
38
  const T1 = "2026-10-01T09:20:12.500Z";
18
39
  const T2 = "2026-10-01T09:20:20Z";
@@ -116,7 +137,15 @@ function inputs({
116
137
  { config: { ...CONFIG, disabled: disabled.includes(id) } },
117
138
  ]),
118
139
  );
119
- return { executions: stream, results, cells, requested, blocked, runtimeId };
140
+ return {
141
+ executions: stream,
142
+ results,
143
+ cells,
144
+ requested,
145
+ blocked,
146
+ shownBlocked: blocked,
147
+ runtimeId,
148
+ };
120
149
  }
121
150
 
122
151
  describe("cellExecutionView", () => {
@@ -124,6 +153,7 @@ describe("cellExecutionView", () => {
124
153
  expect(cellExecutionView(inputs({}), "c1")).toEqual({
125
154
  status: "idle",
126
155
  blocked: false,
156
+ shownBlock: null,
127
157
  outcome: null,
128
158
  startedAt: null,
129
159
  duration: null,
@@ -153,6 +183,7 @@ describe("cellExecutionView", () => {
153
183
  expect(cellExecutionView(running, "c1")).toEqual({
154
184
  status: "running",
155
185
  blocked: false,
186
+ shownBlock: null,
156
187
  outcome: null,
157
188
  startedAt: Date.parse(T2),
158
189
  duration: null,
@@ -206,6 +237,7 @@ describe("cellExecutionView", () => {
206
237
  expect(value).toEqual({
207
238
  status: "idle",
208
239
  blocked: false,
240
+ shownBlock: null,
209
241
  outcome: "succeeded",
210
242
  startedAt: Date.parse(T0),
211
243
  duration: 1500,
@@ -26,6 +26,7 @@ import {
26
26
  } from "./output";
27
27
  import {
28
28
  anyRunning,
29
+ blockedDescendants,
29
30
  type CellExecutionInputs,
30
31
  queuedOrRunningCount,
31
32
  } from "./select";
@@ -82,14 +83,6 @@ export interface RunRequest {
82
83
  */
83
84
  const requestsAtom = atom<Marks<ReadonlySet<RunRequest>>>(null);
84
85
 
85
- /**
86
- * Cells the kernel reports as blocked by a disabled ancestor. Written only
87
- * by the editor session.
88
- *
89
- * TODO(MO-8463): Derive from the document and the analysis stream.
90
- */
91
- const blockedCellsAtom = atom<Marks<ReadonlySet<Protocol.CellId>>>(null);
92
-
93
86
  function sameNotebook(
94
87
  marked: ShownNotebook,
95
88
  shown: ShownNotebook | null,
@@ -133,6 +126,19 @@ const requestedCellsAtom = atom((get) => {
133
126
  : new Set([...requests].flatMap((request) => request.cells));
134
127
  });
135
128
 
129
+ /** Use the disabled flags from the same revision as the dependency graph. */
130
+ const blockedCellsAtom = atom((get) => {
131
+ const replica = get(activeNotebookReplicaAtom);
132
+ const view = replica && get(replica.analysisAtom);
133
+ const shownBlocked = view
134
+ ? blockedDescendants(view.analysis, view.document.cells.values())
135
+ : NO_BLOCKED;
136
+ return {
137
+ shownBlocked,
138
+ blocked: view?.freshness === "current" ? shownBlocked : NO_BLOCKED,
139
+ };
140
+ });
141
+
136
142
  /** What every cell's view derives from. Pair with `cellExecutionView`. */
137
143
  export const cellExecutionInputsAtom = atom((get): CellExecutionInputs => {
138
144
  const replica = get(activeNotebookReplicaAtom);
@@ -142,7 +148,7 @@ export const cellExecutionInputsAtom = atom((get): CellExecutionInputs => {
142
148
  results: replica === null ? NO_RESULTS : get(replica.resultsAtom),
143
149
  cells: document?.cells ?? NO_CELLS,
144
150
  requested: get(requestedCellsAtom),
145
- blocked: current(get(blockedCellsAtom), get(shownNotebookAtom), NO_BLOCKED),
151
+ ...get(blockedCellsAtom),
146
152
  runtimeId: replica === null ? null : (get(replica.runtimeAtom)?.id ?? null),
147
153
  };
148
154
  });
@@ -335,7 +341,7 @@ export function waitForRuntimeRunning(store: Store): Promise<void> {
335
341
  * Record that this browser is asking the host to run `cellIds`, so that
336
342
  * they read as queued before the host has answered.
337
343
  *
338
- * A disabled cell, or one the kernel reports as blocked, may be among them
344
+ * A disabled cell, or one with a disabled ancestor, may be among them
339
345
  * so the kernel can set it aside, but the views do not show it as queued.
340
346
  * Returns null while no notebook is shown, since there is nothing to
341
347
  * record the request against.
@@ -391,24 +397,3 @@ export function acceptRun(
391
397
  }
392
398
  check();
393
399
  }
394
-
395
- export function setCellBlocked(
396
- store: Store,
397
- cellId: Protocol.CellId,
398
- blocked: boolean,
399
- ): void {
400
- const known = store.get(cellExecutionInputsAtom).blocked;
401
- if (known.has(cellId) === blocked) {
402
- return;
403
- }
404
- const next = new Set(known);
405
- if (blocked) {
406
- next.add(cellId);
407
- } else {
408
- next.delete(cellId);
409
- }
410
- const notebook = store.get(shownNotebookAtom);
411
- if (notebook !== null) {
412
- store.set(blockedCellsAtom, { notebook, value: next });
413
- }
414
- }
@@ -23,9 +23,8 @@ import { type CellExecutionView, cellExecutionView } from "./select";
23
23
  /**
24
24
  * A cell's status, timing, and how it last ended.
25
25
  *
26
- * Read from the host's executions, with the editor's own marks for a run
27
- * it has requested and the kernel has not planned yet, and for a cell the
28
- * kernel reports blocked by a disabled ancestor.
26
+ * Host executions describe the run, document analysis identifies blocked
27
+ * cells, and local requests account for runs the host has yet to plan.
29
28
  */
30
29
  export function useCellExecution(id: Protocol.CellId): CellExecutionView {
31
30
  // One atom per mounted cell, kept for its subscription and compared by
@@ -19,7 +19,6 @@ export {
19
19
  clearCellOutputs,
20
20
  notebookIsRunningAtom,
21
21
  notebookQueuedOrRunningCountAtom,
22
- setCellBlocked,
23
22
  releaseCellOutputAtoms,
24
23
  runtimeStatusAtom,
25
24
  waitForRuntimeRunning,
@@ -17,6 +17,7 @@ export interface CellExecutionView {
17
17
  readonly status: CellRunStatus;
18
18
  /** Whether a cell it depends on is disabled, so it cannot run. */
19
19
  readonly blocked: boolean;
20
+ readonly shownBlock: "current" | "stale" | null;
20
21
  /** Null until the cell completes once, and while it runs again. */
21
22
  readonly outcome: CellOutcome | null;
22
23
  /**
@@ -48,8 +49,9 @@ export interface CellExecutionInputs {
48
49
  * shown the run.
49
50
  */
50
51
  readonly requested: ReadonlySet<Protocol.CellId>;
51
- /** Cells the kernel reports as blocked by a disabled ancestor. */
52
+ /** Cells with a disabled ancestor in the confirmed document. */
52
53
  readonly blocked: ReadonlySet<Protocol.CellId>;
54
+ readonly shownBlocked: ReadonlySet<Protocol.CellId>;
53
55
  /** The notebook's runtime, null while it has none or the stream is not ready. */
54
56
  readonly runtimeId: Protocol.RuntimeId | null;
55
57
  }
@@ -72,6 +74,51 @@ function latestOf(
72
74
  : (executions.executions.get(executionId) ?? null);
73
75
  }
74
76
 
77
+ /** Cells with a distinct disabled ancestor in the host's dependency graph. */
78
+ export function blockedDescendants(
79
+ analysis: Protocol.Analysis,
80
+ cells: Iterable<Protocol.Cell>,
81
+ ): ReadonlySet<Protocol.CellId> {
82
+ const blocked = new Set<Protocol.CellId>();
83
+ const roots = [...cells].filter((cell) => cell.config.disabled);
84
+ if (roots.length === 0) {
85
+ return blocked;
86
+ }
87
+ const children = new Map<Protocol.CellId, Protocol.CellId[]>();
88
+ for (const id of Object.keys(analysis.cells)) {
89
+ children.set(id, []);
90
+ }
91
+ for (const [id, { parents }] of Object.entries(analysis.cells)) {
92
+ if (parents === undefined) {
93
+ return blocked;
94
+ }
95
+ for (const parent of parents) {
96
+ children.get(parent)?.push(id);
97
+ }
98
+ }
99
+
100
+ // A second distinct root blocks even the first root in a cycle.
101
+ // Beyond two roots, visiting the same subtree cannot add any blocked cells.
102
+ const visits = new Map<Protocol.CellId, number>();
103
+ for (const root of roots) {
104
+ const reachable = new Set([root.id]);
105
+ for (const id of reachable) {
106
+ if (id !== root.id) {
107
+ blocked.add(id);
108
+ }
109
+ const count = visits.get(id) ?? 0;
110
+ if (count === 2) {
111
+ continue;
112
+ }
113
+ visits.set(id, count + 1);
114
+ for (const child of children.get(id) ?? []) {
115
+ reachable.add(child);
116
+ }
117
+ }
118
+ }
119
+ return blocked;
120
+ }
121
+
75
122
  /**
76
123
  * Whether a run can reach `id`, meaning the document has the cell and
77
124
  * nothing keeps it from running.
@@ -137,9 +184,15 @@ export function cellExecutionView(
137
184
  settled && began !== null && ended !== null
138
185
  ? Time.parse(ended).since(Time.parse(began))
139
186
  : null;
187
+ const blocked = inputs.blocked.has(id);
140
188
  return {
141
189
  status,
142
- blocked: inputs.blocked.has(id),
190
+ blocked,
191
+ shownBlock: blocked
192
+ ? "current"
193
+ : inputs.shownBlocked.has(id)
194
+ ? "stale"
195
+ : null,
143
196
  outcome: settled && result !== null ? outcomeOf(result) : null,
144
197
  live:
145
198
  result === null ||
@@ -26,7 +26,6 @@ import { UI_ELEMENT_REGISTRY } from "../dom/uiregistry";
26
26
  import { FUNCTIONS_REGISTRY } from "../functions/FunctionRegistry";
27
27
  import { createNotebookReplica } from "../notebook/replica";
28
28
  import { consoleObservers } from "../cells/execution-console";
29
- import { setCellBlocked } from "../executions";
30
29
  import { handleKernelReady, handleRemoveUIElements } from "../kernel/handlers";
31
30
  import type { NotificationMessage } from "../kernel/messages";
32
31
  import { queryParamHandlers } from "../kernel/queryParamHandlers";
@@ -261,13 +260,6 @@ function handleNotification(
261
260
  });
262
261
  return;
263
262
  case "cell-op":
264
- if (msg.status != null) {
265
- setCellBlocked(
266
- store,
267
- msg.cell_id,
268
- msg.status === "disabled-transitively",
269
- );
270
- }
271
263
  if (msg.serialization !== undefined) {
272
264
  actions.setCellReusability({
273
265
  cell_id: msg.cell_id,