@marimo-team/frontend 0.24.1-dev58 → 0.24.1-dev59

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 (41) hide show
  1. package/dist/assets/add-cell-with-ai-DVGZNNUv.js +76 -0
  2. package/dist/assets/{agent-panel-D7mo8YLQ.js → agent-panel-BTY3oeHD.js} +3 -3
  3. package/dist/assets/cell-editor-D3YsOG7a.js +21 -0
  4. package/dist/assets/{chat-display-Cgg0xLir.js → chat-display-NTNQQyoE.js} +1 -1
  5. package/dist/assets/chat-panel-Bow0QKrA.js +4 -0
  6. package/dist/assets/{chat-ui-DYLpA8l4.js → chat-ui-Cg69zAqt.js} +4 -4
  7. package/dist/assets/{command-palette-DiT0E_K7.js → command-palette-QFmIvDcT.js} +1 -1
  8. package/dist/assets/{edit-page-DAC4cNKe.js → edit-page-ds4edlkF.js} +6 -6
  9. package/dist/assets/{index-W5CUNEV9.js → index-B36dhEV6.js} +3 -3
  10. package/dist/assets/index-ecw9ngZu.css +2 -0
  11. package/dist/assets/{layout-D3zwsTvR.js → layout-iNJ-1JI2.js} +2 -2
  12. package/dist/assets/{panels-ChFSBlsU.js → panels-BbkuRtEi.js} +1 -1
  13. package/dist/assets/{reveal-component-BFRmOcQr.js → reveal-component-C4pF9OE7.js} +1 -1
  14. package/dist/assets/{run-page-MZCCEXct.js → run-page-Bo57bjbp.js} +1 -1
  15. package/dist/assets/{scratchpad-panel-BqYT2vj3.js → scratchpad-panel-vBIq9BfA.js} +1 -1
  16. package/dist/assets/{skeleton-gmxAkHfa.js → skeleton-B5iAa5n_.js} +1 -1
  17. package/dist/assets/{useNotebookActions-BoFJmccb.js → useNotebookActions-DGuDG0Px.js} +1 -1
  18. package/dist/index.html +2 -2
  19. package/package.json +1 -1
  20. package/src/components/editor/ai/__tests__/completion-utils.test.ts +0 -178
  21. package/src/components/editor/ai/__tests__/staged-cell-submission.test.ts +106 -0
  22. package/src/components/editor/ai/add-cell-with-ai.tsx +83 -62
  23. package/src/components/editor/ai/ai-completion-editor.tsx +71 -37
  24. package/src/components/editor/ai/completion-handlers.tsx +4 -0
  25. package/src/components/editor/ai/completion-utils.ts +0 -92
  26. package/src/components/editor/ai/staged-cell-submission.ts +46 -0
  27. package/src/components/editor/cell/StagedAICell.tsx +4 -2
  28. package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +64 -0
  29. package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +77 -0
  30. package/src/components/editor/chrome/wrapper/pending-ai-cells.tsx +8 -2
  31. package/src/core/ai/__tests__/staged-cells.test.ts +442 -125
  32. package/src/core/ai/__tests__/stream-completion-text.test.ts +74 -0
  33. package/src/core/ai/completion-output.ts +56 -0
  34. package/src/core/ai/staged-cells.ts +245 -164
  35. package/src/core/ai/stream-completion-text.ts +23 -6
  36. package/dist/assets/add-cell-with-ai-0dqk0f7O.js +0 -77
  37. package/dist/assets/cell-editor-e7_o4mEh.js +0 -24
  38. package/dist/assets/chat-panel-BaG-5LiN.js +0 -4
  39. package/dist/assets/index-DIUt_9oR.css +0 -2
  40. package/src/core/ai/__tests__/strip-wrapping-backticks.test.ts +0 -133
  41. package/src/core/ai/strip-wrapping-backticks.ts +0 -88
@@ -1,10 +1,14 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import { consumeStream, parseJsonEventStream, uiMessageChunkSchema } from "ai";
4
- import { stripWrappingBackticks } from "./strip-wrapping-backticks";
4
+ import {
5
+ CELL_COMPLETION_DATA_TYPE,
6
+ cellCompletionSchema,
7
+ isDataChunk,
8
+ } from "./completion-output";
5
9
 
6
10
  /**
7
- * Read an AI SDK UI message stream response and return the assistant text.
11
+ * Read an AI SDK UI message stream response and return validated cell code.
8
12
  */
9
13
  export async function streamCompletionText(
10
14
  response: Response,
@@ -17,7 +21,8 @@ export async function streamCompletionText(
17
21
  throw new Error("Failed to get response body");
18
22
  }
19
23
 
20
- let result = "";
24
+ let result: string | null = null;
25
+ let finishedSuccessfully = false;
21
26
 
22
27
  await consumeStream({
23
28
  stream: parseJsonEventStream({
@@ -31,10 +36,15 @@ export async function streamCompletionText(
31
36
  }
32
37
 
33
38
  const streamPart = part.value;
34
- if (streamPart.type === "text-delta") {
35
- result += streamPart.delta;
39
+ if (
40
+ isDataChunk(streamPart) &&
41
+ streamPart.type === CELL_COMPLETION_DATA_TYPE
42
+ ) {
43
+ result = cellCompletionSchema.parse(streamPart.data).code;
36
44
  } else if (streamPart.type === "error") {
37
45
  throw new Error(streamPart.errorText);
46
+ } else if (streamPart.type === "finish") {
47
+ finishedSuccessfully = streamPart.finishReason === "stop";
38
48
  }
39
49
  },
40
50
  }),
@@ -44,5 +54,12 @@ export async function streamCompletionText(
44
54
  },
45
55
  });
46
56
 
47
- return stripWrappingBackticks(result);
57
+ if (!finishedSuccessfully) {
58
+ throw new Error("AI completion ended before final validation");
59
+ }
60
+ if (result === null) {
61
+ throw new Error("AI completion returned no cell code");
62
+ }
63
+
64
+ return result;
48
65
  }