@marimo-team/islands 0.15.2 → 0.15.4

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 (211) hide show
  1. package/dist/{ConnectedDataExplorerComponent-C39nQwtD.js → ConnectedDataExplorerComponent-B68gXlbY.js} +323 -328
  2. package/dist/{ImageComparisonComponent-BhkiyswP.js → ImageComparisonComponent-Cw1oA8Tn.js} +13 -13
  3. package/dist/{_baseUniq-DdHL34FO.js → _baseUniq-CQrhBg_9.js} +67 -67
  4. package/dist/any-language-editor-pzUl6lxp.js +27 -0
  5. package/dist/{arc-BXrety1g.js → arc-BOhn-m2C.js} +1 -1
  6. package/dist/{architectureDiagram-KFL7JDKH-BMy6ywCF.js → architectureDiagram-W76B3OCA-DdYf2VnU.js} +144 -144
  7. package/dist/assets/{worker-COGufAQn.js → worker-BcG8m3h5.js} +33 -29
  8. package/dist/asterisk-DS281yxp.js +271 -0
  9. package/dist/{blockDiagram-ZYB65J3Q-DYT2-nlI.js → blockDiagram-QIGZ2CNN-DmmYotkP.js} +10 -10
  10. package/dist/{c4Diagram-AAMF2YG6-ZiQzioe6.js → c4Diagram-FPNF74CW-Dyz4zMHJ.js} +8 -8
  11. package/dist/{channel-CeuXqUAU.js → channel-CCL8jXAe.js} +1 -1
  12. package/dist/{chunk-ANTBXLJU-BvYnIrdq.js → chunk-4BX2VUAB-BfKwWLfJ.js} +1 -1
  13. package/dist/{chunk-WVR4S24B-DXj8yaUk.js → chunk-55IACEB6-CFQU7zSp.js} +1 -1
  14. package/dist/{chunk-GLLZNHP4-CyFsosAe.js → chunk-FMBD7UC4-DDjZzUcl.js} +1 -1
  15. package/dist/{chunk-JBRWN2VN-DA_EEhy2.js → chunk-K7UQS3LO-nBRjBU1H.js} +117 -117
  16. package/dist/{chunk-NRVI72HA-BYx2jMlI.js → chunk-QN33PNHL-B-g8sJzl.js} +1 -1
  17. package/dist/{chunk-FHKO5MBM-DfCztBk8.js → chunk-QZHKN3VN-B7QSJS3J.js} +1 -1
  18. package/dist/{chunk-LXBSTHXV-Se7vdY6J.js → chunk-TVAH2DTR-pGXll4d1.js} +7 -7
  19. package/dist/{chunk-OMD6QJNC-CqgcPMgL.js → chunk-TZMSLE5B-Dx9h-1mv.js} +1 -1
  20. package/dist/{classDiagram-v2-QTMF73CY-B19A3G1l.js → classDiagram-KNZD7YFC-BXryI7DY.js} +2 -2
  21. package/dist/{classDiagram-3BZAVTQC-B19A3G1l.js → classDiagram-v2-RKCZMP56-BXryI7DY.js} +2 -2
  22. package/dist/{clone-78au0tn1.js → clone-DqwV7ges.js} +1 -1
  23. package/dist/cose-bilkent-S5V4N54A-Di6FNMXz.js +2609 -0
  24. package/dist/{cytoscape.esm-BYnVVhJX.js → cytoscape.esm-DfdJODL8.js} +34 -34
  25. package/dist/{dagre-2BBEFEWP-BfEn3ZUV.js → dagre-5GWH7T2D-BTZPMTey.js} +6 -6
  26. package/dist/{data-grid-overlay-editor-CH_qLkV2.js → data-grid-overlay-editor-ryatXXby.js} +11 -11
  27. package/dist/{diagram-4IRLE6MV-CL8xidnG.js → diagram-N5W7TBWH-D79_zdOu.js} +59 -60
  28. package/dist/{diagram-RP2FKANI-B1BPcUew.js → diagram-QEK2KX5R-DX2A_SD0.js} +15 -15
  29. package/dist/{diagram-GUPCWM2R-CZ5cfqlq.js → diagram-S2PKOQOG-DM6VMTrJ.js} +10 -10
  30. package/dist/dockerfile-BoowzQlp.js +194 -0
  31. package/dist/ebnf-DUPDuY4r.js +78 -0
  32. package/dist/{erDiagram-HZWUO2LU-BEAIww50.js → erDiagram-AWTI2OKA-BBirxtlI.js} +8 -8
  33. package/dist/fcl-CPC2WYrI.js +103 -0
  34. package/dist/{flowDiagram-THRYKUMA-Czs2UAI2.js → flowDiagram-PVAE7QVJ-DyVweEMs.js} +9 -9
  35. package/dist/{ganttDiagram-WV7ZQ7D5-ByYIAVFO.js → ganttDiagram-OWAHRB6G-DTB7FX7r.js} +34 -34
  36. package/dist/{gitGraphDiagram-OJR772UL-BcpDsiyB.js → gitGraphDiagram-NY62KEGX-BrbIb5pD.js} +4 -4
  37. package/dist/{glide-data-editor-CmN6FVyi.js → glide-data-editor-DhMX4nmM.js} +33 -33
  38. package/dist/{graph-77W6heli.js → graph-CuLSrclI.js} +3 -3
  39. package/dist/http-D9LttvKF.js +44 -0
  40. package/dist/{index-BOojn38D.js → index-BNgdUQ2e.js} +7711 -7711
  41. package/dist/index-DIy6LHLJ.js +98 -0
  42. package/dist/{index-CmozKMxx.js → index-Df2dsx1t.js} +6 -6
  43. package/dist/{index-pBmAzQJl.js → index-MCx5v1x0.js} +2 -2
  44. package/dist/{index-Bfk9dnyS.js → index-cz_xaKvT.js} +33090 -32892
  45. package/dist/{infoDiagram-6WOFNB3A-CfzLHHVP.js → infoDiagram-STP46IZ2-CCBHc7-K.js} +2 -2
  46. package/dist/{journeyDiagram-FFXJYRFH-ndAcpkGn.js → journeyDiagram-BIP6EPQ6-LhGSj54j.js} +24 -26
  47. package/dist/{kanban-definition-KOZQBZVT-DcQYzNvc.js → kanban-definition-6OIFK2YF-aegTMFS6.js} +14 -14
  48. package/dist/{layout-XySVHJgD.js → layout-BEARWMhl.js} +81 -81
  49. package/dist/{linear-PbooOqg7.js → linear-fbJq6cdO.js} +35 -35
  50. package/dist/{main-B5yML0bw.js → main-HerZgEhd.js} +76533 -69945
  51. package/dist/main.js +1 -1
  52. package/dist/{mermaid-Cg5IX6Nv.js → mermaid-DxPYK0KX.js} +6160 -7493
  53. package/dist/min-DBJkhObB.js +80 -0
  54. package/dist/mindmap-definition-Q6HEUPPD-A3Fh5XDZ.js +785 -0
  55. package/dist/nginx-zDPm3Z74.js +89 -0
  56. package/dist/{number-overlay-editor-DUhfZqtP.js → number-overlay-editor-USMrY6k3.js} +19 -19
  57. package/dist/{pieDiagram-DBDJKBY4-DTOlNsja.js → pieDiagram-ADFJNKIX-Q9uFlCV0.js} +17 -17
  58. package/dist/{quadrantDiagram-YPSRARAO-BX2d8VS-.js → quadrantDiagram-LMRXKWRM-BuPh-qpK.js} +6 -6
  59. package/dist/{react-plotly-Dcyw-3Sa.js → react-plotly-HSqJPRfa.js} +3577 -3577
  60. package/dist/{requirementDiagram-EGVEC5DT-D1T5u-wG.js → requirementDiagram-4UW4RH46-CHROYNU_.js} +7 -7
  61. package/dist/{sankeyDiagram-HRAUVNP4-G6xDfnp-.js → sankeyDiagram-GR3RE2ED-DkUqHP2d.js} +5 -5
  62. package/dist/sequenceDiagram-C3RYC4MD-YoPTMplP.js +2519 -0
  63. package/dist/{slides-component-BJLlPJSr.js → slides-component-D7CHSR00.js} +66 -66
  64. package/dist/solr-BNlsLglM.js +41 -0
  65. package/dist/spreadsheet-C-cy4P5N.js +49 -0
  66. package/dist/{stateDiagram-UUKSUZ4H-CYXbjaom.js → stateDiagram-KXAO66HF-DEN00mVU.js} +5 -5
  67. package/dist/{stateDiagram-v2-EYPG3UTE-Br1HYKT6.js → stateDiagram-v2-UMBNRL4Z-DlQqSUAa.js} +2 -2
  68. package/dist/style.css +1 -1
  69. package/dist/tiddlywiki-5wqsXtSk.js +155 -0
  70. package/dist/tiki-__Kn3CeS.js +181 -0
  71. package/dist/{time-B9SZnSen.js → time-BtVcKqeD.js} +58 -58
  72. package/dist/{timeline-definition-3HZDQTIS-DeK_ZRD0.js → timeline-definition-XQNQX7LJ-DEteLt8D.js} +10 -12
  73. package/dist/{timer-BYwnU4DF.js → timer-B0-z63CM.js} +16 -16
  74. package/dist/{treemap-75Q7IDZK-CKP4vV_0.js → treemap-75Q7IDZK-8S6podme.js} +14 -14
  75. package/dist/{vega-component-CpgdqX2d.js → vega-component-D35L45kI.js} +30 -30
  76. package/dist/{xychartDiagram-FDP5SA34-AMEPsx_R.js → xychartDiagram-6GGTOJPD-DKwGThyy.js} +7 -7
  77. package/package.json +44 -41
  78. package/src/__mocks__/notebook.ts +3 -0
  79. package/src/__mocks__/requests.ts +3 -0
  80. package/src/__tests__/__snapshots__/CellStatus.test.tsx.snap +12 -12
  81. package/src/__tests__/chat-utils.test.ts +26 -211
  82. package/src/components/ai/ai-model-dropdown.tsx +25 -9
  83. package/src/components/ai/ai-provider-icon.tsx +5 -1
  84. package/src/components/app-config/ai-config.tsx +7 -0
  85. package/src/components/chat/acp/__tests__/__snapshots__/prompt.test.ts.snap +304 -0
  86. package/src/components/chat/acp/__tests__/atoms.test.ts +56 -0
  87. package/src/components/chat/acp/__tests__/prompt.test.ts +12 -0
  88. package/src/components/chat/acp/__tests__/state.test.ts +621 -0
  89. package/src/components/chat/acp/agent-docs.tsx +78 -0
  90. package/src/components/chat/acp/agent-panel.css +23 -0
  91. package/src/components/chat/acp/agent-panel.tsx +715 -0
  92. package/src/components/chat/acp/agent-selector.tsx +138 -0
  93. package/src/components/chat/acp/blocks.tsx +664 -0
  94. package/src/components/chat/acp/common.tsx +198 -0
  95. package/src/components/chat/acp/prompt.ts +284 -0
  96. package/src/components/chat/acp/scroll-to-bottom-button.tsx +50 -0
  97. package/src/components/chat/acp/session-tabs.tsx +138 -0
  98. package/src/components/chat/acp/state.ts +263 -0
  99. package/src/components/chat/acp/thread.tsx +121 -0
  100. package/src/components/chat/acp/types.ts +63 -0
  101. package/src/components/chat/acp/utils.ts +45 -0
  102. package/src/components/chat/chat-components.tsx +71 -0
  103. package/src/components/chat/chat-panel.tsx +481 -291
  104. package/src/components/chat/chat-utils.ts +50 -0
  105. package/src/components/chat/markdown-renderer.tsx +3 -7
  106. package/src/components/chat/tool-call-accordion.tsx +6 -6
  107. package/src/components/datasources/__tests__/utils.test.ts +6 -0
  108. package/src/components/datasources/column-preview.tsx +1 -3
  109. package/src/components/editor/actions/useNotebookActions.tsx +1 -1
  110. package/src/components/editor/ai/add-cell-with-ai.tsx +20 -15
  111. package/src/components/editor/ai/ai-completion-editor.tsx +22 -3
  112. package/src/components/editor/ai/completion-handlers.tsx +2 -4
  113. package/src/components/editor/ai/completion-utils.ts +85 -11
  114. package/src/components/editor/alerts/startup-logs-alert.tsx +72 -0
  115. package/src/components/editor/chrome/panels/datasources-panel.tsx +3 -1
  116. package/src/components/editor/chrome/panels/dependency-graph-panel.tsx +3 -1
  117. package/src/components/editor/chrome/panels/documentation-panel.tsx +3 -1
  118. package/src/components/editor/chrome/panels/error-panel.tsx +3 -1
  119. package/src/components/editor/chrome/panels/file-explorer-panel.tsx +3 -1
  120. package/src/components/editor/chrome/panels/logs-panel.tsx +3 -1
  121. package/src/components/editor/chrome/panels/outline-panel.tsx +3 -1
  122. package/src/components/editor/chrome/panels/packages-panel.tsx +4 -2
  123. package/src/components/editor/chrome/panels/scratchpad-panel.tsx +3 -1
  124. package/src/components/editor/chrome/panels/secrets-panel.tsx +3 -1
  125. package/src/components/editor/chrome/panels/snippets-panel.tsx +3 -1
  126. package/src/components/editor/chrome/panels/tracing-panel.tsx +3 -1
  127. package/src/components/editor/chrome/panels/variable-panel.tsx +3 -1
  128. package/src/components/editor/chrome/types.ts +10 -0
  129. package/src/components/editor/chrome/wrapper/app-chrome.tsx +55 -31
  130. package/src/components/editor/controls/command-palette-button.tsx +1 -1
  131. package/src/components/editor/controls/command-palette.tsx +5 -4
  132. package/src/components/editor/controls/state.ts +4 -0
  133. package/src/components/editor/package-alert.tsx +108 -58
  134. package/src/components/editor/renderers/CellArray.tsx +2 -0
  135. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +0 -1
  136. package/src/components/pages/edit-page.tsx +7 -3
  137. package/src/core/ai/chat-utils.ts +26 -43
  138. package/src/core/ai/config.ts +1 -1
  139. package/src/core/ai/context/__tests__/registry.test.ts +277 -3
  140. package/src/core/ai/context/context.ts +11 -1
  141. package/src/core/ai/context/providers/__tests__/cell-output.test.ts +378 -0
  142. package/src/core/ai/context/providers/__tests__/error.test.ts +3 -2
  143. package/src/core/ai/context/providers/__tests__/file.test.ts +119 -0
  144. package/src/core/ai/context/providers/cell-output.ts +349 -0
  145. package/src/core/ai/context/providers/common.ts +5 -1
  146. package/src/core/ai/context/providers/file.ts +287 -0
  147. package/src/core/ai/context/registry.ts +79 -0
  148. package/src/core/ai/state.ts +22 -5
  149. package/src/core/alerts/state.ts +71 -3
  150. package/src/core/cells/cell.ts +2 -2
  151. package/src/core/cells/cells.ts +1 -1
  152. package/src/core/cells/logs.ts +1 -1
  153. package/src/core/cells/runs.ts +6 -5
  154. package/src/core/codemirror/ai/resources.ts +47 -5
  155. package/src/core/codemirror/ai/state.ts +12 -0
  156. package/src/core/codemirror/language/__tests__/sql.test.ts +45 -0
  157. package/src/core/codemirror/markdown/__tests__/commands.test.ts +1 -0
  158. package/src/core/codemirror/theme/dark.ts +1 -1
  159. package/src/core/config/capabilities.ts +1 -1
  160. package/src/core/config/feature-flag.tsx +2 -0
  161. package/src/core/datasets/__tests__/data-source.test.ts +24 -0
  162. package/src/core/errors/__tests__/errors.test.ts +2 -0
  163. package/src/core/islands/bridge.ts +1 -0
  164. package/src/core/islands/main.ts +1 -0
  165. package/src/core/kernel/messages.ts +12 -6
  166. package/src/core/layout/layout.ts +3 -3
  167. package/src/core/network/requests-network.ts +8 -0
  168. package/src/core/network/requests-static.ts +1 -0
  169. package/src/core/network/requests-toasting.ts +1 -0
  170. package/src/core/network/types.ts +4 -1
  171. package/src/core/wasm/bridge.ts +18 -2
  172. package/src/core/wasm/worker/bootstrap.ts +3 -1
  173. package/src/core/wasm/worker/getMarimoWheel.ts +3 -8
  174. package/src/core/wasm/worker/types.ts +3 -0
  175. package/src/core/websocket/useMarimoWebSocket.tsx +7 -1
  176. package/src/css/app/Cell.css +42 -21
  177. package/src/css/app/codemirror.css +5 -1
  178. package/src/css/globals.css +3 -0
  179. package/src/css/md.css +1 -1
  180. package/src/plugins/impl/MicrophonePlugin.tsx +2 -2
  181. package/src/plugins/impl/chat/ChatPlugin.tsx +2 -9
  182. package/src/plugins/impl/chat/chat-ui.tsx +129 -110
  183. package/src/plugins/impl/chat/types.ts +5 -8
  184. package/src/plugins/impl/code/__tests__/language.test.ts +15 -0
  185. package/src/plugins/impl/code/any-language-editor.tsx +11 -8
  186. package/src/plugins/impl/vega/vega.css +121 -0
  187. package/src/plugins/layout/MimeRenderPlugin.tsx +3 -6
  188. package/src/stories/cell.stories.tsx +6 -0
  189. package/src/stories/layout/vertical/one-column.stories.tsx +215 -0
  190. package/src/theme/useTheme.ts +11 -6
  191. package/src/utils/Logger.ts +5 -6
  192. package/src/utils/__tests__/blob.test.ts +37 -0
  193. package/src/utils/arrays.ts +13 -0
  194. package/src/utils/fileToBase64.ts +21 -6
  195. package/src/utils/json/base64.ts +5 -2
  196. package/src/utils/numbers.ts +9 -7
  197. package/dist/any-language-editor-DC5170DQ.js +0 -45
  198. package/dist/asn1-jKiBa2Ya.js +0 -95
  199. package/dist/clojure-CCKyeQKf.js +0 -800
  200. package/dist/css-BkF-NPzE.js +0 -1553
  201. package/dist/index-5ZH_qS8j.js +0 -288
  202. package/dist/index-U4yn89qO.js +0 -341
  203. package/dist/javascript-C2yteZeJ.js +0 -691
  204. package/dist/min-DS5Jz-hg.js +0 -80
  205. package/dist/mindmap-definition-LNHGMQRG-0aOVaMR8.js +0 -3234
  206. package/dist/mllike-BSnXJBGA.js +0 -272
  207. package/dist/pug-CwAQJzGR.js +0 -248
  208. package/dist/python-BkR3uSy8.js +0 -313
  209. package/dist/rpm-IznJm2Xc.js +0 -57
  210. package/dist/sequenceDiagram-WFGC7UMF-DMhHzllb.js +0 -2284
  211. package/dist/ttcn-cfg-Bac_acMi.js +0 -88
