@marimo-team/frontend 0.25.3-dev92 → 0.25.3-dev95

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 (123) hide show
  1. package/dist/assets/{CellStatus-DwPjR2_8.js → CellStatus-CplYFNTy.js} +1 -1
  2. package/dist/assets/{ConnectedDataExplorerComponent-D9UK8o9A.js → ConnectedDataExplorerComponent-Dft8R6l5.js} +1 -1
  3. package/dist/assets/{ErrorBoundary-BhXbaVBa.js → ErrorBoundary-CdGuz4a_.js} +2 -2
  4. package/dist/assets/{JsonOutput-Dti6dc1X.js → JsonOutput-Csbov8Fx.js} +1 -1
  5. package/dist/assets/{MarimoErrorOutput-BKvntkfq.js → MarimoErrorOutput-czclLlOn.js} +1 -1
  6. package/dist/assets/{RenderHTML-DUI47UDk.js → RenderHTML-CNDedpS4.js} +1 -1
  7. package/dist/assets/{RunButton-CLhvSMZG.js → RunButton-CRfdOxVd.js} +1 -1
  8. package/dist/assets/{add-cell-with-ai-ev63rhN4.js → add-cell-with-ai-BAIX7r0P.js} +1 -1
  9. package/dist/assets/{add-connection-dialog-2Tgl7Mjn.js → add-connection-dialog-DrDuM-tI.js} +1 -1
  10. package/dist/assets/{agent-panel-D4lNacey.js → agent-panel-CoXq_rlA.js} +1 -1
  11. package/dist/assets/{ai-model-dropdown-BqjVBWQp.js → ai-model-dropdown-COvWn46z.js} +1 -1
  12. package/dist/assets/{app-config-button-BToMQZBN.js → app-config-button-CtxoYG4F.js} +1 -1
  13. package/dist/assets/{blob-DMgg2NZo.js → blob-DCjrjZKW.js} +1 -1
  14. package/dist/assets/{cache-panel-Byolv2ht.js → cache-panel-CbWZcBu0.js} +1 -1
  15. package/dist/assets/{cell-editor-DGRa0o5e.js → cell-editor-BnL0Sorl.js} +1 -1
  16. package/dist/assets/{cell-link-D6rI90gy.js → cell-link-BFbgKiRH.js} +1 -1
  17. package/dist/assets/{cells-Cetiartc.js → cells-yOs72eZm.js} +1 -1
  18. package/dist/assets/{chat-display-CgpJ6XM4.js → chat-display-DwRM41t_.js} +1 -1
  19. package/dist/assets/{chat-panel-Djs36Uy4.js → chat-panel-DeTEdjxF.js} +1 -1
  20. package/dist/assets/{chat-ui-B_JGdp0E.js → chat-ui-D6XucD07.js} +1 -1
  21. package/dist/assets/{code-visibility-ny5n3-GH.js → code-visibility-DYDagVy7.js} +1 -1
  22. package/dist/assets/{column-preview-BIpGfTJf.js → column-preview-DXM8SqGY.js} +1 -1
  23. package/dist/assets/{command-palette-9pxpuKHs.js → command-palette-CA6yfNLb.js} +1 -1
  24. package/dist/assets/{common-D0jeQZnr.js → common-B-ZYnO1x.js} +1 -1
  25. package/dist/assets/{components-CJRBUI2s.js → components-CBE8cOLK.js} +1 -1
  26. package/dist/assets/{components-DrU8dOzy.js → components-DCo7mAWO.js} +1 -1
  27. package/dist/assets/{components-DkQChRNr.js → components-vu2jLG08.js} +1 -1
  28. package/dist/assets/{config-BWKfkUWA.js → config-CD1IuZFJ.js} +1 -1
  29. package/dist/assets/{config-CP8Y8_R0.js → config-DMz7oN0r.js} +1 -1
  30. package/dist/assets/{config-DGX7JYor.js → config-DpY86_Yq.js} +1 -1
  31. package/dist/assets/{createReducer-HKXUbqyz.js → createReducer-CaI_Oa0v.js} +1 -1
  32. package/dist/assets/{datasource-BXFNO5td.js → datasource-BakEOWsf.js} +1 -1
  33. package/dist/assets/{dependency-graph-panel-BFVIEz0s.js → dependency-graph-panel-DCGB3_id.js} +1 -1
  34. package/dist/assets/{documentation-panel-CaUMsgkg.js → documentation-panel-CpGZ2Dfn.js} +1 -1
  35. package/dist/assets/{download-C-q7-OBT.js → download-CV1k4XQ4.js} +1 -1
  36. package/dist/assets/{edit-page-VhYLLklC.js → edit-page-By7n2M84.js} +4 -4
  37. package/dist/assets/{error-entries-p_IDc4iy.js → error-entries-JgrZYMbe.js} +1 -1
  38. package/dist/assets/{error-panel-B0BwSTRv.js → error-panel-DS7HWph-.js} +1 -1
  39. package/dist/assets/feedback-button-Dgs_HOOC.js +1 -0
  40. package/dist/assets/{feedback-button-D0HjY39R.js → feedback-button-eYsTCK-g.js} +1 -1
  41. package/dist/assets/{file-explorer-panel-BLIEpQzW.js → file-explorer-panel-BTLwwwD4.js} +1 -1
  42. package/dist/assets/{file-name-input-CZ_W4QXG.js → file-name-input-BaR4h2Ud.js} +1 -1
  43. package/dist/assets/{floating-outline-D7DFh_29.js → floating-outline-Drd73Quo.js} +1 -1
  44. package/dist/assets/{gallery-page-BLgoybvc.js → gallery-page-DXUD11Rm.js} +1 -1
  45. package/dist/assets/{glide-data-editor-DVpOmYXo.js → glide-data-editor-DqBBoQBl.js} +1 -1
  46. package/dist/assets/{home-page--OLVJPiE.js → home-page-pgFFsmga.js} +1 -1
  47. package/dist/assets/{hooks-D0Pzb8Q4.js → hooks-D25kP4Sr.js} +1 -1
  48. package/dist/assets/{index-DB50a7AR.js → index-DNG4qQ-E.js} +6 -6
  49. package/dist/assets/{input-BZdRe7pb.js → input-DmHMEZGh.js} +1 -1
  50. package/dist/assets/kiosk-mode-DFS6HopF.js +1 -0
  51. package/dist/assets/{layout-HYpXx9Kc.js → layout-DLHIGZTK.js} +3 -3
  52. package/dist/assets/links-DX2w97N9.js +1 -0
  53. package/dist/assets/{logs-panel-Cbx5BJ3w.js → logs-panel-D5AAD2s9.js} +1 -1
  54. package/dist/assets/{markdown-renderer-B1GLwS-C.js → markdown-renderer--CwVm4kJ.js} +1 -1
  55. package/dist/assets/{mermaid-B6mqMm5_.js → mermaid-BKXlWk4F.js} +1 -1
  56. package/dist/assets/{name-cell-input-CgINqxMv.js → name-cell-input-BFKZaNI5.js} +1 -1
  57. package/dist/assets/{outline-panel-DaCt5blP.js → outline-panel-qcwRnl0R.js} +1 -1
  58. package/dist/assets/{package-data-dv4FBHxR.js → package-data-CKPmBDtg.js} +1 -1
  59. package/dist/assets/{packages-panel-DRKwpeJ2.js → packages-panel-DnSryNcz.js} +1 -1
  60. package/dist/assets/{panel-accordion-state-C4fxJULv.js → panel-accordion-state-BwJpDMVt.js} +1 -1
  61. package/dist/assets/{panels-D_TmFEit.js → panels-Aqzwb3UR.js} +1 -1
  62. package/dist/assets/{process-output-D1KxMfN7.js → process-output-DuUfHYSr.js} +1 -1
  63. package/dist/assets/{readonly-code-display-DVn7_uLn.js → readonly-code-display-BY-9I_Yk.js} +1 -1
  64. package/dist/assets/{readonly-python-code-5F8u1711.js → readonly-python-code-DSyr-yE2.js} +1 -1
  65. package/dist/assets/{renderShortcut-H60uiHBp.js → renderShortcut-rUwGqKgC.js} +1 -1
  66. package/dist/assets/{requests-lt0JK8Jt.js → requests-BIFR-h4M.js} +1 -1
  67. package/dist/assets/requests-DuLJN9Tf.js +1 -0
  68. package/dist/assets/{reveal-component-B4rC_fg1.js → reveal-component-C_Lb7Mom.js} +1 -1
  69. package/dist/assets/{run-page-BHdHPiQA.js → run-page-ZTw-kCU-.js} +1 -1
  70. package/dist/assets/{runs-6lJxKV1w.js → runs-C49hleBy.js} +1 -1
  71. package/dist/assets/{runtime-details-state-BLDCeDBF.js → runtime-details-state-B7gpnuXx.js} +1 -1
  72. package/dist/assets/{scratchpad-panel-ChSdhkiu.js → scratchpad-panel-D2IHkKoG.js} +1 -1
  73. package/dist/assets/{secrets-panel-Dh3v7XPE.js → secrets-panel-bcfEKxRx.js} +1 -1
  74. package/dist/assets/{session-B8Y-GJnS.js → session-CMLIzZKw.js} +1 -1
  75. package/dist/assets/session-panel-cOSO3WCX.js +1 -0
  76. package/dist/assets/{snippets-panel-D7PPIwX1.js → snippets-panel-BNadUJLU.js} +1 -1
  77. package/dist/assets/{state-BY4_P6ko.js → state-3mcyTS9q.js} +1 -1
  78. package/dist/assets/{state-C0irhlOZ.js → state-B_MCKzBL.js} +1 -1
  79. package/dist/assets/{state-Bd_wAeZf.js → state-BaYudep3.js} +1 -1
  80. package/dist/assets/{state-DaWgt-rn.js → state-C5WAeuTu.js} +1 -1
  81. package/dist/assets/{state-Ck7FMD5A.js → state-Cv2JW3l9.js} +1 -1
  82. package/dist/assets/{state-pXUWLVXv.js → state-_1LTGJQM.js} +1 -1
  83. package/dist/assets/{switch-IoWE8PbW.js → switch-DYjBfpNJ.js} +1 -1
  84. package/dist/assets/{terminal-BwLC9HS5.js → terminal-Ca-kubKb.js} +1 -1
  85. package/dist/assets/{tracing-WN4XSiAm.js → tracing-DbTgS4u9.js} +1 -1
  86. package/dist/assets/{tracing-panel-BVC4DsH6.js → tracing-panel-CjlrpXPy.js} +2 -2
  87. package/dist/assets/{tree-actions-MaUvbTxA.js → tree-actions-C_KYlaSv.js} +1 -1
  88. package/dist/assets/{useAddCell-D7SKNQll.js → useAddCell-C0J8quGE.js} +1 -1
  89. package/dist/assets/{useAsyncData-DhhdOGGd.js → useAsyncData-qvoPYHtx.js} +1 -1
  90. package/dist/assets/{useBoolean-WABMLM83.js → useBoolean-Dd2nWXFJ.js} +1 -1
  91. package/dist/assets/{useCellActionButton-Byz7LlUo.js → useCellActionButton-CbkOj6BE.js} +1 -1
  92. package/dist/assets/{useDebounce-k9QTpQ9-.js → useDebounce-DwTQ_1Pu.js} +1 -1
  93. package/dist/assets/{useDeepCompareMemoize-DFIVN9dn.js → useDeepCompareMemoize-B2DVK2De.js} +1 -1
  94. package/dist/assets/{useDeleteCell-D-k2fD1X.js → useDeleteCell-DHkF5wgS.js} +1 -1
  95. package/dist/assets/{useDependencyPanelTab-neRJ4T16.js → useDependencyPanelTab--yXJW6X5.js} +1 -1
  96. package/dist/assets/{useEvent-Dfcbgjhg.js → useEvent-BDjgaBtz.js} +1 -1
  97. package/dist/assets/{useInstallPackage-CWcPxSLP.js → useInstallPackage-wcDq9hYT.js} +1 -1
  98. package/dist/assets/{useNotebookActions-Df_jxEKJ.js → useNotebookActions-dJQalORg.js} +1 -1
  99. package/dist/assets/{useRunCells-AZJD5ITo.js → useRunCells-C_IwVJR_.js} +1 -1
  100. package/dist/assets/{useSplitCell-CgiU_w77.js → useSplitCell-Ci4MEUj8.js} +1 -1
  101. package/dist/assets/{useTheme-DLtPc-39.js → useTheme-BAA27lh7.js} +1 -1
  102. package/dist/assets/{vega-component-CY6HmM06.js → vega-component-BeyxAJad.js} +1 -1
  103. package/dist/assets/{write-secret-modal-7DzehGyr.js → write-secret-modal-BEx-EUlh.js} +1 -1
  104. package/dist/index.html +40 -40
  105. package/package.json +1 -1
  106. package/src/components/datasources/__tests__/table-list.test.tsx +118 -0
  107. package/src/components/datasources/datasources.tsx +35 -21
  108. package/src/components/pages/__tests__/home-page.test.tsx +116 -0
  109. package/src/components/pages/home-page.tsx +24 -3
  110. package/src/core/document/__tests__/draft.test.ts +322 -0
  111. package/src/core/document/__tests__/fixtures.ts +92 -0
  112. package/src/core/document/__tests__/model.test.ts +434 -0
  113. package/src/core/document/__tests__/submission.test.ts +334 -0
  114. package/src/core/document/draft.ts +472 -0
  115. package/src/core/document/model.ts +395 -0
  116. package/src/core/state/__tests__/jotai.test.tsx +108 -0
  117. package/src/core/state/jotai.ts +1 -1
  118. package/dist/assets/feedback-button-BFoleTOt.js +0 -1
  119. package/dist/assets/kiosk-mode-BGmMSc7A.js +0 -1
  120. package/dist/assets/links-CXcpNIM0.js +0 -1
  121. package/dist/assets/requests-CgSY1X4a.js +0 -1
  122. package/dist/assets/session-panel-CtQgwbFW.js +0 -1
  123. package/src/core/state/__tests__/jotai.test.ts +0 -25
