@marimo-team/islands 0.19.8-dev3 → 0.19.8-dev31

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 (115) hide show
  1. package/dist/{Combination-Bg-xN8JV.js → Combination-BTMrlhzT.js} +11 -10
  2. package/dist/{ConnectedDataExplorerComponent-DewsKLl2.js → ConnectedDataExplorerComponent-BAeQ8DWw.js} +11 -11
  3. package/dist/{ImageComparisonComponent-Bijp8beW.js → ImageComparisonComponent-DkEXPki_.js} +2 -2
  4. package/dist/{any-language-editor-DZc6NCTp.js → any-language-editor-D0UQItkS.js} +6 -6
  5. package/dist/{architectureDiagram-VXUJARFQ--NkyBn9Y.js → architectureDiagram-VXUJARFQ-DPPYVq8H.js} +4 -4
  6. package/dist/assets/__vite-browser-external-6-UwTyQC.js +1 -0
  7. package/dist/assets/{worker-SqntmiwV.js → worker-D3e5wDxM.js} +4 -4
  8. package/dist/{blockDiagram-VD42YOAC-DEZZaTW0.js → blockDiagram-VD42YOAC-BA5N05Y9.js} +4 -4
  9. package/dist/{button-BWvsJ2Wr.js → button-Cy0ElmIm.js} +2 -2
  10. package/dist/{c4Diagram-YG6GDRKO-Bj7hwWCO.js → c4Diagram-YG6GDRKO-DJLzuGJJ.js} +3 -3
  11. package/dist/{channel-B_QrFrGg.js → channel-Dob5kWXR.js} +1 -1
  12. package/dist/{check-CM_kewwn.js → check-DkNR52Mm.js} +1 -1
  13. package/dist/{chunk-5FQGJX7Z-D5VFKHmt.js → chunk-5FQGJX7Z-BEb20Lzt.js} +3 -3
  14. package/dist/{chunk-ABZYJK2D-SZPYmRzN.js → chunk-ABZYJK2D-BXTC53mt.js} +1 -1
  15. package/dist/{chunk-ATLVNIR6-BI_WwH1o.js → chunk-ATLVNIR6-BJDjUR_c.js} +1 -1
  16. package/dist/{chunk-B4BG7PRW-BlI9Gm1l.js → chunk-B4BG7PRW-DzmUUpfH.js} +4 -4
  17. package/dist/{chunk-DI55MBZ5-BXxemMn5.js → chunk-DI55MBZ5-gTd3J8Tu.js} +4 -4
  18. package/dist/{chunk-EXTU4WIE-CzWtDV99.js → chunk-EXTU4WIE-DyoOs5QX.js} +1 -1
  19. package/dist/{chunk-JA3XYJ7Z-DQ-2ARfa.js → chunk-JA3XYJ7Z-BGnAIbOP.js} +2 -2
  20. package/dist/{chunk-JZLCHNYA-CVfjf2vv.js → chunk-JZLCHNYA-CIRgweVQ.js} +4 -4
  21. package/dist/{chunk-N4CR4FBY-BCZvQ7Jq.js → chunk-N4CR4FBY-DKSvXAIS.js} +5 -5
  22. package/dist/{chunk-QN33PNHL-DY_2Q2zl.js → chunk-QN33PNHL-B6zC8BTi.js} +1 -1
  23. package/dist/{chunk-QXUST7PY-BMCjAVR_.js → chunk-QXUST7PY-C7750n_u.js} +5 -5
  24. package/dist/{chunk-S3R3BYOJ-Ddu0H4Qa.js → chunk-S3R3BYOJ-CBkH6JZZ.js} +1 -1
  25. package/dist/{chunk-TZMSLE5B-C2wVlbMl.js → chunk-TZMSLE5B-DObGL7xi.js} +1 -1
  26. package/dist/{classDiagram-2ON5EDUG-D-g7zbyO.js → classDiagram-2ON5EDUG-B9pkKjjc.js} +9 -9
  27. package/dist/{classDiagram-v2-WZHVMYZB-C7v5zNRD.js → classDiagram-v2-WZHVMYZB-CRhhA0tV.js} +9 -9
  28. package/dist/{click-outside-container-BCN5BtVO.js → click-outside-container-DNfggvIW.js} +1 -1
  29. package/dist/{code-block-37QAKDTI-eUgXqGNG.js → code-block-37QAKDTI-u5kgjqmr.js} +2 -2
  30. package/dist/{compiler-runtime-DHFVbq0b.js → compiler-runtime-B_OLMU9S.js} +1 -1
  31. package/dist/{copy-B59Bw3-w.js → copy-DRaXIb_a.js} +3 -3
  32. package/dist/{dagre-6UL2VRFP-DKIPL74O.js → dagre-6UL2VRFP-C2C2XxsB.js} +6 -6
  33. package/dist/{data-grid-overlay-editor-COyFwFmE.js → data-grid-overlay-editor-BXqtz1ia.js} +4 -4
  34. package/dist/{diagram-PSM6KHXK-CVTrAZaP.js → diagram-PSM6KHXK-DHBY-94p.js} +5 -5
  35. package/dist/{diagram-QEK2KX5R-BqHBzu3x.js → diagram-QEK2KX5R-CgMshOwn.js} +3 -3
  36. package/dist/{diagram-S2PKOQOG-CJD6owcg.js → diagram-S2PKOQOG-F1KPva3Y.js} +3 -3
  37. package/dist/{dist-Co5PD8Fb.js → dist-BBYTEAvO.js} +1 -1
  38. package/dist/{erDiagram-Q2GNP2WA-CqOceSf9.js → erDiagram-Q2GNP2WA-18gGng8V.js} +9 -9
  39. package/dist/{error-banner-C7KLpECd.js → error-banner-D2zjeN_a.js} +5 -5
  40. package/dist/{esm-D4WO8J3G.js → esm-CgRNPmz8.js} +6 -6
  41. package/dist/{flowDiagram-NV44I4VS-K7-DUifo.js → flowDiagram-NV44I4VS-iHFiHYe0.js} +9 -9
  42. package/dist/{ganttDiagram-JELNMOA3-BwUFY9Nu.js → ganttDiagram-JELNMOA3-D7GixxiF.js} +2 -2
  43. package/dist/{gitGraphDiagram-NY62KEGX-CjGRtLb1.js → gitGraphDiagram-NY62KEGX-CJFHytRK.js} +2 -2
  44. package/dist/{glide-data-editor-C3T7HsLi.js → glide-data-editor-BYwb17Bf.js} +13 -13
  45. package/dist/{infoDiagram-WHAUD3N6-DNhmDn-6.js → infoDiagram-WHAUD3N6-B5Lkh3A9.js} +2 -2
  46. package/dist/{journeyDiagram-XKPGCS4Q-BOdK47P8.js → journeyDiagram-XKPGCS4Q-CV_9R9iP.js} +2 -2
  47. package/dist/{kanban-definition-3W4ZIXB7-A0JC9d0g.js → kanban-definition-3W4ZIXB7-Dp21D5Ym.js} +6 -6
  48. package/dist/{katex-DJyOeQ91.js → katex-CX2BKujk.js} +1 -1
  49. package/dist/{katex-Dm9nZf6A.js → katex-Db0k5oV_.js} +1 -1
  50. package/dist/{label-C4PtQcza.js → label-CxU5JNBW.js} +6 -6
  51. package/dist/main.js +282 -193
  52. package/dist/mermaid-4DMBBIKO-BhDCqnO1.js +6 -0
  53. package/dist/{mermaid-Bqp2Xw99.js → mermaid-B__BZSXU.js} +39 -39
  54. package/dist/{mhchem-BqdXeZVX.js → mhchem-w1tkUnWr.js} +1 -1
  55. package/dist/{mindmap-definition-VGOIOE7T-CS6nKN_L.js → mindmap-definition-VGOIOE7T-B_5mfdYp.js} +8 -8
  56. package/dist/{number-overlay-editor-Bz_bDJQb.js → number-overlay-editor-D-4WQAGX.js} +2 -2
  57. package/dist/{pieDiagram-ADFJNKIX-DSa60Grk.js → pieDiagram-ADFJNKIX-B-DGEopK.js} +3 -3
  58. package/dist/{quadrantDiagram-AYHSOK5B-CFnMbP2J.js → quadrantDiagram-AYHSOK5B-M_yRSIZn.js} +1 -1
  59. package/dist/{react-DdA8EBol.js → react-Bs6Z0kvn.js} +1 -1
  60. package/dist/{react-dom-DJW8xUDg.js → react-dom-CqtLRVZP.js} +2 -2
  61. package/dist/{react-plotly-jVjTu07w.js → react-plotly-BuRa9xtI.js} +1 -1
  62. package/dist/{react-vega-DgHpnZ04.js → react-vega-3WcLHYC7.js} +2 -2
  63. package/dist/{react-vega-CjiPWyw0.js → react-vega-DLFvGrpJ.js} +1 -1
  64. package/dist/{requirementDiagram-UZGBJVZJ-ytLQrFTk.js → requirementDiagram-UZGBJVZJ-9Wt82hOZ.js} +8 -8
  65. package/dist/{sankeyDiagram-TZEHDZUN-KQqXDoky.js → sankeyDiagram-TZEHDZUN-x_aTXZeN.js} +1 -1
  66. package/dist/{sequenceDiagram-WL72ISMW-ByLI04T5.js → sequenceDiagram-WL72ISMW-CXXmJqiQ.js} +3 -3
  67. package/dist/{slides-component-BVjvNo92.js → slides-component-Dp-y50K9.js} +4 -4
  68. package/dist/{spec-Dmb1KfK3.js → spec-HoYHAQo2.js} +6 -6
  69. package/dist/{stateDiagram-FKZM4ZOC-Dfz8vBbP.js → stateDiagram-FKZM4ZOC-CiSKS_Mx.js} +9 -9
  70. package/dist/{stateDiagram-v2-4FDKWEC3-DRYoLdT5.js → stateDiagram-v2-4FDKWEC3-A43Itnjp.js} +9 -9
  71. package/dist/style.css +1 -1
  72. package/dist/{timeline-definition-IT6M3QCI-CO48XU1B.js → timeline-definition-IT6M3QCI-DR26eWb4.js} +1 -1
  73. package/dist/{types-CzEZ3EWT.js → types-Bb-6p8hv.js} +8 -8
  74. package/dist/{useAsyncData-BjNwqCfS.js → useAsyncData-Dyq3DyOF.js} +3 -3
  75. package/dist/{useDeepCompareMemoize-CfoxVor3.js → useDeepCompareMemoize-CMGprt3H.js} +5 -5
  76. package/dist/{useIframeCapabilities-BBO_R0ww.js → useIframeCapabilities-DurI5SJh.js} +2 -2
  77. package/dist/{useTheme-BYG2SH8J.js → useTheme-SlKl8MlS.js} +5 -6
  78. package/dist/{vega-component-rDX7xwxH.js → vega-component-DU3aSp4m.js} +10 -10
  79. package/dist/{xychartDiagram-PRI3JC2R-CUIfjNVD.js → xychartDiagram-PRI3JC2R-BcVxCRox.js} +4 -4
  80. package/dist/{zod-DITCj31F.js → zod-bjADtMKr.js} +3 -3
  81. package/package.json +18 -18
  82. package/src/components/app-config/ai-config.tsx +11 -2
  83. package/src/components/app-config/user-config-form.tsx +0 -54
  84. package/src/components/chat/acp/__tests__/state.test.ts +69 -0
  85. package/src/components/chat/acp/state.ts +6 -6
  86. package/src/components/chat/chat-panel.tsx +47 -30
  87. package/src/components/data-table/__tests__/data-table.test.tsx +94 -2
  88. package/src/components/editor/actions/useCellActionButton.tsx +14 -1
  89. package/src/components/editor/cell/CreateCellButton.tsx +2 -1
  90. package/src/components/editor/cell/code/cell-editor.tsx +12 -0
  91. package/src/components/editor/renderers/cell-array.tsx +2 -1
  92. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +12 -0
  93. package/src/components/pages/gallery-page.tsx +37 -6
  94. package/src/core/MarimoApp.tsx +12 -8
  95. package/src/core/ai/context/providers/file.ts +1 -1
  96. package/src/core/cells/__tests__/cells.test.ts +120 -0
  97. package/src/core/cells/cells.ts +14 -0
  98. package/src/core/codemirror/language/languages/markdown.ts +7 -0
  99. package/src/core/config/feature-flag.tsx +0 -4
  100. package/src/core/islands/__tests__/bridge.test.ts +241 -0
  101. package/src/core/islands/bridge.ts +22 -6
  102. package/src/core/run-app.tsx +11 -4
  103. package/src/core/static/__tests__/files.test.ts +195 -1
  104. package/src/core/static/files.ts +39 -9
  105. package/src/plugins/core/registerReactComponent.tsx +9 -1
  106. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +164 -0
  107. package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +7 -1
  108. package/src/utils/__tests__/blob.test.ts +3 -3
  109. package/src/utils/__tests__/mime-types.test.ts +8 -10
  110. package/src/utils/__tests__/url-parser.test.ts +22 -0
  111. package/src/utils/blob.ts +14 -27
  112. package/src/utils/mime-types.ts +5 -5
  113. package/src/utils/url-parser.ts +1 -1
  114. package/dist/assets/__vite-browser-external-DRa9CT_O.js +0 -1
  115. package/dist/mermaid-4DMBBIKO-o3xNphpD.js +0 -6
