@malloy-publisher/sdk 0.17.0 → 0.17.2

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 (87) hide show
  1. package/README.md +32 -50
  2. package/dist/{RenderedResult-BcEDcw0V.es.js → RenderedResult-CYJ2Y9Fm.es.js} +24 -24
  3. package/dist/{RenderedResult-uT2oc6ke.cjs.js → RenderedResult-hRvgFMAF.cjs.js} +1 -1
  4. package/dist/ServerProvider-DeVejmVr.cjs.js +1 -0
  5. package/dist/{ServerProvider-vmEUjlEu.es.js → ServerProvider-DzzfVDg_.es.js} +1314 -1712
  6. package/dist/builder/index.cjs.js +12 -12
  7. package/dist/builder/index.es.js +4 -9
  8. package/dist/client/api.d.ts +63 -506
  9. package/dist/client/configuration.d.ts +1 -1
  10. package/dist/client/index.cjs.js +1 -1
  11. package/dist/client/index.d.ts +1 -1
  12. package/dist/client/index.es.js +132 -144
  13. package/dist/components/Dashboard/DashboardGrid.d.ts +1 -1
  14. package/dist/components/Model/ExplorerPage.d.ts +1 -3
  15. package/dist/components/Model/Model.d.ts +1 -4
  16. package/dist/components/Model/ModelExplorer.d.ts +1 -2
  17. package/dist/components/Package/reportQueries.d.ts +2 -4
  18. package/dist/components/Report/Report.d.ts +20 -9
  19. package/dist/components/{legacy → Report}/malloynb/CellRunnerView.d.ts +13 -16
  20. package/dist/components/Report/malloynb/MalloynbReport.d.ts +11 -0
  21. package/dist/components/{legacy → Report}/malloynb/cellKind.d.ts +1 -1
  22. package/dist/components/ServerProvider.d.ts +1 -3
  23. package/dist/components/drill/drillClauses.d.ts +8 -9
  24. package/dist/components/drill/rowsTarget.d.ts +7 -9
  25. package/dist/components/legacy/index.d.ts +3 -7
  26. package/dist/components/modelPage.d.ts +2 -5
  27. package/dist/hooks/useModelGivens.d.ts +2 -2
  28. package/dist/hooks/useQueryResult.d.ts +7 -0
  29. package/dist/index.cjs.js +33 -33
  30. package/dist/index.es.js +8799 -8903
  31. package/dist/{useCompiledDocument-h5-Kc1Zh.cjs.js → useCompiledDocument-BCr-xB_i.cjs.js} +4 -4
  32. package/dist/{useCompiledDocument-rOwDSK_s.es.js → useCompiledDocument-E0tU5KzP.es.js} +266 -277
  33. package/package.json +1 -1
  34. package/src/components/Dashboard/DashboardGrid.tsx +1 -1
  35. package/src/components/Dashboard/DashboardTile.spec.tsx +1 -1
  36. package/src/components/Model/ExplorerPage.tsx +1 -3
  37. package/src/components/Model/Model.tsx +1 -4
  38. package/src/components/Model/ModelExplorer.tsx +1 -2
  39. package/src/components/Package/Package.tsx +1 -5
  40. package/src/components/Package/reportQueries.ts +3 -15
  41. package/src/components/Report/Report.malloynb.spec.tsx +230 -0
  42. package/src/components/Report/Report.spec.tsx +429 -38
  43. package/src/components/Report/Report.telemetry.spec.tsx +51 -10
  44. package/src/components/Report/Report.tsx +63 -44
  45. package/src/components/{legacy → Report}/malloynb/CellRunnerView.spec.tsx +11 -44
  46. package/src/components/{legacy → Report}/malloynb/CellRunnerView.tsx +63 -107
  47. package/src/components/Report/malloynb/MalloynbReport.tsx +110 -0
  48. package/src/components/{legacy → Report}/malloynb/cellKind.ts +5 -4
  49. package/src/components/ReportBuilder/EditorSurface.tsx +3 -3
  50. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +2 -2
  51. package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +0 -4
  52. package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +0 -1
  53. package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -3
  54. package/src/components/ReportBuilder/ReportEditor.tsx +1 -1
  55. package/src/components/ReportBuilder/loadMalloy.ts +1 -4
  56. package/src/components/ReportBuilder/useSaveChannel.ts +1 -6
  57. package/src/components/ServerProvider.tsx +0 -4
  58. package/src/components/drill/drillClauses.ts +8 -9
  59. package/src/components/drill/rowsTarget.ts +7 -9
  60. package/src/components/index.ts +2 -3
  61. package/src/components/legacy/index.ts +3 -7
  62. package/src/components/modelPage.ts +2 -5
  63. package/src/hooks/useGivensState.ts +8 -8
  64. package/src/hooks/useModelGivens.ts +2 -2
  65. package/src/hooks/useQueryResult.ts +30 -18
  66. package/test/README.md +4 -4
  67. package/dist/ServerProvider-DDRwHiPz.cjs.js +0 -1
  68. package/dist/components/legacy/Dashboard.d.ts +0 -68
  69. package/dist/components/legacy/malloynb/MalloynbCells.d.ts +0 -13
  70. package/dist/components/legacy/malloynb/Notebook.d.ts +0 -15
  71. package/dist/components/legacy/queryKeys.d.ts +0 -8
  72. package/src/components/legacy/Dashboard.spec.tsx +0 -242
  73. package/src/components/legacy/Dashboard.tsx +0 -181
  74. package/src/components/legacy/malloynb/MalloynbCells.tsx +0 -88
  75. package/src/components/legacy/malloynb/Notebook.layout.spec.tsx +0 -103
  76. package/src/components/legacy/malloynb/Notebook.served.spec.tsx +0 -84
  77. package/src/components/legacy/malloynb/Notebook.spec.tsx +0 -223
  78. package/src/components/legacy/malloynb/Notebook.tsx +0 -46
  79. package/src/components/legacy/queryKeys.ts +0 -26
  80. /package/dist/components/{legacy → Report}/malloynb/NotebookCell.d.ts +0 -0
  81. /package/dist/components/{legacy → Report}/malloynb/runPlan.d.ts +0 -0
  82. /package/dist/components/{legacy → Report}/malloynb/types.d.ts +0 -0
  83. /package/src/components/{legacy → Report}/malloynb/NotebookCell.tsx +0 -0
  84. /package/src/components/{legacy → Report}/malloynb/cellKind.spec.ts +0 -0
  85. /package/src/components/{legacy → Report}/malloynb/runPlan.spec.ts +0 -0
  86. /package/src/components/{legacy → Report}/malloynb/runPlan.ts +0 -0
  87. /package/src/components/{legacy → Report}/malloynb/types.ts +0 -0