@@ -0,0 +1,334 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { atom, createStore } from "jotai/vanilla";
4
+ import { describe, expect, it, vi } from "vitest";
5
+ import type { Document } from "../../host/resources/document";
6
+ import { createDocumentModel, type DocumentSubmission } from "../model";
7
+ import { cell, document, withCells } from "./fixtures";
8
+
9
+ function setup() {
10
+ const store = createStore();
11
+ const source = atom<Document | null>(document());
12
+ const model = createDocumentModel(store, source);
13
+ return {
14
+ store,
15
+ source,
16
+ ...model,
17
+ submit() {
18
+ const submission = store.set(model.submitAtom);
19
+ if (submission === null) {
20
+ throw new Error("Expected a submission");
21
+ }
22
+ return submission;
23
+ },
24
+ settle(submission: DocumentSubmission, confirmed: Document) {
25
+ store.set(model.settleAtom, submission, confirmed.revision);
26
+ },
27
+ };
28
+ }
29
+
30
+ describe("document submissions", () => {
31
+ it.each(["host source", "replacement code"] as const)(
32
+ "retains an unsendable draft until it receives %s",
33
+ (recovery) => {
34
+ const {
35
+ store,
36
+ source,
37
+ editAtom,
38
+ changesAtom,
39
+ submitAtom,
40
+ submit,
41
+ settle,
42
+ } = setup();
43
+ const hidden = withCells(document(), {
44
+ c1: cell("c1", "", { code: null }),
45
+ });
46
+ store.set(source, hidden);
47
+ store.set(editAtom, (tx) => {
48
+ tx.setCode("c2", "other edit");
49
+ tx.setName("c1", "renamed");
50
+ });
51
+ expect(store.get(changesAtom)).toBeNull();
52
+ expect(store.set(submitAtom)).toBeNull();
53
+ expect(store.set(submitAtom)).toBeNull();
54
+
55
+ const code = recovery === "host source" ? "revealed" : "";
56
+ if (recovery === "host source") {
57
+ store.set(source, withCells(hidden, { c1: cell("c1", code) }));
58
+ } else {
59
+ store.set(editAtom, (tx) => tx.setCode("c1", code));
60
+ }
61
+ const sent = submit();
62
+ expect(sent.changes).toEqual([
63
+ {
64
+ kind: "put_cell",
65
+ base_etag: "c2-etag",
66
+ cell: {
67
+ id: "c2",
68
+ code: "other edit",
69
+ name: "_",
70
+ config: cell("c2", "").config,
71
+ },
72
+ },
73
+ {
74
+ kind: "put_cell",
75
+ base_etag: "c1-etag",
76
+ cell: {
77
+ id: "c1",
78
+ code,
79
+ name: "renamed",
80
+ config: cell("c1", "").config,
81
+ },
82
+ },
83
+ ]);
84
+ const accepted = withCells(store.get(source)!, {
85
+ c1: cell("c1", code, { name: "renamed" }),
86
+ c2: cell("c2", "other edit"),
87
+ });
88
+ settle(sent, accepted);
89
+ store.set(source, accepted);
90
+ expect(store.get(changesAtom)).toEqual([]);
91
+ },
92
+ );
93
+
94
+ it.each(["response", "stream"] as const)(
95
+ "preserves later typing when the %s arrives first",
96
+ (first) => {
97
+ const {
98
+ store,
99
+ source,
100
+ editAtom,
101
+ cellAtom,
102
+ changesAtom,
103
+ submitAtom,
104
+ submit,
105
+ settle,
106
+ } = setup();
107
+ store.set(editAtom, (tx) => {
108
+ tx.setCode("c1", "sent");
109
+ tx.updateConfig("c1", { hide_code: true });
110
+ });
111
+ const sent = submit();
112
+ store.set(editAtom, (tx) => tx.setCode("c1", "still typing"));
113
+ const confirmed = withCells(document(), {
114
+ c1: cell("c1", "sent", {
115
+ etag: "accepted",
116
+ config: { ...cell("c1", "").config, hide_code: true },
117
+ }),
118
+ });
119
+ const onCell = vi.fn();
120
+ store.sub(cellAtom("c1"), onCell);
121
+ const arrivals = {
122
+ response: () => settle(sent, confirmed),
123
+ stream: () => store.set(source, confirmed),
124
+ };
125
+ arrivals[first]();
126
+ expect(store.set(submitAtom)).toBeNull();
127
+ arrivals[first === "response" ? "stream" : "response"]();
128
+ expect(onCell).not.toHaveBeenCalled();
129
+ expect(store.get(cellAtom("c1"))?.code).toBe("still typing");
130
+ expect(store.get(changesAtom)).toEqual([
131
+ {
132
+ kind: "put_cell",
133
+ base_etag: "accepted",
134
+ cell: {
135
+ id: "c1",
136
+ code: "still typing",
137
+ name: "_",
138
+ config: confirmed.cells.get("c1")?.config,
139
+ },
140
+ },
141
+ ]);
142
+ const next = submit();
143
+ settle(sent, confirmed);
144
+ expect(store.set(submitAtom)).toBeNull();
145
+ const updated = withCells(confirmed, {
146
+ c1: cell("c1", "still typing", {
147
+ config: confirmed.cells.get("c1")!.config,
148
+ }),
149
+ });
150
+ settle(next, updated);
151
+ store.set(source, updated);
152
+ expect(store.get(changesAtom)).toEqual([]);
153
+ },
154
+ );
155
+
156
+ it.each(["response", "stream"] as const)(
157
+ "never shows a cancelled creation when the %s arrives first",
158
+ (first) => {
159
+ const {
160
+ store,
161
+ source,
162
+ editAtom,
163
+ cellAtom,
164
+ orderAtom,
165
+ changesAtom,
166
+ submit,
167
+ settle,
168
+ } = setup();
169
+ store.set(editAtom, (tx) => tx.createCell({ id: "c3", code: "new" }));
170
+ const sent = submit();
171
+ store.set(editAtom, (tx) => tx.deleteCell("c3"));
172
+ const onCell = vi.fn();
173
+ store.sub(cellAtom("c3"), onCell);
174
+ // An unrelated revision before the creation must not forget the deletion.
175
+ const intermediate = withCells(document(), { c2: cell("c2", "remote") });
176
+ store.set(source, intermediate);
177
+ const confirmed = withCells(intermediate, { c3: cell("c3", "new") });
178
+ const arrivals = {
179
+ response: () => settle(sent, confirmed),
180
+ stream: () => store.set(source, confirmed),
181
+ };
182
+ arrivals[first]();
183
+ arrivals[first === "response" ? "stream" : "response"]();
184
+ expect(onCell).not.toHaveBeenCalled();
185
+ expect(store.get(orderAtom)).toEqual(["c1", "c2"]);
186
+ expect(store.get(changesAtom)).toEqual([
187
+ { kind: "delete_cell", id: "c3", base_etag: "c3-etag" },
188
+ ]);
189
+ const deletion = submit();
190
+ const removed = withCells(confirmed, { c3: null });
191
+ store.set(source, removed);
192
+ settle(deletion, removed);
193
+ settle(sent, confirmed);
194
+ expect(store.get(changesAtom)).toEqual([]);
195
+ },
196
+ );
197
+
198
+ it("waits for the response's later revision and follows subsequent host edits", () => {
199
+ const { store, source, editAtom, cellAtom, submitAtom, submit, settle } =
200
+ setup();
201
+ store.set(editAtom, (tx) => tx.setCode("c1", "sent"));
202
+ const sent = submit();
203
+ const edited = withCells(document(), { c1: cell("c1", "sent") });
204
+ const response = withCells(edited, { c2: cell("c2", "mirrored update") });
205
+ settle(sent, response);
206
+ store.set(source, edited);
207
+ expect(store.set(submitAtom)).toBeNull();
208
+ const later = withCells(response, {
209
+ c1: cell("c1", "another client's edit"),
210
+ });
211
+ const seen: (string | null | undefined)[] = [];
212
+ store.sub(cellAtom("c1"), () => seen.push(store.get(cellAtom("c1"))?.code));
213
+ store.set(source, later);
214
+ expect(seen).toEqual(["another client's edit"]);
215
+ expect(store.set(submitAtom)).toBeNull();
216
+ });
217
+
218
+ it.each(["before reset", "during reset", "after snapshot"] as const)(
219
+ "confirms a submission across reset when its response arrives %s",
220
+ (arrival) => {
221
+ const { store, source, editAtom, cellAtom, submit, settle } = setup();
222
+ store.set(editAtom, (tx) => tx.setCode("c1", "unsaved"));
223
+ const sent = submit();
224
+ const old = withCells(document(), { c1: cell("c1", "unsaved") });
225
+ store.set(editAtom, (tx) => tx.setCode("c1", "newer typing"));
226
+ if (arrival === "before reset") {
227
+ settle(sent, old);
228
+ }
229
+ store.set(source, null);
230
+ if (arrival === "during reset") {
231
+ settle(sent, old);
232
+ }
233
+ const fresh = withCells(old, { c2: cell("c2", "unrelated") });
234
+ store.set(source, fresh);
235
+ if (arrival === "after snapshot") {
236
+ settle(sent, old);
237
+ }
238
+ expect(store.get(cellAtom("c1"))?.code).toBe("newer typing");
239
+ const retried = submit();
240
+ const accepted = withCells(fresh, { c1: cell("c1", "newer typing") });
241
+ settle(retried, accepted);
242
+ store.set(source, accepted);
243
+ store.set(source, withCells(accepted, { c1: cell("c1", "remote") }));
244
+ expect(store.get(cellAtom("c1"))?.code).toBe("remote");
245
+ },
246
+ );
247
+
248
+ it("invalidates submissions when switching notebooks, retaining each draft", () => {
249
+ const { store, source, editAtom, cellAtom, submit, settle } = setup();
250
+ store.set(editAtom, (tx) => tx.setCode("c1", "first"));
251
+ const sent = submit();
252
+ store.set(source, document("n2"));
253
+ store.set(editAtom, (tx) => tx.setCode("c1", "second"));
254
+ store.set(source, withCells(document(), { c2: cell("c2", "remote") }));
255
+ settle(sent, withCells(document(), { c1: cell("c1", "first") }));
256
+ expect(store.get(cellAtom("c1"))?.code).toBe("first");
257
+ store.set(source, document("n2"));
258
+ expect(store.get(cellAtom("c1"))?.code).toBe("second");
259
+ });
260
+
261
+ it("retries a rejected edit with fresh preconditions and ignores its late reply", () => {
262
+ const { store, source, editAtom, settleAtom, submitAtom, submit, settle } =
263
+ setup();
264
+ store.set(editAtom, (tx) => tx.setCode("c1", "local"));
265
+ const sent = submit();
266
+ store.set(settleAtom, sent, null);
267
+ const remote = withCells(document(), {
268
+ c1: cell("c1", "remote", { name: "renamed", etag: "fresh" }),
269
+ });
270
+ store.set(source, remote);
271
+ const retry = submit();
272
+ expect(retry.changes).toEqual([
273
+ {
274
+ kind: "put_cell",
275
+ base_etag: "fresh",
276
+ cell: {
277
+ id: "c1",
278
+ code: "local",
279
+ name: "renamed",
280
+ config: cell("c1", "").config,
281
+ },
282
+ },
283
+ ]);
284
+ settle(sent, remote);
285
+ expect(store.set(submitAtom)).toBeNull();
286
+ });
287
+
288
+ it("does not treat a response for another notebook as acceptance", () => {
289
+ const { store, editAtom, settleAtom, submitAtom, submit } = setup();
290
+ store.set(editAtom, (tx) => tx.setCode("c1", "local"));
291
+ const sent = submit();
292
+ expect(() => store.set(settleAtom, sent, document("n2").revision)).toThrow(
293
+ "another notebook",
294
+ );
295
+ expect(store.set(submitAtom)).toBeNull();
296
+ });
297
+
298
+ it("releases an unsent reversal without making a request", () => {
299
+ const { store, source, editAtom, cellAtom, submitAtom } = setup();
300
+ store.set(editAtom, (tx) => tx.setCode("c1", "local"));
301
+ store.set(editAtom, (tx) => tx.setCode("c1", "x = 1"));
302
+ expect(store.set(submitAtom)).toBeNull();
303
+ store.set(source, withCells(document(), { c1: cell("c1", "remote") }));
304
+ expect(store.get(cellAtom("c1"))?.code).toBe("remote");
305
+ });
306
+
307
+ it("stops observing and accepting work after disposal", () => {
308
+ const {
309
+ store,
310
+ source,
311
+ editAtom,
312
+ orderAtom,
313
+ submitAtom,
314
+ submit,
315
+ settle,
316
+ dispose,
317
+ } = setup();
318
+ store.set(editAtom, (tx) => tx.setCode("c1", "local"));
319
+ const sent = submit();
320
+ dispose();
321
+ const onOrder = vi.fn();
322
+ store.sub(orderAtom, onOrder);
323
+ const confirmed = withCells(document(), { c1: cell("c1", "local") });
324
+ store.set(source, confirmed);
325
+ settle(sent, confirmed);
326
+ const edit = vi.fn();
327
+ store.set(editAtom, edit);
328
+ dispose();
329
+ expect(edit).not.toHaveBeenCalled();
330
+ expect(onOrder).not.toHaveBeenCalled();
331
+ expect(store.get(orderAtom)).toBeNull();
332
+ expect(store.set(submitAtom)).toBeNull();
333
+ });
334
+ });