@@ -14,9 +14,13 @@ import type { ProviderId } from "@/core/ai/ids/ids";
14
14
  import { cn } from "@/utils/cn";
15
15
  import marimoIcon from "../../assets/icon-32x32.png?inline";
16
16
 
17
- const icons: Record<ProviderId, string> = {
17
+ type Aliases = "claude" | "gemini";
18
+
19
+ const icons: Record<ProviderId | Aliases, string> = {
18
20
  openai: OpenAIIcon,
19
21
  anthropic: AnthropicIcon,
22
+ claude: AnthropicIcon,
23
+ gemini: GeminiIcon,
20
24
  google: GeminiIcon,
21
25
  ollama: OllamaIcon,
22
26
  azure: AzureIcon,
@@ -31,6 +31,7 @@ import { Input } from "@/components/ui/input";
31
31
  import { Kbd } from "@/components/ui/kbd";
32
32
  import { NativeSelect } from "@/components/ui/native-select";
33
33
  import { Textarea } from "@/components/ui/textarea";
34
+ import type { SupportedRole } from "@/core/ai/config";
34
35
  import {
35
36
  AiModelId,
36
37
  PROVIDERS,
@@ -225,6 +226,7 @@ interface ModelSelectorProps {
225
226
  description?: React.ReactNode;
226
227
  disabled?: boolean;
227
228
  label: string;
229
+ forRole: SupportedRole;
228
230
  onSubmit: (values: UserConfig) => void;
229
231
  }
230
232
 
@@ -237,6 +239,7 @@ export const ModelSelector: React.FC<ModelSelectorProps> = ({
237
239
  description,
238
240
  disabled = false,
239
241
  label,
242
+ forRole,
240
243
  onSubmit,
241
244
  }) => {
242
245
  return (
@@ -289,6 +292,7 @@ export const ModelSelector: React.FC<ModelSelectorProps> = ({
289
292
  </div>
290
293
  </>
291
294
  }
295
+ forRole={forRole}
292
296
  />
293
297
  </FormControl>
294
298
  <FormMessage />
@@ -420,6 +424,7 @@ const renderCopilotProvider = ({
420
424
  testId="custom-model-input"
421
425
  description="Model to use for code completion when using a custom provider."
422
426
  onSubmit={onSubmit}
427
+ forRole="autocomplete"
423
428
  />
424
429
  );
425
430
  }
@@ -905,6 +910,7 @@ export const AiAssistConfig: React.FC<AiConfigProps> = ({
905
910
  description={
906
911
  <span>Model to use for chat conversations in the Chat panel.</span>
907
912
  }
913
+ forRole="chat"
908
914
  onSubmit={onSubmit}
909
915
  />
910
916
  <ModelSelector
@@ -921,6 +927,7 @@ export const AiAssistConfig: React.FC<AiConfigProps> = ({
921
927
  <Kbd className="inline">Generate with AI</Kbd> button.
922
928
  </span>
923
929
  }
930
+ forRole="edit"
924
931
  onSubmit={onSubmit}
925
932
  />
926
933
 
@@ -0,0 +1,304 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`getAgentPrompt > should generate complete agent prompt with default filename 1`] = `
4
+ "
5
+ I am currently editing a marimo notebook.
6
+ You can read or write to the notebook at @test-notebook.py
7
+
8
+ If you make edits to the notebook, only edit the contents inside the function decorator with @app.cell.
9
+ marimo will automatically handle adding the parameters and return statement of the function. For example,
10
+ for each edit, just return:
11
+
12
+ \`\`\`
13
+ @app.cell
14
+ def __():
15
+ <your code here>
16
+ return
17
+ \`\`\`
18
+
19
+ ## Marimo fundamentals
20
+
21
+ Marimo is a reactive notebook that differs from traditional notebooks in key ways:
22
+
23
+ - Cells execute automatically when their dependencies change
24
+ - Variables cannot be redeclared across cells
25
+ - The notebook forms a directed acyclic graph (DAG)
26
+ - The last expression in a cell is automatically displayed
27
+ - UI elements are reactive and update the notebook automatically
28
+
29
+ ## Code Requirements
30
+
31
+ 1. All code must be complete and runnable
32
+ 2. Follow consistent coding style throughout
33
+ 3. Include descriptive variable names and helpful comments
34
+ 4. Import all modules in the first cell, always including \`import marimo as mo\`
35
+ 5. Never redeclare variables across cells
36
+ 6. Ensure no cycles in notebook dependency graph
37
+ 7. The last expression in a cell is automatically displayed, just like in Jupyter notebooks.
38
+ 8. Don't include comments in markdown cells
39
+ 9. Don't include comments in SQL cells
40
+
41
+ ## Reactivity
42
+
43
+ Marimo's reactivity means:
44
+
45
+ - When a variable changes, all cells that use that variable automatically re-execute
46
+ - UI elements trigger updates when their values change without explicit callbacks
47
+ - UI element values are accessed through \`.value\` attribute
48
+ - You cannot access a UI element's value in the same cell where it's defined
49
+
50
+ ## Best Practices
51
+
52
+ <data_handling>
53
+ - Use pandas for data manipulation
54
+ - Implement proper data validation
55
+ - Handle missing values appropriately
56
+ - Use efficient data structures
57
+ - A variable in the last expression of a cell is automatically displayed as a table
58
+ </data_handling>
59
+
60
+ <visualization>
61
+ - For matplotlib: use plt.gca() as the last expression instead of plt.show()
62
+ - For plotly: return the figure object directly
63
+ - For altair: return the chart object directly
64
+ - Include proper labels, titles, and color schemes
65
+ - Make visualizations interactive where appropriate
66
+ </visualization>
67
+
68
+ <ui_elements>
69
+ - Access UI element values with .value attribute (e.g., slider.value)
70
+ - Create UI elements in one cell and reference them in later cells
71
+ - Create intuitive layouts with mo.hstack(), mo.vstack(), and mo.tabs()
72
+ - Prefer reactive updates over callbacks (marimo handles reactivity automatically)
73
+ - Group related UI elements for better organization
74
+ </ui_elements>
75
+
76
+ <sql>
77
+ - When writing duckdb, prefer using marimo's SQL cells, which start with _df = mo.sql(query)
78
+ - See the SQL with duckdb example for an example on how to do this
79
+ - Don't add comments in cells that use mo.sql()
80
+ - Consider using \`vega_datasets\` for common example datasets
81
+ </sql>
82
+
83
+ ## Troubleshooting
84
+
85
+ Common issues and solutions:
86
+ - Circular dependencies: Reorganize code to remove cycles in the dependency graph
87
+ - UI element value access: Move access to a separate cell from definition
88
+ - Visualization not showing: Ensure the visualization object is the last expression
89
+
90
+ ## Available UI elements
91
+
92
+ - \`mo.ui.altair_chart(altair_chart)\`
93
+ - \`mo.ui.button(value=None, kind='primary')\`
94
+ - \`mo.ui.run_button(label=None, tooltip=None, kind='primary')\`
95
+ - \`mo.ui.checkbox(label='', value=False)\`
96
+ - \`mo.ui.date(value=None, label=None, full_width=False)\`
97
+ - \`mo.ui.dropdown(options, value=None, label=None, full_width=False)\`
98
+ - \`mo.ui.file(label='', multiple=False, full_width=False)\`
99
+ - \`mo.ui.number(value=None, label=None, full_width=False)\`
100
+ - \`mo.ui.radio(options, value=None, label=None, full_width=False)\`
101
+ - \`mo.ui.refresh(options: List[str], default_interval: str)\`
102
+ - \`mo.ui.slider(start, stop, value=None, label=None, full_width=False, step=None)\`
103
+ - \`mo.ui.range_slider(start, stop, value=None, label=None, full_width=False, step=None)\`
104
+ - \`mo.ui.table(data, columns=None, on_select=None, sortable=True, filterable=True)\`
105
+ - \`mo.ui.text(value='', label=None, full_width=False)\`
106
+ - \`mo.ui.text_area(value='', label=None, full_width=False)\`
107
+ - \`mo.ui.data_explorer(df)\`
108
+ - \`mo.ui.dataframe(df)\`
109
+ - \`mo.ui.plotly(plotly_figure)\`
110
+ - \`mo.ui.tabs(elements: dict[str, mo.ui.Element])\`
111
+ - \`mo.ui.array(elements: list[mo.ui.Element])\`
112
+ - \`mo.ui.form(element: mo.ui.Element, label='', bordered=True)\`
113
+
114
+ ## Layout and utility functions
115
+
116
+ - \`mo.md(text)\` - display markdown
117
+ - \`mo.stop(predicate, output=None)\` - stop execution conditionally
118
+ - \`mo.Html(html)\` - display HTML
119
+ - \`mo.image(image)\` - display an image
120
+ - \`mo.hstack(elements)\` - stack elements horizontally
121
+ - \`mo.vstack(elements)\` - stack elements vertically
122
+ - \`mo.tabs(elements)\` - create a tabbed interface
123
+
124
+ ## Examples
125
+
126
+ <example title="Basic UI with reactivity">
127
+
128
+ @app.cell
129
+ def __():
130
+ import marimo as mo
131
+ import matplotlib.pyplot as plt
132
+ import numpy as np
133
+ return
134
+
135
+ @app.cell
136
+ def __():
137
+ n_points = mo.ui.slider(10, 100, value=50, label="Number of points")
138
+ n_points
139
+ return
140
+
141
+ @app.cell
142
+ def __():
143
+ x = np.random.rand(n_points.value)
144
+ y = np.random.rand(n_points.value)
145
+
146
+ plt.figure(figsize=(8, 6))
147
+ plt.scatter(x, y, alpha=0.7)
148
+ plt.title(f"Scatter plot with {n_points.value} points")
149
+ plt.xlabel("X axis")
150
+ plt.ylabel("Y axis")
151
+ plt.gca()
152
+ return
153
+
154
+ </example>
155
+
156
+ <example title="Data explorer">
157
+
158
+ @app.cell
159
+ def __():
160
+ import marimo as mo
161
+ import pandas as pd
162
+ from vega_datasets import data
163
+ return
164
+
165
+ @app.cell
166
+ def __():
167
+ cars_df = data.cars()
168
+ mo.ui.data_explorer(cars_df)
169
+ return
170
+
171
+ </example>
172
+
173
+ <example title="Multiple UI elements">
174
+
175
+ @app.cell
176
+ def __():
177
+ import marimo as mo
178
+ import pandas as pd
179
+ import matplotlib.pyplot as plt
180
+ import seaborn as sns
181
+ return
182
+
183
+ @app.cell
184
+ def __():
185
+ iris = sns.load_dataset('iris')
186
+ return
187
+
188
+ @app.cell
189
+ def __():
190
+ species_selector = mo.ui.dropdown(
191
+ options=["All"] + iris["species"].unique().tolist(),
192
+ value="All",
193
+ label="Species"
194
+ )
195
+ x_feature = mo.ui.dropdown(
196
+ options=iris.select_dtypes('number').columns.tolist(),
197
+ value="sepal_length",
198
+ label="X Feature"
199
+ )
200
+ y_feature = mo.ui.dropdown(
201
+ options=iris.select_dtypes('number').columns.tolist(),
202
+ value="sepal_width",
203
+ label="Y Feature"
204
+ )
205
+ mo.hstack([species_selector, x_feature, y_feature])
206
+ return
207
+
208
+ @app.cell
209
+ def __():
210
+ filtered_data = iris if species_selector.value == "All" else iris[iris["species"] == species_selector.value]
211
+
212
+ plt.figure(figsize=(10, 6))
213
+ sns.scatterplot(
214
+ data=filtered_data,
215
+ x=x_feature.value,
216
+ y=y_feature.value,
217
+ hue="species"
218
+ )
219
+ plt.title(f"{y_feature.value} vs {x_feature.value}")
220
+ plt.gca()
221
+ return
222
+
223
+ </example>
224
+
225
+ <example title="Interactive chart with Altair">
226
+
227
+ @app.cell
228
+ def __():
229
+ import marimo as mo
230
+ import altair as alt
231
+ import pandas as pd
232
+ return
233
+
234
+ @app.cell
235
+ def __():
236
+ # Load dataset
237
+ cars_df = pd.read_csv('<https://raw.githubusercontent.com/vega/vega-datasets/master/data/cars.json>')
238
+ _chart = alt.Chart(cars_df).mark_point().encode(
239
+ x='Horsepower',
240
+ y='Miles_per_Gallon',
241
+ color='Origin',
242
+ )
243
+ return
244
+
245
+ @app.cell
246
+ def __():
247
+ chart = mo.ui.altair_chart(_chart)
248
+ chart
249
+ return
250
+
251
+ @app.cell
252
+ def __():
253
+ # Display the selection
254
+ chart.value
255
+ return
256
+
257
+ </example>
258
+
259
+ <example title="Run Button Example">
260
+
261
+ @app.cell
262
+ def __():
263
+ import marimo as mo
264
+ return
265
+
266
+ @app.cell
267
+ def __():
268
+ first_button = mo.ui.run_button(label="Option 1")
269
+ second_button = mo.ui.run_button(label="Option 2")
270
+ [first_button, second_button]
271
+ return
272
+
273
+ @app.cell
274
+ def __():
275
+ if first_button.value:
276
+ print("You chose option 1!")
277
+ elif second_button.value:
278
+ print("You chose option 2!")
279
+ else:
280
+ print("Click a button!")
281
+ return
282
+
283
+ </example>
284
+
285
+ <example title="SQL with duckdb">
286
+
287
+ @app.cell
288
+ def __():
289
+ import marimo as mo
290
+ import pandas as pd
291
+ return
292
+
293
+ @app.cell
294
+ def __():
295
+ cars_df = pd.read_csv('<https://raw.githubusercontent.com/vega/vega-datasets/master/data/cars.json>')
296
+ return
297
+
298
+ @app.cell
299
+ def __():
300
+ _df = mo.sql("SELECT * from cars_df WHERE Miles_per_Gallon > 20")
301
+ return
302
+
303
+ </example>"
304
+ `;
@@ -0,0 +1,56 @@
1
+ /* Copyright 2025 Marimo. All rights reserved. */
2
+
3
+ import { createStore } from "jotai";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ import { addSession, agentSessionStateAtom, selectedTabAtom } from "../state";
6
+
7
+ describe("Jotai atoms", () => {
8
+ let store: ReturnType<typeof createStore>;
9
+
10
+ beforeEach(() => {
11
+ store = createStore();
12
+ vi.useFakeTimers();
13
+ vi.setSystemTime(new Date("2025-01-01T00:00:00Z"));
14
+ });
15
+
16
+ afterEach(() => {
17
+ vi.useRealTimers();
18
+ });
19
+
20
+ describe("agentSessionStateAtom", () => {
21
+ it("should have initial empty state", () => {
22
+ const state = store.get(agentSessionStateAtom);
23
+ expect(state).toEqual({
24
+ sessions: [],
25
+ activeTabId: null,
26
+ });
27
+ });
28
+ });
29
+
30
+ describe("activeSessionAtom", () => {
31
+ it("should return null when no active session", () => {
32
+ const activeSession = store.get(selectedTabAtom);
33
+ expect(activeSession).toBe(null);
34
+ });
35
+
36
+ it("should return active session when available", () => {
37
+ const state = addSession(
38
+ {
39
+ sessions: [],
40
+ activeTabId: null,
41
+ },
42
+ { agentId: "gemini" },
43
+ );
44
+
45
+ store.set(agentSessionStateAtom, state);
46
+ const activeSession = store.get(selectedTabAtom);
47
+
48
+ expect(activeSession).toEqual(
49
+ expect.objectContaining({
50
+ agentId: "gemini",
51
+ title: "New gemini session",
52
+ }),
53
+ );
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,12 @@
1
+ /* Copyright 2025 Marimo. All rights reserved. */
2
+
3
+ import { describe, expect, it } from "vitest";
4
+ import { getAgentPrompt } from "../prompt";
5
+
6
+ describe("getAgentPrompt", () => {
7
+ it("should generate complete agent prompt with default filename", () => {
8
+ const result = getAgentPrompt("test-notebook.py");
9
+
10
+ expect(result).toMatchSnapshot();
11
+ });
12
+ });