@@ -14,6 +14,7 @@ import type { TileChrome } from "../Dashboard/TileCard";
14
14
  import type { DrillNavigation } from "../drill";
15
15
  import { Loading, LOADING_COPY } from "../Loading";
16
16
  import { useServer } from "../ServerProvider";
17
+ import { MalloynbReport } from "./malloynb/MalloynbReport";
17
18
  import { reportQueryOptions } from "./reportQuery";
18
19
  import {
19
20
  failureCategory,
@@ -28,9 +29,9 @@ export interface ReportProps {
28
29
  resourceUri: string;
29
30
  /**
30
31
  * The report's package path, including `.malloy`, exactly as
31
- * `GET …/reports` lists it: `sales/q3.malloy`. Its identity. A `.malloynb`
32
- * the listing also has is rendered by the deprecated `Notebook`, which runs
33
- * its cells through the only routes that can.
32
+ * `GET …/reports` lists it: `sales/q3.malloy`. Its identity. A legacy
33
+ * `.malloynb` the listing also has is rendered cell by cell, each code cell
34
+ * run through the same query endpoint as a tile.
34
35
  */
35
36
  path: string;
36
37
  /**
@@ -66,7 +67,10 @@ export interface ReportProps {
66
67
  * router. Omitted, links are plain anchors.
67
68
  */
68
69
  onLinkNavigate?: (to: string, event?: NavigationClick) => void;
69
- /** Height cap for a grid tile's result panel; see `Dashboard`. */
70
+ /**
71
+ * Height cap for a grid tile's result panel; see `DashboardView`. A linear
72
+ * report's tiles, and a `.malloynb`'s cells, take the layout's own.
73
+ */
70
74
  height?: number;
71
75
  maxResultSize?: number;
72
76
  /**
@@ -74,7 +78,10 @@ export interface ReportProps {
74
78
  * shown, a drill — for the host to log or count; see `ReportEvent`.
75
79
  */
76
80
  onEvent?: ReportEventHandler;
77
- /** Ignored: kept so existing callers compile. Both layouts draw the same cards. */
81
+ /**
82
+ * Ignored: kept so existing callers compile. Both layouts draw the same
83
+ * cards, and a `.malloynb` draws its cells the same way.
84
+ */
78
85
  chrome?: TileChrome;
79
86
  /**
80
87
  * How long a read of the report is reused without asking the server again,
@@ -88,12 +95,16 @@ export interface ReportProps {
88
95
  /**
89
96
  * The host's actions for the report (a download, its own menu), drawn at
90
97
  * the end of the title's line rather than on a row of their own above it.
98
+ * A `.malloynb` has no title line, since its title is its own first
99
+ * markdown cell, so there they are drawn on a row of their own above the
100
+ * cells.
91
101
  */
92
102
  actions?: ReactNode;
93
103
  /**
94
104
  * The host's actions for the rows behind a clicked value (a download),
95
105
  * drawn in the rows dialog's title row. Omitted, the dialog offers its own
96
- * Download CSV; return `null` for none.
106
+ * Download CSV; return `null` for none. A `.malloynb`'s cells open no rows
107
+ * dialog, so there it is unused.
97
108
  */
98
109
  rowsActions?: RowsActions;
99
110
  }
@@ -101,10 +112,11 @@ export interface ReportProps {
101
112
  /**
102
113
  * A report of either layout, from `GET …/reports/{path}`: a grid drawn as a
103
114
  * dashboard, or a linear report top to bottom (a legacy `.malloynb` among
104
- * them, read-only), each tile run through the governed query endpoint.
115
+ * them, read-only, cell by cell), each tile or cell run through the governed
116
+ * query endpoint.
105
117
  *
106
- * Host-agnostic, like `Dashboard`: it takes props rather than reading a
107
- * router, and hands navigation and URL state back to whoever mounted it.
118
+ * Host-agnostic: it takes props rather than reading a router, and hands
119
+ * navigation and URL state back to whoever mounted it.
108
120
  */
109
121
  export function Report({
110
122
  resourceUri,
@@ -174,21 +186,19 @@ export function Report({
174
186
  surface: "view",
175
187
  category: failureCategory(error),
176
188
  });
177
- } else if (manifest?.notebook?.format === "malloynb") {
178
- // Report does not run one; the host renders it with `Notebook`.
179
- reported.current = reportKey;
180
- events.emit({
181
- type: "report.load_failed",
182
- surface: "view",
183
- category: "unsupported",
184
- });
185
189
  } else if (isSuccess && manifest) {
186
190
  reported.current = reportKey;
187
191
  events.emit({
188
192
  type: "report.opened",
189
193
  surface: "view",
190
194
  from: "package",
191
- tiles: manifest.tiles?.length ?? 0,
195
+ // A `.malloynb` has cells instead of tiles: count the ones it runs.
196
+ tiles:
197
+ manifest.tiles?.length ??
198
+ manifest.notebook?.notebookCells?.filter(
199
+ (cell) => cell.type === "code" && cell.runQuery !== undefined,
200
+ ).length ??
201
+ 0,
192
202
  durationMs: now() - started.current.at,
193
203
  });
194
204
  }
@@ -224,33 +234,42 @@ export function Report({
224
234
  return <Loading text={LOADING_COPY.opening("report")} />;
225
235
  }
226
236
 
227
- if (manifest.notebook?.format === "malloynb") {
228
- return (
229
- <Alert severity="info">
230
- {path} is a .malloynb notebook, which Report does not run: render it
231
- with Notebook.
232
- </Alert>
237
+ // Either layout: the same view, arranged as the manifest's layout says. A
238
+ // legacy `.malloynb` is cells, each code cell run as its own query, under
239
+ // no header: its own markdown is its title, as it always was.
240
+ const body =
241
+ manifest.notebook?.format === "malloynb" ? (
242
+ <MalloynbReport
243
+ environmentName={environmentName}
244
+ packageName={packageName}
245
+ versionId={versionId}
246
+ path={path}
247
+ notebook={manifest.notebook}
248
+ givens={givens}
249
+ onGivensChange={onGivensChange}
250
+ onNavigate={onLinkNavigate}
251
+ onDrillNavigate={drillNavigate}
252
+ maxResultSize={maxResultSize}
253
+ {...(actions !== undefined ? { actions } : {})}
254
+ />
255
+ ) : (
256
+ <DashboardView
257
+ manifest={manifest}
258
+ environmentName={environmentName}
259
+ packageName={packageName}
260
+ versionId={versionId}
261
+ documentName={path}
262
+ givens={givens}
263
+ onGivensChange={onGivensChange}
264
+ onNavigate={drillNavigate}
265
+ {...(onLinkNavigate ? { onLinkNavigate } : {})}
266
+ height={height}
267
+ maxResultSize={maxResultSize}
268
+ chrome={chrome}
269
+ {...(actions !== undefined ? { actions } : {})}
270
+ {...(rowsActions !== undefined ? { rowsActions } : {})}
271
+ />
233
272
  );
234
- }
235
- // Either layout: the same view, arranged as the manifest's layout says.
236
- const body = (
237
- <DashboardView
238
- manifest={manifest}
239
- environmentName={environmentName}
240
- packageName={packageName}
241
- versionId={versionId}
242
- documentName={path}
243
- givens={givens}
244
- onGivensChange={onGivensChange}
245
- onNavigate={drillNavigate}
246
- {...(onLinkNavigate ? { onLinkNavigate } : {})}
247
- height={height}
248
- maxResultSize={maxResultSize}
249
- chrome={chrome}
250
- {...(actions !== undefined ? { actions } : {})}
251
- {...(rowsActions !== undefined ? { rowsActions } : {})}
252
- />
253
- );
254
273
  return (
255
274
  <ReportEventsContext.Provider value={events}>
256
275
  {body}
@@ -5,18 +5,17 @@
5
5
  // `.malloynb` notebooks (see RELEASE_NOTES deprecations).
6
6
 
7
7
  /**
8
- * What a `.malloynb` shows when something fails: a cell the server refuses
9
- * says why in that cell and leaves the others running, and cells that could
10
- * not be read at all say so in place of the cells.
8
+ * What a `.malloynb` shows when a cell fails: a cell the server refuses says
9
+ * why in that cell and leaves the others running.
11
10
  */
12
11
  import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test";
13
- import { render, screen, waitFor } from "@testing-library/react";
12
+ import { render, screen } from "@testing-library/react";
14
13
  import {
15
14
  clearCache,
16
15
  mockServerProvider,
17
16
  serverWrapper,
18
17
  } from "../../../../test/serverProvider";
19
- import type { RawNotebook } from "../../../client";
18
+ import type { ReportCells } from "../../../client";
20
19
  import type { CellRunner } from "./CellRunnerView";
21
20
 
22
21
  // Cells run through the runner each test hands in, never the server.
@@ -27,7 +26,7 @@ const { CellRunnerView } = await import("./CellRunnerView");
27
26
 
28
27
  const URI = "publisher://environments/env/packages/pkg/models/review.malloynb";
29
28
 
30
- const cells = (...queries: string[]): RawNotebook => ({
29
+ const cells = (...queries: string[]): ReportCells => ({
31
30
  format: "malloynb",
32
31
  notebookCells: [
33
32
  { type: "markdown", text: "Intro prose" },
@@ -41,11 +40,11 @@ const refused = (message: string) =>
41
40
  response: { data: { message } },
42
41
  });
43
42
 
44
- /** A runner that answers each cell's code with `answer`, and records the order it was asked in. */
43
+ /** A runner that answers each cell's code with `answer`, and records the cells it was asked for. */
45
44
  function runner(answer: (code: string) => Promise<unknown>) {
46
- const asked: number[] = [];
47
- const runCell: CellRunner = ({ cell, index }) => {
48
- asked.push(index);
45
+ const asked: string[] = [];
46
+ const runCell: CellRunner = ({ cell }) => {
47
+ asked.push(cell.text ?? "");
49
48
  return answer(cell.text ?? "") as ReturnType<CellRunner>;
50
49
  };
51
50
  return { asked, runCell };
@@ -110,42 +109,10 @@ describe("a cell that fails", () => {
110
109
  );
111
110
 
112
111
  expect(await screen.findByText("no such source")).toBeTruthy();
113
- // The markdown cell is index 0 and never runs.
114
- expect(asked).toEqual([1, 2]);
112
+ // The markdown cell never runs.
113
+ expect(asked).toEqual(["run: bad -> v", "run: good -> v"]);
115
114
  expect(screen.getAllByText("This cell could not be run.")).toHaveLength(
116
115
  1,
117
116
  );
118
117
  });
119
118
  });
120
-
121
- describe("cells that could not be read", () => {
122
- const view = (error: { status: number; message: string }) =>
123
- render(
124
- <CellRunnerView
125
- resourceUri={URI}
126
- notebook={undefined}
127
- error={{
128
- ...error,
129
- name: "ApiError",
130
- data: { code: error.status, message: error.message },
131
- }}
132
- runCell={() => Promise.resolve({})}
133
- />,
134
- { wrapper: serverWrapper },
135
- );
136
-
137
- it("names the notebook that does not exist", () => {
138
- view({ status: 404, message: "Not found" });
139
- expect(screen.getByText("env > pkg > review.malloynb")).toBeTruthy();
140
- expect(screen.getByText(/not found\./)).toBeTruthy();
141
- });
142
-
143
- it("shows any other failure with the notebook it was reading", async () => {
144
- view({ status: 500, message: "The package did not load" });
145
- await waitFor(() =>
146
- expect(screen.getByText("env > pkg > review.malloynb")).toBeTruthy(),
147
- );
148
- expect(screen.getByText("The package did not load")).toBeTruthy();
149
- expect(screen.queryByText(/not found\./)).toBeNull();
150
- });
151
- });
@@ -2,41 +2,40 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  /**
5
- * @deprecated `.malloynb` only. The cell runner behind the deprecated
6
- * `Notebook`: it runs a `.malloynb` notebook's code cells through the
7
- * deprecated `…/notebooks/*` routes and draws them on the shared report page.
8
- * Nothing outside `legacy/malloynb/` imports it (eslint enforces this), and it
9
- * is deleted with the `.malloynb` format. A `.malloy` report is always tiles,
10
- * drawn by `DashboardView`.
5
+ * @deprecated `.malloynb` only, and deleted with the format. Draws a
6
+ * `.malloynb` notebook's cells on the shared report page and runs each code
7
+ * cell through the runner its caller passes: `Report` runs them through the
8
+ * governed query endpoint. A `.malloy` report is always tiles, drawn by
9
+ * `DashboardView`.
11
10
  */
12
11
 
13
12
  import "@malloydata/malloy-explorer/styles.css";
14
- import { Typography } from "@mui/material";
15
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
16
- import type { NotebookCell as RawCell, RawNotebook } from "../../../client";
13
+ import { Stack } from "@mui/material";
14
+ import {
15
+ useCallback,
16
+ useEffect,
17
+ useMemo,
18
+ useRef,
19
+ useState,
20
+ type ReactNode,
21
+ } from "react";
22
+ import type { NotebookCell as RawCell, ReportCells } from "../../../client";
17
23
  import type { GivenValue } from "../../../hooks/givenValue";
18
24
  import { useDocumentControls } from "../../../hooks/useDocumentControls";
19
25
  import { useModelGivens } from "../../../hooks/useModelGivens";
20
26
  import { GIVEN_SETTLE_MS } from "../../../hooks/useSettled";
21
27
  import { parseResourceUri } from "../../../utils/formatting";
22
- import { ApiErrorDisplay, type ApiError } from "../../ApiErrorDisplay";
28
+ import { ApiErrorDisplay } from "../../ApiErrorDisplay";
23
29
  import type { NavigationClick } from "../../click_helper";
24
30
  import type { DrillNavigation } from "../../drill";
25
31
  import { GivensPanel } from "../../given";
26
32
  import { givensToParams, givensToRequest } from "../../given/paramCodec";
27
- import { Loading, LOADING_COPY } from "../../Loading";
28
33
  import { cellRuns } from "./cellKind";
29
34
  import { NotebookCell } from "./NotebookCell";
30
35
  import { planRun } from "./runPlan";
31
36
  import type { EnhancedNotebookCell } from "./types";
32
37
  import { failureCategory, useReportEvents } from "../../Report/telemetry";
33
- import { Prose } from "../../Prose";
34
- import {
35
- ReportHeader,
36
- ReportPage,
37
- StickyControls,
38
- TextTileFrame,
39
- } from "../../Report/ReportPage";
38
+ import { ReportPage, StickyControls } from "../../Report/ReportPage";
40
39
 
41
40
  // Maximum number of concurrent cell executions to avoid overwhelming the server
42
41
  const MAX_CONCURRENT = 4;
@@ -58,26 +57,20 @@ function cellErrorMessage(error: unknown): string {
58
57
  return "The server did not say why.";
59
58
  }
60
59
 
61
- /** What one cell's run is handed: the cell, its index, the values to run it with, and the signal that cancels it. */
60
+ /** What one cell's run is handed: the cell, the values to run it with, and the signal that cancels it. */
62
61
  interface CellRun {
63
62
  cell: RawCell;
64
- index: number;
65
63
  givens: ReadonlyMap<string, GivenValue>;
66
64
  declaredTypes: ReadonlyMap<string, string | undefined>;
67
65
  signal: AbortSignal;
68
66
  }
69
67
 
70
68
  /** Runs one cell. Stable across renders: a new runner re-runs every cell. */
71
- export type CellRunner = (
72
- run: CellRun,
73
- ) => Promise<{ result?: string; newSources?: string[] }>;
69
+ export type CellRunner = (run: CellRun) => Promise<{ result?: string }>;
74
70
 
75
71
  export interface CellReportProps {
76
72
  /** `publisher://…/models/<path>`: the report, and the model its cells run against. */
77
73
  resourceUri: string;
78
- /** The report's title and description, drawn in the header every report has. */
79
- title?: string;
80
- description?: string;
81
74
  maxResultSize?: number;
82
75
  /**
83
76
  * Parameter values from the host, typically its URL query parameters: the
@@ -124,30 +117,30 @@ export interface CellReportProps {
124
117
  * destinations inert AND unmarked rather than painting a dead link.
125
118
  */
126
119
  onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
120
+ /**
121
+ * The host's actions for the report, drawn on a row of their own above the
122
+ * cells, since a `.malloynb`'s title is its own first markdown cell.
123
+ */
124
+ actions?: ReactNode;
127
125
  }
128
126
 
129
127
  /**
130
- * Cells run one by one, the engine behind a report written as `run:` cells.
131
- * Takes the cells (undefined while they load, `error` when they could not be
132
- * read) and the runner that executes one; what reads the cells and what runs
133
- * them is the caller's.
128
+ * Cells run one by one, the engine behind a `.malloynb` notebook.
129
+ * Takes the loaded cells and the runner that executes one; what reads the
130
+ * cells and what runs them is the caller's.
134
131
  */
135
132
  export function CellRunnerView({
136
133
  resourceUri,
137
- title,
138
- description,
139
134
  maxResultSize = 0,
140
135
  givens,
141
136
  onGivensChange,
142
137
  onNavigate,
143
138
  onDrillNavigate,
139
+ actions,
144
140
  notebook,
145
- error,
146
141
  runCell,
147
142
  }: CellReportProps & {
148
- notebook: RawNotebook | undefined;
149
- /** Why the cells could not be read; the view says so in place of them. */
150
- error?: ApiError | null;
143
+ notebook: ReportCells;
151
144
  runCell: CellRunner;
152
145
  }) {
153
146
  const {
@@ -156,8 +149,6 @@ export function CellRunnerView({
156
149
  versionId,
157
150
  modelPath: notebookPath,
158
151
  } = parseResourceUri(resourceUri);
159
- const isSuccess = notebook !== undefined;
160
- const isError = !isSuccess && !!error;
161
152
 
162
153
  // State to store executed cells with results
163
154
  const [enhancedCells, setEnhancedCells] = useState<EnhancedNotebookCell[]>(
@@ -176,18 +167,18 @@ export function CellRunnerView({
176
167
  // the same hook a grid uses, so both layouts get URL-addressable
177
168
  // parameters, Apply batching and `to=self` drill from one implementation.
178
169
  const declaredGivens = useModelGivens(notebook);
179
- // A file-level `## autorun=false` arrives as `RawNotebook.autorun`, the same
170
+ // A file-level `## autorun=false` arrives as `ReportCells.autorun`, the same
180
171
  // field with the same default a grid's `## artifact { autorun=false }`
181
172
  // produces. Batching matters more here than on a grid: one control change
182
173
  // re-runs every cell in the document.
183
- const autorun = notebook?.autorun !== false;
184
- // Set by `Report`; silent under the deprecated `Notebook`, which shares this view.
174
+ const autorun = notebook.autorun !== false;
175
+ // Set by `Report`.
185
176
  const events = useReportEvents();
186
177
  const controls = useDocumentControls({
187
178
  specs: declaredGivens,
188
- loaded: isSuccess,
179
+ loaded: true,
189
180
  // Where the controls start, from a file-level `## givens { … }`.
190
- startingValues: notebook?.startingGivens,
181
+ startingValues: notebook.startingGivens,
191
182
  params: givens,
192
183
  onGivensChange,
193
184
  documentKey: resourceUri,
@@ -269,7 +260,7 @@ export function CellRunnerView({
269
260
  );
270
261
  const executeCells = useCallback(
271
262
  async (givensToApply: Map<string, GivenValue> = new Map()) => {
272
- if (!isSuccess || !notebook?.notebookCells) return;
263
+ if (!notebook.notebookCells) return;
273
264
 
274
265
  const runId = ++runIdRef.current;
275
266
 
@@ -304,7 +295,6 @@ export function CellRunnerView({
304
295
  try {
305
296
  const executedCell = await runCell({
306
297
  cell: rawCell,
307
- index: cellIndex,
308
298
  givens: givensToApply,
309
299
  declaredTypes,
310
300
  signal: controller.signal,
@@ -313,10 +303,6 @@ export function CellRunnerView({
313
303
  if (runIdRef.current !== runId) return;
314
304
 
315
305
  const result = executedCell.result;
316
- // A `.malloy` report's cells carry their sources on the
317
- // manifest; a run adds none.
318
- const newSources =
319
- rawCell.newSources || executedCell.newSources;
320
306
 
321
307
  setEnhancedCells((prev) => {
322
308
  const next = [...prev];
@@ -326,7 +312,6 @@ export function CellRunnerView({
326
312
  next[cellIndex] = {
327
313
  ...next[cellIndex],
328
314
  result,
329
- newSources,
330
315
  };
331
316
  return next;
332
317
  });
@@ -399,7 +384,7 @@ export function CellRunnerView({
399
384
  }
400
385
  }
401
386
  },
402
- [isSuccess, notebook, declaredTypes, runCell, events],
387
+ [notebook, declaredTypes, runCell, events],
403
388
  );
404
389
 
405
390
  // Run the cells on load, and again whenever the applied parameters change.
@@ -416,7 +401,7 @@ export function CellRunnerView({
416
401
  // a new object only when the content actually differs, so identity is
417
402
  // exactly the "has this document changed" signal.
418
403
  const notebookGenRef = useRef(0);
419
- const seenNotebookRef = useRef<RawNotebook | undefined>(undefined);
404
+ const seenNotebookRef = useRef<ReportCells | undefined>(undefined);
420
405
  if (seenNotebookRef.current !== notebook) {
421
406
  seenNotebookRef.current = notebook;
422
407
  notebookGenRef.current += 1;
@@ -440,7 +425,7 @@ export function CellRunnerView({
440
425
  lastDocumentRef.current = documentKey;
441
426
 
442
427
  const plan = planRun({
443
- ready: isSuccess && !!notebook?.notebookCells,
428
+ ready: !!notebook.notebookCells,
444
429
  lastRunKey: lastRunRef.current,
445
430
  pendingKey: pendingRunRef.current?.key,
446
431
  runKey,
@@ -473,7 +458,6 @@ export function CellRunnerView({
473
458
  timer: setTimeout(start, GIVEN_SETTLE_MS),
474
459
  };
475
460
  }, [
476
- isSuccess,
477
461
  notebook,
478
462
  notebookGen,
479
463
  resourceUri,
@@ -483,7 +467,7 @@ export function CellRunnerView({
483
467
  ]);
484
468
 
485
469
  const shownCells =
486
- enhancedCells.length > 0 ? enhancedCells : notebook?.notebookCells || [];
470
+ enhancedCells.length > 0 ? enhancedCells : notebook.notebookCells || [];
487
471
  // A .malloynb keeps the copy-link icon on its first cell.
488
472
  const copyLinkIndex = 0;
489
473
 
@@ -494,17 +478,10 @@ export function CellRunnerView({
494
478
  // Cells read top to bottom, so a report of cells is linear.
495
479
  layout="linear"
496
480
  header={
497
- title || description ? (
498
- <ReportHeader
499
- title={title ?? ""}
500
- description={
501
- description ? (
502
- <TextTileFrame>
503
- <Prose variant="document">{description}</Prose>
504
- </TextTileFrame>
505
- ) : undefined
506
- }
507
- />
481
+ actions ? (
482
+ <Stack direction="row" sx={{ justifyContent: "flex-end" }}>
483
+ {actions}
484
+ </Stack>
508
485
  ) : null
509
486
  }
510
487
  controls={
@@ -515,48 +492,27 @@ export function CellRunnerView({
515
492
  ) : undefined
516
493
  }
517
494
  >
518
- {!isSuccess && !isError && (
519
- <Loading text={LOADING_COPY.opening("report")} />
520
- )}
521
-
522
- {isSuccess &&
523
- shownCells.map((cell, index) => (
524
- <NotebookCell
525
- cell={cell as EnhancedNotebookCell}
526
- key={index}
527
- showCopyLink={index === copyLinkIndex}
528
- resourceUri={resourceUri}
529
- maxResultSize={maxResultSize}
530
- isExecuting={isExecuting}
531
- givens={cellStartingGivens}
532
- givenSpecs={declaredGivens}
533
- // Distinct from `isExecuting`: the cell's spinner is
534
- // gated on `!cell.result`, so feeding this through it
535
- // showed nothing on a re-run, which is the only case
536
- // the settle window has to signal.
537
- pendingRerun={runScheduled}
538
- onNavigate={onNavigate}
539
- onDrillNavigate={onDrillNavigate}
540
- onDrillSelf={
541
- declaredGivens.length > 0 ? onDrillSelf : undefined
542
- }
543
- canDrillSelf={canDrillSelf}
544
- />
545
- ))}
546
-
547
- {isError && error?.status === 404 && (
548
- <Typography variant="body2" sx={{ color: "text.secondary" }}>
549
- <code>{`${environmentName} > ${packageName} > ${notebookPath}`}</code>{" "}
550
- not found.
551
- </Typography>
552
- )}
553
-
554
- {isError && error?.status !== 404 && (
555
- <ApiErrorDisplay
556
- error={error as ApiError}
557
- context={`${environmentName} > ${packageName} > ${notebookPath}`}
495
+ {shownCells.map((cell, index) => (
496
+ <NotebookCell
497
+ cell={cell as EnhancedNotebookCell}
498
+ key={index}
499
+ showCopyLink={index === copyLinkIndex}
500
+ resourceUri={resourceUri}
501
+ maxResultSize={maxResultSize}
502
+ isExecuting={isExecuting}
503
+ givens={cellStartingGivens}
504
+ givenSpecs={declaredGivens}
505
+ // Distinct from `isExecuting`: the cell's spinner is
506
+ // gated on `!cell.result`, so feeding this through it
507
+ // showed nothing on a re-run, which is the only case
508
+ // the settle window has to signal.
509
+ pendingRerun={runScheduled}
510
+ onNavigate={onNavigate}
511
+ onDrillNavigate={onDrillNavigate}
512
+ onDrillSelf={declaredGivens.length > 0 ? onDrillSelf : undefined}
513
+ canDrillSelf={canDrillSelf}
558
514
  />
559
- )}
515
+ ))}
560
516
 
561
517
  {executionError && (
562
518
  <ApiErrorDisplay