@marimo-team/islands 0.23.6-dev2 → 0.23.6-dev21

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 (36) hide show
  1. package/dist/{ConnectedDataExplorerComponent-CWU3Az6F.js → ConnectedDataExplorerComponent-PmilQqXR.js} +4 -4
  2. package/dist/assets/__vite-browser-external-rrUYDKRl.js +1 -0
  3. package/dist/assets/{worker-D-EdLKct.js → worker-Bfy15ViQ.js} +2 -2
  4. package/dist/{chat-ui-b_bJR7A9.js → chat-ui-CVfL3lSs.js} +6 -6
  5. package/dist/{code-visibility-Ct9_oZ3S.js → code-visibility--D4LeN-D.js} +670 -533
  6. package/dist/{formats-Dh5M1ZRs.js → formats-DJvu12E_.js} +1 -1
  7. package/dist/{glide-data-editor-DXti2axL.js → glide-data-editor-CvlvtPWJ.js} +2 -2
  8. package/dist/{html-to-image-CzFE0Irw.js → html-to-image-Ctyt_1RZ.js} +2142 -2122
  9. package/dist/{input-Drx1pguW.js → input-BAOe64zx.js} +1 -1
  10. package/dist/main.js +18 -18
  11. package/dist/{mermaid-BagLPXm9.js → mermaid-DJ1NyBGw.js} +2 -2
  12. package/dist/{process-output-D3EbEd3k.js → process-output-V4Xi7mGt.js} +1 -1
  13. package/dist/{reveal-component-D52utNOJ.js → reveal-component-RFJhlir1.js} +5 -5
  14. package/dist/{spec-BKWq0wn2.js → spec-DSIuqd3f.js} +1 -1
  15. package/dist/{toDate-yqOcZ_tY.js → toDate-0ZO2rMtR.js} +1 -1
  16. package/dist/{useAsyncData-CKYzhCis.js → useAsyncData-B6hCGywC.js} +1 -1
  17. package/dist/{useDeepCompareMemoize-je76AJS_.js → useDeepCompareMemoize-CmwDuYUH.js} +1 -1
  18. package/dist/{useLifecycle-smVfjLNI.js → useLifecycle-CjMjllqy.js} +1 -1
  19. package/dist/{useTheme-CX9pPLUH.js → useTheme-CByZUW0p.js} +1 -0
  20. package/dist/{vega-component-BnCQmtxw.js → vega-component-D3zDd-Uu.js} +5 -5
  21. package/package.json +5 -5
  22. package/src/components/ai/ai-provider-icon.tsx +1 -0
  23. package/src/components/ai/ai-utils.ts +1 -0
  24. package/src/components/app-config/ai-config.tsx +30 -0
  25. package/src/components/slides/slide-form.tsx +43 -0
  26. package/src/components/ui/links.tsx +2 -1
  27. package/src/core/ai/ids/ids.ts +1 -0
  28. package/src/core/cells/__tests__/apply-transaction.test.ts +193 -27
  29. package/src/core/cells/__tests__/cells.test.ts +99 -0
  30. package/src/core/cells/__tests__/document-changes.test.ts +14 -0
  31. package/src/core/cells/cells.ts +14 -1
  32. package/src/core/cells/document-changes.ts +17 -14
  33. package/src/core/config/config-schema.ts +1 -0
  34. package/src/plugins/core/RenderHTML.tsx +49 -3
  35. package/src/plugins/core/__test__/RenderHTML.test.ts +54 -0
  36. package/dist/assets/__vite-browser-external-C4JkHbyY.js +0 -1
