@marimo-team/frontend 0.21.2-dev39 → 0.21.2-dev41

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 (78) hide show
  1. package/dist/assets/{edit-page-OLDApdB5.js → edit-page-Cqvk7zWH.js} +7 -7
  2. package/dist/assets/{index-DZVnuqxZ.js → index-BSzIstPK.js} +2 -2
  3. package/dist/assets/{panels-LFK8M8Jo.js → panels-B2DAaT1E.js} +1 -1
  4. package/dist/assets/{run-page-B-zpKjX2.js → run-page-DMpRvHgf.js} +1 -1
  5. package/dist/assets/tracing-BxcUfhUv.js +1 -0
  6. package/dist/assets/{tracing-panel-CKmy1CaA.js → tracing-panel-DK4YfdoZ.js} +2 -2
  7. package/dist/index.html +1 -1
  8. package/package.json +1 -1
  9. package/src/__mocks__/notebook.ts +9 -9
  10. package/src/__tests__/branded.ts +20 -0
  11. package/src/components/data-table/charts/__tests__/storage.test.ts +7 -7
  12. package/src/components/editor/__tests__/data-attributes.test.tsx +8 -8
  13. package/src/components/editor/ai/__tests__/completion-utils.test.ts +15 -15
  14. package/src/components/editor/navigation/__tests__/clipboard.test.ts +2 -2
  15. package/src/components/editor/navigation/__tests__/selection.test.ts +7 -6
  16. package/src/components/editor/navigation/__tests__/state.test.ts +8 -7
  17. package/src/components/editor/output/MarimoErrorOutput.tsx +7 -7
  18. package/src/components/editor/output/__tests__/traceback.test.tsx +4 -4
  19. package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +4 -4
  20. package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +8 -1
  21. package/src/components/storage/storage-inspector.tsx +1 -2
  22. package/src/components/tracing/tracing.tsx +3 -1
  23. package/src/core/ai/__tests__/staged-cells.test.ts +9 -8
  24. package/src/core/ai/context/providers/__tests__/cell-output.test.ts +31 -31
  25. package/src/core/ai/context/providers/__tests__/datasource.test.ts +3 -3
  26. package/src/core/ai/context/providers/__tests__/tables.test.ts +3 -2
  27. package/src/core/ai/context/providers/__tests__/variable.test.ts +84 -63
  28. package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +10 -9
  29. package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +6 -6
  30. package/src/core/ai/tools/edit-notebook-tool.ts +3 -3
  31. package/src/core/cells/__tests__/add-missing-import.test.ts +3 -3
  32. package/src/core/cells/__tests__/cells.test.ts +192 -135
  33. package/src/core/cells/__tests__/focus.test.ts +5 -4
  34. package/src/core/cells/__tests__/logs.test.ts +13 -12
  35. package/src/core/cells/__tests__/pending-delete-service.test.tsx +3 -3
  36. package/src/core/cells/__tests__/runs.test.ts +22 -21
  37. package/src/core/cells/__tests__/scrollCellIntoView.test.ts +8 -7
  38. package/src/core/cells/__tests__/session.test.ts +23 -22
  39. package/src/core/cells/cells.ts +1 -1
  40. package/src/core/cells/ids.ts +5 -5
  41. package/src/core/cells/logs.ts +2 -2
  42. package/src/core/cells/runs.ts +6 -8
  43. package/src/core/codemirror/__tests__/format.test.ts +34 -36
  44. package/src/core/codemirror/__tests__/setup.test.ts +2 -2
  45. package/src/core/codemirror/cells/__tests__/traceback-decorations.test.ts +33 -32
  46. package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +12 -13
  47. package/src/core/codemirror/language/__tests__/utils.test.ts +3 -3
  48. package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +7 -8
  49. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +4 -3
  50. package/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts +7 -6
  51. package/src/core/codemirror/reactive-references/analyzer.ts +2 -2
  52. package/src/core/datasets/__tests__/data-source.test.ts +5 -6
  53. package/src/core/datasets/state.ts +1 -1
  54. package/src/core/errors/__tests__/errors.test.ts +2 -1
  55. package/src/core/export/__tests__/hooks.test.ts +37 -36
  56. package/src/core/islands/main.ts +2 -7
  57. package/src/core/kernel/__tests__/handlers.test.ts +5 -4
  58. package/src/core/kernel/handlers.ts +7 -4
  59. package/src/core/network/DeferredRequestRegistry.ts +2 -2
  60. package/src/core/network/__tests__/CachingRequestRegistry.test.ts +9 -10
  61. package/src/core/network/__tests__/DeferredRequestRegistry.test.ts +4 -6
  62. package/src/core/static/__tests__/virtual-file-tracker.test.ts +8 -8
  63. package/src/core/static/virtual-file-tracker.ts +1 -1
  64. package/src/core/storage/__tests__/state.test.ts +31 -21
  65. package/src/core/storage/state.ts +1 -1
  66. package/src/core/variables/__tests__/state.test.ts +6 -6
  67. package/src/core/variables/types.ts +2 -2
  68. package/src/core/wasm/__tests__/state.test.ts +8 -8
  69. package/src/core/websocket/useMarimoKernelConnection.tsx +12 -15
  70. package/src/plugins/impl/anywidget/model.ts +1 -2
  71. package/src/stories/cell.stories.tsx +8 -8
  72. package/src/stories/layout/vertical/one-column.stories.tsx +9 -8
  73. package/src/stories/log-viewer.stories.tsx +8 -8
  74. package/src/stories/variables.stories.tsx +2 -2
  75. package/src/utils/__tests__/download.test.tsx +19 -18
  76. package/src/utils/json/base64.ts +3 -3
  77. package/src/utils/traceback.ts +5 -3
  78. package/dist/assets/tracing-QGIu3SN5.js +0 -1
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
 