@@ -9,7 +9,11 @@ import { useAtom, useAtomValue, useSetAtom, useStore } from "jotai";
9
9
  import {
10
10
  AtSignIcon,
11
11
  BotMessageSquareIcon,
12
+ HatGlasses,
12
13
  Loader2,
14
+ type LucideIcon,
15
+ MessageCircleIcon,
16
+ NotebookText,
13
17
  PaperclipIcon,
14
18
  PlusIcon,
15
19
  SendIcon,
@@ -45,7 +49,6 @@ import {
45
49
  import { useCellActions } from "@/core/cells/cells";
46
50
  import { aiAtom, aiEnabledAtom } from "@/core/config/config";
47
51
  import { DEFAULT_AI_MODEL } from "@/core/config/config-schema";
48
- import { FeatureFlagged } from "@/core/config/feature-flag";
49
52
  import { useRequestClient } from "@/core/network/requests";
50
53
  import { useRuntimeManager } from "@/core/runtime/config";
51
54
  import { ErrorBanner } from "@/plugins/impl/common/error-banner";
@@ -238,58 +241,72 @@ const ChatInputFooter: React.FC<ChatInputFooterProps> = memo(
238
241
  value: CopilotMode;
239
242
  label: string;
240
243
  subtitle: string;
244
+ Icon: LucideIcon;
241
245
  }[] = [
246
+ {
247
+ value: "manual",
248
+ label: "Manual",
249
+ subtitle: "Pure chat, no tool usage",
250
+ Icon: MessageCircleIcon,
251
+ },
242
252
  {
243
253
  value: "ask",
244
254
  label: "Ask",
245
255
  subtitle:
246
256
  "Use AI with access to read-only tools like documentation search",
247
- },
248
- {
249
- value: "manual",
250
- label: "Manual",
251
- subtitle: "Pure chat, no tool usage",
257
+ Icon: NotebookText,
252
258
  },
253
259
  {
254
260
  value: "agent",
255
261
  label: "Agent (beta)",
256
262
  subtitle: "Use AI with access to read and write tools",
263
+ Icon: HatGlasses,
257
264
  },
258
265
  ];
259
266
 
260
267
  const isAttachmentSupported =
261
268
  PROVIDERS_THAT_SUPPORT_ATTACHMENTS.has(currentProvider);
262
269
 
270
+ const CurrentModeIcon = modeOptions.find(
271
+ (o) => o.value === currentMode,
272
+ )?.Icon;
273
+
263
274
  return (
264
275
  <TooltipProvider>
265
276
  <div className="px-3 py-2 border-t border-border/20 flex flex-row flex-wrap items-center justify-between gap-1">
266
277
  <div className="flex items-center gap-2">
267
- <FeatureFlagged feature="chat_modes">
268
- <Select value={currentMode} onValueChange={saveModeChange}>
269
- <SelectTrigger className="h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1 capitalize">
270
- {currentMode}
271
- </SelectTrigger>
272
- <SelectContent>
273
- <SelectGroup>
274
- <SelectLabel>AI Mode</SelectLabel>
275
- {modeOptions.map((option) => (
276
- <SelectItem
277
- key={option.value}
278
- value={option.value}
279
- className="text-xs"
280
- >
281
- <div className="flex flex-col">
282
- {option.label}
283
- <div className="text-muted-foreground text-xs pt-1 block">
278
+ <Select value={currentMode} onValueChange={saveModeChange}>
279
+ <SelectTrigger className="h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1.5">
280
+ {CurrentModeIcon && <CurrentModeIcon className="h-3 w-3" />}
281
+ <span className="capitalize">{currentMode}</span>
282
+ </SelectTrigger>
283
+ <SelectContent>
284
+ <SelectGroup>
285
+ <SelectLabel className="text-xs uppercase tracking-wider text-muted-foreground/70 font-medium">
286
+ AI Mode
287
+ </SelectLabel>
288
+ {modeOptions.map((option) => (
289
+ <SelectItem
290
+ key={option.value}
291
+ value={option.value}
292
+ className="text-xs py-1"
293
+ >
294
+ <div className="flex items-start gap-2.5">
295
+ <span className="mt-1 text-muted-foreground">
296
+ <option.Icon className="h-3 w-3" />
297
+ </span>
298
+ <div className="flex flex-col gap-0.5">
299
+ <span className="font-semibold">{option.label}</span>
300
+ <span className="text-muted-foreground">
284
301
  {option.subtitle}
285
- </div>
302
+ </span>
286
303
  </div>
287
- </SelectItem>
288
- ))}
289
- </SelectGroup>
290
- </SelectContent>
291
- </Select>
292
- </FeatureFlagged>
304
+ </div>
305
+ </SelectItem>
306
+ ))}
307
+ </SelectGroup>
308
+ </SelectContent>
309
+ </Select>
293
310
  <AIModelDropdown
294
311
  placeholder="Model"
295
312
  triggerClassName="h-6 text-xs shadow-none! ring-0! bg-muted hover:bg-muted/30 rounded-sm"
@@ -1,6 +1,11 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
- import type { ColumnDef, RowSelectionState } from "@tanstack/react-table";
3
- import { render, screen } from "@testing-library/react";
2
+ import type {
3
+ ColumnDef,
4
+ PaginationState,
5
+ RowSelectionState,
6
+ SortingState,
7
+ } from "@tanstack/react-table";
8
+ import { render, screen, within } from "@testing-library/react";
4
9
  import { describe, expect, it, vi } from "vitest";
5
10
  import { TooltipProvider } from "@/components/ui/tooltip";
6
11
  import { DataTable } from "../data-table";
@@ -95,4 +100,91 @@ describe("DataTable", () => {
95
100
  expect(rows[1]).toHaveAttribute("title", "Michael Scott");
96
101
  expect(rows[2]).toHaveAttribute("title", "Jim Halpert");
97
102
  });
103
+
104
+ it("should display updated data after rerender with manual sorting and pagination", () => {
105
+ // Simulates the bug from issue #8023:
106
+ // When a user sorts a table, rows that moved from page 2 to page 1
107
+ // don't visually refresh after the underlying data is updated.
108
+
109
+ interface RowData {
110
+ id: number;
111
+ status: string;
112
+ value: number;
113
+ }
114
+
115
+ // Initial data: 4 rows, page_size=3
116
+ const initialData: RowData[] = [
117
+ { id: 4, status: "pending", value: 40 },
118
+ { id: 3, status: "pending", value: 30 },
119
+ { id: 2, status: "pending", value: 20 },
120
+ ];
121
+
122
+ const columns: ColumnDef<RowData>[] = [
123
+ { id: "id", accessorFn: (row) => row.id, header: "id" },
124
+ { id: "status", accessorFn: (row) => row.status, header: "status" },
125
+ { id: "value", accessorFn: (row) => row.value, header: "value" },
126
+ ];
127
+
128
+ // Simulate sorted state (value descending) - manual sorting means
129
+ // data comes pre-sorted from backend
130
+ const sorting: SortingState = [{ id: "value", desc: true }];
131
+ const setSorting = vi.fn();
132
+
133
+ const paginationState: PaginationState = { pageIndex: 0, pageSize: 3 };
134
+ const setPaginationState = vi.fn();
135
+
136
+ const commonProps = {
137
+ columns,
138
+ selection: null as "single" | "multi" | null,
139
+ totalRows: 4,
140
+ totalColumns: 3,
141
+ pagination: true,
142
+ manualPagination: true,
143
+ paginationState,
144
+ setPaginationState,
145
+ manualSorting: true,
146
+ sorting,
147
+ setSorting,
148
+ };
149
+
150
+ const { rerender } = render(
151
+ <TooltipProvider>
152
+ <DataTable {...commonProps} data={initialData} />
153
+ </TooltipProvider>,
154
+ );
155
+
156
+ // Verify initial data is displayed - look for "pending" in cells
157
+ const rows = screen.getAllByRole("row");
158
+ // Row 0 is header, rows 1-3 are data rows
159
+ expect(rows).toHaveLength(4); // 1 header + 3 data rows
160
+ // All rows should show "pending"
161
+ expect(within(rows[1]).getByText("pending")).toBeTruthy();
162
+ expect(within(rows[2]).getByText("pending")).toBeTruthy();
163
+ expect(within(rows[3]).getByText("pending")).toBeTruthy();
164
+
165
+ // Now simulate data update: row with id=4 is now "approved"
166
+ // Backend returns sorted data with the update applied
167
+ const updatedData: RowData[] = [
168
+ { id: 4, status: "approved", value: 40 },
169
+ { id: 3, status: "pending", value: 30 },
170
+ { id: 2, status: "pending", value: 20 },
171
+ ];
172
+
173
+ // Rerender with updated data (same sorting, same pagination)
174
+ rerender(
175
+ <TooltipProvider>
176
+ <DataTable {...commonProps} data={updatedData} />
177
+ </TooltipProvider>,
178
+ );
179
+
180
+ // BUG: The row should show "approved" but might show stale "pending"
181
+ const updatedRows = screen.getAllByRole("row");
182
+ expect(updatedRows).toHaveLength(4);
183
+
184
+ // The first data row (id=4) should now show "approved"
185
+ expect(within(updatedRows[1]).getByText("approved")).toBeTruthy();
186
+ // Other rows should still show "pending"
187
+ expect(within(updatedRows[2]).getByText("pending")).toBeTruthy();
188
+ expect(within(updatedRows[3]).getByText("pending")).toBeTruthy();
189
+ });
98
190
  });
@@ -43,6 +43,7 @@ import type { CellData } from "@/core/cells/types";
43
43
  import { formatEditorViews } from "@/core/codemirror/format";
44
44
  import { toggleToLanguage } from "@/core/codemirror/language/commands";
45
45
  import { switchLanguage } from "@/core/codemirror/language/extension";
46
+ import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
46
47
  import {
47
48
  aiEnabledAtom,
48
49
  appWidthAtom,
@@ -85,6 +86,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) {
85
86
  sendToBottom,
86
87
  addColumnBreakpoint,
87
88
  clearCellOutput,
89
+ markUntouched,
88
90
  } = useCellActions();
89
91
  const splitCell = useSplitCellCallback();
90
92
  const runCell = useRunCell(cell?.cellId);
@@ -209,7 +211,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) {
209
211
  icon: <MarkdownIcon />,
210
212
  label: "Convert to Markdown",
211
213
  hotkey: "cell.viewAsMarkdown",
212
- handle: () => {
214
+ handle: async () => {
213
215
  const editorView = getEditorView();
214
216
  if (!editorView) {
215
217
  return;
@@ -219,6 +221,17 @@ export function useCellActionButtons({ cell, closePopover }: Props) {
219
221
  language: "markdown",
220
222
  keepCodeAsIs: false,
221
223
  });
224
+ // Code stays visible until the user blurs the cell
225
+ if (!config.hide_code && MARKDOWN_INITIAL_HIDE_CODE) {
226
+ await saveCellConfig({
227
+ configs: { [cellId]: { hide_code: MARKDOWN_INITIAL_HIDE_CODE } },
228
+ });
229
+ updateCellConfig({
230
+ cellId,
231
+ config: { hide_code: MARKDOWN_INITIAL_HIDE_CODE },
232
+ });
233
+ markUntouched({ cellId });
234
+ }
222
235
  },
223
236
  hidden: isSetupCell,
224
237
  },
@@ -12,6 +12,7 @@ import {
12
12
  import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
13
13
  import { useCellActions } from "@/core/cells/cells";
14
14
  import { LanguageAdapters } from "@/core/codemirror/language/LanguageAdapters";
15
+ import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
15
16
  import {
16
17
  getConnectionTooltip,
17
18
  isAppInteractionDisabled,
@@ -63,7 +64,7 @@ export const CreateCellButton = ({
63
64
  maybeAddMarimoImport({ autoInstantiate: true, createNewCell });
64
65
  onClick?.({
65
66
  code: LanguageAdapters.markdown.defaultCode,
66
- hideCode: true,
67
+ hideCode: MARKDOWN_INITIAL_HIDE_CODE,
67
68
  });
68
69
  };
69
70
 
@@ -19,6 +19,7 @@ import {
19
19
  reconfigureLanguageEffect,
20
20
  switchLanguage,
21
21
  } from "@/core/codemirror/language/extension";
22
+ import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
22
23
  import type { LanguageAdapterType } from "@/core/codemirror/language/types";
23
24
  import {
24
25
  connectedDocAtom,
@@ -149,6 +150,17 @@ const CellEditorInternal = ({
149
150
  autoInstantiate,
150
151
  createNewCell: cellActions.createNewCell,
151
152
  });
153
+ // Code stays visible until the user blurs the cell
154
+ if (!cellConfig.hide_code && MARKDOWN_INITIAL_HIDE_CODE) {
155
+ void saveCellConfig({
156
+ configs: { [cellId]: { hide_code: MARKDOWN_INITIAL_HIDE_CODE } },
157
+ });
158
+ cellActions.updateCellConfig({
159
+ cellId,
160
+ config: { hide_code: MARKDOWN_INITIAL_HIDE_CODE },
161
+ });
162
+ cellActions.markUntouched({ cellId });
163
+ }
152
164
  });
153
165
 
154
166
  const aiEnabled = isAiEnabled(userConfig);
@@ -23,6 +23,7 @@ import { Tooltip } from "@/components/ui/tooltip";
23
23
  import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
24
24
  import { SETUP_CELL_ID } from "@/core/cells/ids";
25
25
  import { LanguageAdapters } from "@/core/codemirror/language/LanguageAdapters";
26
+ import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
26
27
  import { aiEnabledAtom } from "@/core/config/config";
27
28
  import { canInteractWithAppAtom } from "@/core/network/connection";
28
29
  import { useBoolean } from "@/hooks/useBoolean";
@@ -295,7 +296,7 @@ const AddCellButtons: React.FC<{
295
296
  cellId: { type: "__end__", columnId },
296
297
  before: false,
297
298
  code: LanguageAdapters.markdown.defaultCode,
298
- hideCode: true,
299
+ hideCode: MARKDOWN_INITIAL_HIDE_CODE,
299
300
  });
300
301
  }}