@@ -469,10 +469,34 @@ describe("applyTransactionChanges column rebuild", () => {
469
469
  const [a, b, c, d] = state.cellIds.inOrderIds;
470
470
  apply([
471
471
  { type: "reorder-cells", cellIds: [a, b, c, d] },
472
- { type: "set-config", cellId: a, column: 0 },
473
- { type: "set-config", cellId: b, column: 1 },
474
- { type: "set-config", cellId: c, column: 0 },
475
- { type: "set-config", cellId: d, column: 1 },
472
+ {
473
+ type: "set-config",
474
+ cellId: a,
475
+ column: 0,
476
+ disabled: false,
477
+ hideCode: false,
478
+ },
479
+ {
480
+ type: "set-config",
481
+ cellId: b,
482
+ column: 1,
483
+ disabled: false,
484
+ hideCode: false,
485
+ },
486
+ {
487
+ type: "set-config",
488
+ cellId: c,
489
+ column: 0,
490
+ disabled: false,
491
+ hideCode: false,
492
+ },
493
+ {
494
+ type: "set-config",
495
+ cellId: d,
496
+ column: 1,
497
+ disabled: false,
498
+ hideCode: false,
499
+ },
476
500
  ]);
477
501
  // a and c in col0; b and d in col1. Order within each column follows
478
502
  // the reorder-cells order.
@@ -487,7 +511,15 @@ describe("applyTransactionChanges column rebuild", () => {
487
511
  it("set-config without reorder-cells moves the cell to the new column", () => {
488
512
  setup("a", "b", "c");
489
513
  const [, b] = state.cellIds.inOrderIds;
490
- apply([{ type: "set-config", cellId: b, column: 1 }]);
514
+ apply([
515
+ {
516
+ type: "set-config",
517
+ cellId: b,
518
+ column: 1,
519
+ disabled: false,
520
+ hideCode: false,
521
+ },
522
+ ]);
491
523
  // Without reorder-cells, the flat order comes from the current tree.
492
524
  // b gets explicit col=1; a and c stay with default null → follow the
493
525
  // previous cell's column (a → col0 because prev=0; c → col1 because
@@ -503,7 +535,15 @@ describe("applyTransactionChanges column rebuild", () => {
503
535
  it("no column change: set-config only touching other fields does not repartition", () => {
504
536
  setup("a", "b", "c");
505
537
  const [, b] = state.cellIds.inOrderIds;
506
- apply([{ type: "set-config", cellId: b, hideCode: true }]);
538
+ apply([
539
+ {
540
+ type: "set-config",
541
+ cellId: b,
542
+ column: null,
543
+ disabled: false,
544
+ hideCode: true,
545
+ },
546
+ ]);
507
547
  // All three cells remain in a single column. No rebuild triggered.
508
548
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
509
549
  "
@@ -525,8 +565,20 @@ describe("applyTransactionChanges column rebuild", () => {
525
565
  const [a, b] = state.cellIds.inOrderIds;
526
566
  apply([
527
567
  { type: "reorder-cells", cellIds: [a, b] },
528
- { type: "set-config", cellId: a, column: 0 },
529
- { type: "set-config", cellId: b, column: 1 },
568
+ {
569
+ type: "set-config",
570
+ cellId: a,
571
+ column: 0,
572
+ disabled: false,
573
+ hideCode: false,
574
+ },
575
+ {
576
+ type: "set-config",
577
+ cellId: b,
578
+ column: 1,
579
+ disabled: false,
580
+ hideCode: false,
581
+ },
530
582
  ]);
531
583
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
532
584
  "
@@ -550,8 +602,20 @@ describe("applyTransactionChanges column rebuild", () => {
550
602
  const [a, b, c, d] = state.cellIds.inOrderIds;
551
603
  apply([
552
604
  { type: "reorder-cells", cellIds: [a, b, c, d] },
553
- { type: "set-config", cellId: a, column: 0 },
554
- { type: "set-config", cellId: c, column: 1 },
605
+ {
606
+ type: "set-config",
607
+ cellId: a,
608
+ column: 0,
609
+ disabled: false,
610
+ hideCode: false,
611
+ },
612
+ {
613
+ type: "set-config",
614
+ cellId: c,
615
+ column: 1,
616
+ disabled: false,
617
+ hideCode: false,
618
+ },
555
619
  ]);
556
620
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
557
621
  "
@@ -562,8 +626,20 @@ describe("applyTransactionChanges column rebuild", () => {
562
626
  // Now merge everything back to col 0.
563
627
  apply([
564
628
  { type: "reorder-cells", cellIds: [a, b, c, d] },
565
- { type: "set-config", cellId: c, column: 0 },
566
- { type: "set-config", cellId: d, column: 0 },
629
+ {
630
+ type: "set-config",
631
+ cellId: c,
632
+ column: 0,
633
+ disabled: false,
634
+ hideCode: false,
635
+ },
636
+ {
637
+ type: "set-config",
638
+ cellId: d,
639
+ column: 0,
640
+ disabled: false,
641
+ hideCode: false,
642
+ },
567
643
  ]);
568
644
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
569
645
  "
@@ -609,8 +685,20 @@ describe("applyTransactionChanges column rebuild", () => {
609
685
  { type: "reorder-cells", cellIds: [a, b, c] },
610
686
  { type: "set-code", cellId: a, code: "x = 1" },
611
687
  { type: "set-name", cellId: b, name: "middle" },
612
- { type: "set-config", cellId: a, column: 0 },
613
- { type: "set-config", cellId: b, column: 1 },
688
+ {
689
+ type: "set-config",
690
+ cellId: a,
691
+ column: 0,
692
+ disabled: false,
693
+ hideCode: false,
694
+ },
695
+ {
696
+ type: "set-config",
697
+ cellId: b,
698
+ column: 1,
699
+ disabled: false,
700
+ hideCode: false,
701
+ },
614
702
  ]);
615
703
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
616
704
  "
@@ -658,8 +746,20 @@ describe("applyTransactionChanges column rebuild", () => {
658
746
  // Split into two columns. Only a and c are anchors.
659
747
  apply([
660
748
  { type: "reorder-cells", cellIds: [a, b, c, d] },
661
- { type: "set-config", cellId: a, column: 0 },
662
- { type: "set-config", cellId: c, column: 1 },
749
+ {
750
+ type: "set-config",
751
+ cellId: a,
752
+ column: 0,
753
+ disabled: false,
754
+ hideCode: false,
755
+ },
756
+ {
757
+ type: "set-config",
758
+ cellId: c,
759
+ column: 1,
760
+ disabled: false,
761
+ hideCode: false,
762
+ },
663
763
  ]);
664
764
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
665
765
  "
@@ -670,7 +770,13 @@ describe("applyTransactionChanges column rebuild", () => {
670
770
  // Move the c anchor to col 0. d has no explicit column so it follows c.
671
771
  apply([
672
772
  { type: "reorder-cells", cellIds: [a, b, c, d] },
673
- { type: "set-config", cellId: c, column: 0 },
773
+ {
774
+ type: "set-config",
775
+ cellId: c,
776
+ column: 0,
777
+ disabled: false,
778
+ hideCode: false,
779
+ },
674
780
  ]);
675
781
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
676
782
  "
@@ -686,9 +792,27 @@ describe("applyTransactionChanges column rebuild", () => {
686
792
  const [a, b, c, d] = state.cellIds.inOrderIds;
687
793
  apply([
688
794
  { type: "reorder-cells", cellIds: [a, b, c, d] },
689
- { type: "set-config", cellId: a, column: 0 },
690
- { type: "set-config", cellId: c, column: 1 },
691
- { type: "set-config", cellId: d, column: 1 },
795
+ {
796
+ type: "set-config",
797
+ cellId: a,
798
+ column: 0,
799
+ disabled: false,
800
+ hideCode: false,
801
+ },
802
+ {
803
+ type: "set-config",
804
+ cellId: c,
805
+ column: 1,
806
+ disabled: false,
807
+ hideCode: false,
808
+ },
809
+ {
810
+ type: "set-config",
811
+ cellId: d,
812
+ column: 1,
813
+ disabled: false,
814
+ hideCode: false,
815
+ },
692
816
  ]);
693
817
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
694
818
  "
@@ -700,7 +824,13 @@ describe("applyTransactionChanges column rebuild", () => {
700
824
  // does NOT follow c.
701
825
  apply([
702
826
  { type: "reorder-cells", cellIds: [a, b, c, d] },
703
- { type: "set-config", cellId: c, column: 0 },
827
+ {
828
+ type: "set-config",
829
+ cellId: c,
830
+ column: 0,
831
+ disabled: false,
832
+ hideCode: false,
833
+ },
704
834
  ]);
705
835
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
706
836
  "
@@ -719,8 +849,20 @@ describe("applyTransactionChanges column rebuild", () => {
719
849
  const [a, b, c, d] = state.cellIds.inOrderIds;
720
850
  apply([
721
851
  // set-config appears FIRST in the transaction.
722
- { type: "set-config", cellId: a, column: 0 },
723
- { type: "set-config", cellId: c, column: 1 },
852
+ {
853
+ type: "set-config",
854
+ cellId: a,
855
+ column: 0,
856
+ disabled: false,
857
+ hideCode: false,
858
+ },
859
+ {
860
+ type: "set-config",
861
+ cellId: c,
862
+ column: 1,
863
+ disabled: false,
864
+ hideCode: false,
865
+ },
724
866
  // reorder-cells comes afterwards.
725
867
  { type: "reorder-cells", cellIds: [a, b, c, d] },
726
868
  ]);
@@ -741,9 +883,21 @@ describe("applyTransactionChanges column rebuild", () => {
741
883
  setup("a", "b", "c", "d");
742
884
  const [a, b, c, d] = state.cellIds.inOrderIds;
743
885
  apply([
744
- { type: "set-config", cellId: a, column: 0 },
886
+ {
887
+ type: "set-config",
888
+ cellId: a,
889
+ column: 0,
890
+ disabled: false,
891
+ hideCode: false,
892
+ },
745
893
  { type: "set-code", cellId: a, code: "x = 1" },
746
- { type: "set-config", cellId: c, column: 1 },
894
+ {
895
+ type: "set-config",
896
+ cellId: c,
897
+ column: 1,
898
+ disabled: false,
899
+ hideCode: false,
900
+ },
747
901
  { type: "reorder-cells", cellIds: [a, b, c, d] },
748
902
  { type: "set-name", cellId: d, name: "last" },
749
903
  ]);
@@ -769,8 +923,20 @@ describe("applyTransactionChanges column rebuild", () => {
769
923
  const [a, b, c, d] = state.cellIds.inOrderIds;
770
924
  apply([
771
925
  { type: "reorder-cells", cellIds: [a, b, c, d] },
772
- { type: "set-config", cellId: a, column: 0 },
773
- { type: "set-config", cellId: c, column: 1 },
926
+ {
927
+ type: "set-config",
928
+ cellId: a,
929
+ column: 0,
930
+ disabled: false,
931
+ hideCode: false,
932
+ },
933
+ {
934
+ type: "set-config",
935
+ cellId: c,
936
+ column: 1,
937
+ disabled: false,
938
+ hideCode: false,
939
+ },
774
940
  ]);
775
941
  expect(prettyColumns(state)).toMatchInlineSnapshot(`
776
942
  "
@@ -46,6 +46,9 @@ vi.mock("@/core/codemirror/editing/commands", () => ({
46
46
  foldAllBulk: vi.fn(),
47
47
  unfoldAllBulk: vi.fn(),
48
48
  }));
49
+ vi.mock("@/core/wasm/utils", () => ({
50
+ isWasm: vi.fn(() => false),
51
+ }));
49
52
  vi.mock("../scrollCellIntoView", async (importOriginal) => {
50
53
  const actual = await importOriginal();
51
54
  return {
@@ -3428,3 +3431,99 @@ describe("createTracebackInfoAtom", () => {
3428
3431
  expect(traceback).toBeUndefined();
3429
3432
  });
3430
3433
  });
3434
+
3435
+ describe("setCells snapshot preservation", () => {
3436
+ const CELL_A = cellId("A");
3437
+ const CELL_B = cellId("B");
3438
+ const newCells: CellData[] = [
3439
+ {
3440
+ id: CELL_A,
3441
+ name: "a",
3442
+ code: "1",
3443
+ edited: false,
3444
+ lastCodeRun: null,
3445
+ lastExecutionTime: null,
3446
+ config: { hide_code: false, disabled: false, column: null },
3447
+ serializedEditorState: null,
3448
+ },
3449
+ {
3450
+ id: CELL_B,
3451
+ name: "b",
3452
+ code: "2",
3453
+ edited: false,
3454
+ lastCodeRun: null,
3455
+ lastExecutionTime: null,
3456
+ config: { hide_code: false, disabled: false, column: null },
3457
+ serializedEditorState: null,
3458
+ },
3459
+ ];
3460
+
3461
+ const hydratedState = () =>
3462
+ MockNotebook.notebookState({
3463
+ cellData: {
3464
+ [CELL_A]: { id: CELL_A, code: "1" },
3465
+ [CELL_B]: { id: CELL_B, code: "2" },
3466
+ },
3467
+ cellRuntime: {
3468
+ [CELL_A]: {
3469
+ output: {
3470
+ channel: "output",
3471
+ mimetype: "text/plain",
3472
+ data: "hydrated-A",
3473
+ timestamp: 0,
3474
+ },
3475
+ },
3476
+ [CELL_B]: {
3477
+ consoleOutputs: [
3478
+ {
3479
+ channel: "stdout",
3480
+ mimetype: "text/plain",
3481
+ data: "hydrated-B-stdout",
3482
+ timestamp: 0,
3483
+ },
3484
+ ],
3485
+ },
3486
+ },
3487
+ });
3488
+
3489
+ beforeEach(async () => {
3490
+ const { isWasm } = await import("@/core/wasm/utils");
3491
+ vi.mocked(isWasm).mockReturnValue(true);
3492
+ });
3493
+
3494
+ it("preserves hydrated output in WASM", () => {
3495
+ const next = exportedForTesting.reducer(hydratedState(), {
3496
+ type: "setCells",
3497
+ payload: newCells,
3498
+ });
3499
+
3500
+ expect(next.cellRuntime[CELL_A].output).toMatchObject({
3501
+ data: "hydrated-A",
3502
+ });
3503
+ });
3504
+
3505
+ it("preserves console-only hydration in WASM", () => {
3506
+ const next = exportedForTesting.reducer(hydratedState(), {
3507
+ type: "setCells",
3508
+ payload: newCells,
3509
+ });
3510
+
3511
+ expect(next.cellRuntime[CELL_B].consoleOutputs).toHaveLength(1);
3512
+ expect(next.cellRuntime[CELL_B].consoleOutputs[0]).toMatchObject({
3513
+ data: "hydrated-B-stdout",
3514
+ });
3515
+ });
3516
+
3517
+ it("resets cells with no prior runtime even in WASM", () => {
3518
+ const empty = MockNotebook.notebookState({ cellData: {} });
3519
+ const next = exportedForTesting.reducer(empty, {
3520
+ type: "setCells",
3521
+ payload: newCells,
3522
+ });
3523
+
3524
+ expect(next.cellRuntime[CELL_A].output).toBeNull();
3525
+ expect(next.cellRuntime[CELL_A].consoleOutputs).toEqual([]);
3526
+ expect(next.cellRuntime[CELL_B].output).toBeNull();
3527
+ expect(next.cellRuntime[CELL_B].consoleOutputs).toEqual([]);
3528
+ });
3529
+ });
@@ -203,6 +203,8 @@ describe("toDocumentChanges", () => {
203
203
  [
204
204
  {
205
205
  "cellId": "0",
206
+ "column": null,
207
+ "disabled": false,
206
208
  "hideCode": true,
207
209
  "type": "set-config",
208
210
  },
@@ -246,6 +248,8 @@ describe("toDocumentChanges", () => {
246
248
  {
247
249
  "cellId": "1",
248
250
  "column": 1,
251
+ "disabled": false,
252
+ "hideCode": false,
249
253
  "type": "set-config",
250
254
  },
251
255
  {
@@ -273,11 +277,15 @@ describe("toDocumentChanges", () => {
273
277
  {
274
278
  "cellId": "1",
275
279
  "column": 1,
280
+ "disabled": false,
281
+ "hideCode": false,
276
282
  "type": "set-config",
277
283
  },
278
284
  {
279
285
  "cellId": "2",
280
286
  "column": 1,
287
+ "disabled": false,
288
+ "hideCode": false,
281
289
  "type": "set-config",
282
290
  },
283
291
  {
@@ -310,11 +318,15 @@ describe("toDocumentChanges", () => {
310
318
  {
311
319
  "cellId": "1",
312
320
  "column": 0,
321
+ "disabled": false,
322
+ "hideCode": false,
313
323
  "type": "set-config",
314
324
  },
315
325
  {
316
326
  "cellId": "2",
317
327
  "column": 0,
328
+ "disabled": false,
329
+ "hideCode": false,
318
330
  "type": "set-config",
319
331
  },
320
332
  {
@@ -358,6 +370,8 @@ describe("toDocumentChanges", () => {
358
370
  {
359
371
  "cellId": "1",
360
372
  "column": 1,
373
+ "disabled": false,
374
+ "hideCode": false,
361
375
  "type": "set-config",
362
376
  },
363
377
  {
@@ -29,6 +29,7 @@ import { isErrorMime } from "../mime";
29
29
  import type { CellConfig } from "../network/types";
30
30
  import { isRtcEnabled } from "../rtc/state";
31
31
  import { createDeepEqualAtom, store } from "../state/jotai";
32
+ import { isWasm } from "../wasm/utils";
32
33
  import { prepareCellForExecution, transitionCell } from "./cell";
33
34
  import { documentTransactionMiddleware } from "./document-changes";
34
35
  import { CellId, SCRATCH_CELL_ID, SETUP_CELL_ID } from "./ids";
@@ -1032,8 +1033,20 @@ const {
1032
1033
  setCells: (state, cells: CellData[]) => {
1033
1034
  const cellData = Object.fromEntries(cells.map((cell) => [cell.id, cell]));
1034
1035
 
1036
+ // WASM has no server-side SessionView to replay outputs, so the
1037
+ // snapshot hydrated by notebookStateFromSession is the only source.
1038
+ const preserveSnapshot = isWasm();
1039
+ const runtimeFor = (cellId: CellId): CellRuntimeState => {
1040
+ if (!preserveSnapshot) {
1041
+ return createCellRuntimeState();
1042
+ }
1043
+ const prev = state.cellRuntime[cellId];
1044
+ const hasSnapshot =
1045
+ prev && (prev.output != null || prev.consoleOutputs.length > 0);
1046
+ return hasSnapshot ? prev : createCellRuntimeState();
1047
+ };
1035
1048
  const cellRuntime = Object.fromEntries(
1036
- cells.map((cell) => [cell.id, createCellRuntimeState()]),
1049
+ cells.map((cell) => [cell.id, runtimeFor(cell.id)]),
1037
1050
  );
1038
1051
 
1039
1052
  return withScratchCell({
@@ -156,10 +156,13 @@ function columnChanges(
156
156
  for (const [cellId, newCol] of newColumns) {
157
157
  const prevCol = prevColumns.get(cellId);
158
158
  if (prevCol !== newCol) {
159
+ const cell = getCell(cellId, newState);
159
160
  changes.push({
160
161
  type: "set-config",
161
162
  cellId: cellId,
162
163
  column: newCol,
164
+ disabled: cell?.config.disabled ?? false,
165
+ hideCode: cell?.config.hide_code ?? false,
163
166
  });
164
167
  }
165
168
  }
@@ -257,18 +260,21 @@ export function toDocumentChanges(
257
260
  }
258
261
 
259
262
  // updateCellConfig → set-config
260
- // Maps CellConfig's snake_case hide_code to the change's camelCase hideCode.
261
- // Only includes fields that were actually specified in the partial config
262
- // (from the action payload, not the full cell config).
263
+ // SetConfig is full-replacement: emit the cell's complete config from
264
+ // newState (which already merged the action's partial payload).
263
265
  case "updateCellConfig": {
264
- const { cellId, config } = action.payload;
266
+ const { cellId } = action.payload;
267
+ const cell = getCell(cellId, newState);
268
+ if (!cell) {
269
+ return [];
270
+ }
265
271
  return [
266
272
  {
267
273
  type: "set-config",
268
274
  cellId: cellId,
269
- ...(config.hide_code != null && { hideCode: config.hide_code }),
270
- ...(config.disabled != null && { disabled: config.disabled }),
271
- ...(config.column != null && { column: config.column }),
275
+ column: cell.config.column ?? null,
276
+ disabled: cell.config.disabled ?? false,
277
+ hideCode: cell.config.hide_code ?? false,
272
278
  },
273
279
  ];
274
280
  }
@@ -538,18 +544,15 @@ export function fromDocumentChanges(
538
544
  break;
539
545
 
540
546
  // set-config → updateCellConfig
541
- // Maps the change's camelCase hideCode back to CellConfig's snake_case
542
- // hide_code. Only includes fields that are non-null (null means
543
- // "not specified" on the wire, not "clear the value").
544
547
  case "set-config":
545
548
  actions.push({
546
549
  type: "updateCellConfig",
547
550
  payload: {
548
551
  cellId: change.cellId,
549
552
  config: {
550
- ...(change.hideCode != null && { hide_code: change.hideCode }),
551
- ...(change.disabled != null && { disabled: change.disabled }),
552
- ...(change.column != null && { column: change.column }),
553
+ column: change.column,
554
+ disabled: change.disabled,
555
+ hide_code: change.hideCode,
553
556
  },
554
557
  },
555
558
  });
@@ -650,7 +653,7 @@ export function applyTransactionChanges(
650
653
  ) {
651
654
  continue;
652
655
  }
653
- if (change.type === "set-config" && change.column != null) {
656
+ if (change.type === "set-config") {
654
657
  hasColumnChange = true;
655
658
  }
656
659
  if (change.type === "create-cell" && change.config?.column != null) {
@@ -166,6 +166,7 @@ export const UserConfigSchema = z
166
166
  ollama: AiConfigSchema.optional(),
167
167
  openrouter: AiConfigSchema.optional(),
168
168
  wandb: AiConfigSchema.optional(),
169
+ opencode_go: AiConfigSchema.optional(),
169
170
  open_ai_compatible: AiConfigSchema.optional(),
170
171
  azure: AiConfigSchema.optional(),
171
172
  bedrock: z
@@ -6,6 +6,7 @@ import parse, {
6
6
  type HTMLReactParserOptions,
7
7
  } from "html-react-parser";
8
8
  import React, {
9
+ cloneElement,
9
10
  isValidElement,
10
11
  type JSX,
11
12
  type ReactNode,
@@ -169,6 +170,35 @@ const addCopyButtonToCodehilite: TransformFn = (
169
170
  }
170
171
  };
171
172
 
173
+ // Decorator (not a match-and-replace transform): applies a src-based key
174
+ // to <img> elements so they remount on src change. Reusing an <img> across
175
+ // src changes can leave the previous image painted (e.g. when the new
176
+ // request is slow/blocked, served stale by a CDN, or fails CORS), so the
177
+ // user sees the old image even though the HTML source is up to date.
178
+ //
179
+ // Runs unconditionally after the match-and-replace transforms so it still
180
+ // applies when an <img> was already wrapped by, say, wrapTooltipTargets.
181
+ const keyImagesBySrc: TransformFn = (
182
+ reactNode: ReactNode,
183
+ domNode: DOMNode,
184
+ index: number,
185
+ ): JSX.Element | undefined => {
186
+ if (!(domNode instanceof Element) || domNode.name !== "img") {
187
+ return undefined;
188
+ }
189
+ const src = domNode.attribs?.src;
190
+ if (!src || !isValidElement(reactNode)) {
191
+ return undefined;
192
+ }
193
+ // data: URIs are inline — no network fetch — so they can't go stale.
194
+ // Skip to avoid bloating the React key with a megabyte base64 payload.
195
+ // URI schemes are case-insensitive per RFC 3986.
196
+ if (/^data:/i.test(src)) {
197
+ return undefined;
198
+ }
199
+ return cloneElement(reactNode, { key: `${src}-${index}` });
200
+ };
201
+
172
202
  // Wrap elements with data-marimo-doc attribute in a DocHoverTarget
173
203
  const wrapDocHoverTargets: TransformFn = (
174
204
  reactNode: ReactNode,
@@ -281,6 +311,8 @@ function parseHtml({
281
311
  ...additionalReplacements,
282
312
  ];
283
313
 
314
+ // Match-and-replace transforms: the first one that returns a value wins
315
+ // (short-circuits the rest).
284
316
  const transformFunctions: TransformFn[] = [
285
317
  addCopyButtonToCodehilite,
286
318
  preserveQueryParamsInAnchorLinks,
@@ -290,6 +322,12 @@ function parseHtml({
290
322
  removeWrappingHtmlTags,
291
323
  ];
292
324
 
325
+ // Decorators: run unconditionally on the result of the transform pipeline
326
+ // and may further wrap/clone it. Used for cross-cutting concerns that
327
+ // should apply regardless of which (if any) match-and-replace transform
328
+ // ran above.
329
+ const decoratorFunctions: TransformFn[] = [keyImagesBySrc];
330
+
293
331
  return parse(html, {
294
332
  replace: (domNode: DOMNode, index: number) => {
295
333
  for (const renderFunction of renderFunctions) {
@@ -301,13 +339,21 @@ function parseHtml({
301
339
  return domNode;
302
340
  },
303
341
  transform: (reactNode: ReactNode, domNode: DOMNode, index: number) => {
342
+ let result: ReactNode = reactNode as JSX.Element;
304
343
  for (const transformFunction of transformFunctions) {
305
- const transformed = transformFunction(reactNode, domNode, index);
344
+ const transformed = transformFunction(result, domNode, index);
306
345
  if (transformed) {
307
- return transformed;
346
+ result = transformed;
347
+ break;
348
+ }
349
+ }
350
+ for (const decorate of decoratorFunctions) {
351
+ const decorated = decorate(result, domNode, index);
352
+ if (decorated) {
353
+ result = decorated;
308
354
  }
309
355
  }
310
- return reactNode as JSX.Element;
356
+ return result as JSX.Element;
311
357
  },
312
358
  });
313
359
  }