4
4
  import { beforeEach, describe, expect, it } from "vitest";
5
- import type { CellId } from "@/core/cells/ids";
5
+ import { cellId, variableName } from "@/__tests__/branded";
6
6
  import type {
7
7
  ConnectionsMap,
8
8
  DatasetTablesMap,
@@ -88,7 +88,7 @@ const createMockDataTable = (
88
88
  source_type: "local",
89
89
  num_rows: 100,
90
90
  num_columns: 3,
91
- variable_name: name, // This makes it a dataframe
91
+ variable_name: variableName(name), // This makes it a dataframe
92
92
  columns: [
93
93
  {
94
94
  name: "id",
@@ -634,7 +634,7 @@ describe("DatasourceContextProvider", () => {
634
634
 
635
635
  describe("getDatasourceContext", () => {
636
636
  it("should return null if no cell ID is found", () => {
637
- const context = getDatasourceContext("1" as CellId);
637
+ const context = getDatasourceContext(cellId("1"));
638
638
  expect(context).toBeNull();
639
639
  });
640
640
  });
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import { describe, expect, it } from "vitest";
4
+ import { variableName } from "@/__tests__/branded";
4
5
  import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";
5
6
  import type { DataTable, DataTableColumn } from "@/core/kernel/messages";
6
7
  import { type TableContextItem, TableContextProvider } from "../tables";
@@ -86,7 +87,7 @@ describe("TableContextProvider", () => {
86
87
 
87
88
  it("should handle dataframe tables with variable names", () => {
88
89
  const dfTable = createMockTable("df_analysis", {
89
- variable_name: "df_analysis",
90
+ variable_name: variableName("df_analysis"),
90
91
  source: "pandas",
91
92
  source_type: "local",
92
93
  columns: [
@@ -180,7 +181,7 @@ describe("TableContextProvider", () => {
180
181
  const table = createMockTable("remote_table", {
181
182
  source: "postgresql://localhost:5432/mydb",
182
183
  source_type: "connection",
183
- engine: "postgresql",
184
+ engine: variableName("postgresql"),
184
185
  columns: [
185
186
  createMockColumn("uuid", "string", "uuid"),
186
187
  createMockColumn("created_at", "string", "timestamp with time zone"),
@@ -2,9 +2,9 @@
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
 
4
4
  import { describe, expect, it, vi } from "vitest";
5
- import type { CellId } from "@/core/cells/ids";
5
+ import { cellId, variableName } from "@/__tests__/branded";
6
6
  import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";
7
- import type { Variable, VariableName, Variables } from "@/core/variables/types";
7
+ import type { Variable, Variables } from "@/core/variables/types";
8
8
  import { type VariableContextItem, VariableContextProvider } from "../variable";
9
9
 
10
10
  // Mock the variable completions module
@@ -17,7 +17,7 @@ vi.mock("@/core/codemirror/completion/variable-completions", () => ({
17
17
  prefix: string,
18
18
  ) => {
19
19
  return Object.entries(variables).map(([name, variable]) => ({
20
- name: `${prefix}${name}`,
20
+ name: variableName(`${prefix}${name}`),
21
21
  displayname: name,
22
22
  detail: variable.dataType || "unknown",
23
23
  boost,
@@ -34,9 +34,9 @@ const createMockVariable = (
34
34
  name: string,
35
35
  options: Partial<Variable> = {},
36
36
  ): Variable => ({
37
- name: name as VariableName,
38
- declaredBy: ["cell1" as CellId],
39
- usedBy: ["cell2" as CellId],
37
+ name: variableName(name),
38
+ declaredBy: [cellId("cell1")],
39
+ usedBy: [cellId("cell2")],
40
40
  value: `value_of_${name}`,
41
41
  dataType: "str",
42
42
  ...options,
@@ -55,10 +55,13 @@ describe("VariableContextProvider", () => {
55
55
 
56
56
  it("should return variable items for single variable", () => {
57
57
  const variables: Variables = {
58
- ["user_name" as VariableName]: createMockVariable("user_name", {
59
- value: '"John Doe"',
60
- dataType: "str",
61
- }),
58
+ [variableName("user_name")]: createMockVariable(
59
+ variableName("user_name"),
60
+ {
61
+ value: '"John Doe"',
62
+ dataType: "str",
63
+ },
64
+ ),
62
65
  };
63
66
  const tablesMap: DatasetTablesMap = new Map();
64
67
  const provider = new VariableContextProvider(variables, tablesMap);
@@ -69,29 +72,32 @@ describe("VariableContextProvider", () => {
69
72
 
70
73
  it("should return variable items for multiple variables with different types", () => {
71
74
  const variables: Variables = {
72
- ["user_id" as VariableName]: createMockVariable("user_id", {
75
+ [variableName("user_id")]: createMockVariable(variableName("user_id"), {
73
76
  value: "123",
74
77
  dataType: "int",
75
- declaredBy: ["cell1" as CellId],
76
- usedBy: ["cell2" as CellId, "cell3" as CellId],
77
- }),
78
- ["is_active" as VariableName]: createMockVariable("is_active", {
79
- value: "True",
80
- dataType: "bool",
81
- declaredBy: ["cell2" as CellId],
82
- usedBy: [],
78
+ declaredBy: [cellId("cell1")],
79
+ usedBy: [cellId("cell2"), cellId("cell3")],
83
80
  }),
84
- ["scores" as VariableName]: createMockVariable("scores", {
81
+ [variableName("is_active")]: createMockVariable(
82
+ variableName("is_active"),
83
+ {
84
+ value: "True",
85
+ dataType: "bool",
86
+ declaredBy: [cellId("cell2")],
87
+ usedBy: [],
88
+ },
89
+ ),
90
+ [variableName("scores")]: createMockVariable(variableName("scores"), {
85
91
  value: "[1, 2, 3, 4, 5]",
86
92
  dataType: "list",
87
- declaredBy: ["cell3" as CellId],
88
- usedBy: ["cell4" as CellId],
93
+ declaredBy: [cellId("cell3")],
94
+ usedBy: [cellId("cell4")],
89
95
  }),
90
- ["config" as VariableName]: createMockVariable("config", {
96
+ [variableName("config")]: createMockVariable(variableName("config"), {
91
97
  value: '{"debug": true, "timeout": 30}',
92
98
  dataType: "dict",
93
- declaredBy: ["cell1" as CellId],
94
- usedBy: ["cell2" as CellId, "cell4" as CellId],
99
+ declaredBy: [cellId("cell1")],
100
+ usedBy: [cellId("cell2"), cellId("cell4")],
95
101
  }),
96
102
  };
97
103
  const tablesMap: DatasetTablesMap = new Map();
@@ -103,18 +109,27 @@ describe("VariableContextProvider", () => {
103
109
 
104
110
  it("should handle variables with null/undefined values", () => {
105
111
  const variables: Variables = {
106
- ["null_var" as VariableName]: createMockVariable("null_var", {
107
- value: null,
108
- dataType: "NoneType",
109
- }),
110
- ["undefined_var" as VariableName]: createMockVariable("undefined_var", {
111
- value: undefined,
112
- dataType: null,
113
- }),
114
- ["empty_string" as VariableName]: createMockVariable("empty_string", {
115
- value: '""',
116
- dataType: "str",
117
- }),
112
+ [variableName("null_var")]: createMockVariable(
113
+ variableName("null_var"),
114
+ {
115
+ value: null,
116
+ dataType: "NoneType",
117
+ },
118
+ ),
119
+ [variableName("undefined_var")]: createMockVariable(
120
+ variableName("undefined_var"),
121
+ {
122
+ value: undefined,
123
+ dataType: null,
124
+ },
125
+ ),
126
+ [variableName("empty_string")]: createMockVariable(
127
+ variableName("empty_string"),
128
+ {
129
+ value: '""',
130
+ dataType: "str",
131
+ },
132
+ ),
118
133
  };
119
134
  const tablesMap: DatasetTablesMap = new Map();
120
135
  const provider = new VariableContextProvider(variables, tablesMap);
@@ -125,23 +140,23 @@ describe("VariableContextProvider", () => {
125
140
 
126
141
  it("should handle complex data types", () => {
127
142
  const variables: Variables = {
128
- ["df" as VariableName]: createMockVariable("df", {
143
+ [variableName("df")]: createMockVariable(variableName("df"), {
129
144
  value: "<DataFrame shape: (100, 5)>",
130
145
  dataType: "pandas.DataFrame",
131
- declaredBy: ["cell1" as CellId],
132
- usedBy: ["cell2" as CellId, "cell3" as CellId],
146
+ declaredBy: [cellId("cell1")],
147
+ usedBy: [cellId("cell2"), cellId("cell3")],
133
148
  }),
134
- ["model" as VariableName]: createMockVariable("model", {
149
+ [variableName("model")]: createMockVariable(variableName("model"), {
135
150
  value: "<sklearn.linear_model.LinearRegression>",
136
151
  dataType: "sklearn.linear_model._base.LinearRegression",
137
- declaredBy: ["cell4" as CellId],
138
- usedBy: ["cell5" as CellId],
152
+ declaredBy: [cellId("cell4")],
153
+ usedBy: [cellId("cell5")],
139
154
  }),
140
- ["array" as VariableName]: createMockVariable("array", {
155
+ [variableName("array")]: createMockVariable(variableName("array"), {
141
156
  value: "array([1, 2, 3, 4, 5])",
142
157
  dataType: "numpy.ndarray",
143
- declaredBy: ["cell2" as CellId],
144
- usedBy: ["cell3" as CellId],
158
+ declaredBy: [cellId("cell2")],
159
+ usedBy: [cellId("cell3")],
145
160
  }),
146
161
  };
147
162
  const tablesMap: DatasetTablesMap = new Map();
@@ -153,21 +168,27 @@ describe("VariableContextProvider", () => {
153
168
 
154
169
  it("should handle variables with special characters in names", () => {
155
170
  const variables: Variables = {
156
- ["_private_var" as VariableName]: createMockVariable("_private_var", {
157
- value: "42",
158
- dataType: "int",
159
- }),
160
- ["var_with_numbers123" as VariableName]: createMockVariable(
161
- "var_with_numbers123",
171
+ [variableName("_private_var")]: createMockVariable(
172
+ variableName("_private_var"),
173
+ {
174
+ value: "42",
175
+ dataType: "int",
176
+ },
177
+ ),
178
+ [variableName("var_with_numbers123")]: createMockVariable(
179
+ variableName("var_with_numbers123"),
162
180
  {
163
181
  value: '"test"',
164
182
  dataType: "str",
165
183
  },
166
184
  ),
167
- ["CONSTANT_VAR" as VariableName]: createMockVariable("CONSTANT_VAR", {
168
- value: "3.14159",
169
- dataType: "float",
170
- }),
185
+ [variableName("CONSTANT_VAR")]: createMockVariable(
186
+ variableName("CONSTANT_VAR"),
187
+ {
188
+ value: "3.14159",
189
+ dataType: "float",
190
+ },
191
+ ),
171
192
  };
172
193
  const tablesMap: DatasetTablesMap = new Map();
173
194
  const provider = new VariableContextProvider(variables, tablesMap);
@@ -191,7 +212,7 @@ describe("VariableContextProvider", () => {
191
212
  data: { variable },
192
213
  };
193
214
 
194
- const variables: Variables = { ["username" as VariableName]: variable };
215
+ const variables: Variables = { [variableName("username")]: variable };
195
216
  const tablesMap: DatasetTablesMap = new Map();
196
217
  const provider = new VariableContextProvider(variables, tablesMap);
197
218
 
@@ -213,7 +234,7 @@ describe("VariableContextProvider", () => {
213
234
  };
214
235
 
215
236
  const variables: Variables = {
216
- ["mystery_var" as VariableName]: variable,
237
+ [variableName("mystery_var")]: variable,
217
238
  };
218
239
  const tablesMap: DatasetTablesMap = new Map();
219
240
  const provider = new VariableContextProvider(variables, tablesMap);
@@ -237,7 +258,7 @@ describe("VariableContextProvider", () => {
237
258
  };
238
259
 
239
260
  const variables: Variables = {
240
- ["complex_data" as VariableName]: variable,
261
+ [variableName("complex_data")]: variable,
241
262
  };
242
263
  const tablesMap: DatasetTablesMap = new Map();
243
264
  const provider = new VariableContextProvider(variables, tablesMap);
@@ -260,7 +281,7 @@ describe("VariableContextProvider", () => {
260
281
  data: { variable },
261
282
  };
262
283
 
263
- const variables: Variables = { ["sales_df" as VariableName]: variable };
284
+ const variables: Variables = { [variableName("sales_df")]: variable };
264
285
  const tablesMap: DatasetTablesMap = new Map();
265
286
  const provider = new VariableContextProvider(variables, tablesMap);
266
287
 
@@ -284,12 +305,12 @@ describe("VariableContextProvider", () => {
284
305
  describe("integration with tables", () => {
285
306
  it("should work with both variables and tables", () => {
286
307
  const variables: Variables = {
287
- ["df" as VariableName]: createMockVariable("df", {
308
+ [variableName("df")]: createMockVariable(variableName("df"), {
288
309
  dataType: "pandas.DataFrame",
289
310
  value: "<DataFrame shape: (50, 3)>",
290
311
  }),
291
- ["connection_string" as VariableName]: createMockVariable(
292
- "connection_string",
312
+ [variableName("connection_string")]: createMockVariable(
313
+ variableName("connection_string"),
293
314
  {
294
315
  dataType: "str",
295
316
  value: '"postgresql://localhost:5432/mydb"',
@@ -5,6 +5,7 @@ import { EditorView } from "@codemirror/view";
5
5
  import { getDefaultStore } from "jotai";
6
6
  import { beforeEach, describe, expect, it, vi } from "vitest";
7
7
  import { MockNotebook } from "@/__mocks__/notebook";
8
+ import { cellId } from "@/__tests__/branded";
8
9
  import { notebookAtom } from "@/core/cells/cells";
9
10
  import type { CellId } from "@/core/cells/ids";
10
11
  import { updateEditorCodeFromPython } from "@/core/codemirror/language/utils";
@@ -32,7 +33,7 @@ function createMockEditorView(code: string): EditorView {
32
33
  doc: code,
33
34
  extensions: [
34
35
  adaptiveLanguageConfiguration({
35
- cellId: "cell1" as CellId,
36
+ cellId: cellId("cell1"),
36
37
  completionConfig: {
37
38
  copilot: false,
38
39
  activate_on_typing: true,
@@ -44,7 +45,7 @@ function createMockEditorView(code: string): EditorView {
44
45
  lspConfig: {},
45
46
  }),
46
47
  cellConfigExtension({
47
- cellId: "cell1" as CellId,
48
+ cellId: cellId("cell1"),
48
49
  completionConfig: {
49
50
  copilot: false,
50
51
  activate_on_typing: true,
@@ -93,9 +94,9 @@ describe("EditNotebookTool", () => {
93
94
  };
94
95
  tool = new EditNotebookTool();
95
96
 
96
- cellId1 = "cell-1" as CellId;
97
- cellId2 = "cell-2" as CellId;
98
- cellId3 = "cell-3" as CellId;
97
+ cellId1 = cellId("cell-1");
98
+ cellId2 = cellId("cell-2");
99
+ cellId3 = cellId("cell-3");
99
100
 
100
101
  // Reset mocks
101
102
  vi.clearAllMocks();
@@ -270,7 +271,7 @@ describe("EditNotebookTool", () => {
270
271
  {
271
272
  edit: {
272
273
  type: "update_cell",
273
- position: { cellId: "nonexistent" as CellId },
274
+ position: { cellId: cellId("nonexistent") },
274
275
  code: "x = 2",
275
276
  },
276
277
  },
@@ -283,7 +284,7 @@ describe("EditNotebookTool", () => {
283
284
  {
284
285
  edit: {
285
286
  type: "update_cell",
286
- position: { cellId: "nonexistent" as CellId },
287
+ position: { cellId: cellId("nonexistent") },
287
288
  code: "x = 2",
288
289
  },
289
290
  },
@@ -496,7 +497,7 @@ describe("EditNotebookTool", () => {
496
497
  type: "add_cell",
497
498
  position: {
498
499
  type: "relative",
499
- cellId: "nonexistent" as CellId,
500
+ cellId: cellId("nonexistent"),
500
501
  before: true,
501
502
  },
502
503
  code: "y = 2",
@@ -660,7 +661,7 @@ describe("EditNotebookTool", () => {
660
661
  {
661
662
  edit: {
662
663
  type: "delete_cell",
663
- position: { cellId: "nonexistent" as CellId },
664
+ position: { cellId: cellId("nonexistent") },
664
665
  },
665
666
  },
666
667
  toolContext as never,
@@ -3,6 +3,7 @@
3
3
  import { getDefaultStore } from "jotai";
4
4
  import { beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import { MockNotebook } from "@/__mocks__/notebook";
6
+ import { cellId } from "@/__tests__/branded";
6
7
  import { notebookAtom } from "@/core/cells/cells";
7
8
  import type { CellId } from "@/core/cells/ids";
8
9
  import { RunStaleCellsTool } from "../run-cells-tool";
@@ -46,9 +47,9 @@ describe("RunStaleCellsTool", () => {
46
47
 
47
48
  tool = new RunStaleCellsTool({ postExecutionDelay: 0 });
48
49
 
49
- cellId1 = "cell-1" as CellId;
50
- cellId2 = "cell-2" as CellId;
51
- cellId3 = "cell-3" as CellId;
50
+ cellId1 = cellId("cell-1");
51
+ cellId2 = cellId("cell-2");
52
+ cellId3 = cellId("cell-3");
52
53
 
53
54
  // Reset mocks
54
55
  vi.clearAllMocks();
@@ -490,9 +491,8 @@ describe("RunStaleCellsTool", () => {
490
491
  });
491
492
 
492
493
  it("should omit output for cells that exceed total output budget", async () => {
493
- const cellIds = Array.from(
494
- { length: 25 },
495
- (_, i) => `budget-cell-${i}` as CellId,
494
+ const cellIds = Array.from({ length: 25 }, (_, i) =>
495
+ cellId(`budget-cell-${i}`),
496
496
  );
497
497
  const cellData: Record<string, { code: string; edited: boolean }> = {};
498
498
  for (const id of cellIds) {
@@ -90,7 +90,7 @@ export class EditNotebookTool
90
90
  switch (edit.type) {
91
91
  case "update_cell": {
92
92
  const { position, code } = edit;
93
- const cellId = position.cellId as CellId;
93
+ const cellId = position.cellId as CellId | undefined;
94
94
 
95
95
  if (!cellId) {
96
96
  throw new ToolExecutionError(
@@ -152,7 +152,7 @@ export class EditNotebookTool
152
152
 
153
153
  switch (position.type) {
154
154
  case "relative": {
155
- const cellId = position.cellId as CellId;
155
+ const cellId = position.cellId as CellId | undefined;
156
156
  if (!cellId) {
157
157
  throw new ToolExecutionError(
158
158
  "Cell ID is required for add_cell with relative position",
@@ -214,7 +214,7 @@ export class EditNotebookTool
214
214
  }
215
215
  case "delete_cell": {
216
216
  const { position } = edit;
217
- const cellId = position.cellId as CellId;
217
+ const cellId = position.cellId as CellId | undefined;
218
218
 
219
219
  if (!cellId) {
220
220
  throw new ToolExecutionError(
@@ -4,6 +4,7 @@ import { createStore } from "jotai";
4
4
  import { beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import { MockNotebook } from "@/__mocks__/notebook";
6
6
  import { MockRequestClient } from "@/__mocks__/requests";
7
+ import { cellId } from "@/__tests__/branded";
7
8
  import { store } from "@/core/state/jotai";
8
9
  import { variablesAtom } from "@/core/variables/state";
9
10
  import type { Variables } from "@/core/variables/types";
@@ -13,7 +14,6 @@ import {
13
14
  maybeAddMissingImport,
14
15
  } from "../add-missing-import";
15
16
  import { notebookAtom } from "../cells";
16
- import type { CellId } from "../ids";
17
17
 
18
18
  // Mock the getRequestClient function
19
19
  const mockRequestClient = MockRequestClient.create();
@@ -21,8 +21,8 @@ vi.mock("@/core/network/requests", () => ({
21
21
  getRequestClient: () => mockRequestClient,
22
22
  }));
23
23
 
24
- const Cell1 = "1" as CellId;
25
- const Cell2 = "2" as CellId;
24
+ const Cell1 = cellId("1");
25
+ const Cell2 = cellId("2");
26
26
 
27
27
  describe("maybeAddMissingImport", () => {
28
28
  beforeEach(() => {