301
302
  >
@@ -7,6 +7,7 @@ import {
7
7
  CodeIcon,
8
8
  FolderDownIcon,
9
9
  ImageIcon,
10
+ Loader2Icon,
10
11
  MoreHorizontalIcon,
11
12
  } from "lucide-react";
12
13
  import type React from "react";
@@ -32,6 +33,7 @@ import { MarkdownLanguageAdapter } from "@/core/codemirror/language/languages/ma
32
33
  import { useResolvedMarimoConfig } from "@/core/config/config";
33
34
  import { CSSClasses, KnownQueryParams } from "@/core/constants";
34
35
  import type { OutputMessage } from "@/core/kernel/messages";
36
+ import { kernelStateAtom } from "@/core/kernel/state";
35
37
  import { showCodeInRunModeAtom } from "@/core/meta/state";
36
38
  import { isErrorMime } from "@/core/mime";
37
39
  import { type AppMode, kioskModeAtom } from "@/core/mode";
@@ -63,6 +65,7 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({
63
65
  }) => {
64
66
  const { invisible } = useDelayVisibility(cells.length, mode);
65
67
  const kioskMode = useAtomValue(kioskModeAtom);
68
+ const kernelState = useAtomValue(kernelStateAtom);
66
69
  const [userConfig] = useResolvedMarimoConfig();
67
70
  const showCodeInRunModePreference = useAtomValue(showCodeInRunModeAtom);
68
71
 
@@ -140,6 +143,15 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({
140
143
  }
141
144
 
142
145
  if (cells.length === 0 && !invisible) {
146
+ // If kernel is not yet instantiated, show loading state
147
+ if (!kernelState.isInstantiated) {
148
+ return (
149
+ <div className="flex-1 flex flex-col items-center justify-center py-8">
150
+ <Loader2Icon className="w-8 h-8 animate-spin text-muted-foreground" />
151
+ </div>
152
+ );
153
+ }
154
+ // Kernel is ready but no cells - truly empty notebook
143
155
  return (
144
156
  <div className="flex-1 flex flex-col items-center justify-center py-8">
145
157
  <Alert variant="info">
@@ -33,6 +33,15 @@ const tabTarget = (path: string): string => {
33
33
  return `${getSessionId()}-${encodeURIComponent(path)}`;
34
34
  };
35
35
 
36
+ const isHttpsUrl = (value: string): boolean => {
37
+ try {
38
+ const url = new URL(value);
39
+ return url.protocol === "https:";
40
+ } catch {
41
+ return false;
42
+ }
43
+ };
44
+
36
45
  const SEARCH_THRESHOLD = 10;
37
46
 
38
47
  const GalleryPage: React.FC = () => {
@@ -43,10 +52,10 @@ const GalleryPage: React.FC = () => {
43
52
  [],
44
53
  );
45
54
  const workspace = response.data;
46
- const files = workspace?.files ?? [];
47
- const root = workspace?.root ?? "";
48
55
 
49
56
  const formattedFiles = useMemo(() => {
57
+ const files = workspace?.files ?? [];
58
+ const root = workspace?.root ?? "";
50
59
  return files
51
60
  .filter((file) => !file.isDirectory)
52
61
  .map((file) => {
@@ -54,17 +63,28 @@ const GalleryPage: React.FC = () => {
54
63
  root && Paths.isAbsolute(file.path) && file.path.startsWith(root)
55
64
  ? Paths.rest(file.path, root)
56
65
  : file.path;
57
- const title = titleCase(Paths.basename(relativePath));
66
+ const title =
67
+ file.opengraph?.title ?? titleCase(Paths.basename(relativePath));
58
68
  const subtitle = titleCase(Paths.dirname(relativePath));
69
+ const description = file.opengraph?.description ?? "";
70
+ const opengraphImage = file.opengraph?.image;
71
+ const thumbnailUrl =
72
+ opengraphImage && isHttpsUrl(opengraphImage)
73
+ ? opengraphImage
74
+ : asURL(
75
+ `/og/thumbnail?file=${encodeURIComponent(relativePath)}`,
76
+ ).toString();
59
77
  return {
60
78
  ...file,
61
79
  relativePath,
62
80
  title,
63
81
  subtitle,
82
+ description,
83
+ thumbnailUrl,
64
84
  };
65
85
  })
66
86
  .sort((a, b) => a.relativePath.localeCompare(b.relativePath));
67
- }, [files, root]);
87
+ }, [workspace?.files, workspace?.root]);
68
88
 
69
89
  const filteredFiles = useMemo(() => {
70
90
  if (!searchQuery) {
@@ -130,8 +150,14 @@ const GalleryPage: React.FC = () => {
130
150
  target={tabTarget(file.path)}
131
151
  className="no-underline"
132
152
  >
133
- <Card className="h-full hover:bg-accent/20 transition-colors">
134
- <CardContent className="p-6">
153
+ <Card className="h-full overflow-hidden hover:bg-accent/20 transition-colors">
154
+ <img
155
+ src={file.thumbnailUrl}
156
+ alt={file.title}
157
+ loading="lazy"
158
+ className="w-full aspect-1200/630 object-cover border-b border-border/60"
159
+ />
160
+ <CardContent className="p-6 pt-4">
135
161
  <div className="flex flex-col gap-1">
136
162
  {file.subtitle && (
137
163
  <div className="text-sm font-semibold text-muted-foreground">
@@ -141,6 +167,11 @@ const GalleryPage: React.FC = () => {
141
167
  <div className="text-lg font-medium">
142
168
  {file.title}
143
169
  </div>
170
+ {file.description && (
171
+ <div className="text-sm text-muted-foreground line-clamp-3 mt-1">
172
+ {file.description}
173
+ </div>
174
+ )}
144
175
  </div>
145
176
  </CardContent>
146
177
  </Card>
@@ -39,14 +39,18 @@ const LazyGalleryPage = reactLazyWithPreload(
39
39
  );
40
40
 
41
41
  export function preloadPage(mode: string) {
42
- if (mode === "home") {
43
- LazyHomePage.preload();
44
- } else if (mode === "gallery") {
45
- LazyGalleryPage.preload();
46
- } else if (mode === "read") {
47
- LazyRunPage.preload();
48
- } else {
49
- LazyEditPage.preload();
42
+ switch (mode) {
43
+ case "home":
44
+ LazyHomePage.preload();
45
+ break;
46
+ case "gallery":
47
+ LazyGalleryPage.preload();
48
+ break;
49
+ case "read":
50
+ LazyRunPage.preload();
51
+ break;
52
+ default:
53
+ LazyEditPage.preload();
50
54
  }
51
55
  }
52
56
 
@@ -237,7 +237,7 @@ export class FileContextProvider extends AIContextProvider<FileContextItem> {
237
237
  fileDetails.contents as Base64String,
238
238
  mimeType,
239
239
  );
240
- blob = await deserializeBlob(dataURL);
240
+ blob = deserializeBlob(dataURL);
241
241
  } catch {
242
242
  // Fallback to treating as text
243
243
  blob = new Blob([fileDetails.contents], { type: mimeType });
@@ -2561,6 +2561,126 @@ describe("cell reducer", () => {
2561
2561
  expect(state.untouchedNewCells.has(newCellId)).toBe(false);
2562
2562
  expect(exportedForTesting.isCellCodeHidden(state, newCellId)).toBe(true);
2563
2563
  });
2564
+
2565
+ it("can mark an existing cell as untouched", () => {
2566
+ // Create a cell without hideCode (not in untouchedNewCells)
2567
+ actions.createNewCell({
2568
+ cellId: "__end__",
2569
+ before: false,
2570
+ hideCode: false,
2571
+ });
2572
+
2573
+ const newCellId =
2574
+ state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
2575
+ expect(state.untouchedNewCells.has(newCellId)).toBe(false);
2576
+
2577
+ // Mark it as untouched
2578
+ actions.markUntouched({ cellId: newCellId });
2579
+
2580
+ expect(state.untouchedNewCells.has(newCellId)).toBe(true);
2581
+ });
2582
+
2583
+ it("markUntouched is idempotent", () => {
2584
+ // Create a cell without hideCode
2585
+ actions.createNewCell({
2586
+ cellId: "__end__",
2587
+ before: false,
2588
+ hideCode: false,
2589
+ });
2590
+
2591
+ const newCellId =
2592
+ state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
2593
+ expect(state.untouchedNewCells.has(newCellId)).toBe(false);
2594
+
2595
+ // Mark as untouched multiple times
2596
+ actions.markUntouched({ cellId: newCellId });
2597
+ actions.markUntouched({ cellId: newCellId });
2598
+ actions.markUntouched({ cellId: newCellId });
2599
+
2600
+ expect(state.untouchedNewCells.has(newCellId)).toBe(true);
2601
+ });
2602
+
2603
+ it("markUntouched does not affect already untouched cells", () => {
2604
+ // Create a cell with hideCode (already in untouchedNewCells)
2605
+ actions.createNewCell({
2606
+ cellId: "__end__",
2607
+ before: false,
2608
+ hideCode: true,
2609
+ });
2610
+
2611
+ const newCellId =
2612
+ state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
2613
+ expect(state.untouchedNewCells.has(newCellId)).toBe(true);
2614
+
2615
+ // Calling markUntouched should not change anything
2616
+ actions.markUntouched({ cellId: newCellId });
2617
+
2618
+ expect(state.untouchedNewCells.has(newCellId)).toBe(true);
2619
+ });
2620
+
2621
+ it("markTouched and markUntouched can toggle cell state", () => {
2622
+ // Create a cell without hideCode
2623
+ actions.createNewCell({
2624
+ cellId: "__end__",
2625
+ before: false,
2626
+ hideCode: false,
2627
+ });
2628
+
2629
+ const newCellId =
2630
+ state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
2631
+
2632
+ // Initially not untouched
2633
+ expect(state.untouchedNewCells.has(newCellId)).toBe(false);
2634
+
2635
+ // Mark as untouched
2636
+ actions.markUntouched({ cellId: newCellId });
2637
+ expect(state.untouchedNewCells.has(newCellId)).toBe(true);
2638
+
2639
+ // Mark as touched
2640
+ actions.markTouched({ cellId: newCellId });
2641
+ expect(state.untouchedNewCells.has(newCellId)).toBe(false);
2642
+
2643
+ // Mark as untouched again
2644
+ actions.markUntouched({ cellId: newCellId });
2645
+ expect(state.untouchedNewCells.has(newCellId)).toBe(true);
2646
+ });
2647
+
2648
+ it("markUntouched works for markdown cell conversion scenario", () => {
2649
+ // Simulates converting a Python cell to Markdown
2650
+ // 1. Create a regular cell (no hideCode)
2651
+ actions.createNewCell({
2652
+ cellId: "__end__",
2653
+ before: false,
2654
+ hideCode: false,
2655
+ });
2656
+
2657
+ const cellId =
2658
+ state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
2659
+
2660
+ // Cell starts without hide_code and not in untouchedNewCells
2661
+ expect(state.cellData[cellId].config.hide_code).toBe(false);
2662
+ expect(state.untouchedNewCells.has(cellId)).toBe(false);
2663
+ expect(exportedForTesting.isCellCodeHidden(state, cellId)).toBe(false);
2664
+
2665
+ // 2. Convert to markdown: set hide_code and mark as untouched
2666
+ actions.updateCellConfig({
2667
+ cellId,
2668
+ config: { hide_code: true },
2669
+ });
2670
+ actions.markUntouched({ cellId });
2671
+
2672
+ // Code should NOT be hidden because cell is untouched (user can edit)
2673
+ expect(state.cellData[cellId].config.hide_code).toBe(true);
2674
+ expect(state.untouchedNewCells.has(cellId)).toBe(true);
2675
+ expect(exportedForTesting.isCellCodeHidden(state, cellId)).toBe(false);
2676
+
2677
+ // 3. User blurs the cell (markTouched)
2678
+ actions.markTouched({ cellId });
2679
+
2680
+ // Now code should be hidden
2681
+ expect(state.untouchedNewCells.has(cellId)).toBe(false);
2682
+ expect(exportedForTesting.isCellCodeHidden(state, cellId)).toBe(true);
2683
+ });
2564
2684
  });
2565
2685
 
2566
2686
  describe("releaseCellAtoms", () => {
@@ -1033,6 +1033,20 @@ const {
1033
1033
 
1034
1034
  return state;
1035
1035
  },
1036
+ markUntouched: (state, action: { cellId: CellId }) => {
1037
+ const { cellId } = action;
1038
+
1039
+ if (!state.untouchedNewCells.has(cellId)) {
1040
+ const nextUntouchedNewCells = new Set(state.untouchedNewCells);
1041
+ nextUntouchedNewCells.add(cellId);
1042
+ return {
1043
+ ...state,
1044
+ untouchedNewCells: nextUntouchedNewCells,
1045
+ };
1046
+ }
1047
+
1048
+ return state;
1049
+ },
1036
1050
  scrollToTarget: (state) => {
1037
1051
  // Scroll to the specified cell and clear the scroll key.
1038
1052
  const scrollKey = state.scrollKey;
@@ -28,6 +28,13 @@ import type { LanguageAdapter } from "../types";
28
28
 
29
29
  export type MarkdownLanguageAdapterMetadata = MarkdownMetadata;
30
30
 
31
+ /**
32
+ * Default hide_code setting for markdown cells.
33
+ * When true, the markdown code is hidden after the cell is blurred,
34
+ * showing only the rendered output.
35
+ */
36
+ export const MARKDOWN_INITIAL_HIDE_CODE = true;
37
+
31
38
  /**
32
39
  * Language adapter for Markdown.
33
40
  */