@marimo-team/frontend 0.25.2-dev66 → 0.25.2-dev89

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 (153) hide show
  1. package/dist/assets/{CellStatus-CRFBVGjI.js → CellStatus-Bj7PvY_u.js} +1 -1
  2. package/dist/assets/{ErrorBoundary-BKmN7zye.js → ErrorBoundary-CG6gtgym.js} +2 -2
  3. package/dist/assets/{JsonOutput-nqqzL-n0.js → JsonOutput-NVH7GWyC.js} +1 -1
  4. package/dist/assets/{MarimoErrorOutput-DCu6fm2y.js → MarimoErrorOutput-z5iFryzf.js} +1 -1
  5. package/dist/assets/{RenderHTML-DRMkieKn.js → RenderHTML-C7QcdAgB.js} +1 -1
  6. package/dist/assets/{RunButton-CPZWjCL9.js → RunButton-A__3wcpF.js} +1 -1
  7. package/dist/assets/{add-cell-with-ai-D20NyZO4.js → add-cell-with-ai-Wyt6GBhk.js} +1 -1
  8. package/dist/assets/{add-connection-dialog-pQcdKIlO.js → add-connection-dialog-bl8dqCVs.js} +1 -1
  9. package/dist/assets/{agent-panel-tNErBgmq.js → agent-panel-BcoO8S6Q.js} +1 -1
  10. package/dist/assets/{ai-model-dropdown-BIeRPKed.js → ai-model-dropdown-CvJsRj9y.js} +1 -1
  11. package/dist/assets/{api-DYL9A86_.js → api-DVLtXyp7.js} +1 -1
  12. package/dist/assets/{app-config-button-DkNGV0b1.js → app-config-button-C7QrZbqr.js} +1 -1
  13. package/dist/assets/{blob-BIYte8oT.js → blob-Bx8A10xl.js} +1 -1
  14. package/dist/assets/{cell-editor-C5RTy4Y0.js → cell-editor-CevZDS63.js} +4 -4
  15. package/dist/assets/cell-link-DC1UZQr_.js +1 -0
  16. package/dist/assets/{cells-h5u00Nz8.js → cells-CxY8RSp7.js} +2 -2
  17. package/dist/assets/{chat-display-DzTkUWMw.js → chat-display-YETh6yXV.js} +1 -1
  18. package/dist/assets/{chat-panel-CKqEpnjN.js → chat-panel-DyaePe7B.js} +1 -1
  19. package/dist/assets/{chat-ui-CGzOsYVb.js → chat-ui-D_QL46qM.js} +1 -1
  20. package/dist/assets/code-visibility-DNzJgrTz.js +1 -0
  21. package/dist/assets/{column-preview-DtrgJzVI.js → column-preview-sL_Jo0hX.js} +1 -1
  22. package/dist/assets/{command-palette-BKYGTfS5.js → command-palette-DMQFuWz1.js} +1 -1
  23. package/dist/assets/{common-BMeq0Bqi.js → common-Cy3lJDvJ.js} +1 -1
  24. package/dist/assets/{components-CWcf8098.js → components-D9ZIJGG8.js} +1 -1
  25. package/dist/assets/{config-BAnYSdpO.js → config-D_c_6ce1.js} +1 -1
  26. package/dist/assets/{datasource-BLHGFSsT.js → datasource-Tst92Pzi.js} +1 -1
  27. package/dist/assets/{dependency-graph-panel-C8X3Nn8W.js → dependency-graph-panel-BwMayTyZ.js} +1 -1
  28. package/dist/assets/{documentation-panel-C8wrSKlX.js → documentation-panel-OMUbXgKW.js} +1 -1
  29. package/dist/assets/{download-CUgiCx7s.js → download-CPMAf7re.js} +1 -1
  30. package/dist/assets/{edit-page-CqPNBpAP.js → edit-page-DD1NFkiu.js} +6 -6
  31. package/dist/assets/{error-entries-DQD4A9cx.js → error-entries-DBpwg0GC.js} +1 -1
  32. package/dist/assets/{error-panel-BJYkwYEY.js → error-panel-ByOEJuZN.js} +1 -1
  33. package/dist/assets/{feedback-button-DbTjGwcX.js → feedback-button-7KY7nL-j.js} +2 -2
  34. package/dist/assets/feedback-button-DxjoRfo3.js +1 -0
  35. package/dist/assets/{file-explorer-panel-BQi88S1o.js → file-explorer-panel-B92ugwxr.js} +1 -1
  36. package/dist/assets/{file-name-input-DPJSxW_X.js → file-name-input-DZehOHLA.js} +1 -1
  37. package/dist/assets/{floating-outline-3PlTr0K1.js → floating-outline-K7cVdOlC.js} +1 -1
  38. package/dist/assets/{gallery-page-BqvVmwde.js → gallery-page-DoriMrLH.js} +1 -1
  39. package/dist/assets/{glide-data-editor-CAa14cIr.js → glide-data-editor-DWyeHe3u.js} +1 -1
  40. package/dist/assets/{home-page-Bg-WqjiD.js → home-page-BcJJsD_Q.js} +1 -1
  41. package/dist/assets/{hooks-DLBvBo8c.js → hooks-DNPsQf79.js} +1 -1
  42. package/dist/assets/index-B7ZZVUcj.css +2 -0
  43. package/dist/assets/{index-BtV91sqJ.js → index-CqJKdR1j.js} +5 -5
  44. package/dist/assets/{layout-mWXZofX2.js → layout-BaluekG6.js} +3 -3
  45. package/dist/assets/{logs-panel-IKL6F2OX.js → logs-panel-OkoO5mbN.js} +1 -1
  46. package/dist/assets/{markdown-renderer-DHvAXF8E.js → markdown-renderer-mDlWBE1M.js} +1 -1
  47. package/dist/assets/{name-cell-input-j4eGLLyd.js → name-cell-input-D_Q2IhP9.js} +1 -1
  48. package/dist/assets/{outline-panel-CprDWmxn.js → outline-panel-Dy2cmYDF.js} +1 -1
  49. package/dist/assets/packages-panel-CIvhx0hb.js +1 -0
  50. package/dist/assets/{panel-accordion-state-8xXVhawu.js → panel-accordion-state-BI4SU22L.js} +1 -1
  51. package/dist/assets/panels-CO6Clgel.js +4 -0
  52. package/dist/assets/{process-output-DOmeJ1VR.js → process-output-Crm0vqbi.js} +1 -1
  53. package/dist/assets/{readonly-code-display-xvH6MyT6.js → readonly-code-display-CNbw6v1-.js} +1 -1
  54. package/dist/assets/{readonly-python-code-D4YGmSvB.js → readonly-python-code-DcYhdd1B.js} +1 -1
  55. package/dist/assets/{reveal-component-CDUG1x74.js → reveal-component-DeZTBbnn.js} +1 -1
  56. package/dist/assets/{run-page-BAqLgcq9.js → run-page-BNEg-Ro9.js} +1 -1
  57. package/dist/assets/runtime-details-state-lxXYwJcI.js +1 -0
  58. package/dist/assets/{scratchpad-panel-BFbUuzdn.js → scratchpad-panel-lDJWcpVs.js} +1 -1
  59. package/dist/assets/{session-panel-BdN43Lzi.js → session-panel-BqutyoYd.js} +1 -1
  60. package/dist/assets/{snippets-panel-5_jR08Zd.js → snippets-panel-YttkYAW9.js} +1 -1
  61. package/dist/assets/state-B2ZbImvm.js +1 -0
  62. package/dist/assets/{state-BxJ_FX3k.js → state-B85OOscw.js} +1 -1
  63. package/dist/assets/{state-7os84dnI.js → state-sbCCk7ZP.js} +1 -1
  64. package/dist/assets/{terminal-DHWTOXu3.js → terminal-3hxM6K9q.js} +1 -1
  65. package/dist/assets/{tracing-CRkNpBaH.js → tracing-DZYfCw6p.js} +1 -1
  66. package/dist/assets/{tracing-panel-DV2-2TUI.js → tracing-panel-BUPJ77jB.js} +2 -2
  67. package/dist/assets/{tree-actions-CShqSonp.js → tree-actions-D5clvgKl.js} +1 -1
  68. package/dist/assets/{useAddCell-DesMfnE4.js → useAddCell-Bhv6GT3m.js} +1 -1
  69. package/dist/assets/{useBoolean-BofUVeKg.js → useBoolean-Co-_MyFz.js} +1 -1
  70. package/dist/assets/{useCellActionButton-BO5SFMxA.js → useCellActionButton-DwAUf_Cn.js} +1 -1
  71. package/dist/assets/{useDeleteCell-DSbUjpSC.js → useDeleteCell-BKN7t4DH.js} +1 -1
  72. package/dist/assets/{useDependencyPanelTab-JIFiQrr2.js → useDependencyPanelTab-CbcGEmqM.js} +1 -1
  73. package/dist/assets/{useInstallPackage-CCQcFc6U.js → useInstallPackage-HTUlGg0U.js} +1 -1
  74. package/dist/assets/{useNotebookActions-CjjED3t-.js → useNotebookActions-pXzVjrlk.js} +1 -1
  75. package/dist/assets/{useRunCells-Bx3wXUWO.js → useRunCells-zMO43eNR.js} +1 -1
  76. package/dist/assets/{useSplitCell-BRmQP02b.js → useSplitCell-xEtFLByO.js} +1 -1
  77. package/dist/assets/{vega-component-C28fL5fD.js → vega-component-Chbfi__Q.js} +1 -1
  78. package/dist/index.html +24 -24
  79. package/package.json +1 -1
  80. package/src/__tests__/mount.test.ts +6 -6
  81. package/src/components/editor/actions/useRestartKernel.tsx +2 -2
  82. package/src/components/editor/alerts/__tests__/connection-notice.test.tsx +224 -17
  83. package/src/components/editor/alerts/connection-details.tsx +61 -0
  84. package/src/components/editor/alerts/connection-notice.tsx +46 -53
  85. package/src/components/editor/alerts/startup-progress.tsx +73 -129
  86. package/src/components/editor/app-container.tsx +2 -2
  87. package/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx +2 -2
  88. package/src/components/editor/cell/CreateCellButton.tsx +2 -2
  89. package/src/components/editor/cell/DeleteButton.tsx +2 -2
  90. package/src/components/editor/cell/RunButton.tsx +3 -3
  91. package/src/components/editor/cell/StopButton.tsx +2 -2
  92. package/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx +4 -4
  93. package/src/components/editor/chrome/components/feedback-button.tsx +3 -3
  94. package/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx +8 -8
  95. package/src/components/editor/chrome/panels/__tests__/{sandbox-details.test.tsx → runtime-details.test.tsx} +94 -22
  96. package/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx +4 -4
  97. package/src/components/editor/chrome/panels/packages-panel.tsx +8 -29
  98. package/src/components/editor/chrome/panels/{sandbox-details-state.ts → runtime-details-state.ts} +1 -1
  99. package/src/components/editor/chrome/panels/{sandbox-panel.tsx → runtime-panel.tsx} +38 -66
  100. package/src/components/editor/chrome/panels/runtime-status-toggle.tsx +56 -0
  101. package/src/components/editor/chrome/panels/sandbox-controller.tsx +2 -2
  102. package/src/components/editor/chrome/wrapper/app-chrome.tsx +3 -3
  103. package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +2 -2
  104. package/src/components/editor/controls/Controls.tsx +3 -3
  105. package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +2 -2
  106. package/src/components/editor/header/__tests__/status.test.tsx +4 -4
  107. package/src/components/editor/header/app-header.tsx +2 -2
  108. package/src/components/editor/header/status.tsx +3 -3
  109. package/src/components/ui/progress-stages.tsx +114 -0
  110. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +106 -5
  111. package/src/core/codemirror/lsp/notebook-lsp.ts +16 -2
  112. package/src/core/codemirror/readonly/__tests__/extension.test.ts +6 -6
  113. package/src/core/codemirror/readonly/extension.ts +2 -2
  114. package/src/core/datasets/__tests__/data-source-discovery.test.ts +2 -2
  115. package/src/core/edit-app.tsx +5 -1
  116. package/src/core/export/hooks.ts +2 -2
  117. package/src/core/network/__tests__/connection.test.ts +3 -3
  118. package/src/core/network/connection-notice.ts +5 -5
  119. package/src/core/network/connection.ts +9 -9
  120. package/src/core/network/requests-lazy.ts +2 -2
  121. package/src/core/packages/__tests__/useSandboxController.test.tsx +2 -2
  122. package/src/core/packages/useSandboxController.ts +6 -6
  123. package/src/core/runtime/__tests__/adapter.test.ts +6 -6
  124. package/src/core/runtime/adapter.ts +7 -7
  125. package/src/core/runtime/config.ts +2 -2
  126. package/src/core/saving/filename.ts +2 -2
  127. package/src/core/saving/save-component.tsx +5 -5
  128. package/src/core/saving/useAutoSave.ts +2 -2
  129. package/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx +30 -25
  130. package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +5 -5
  131. package/src/core/websocket/connection-utils.ts +21 -21
  132. package/src/core/websocket/types.ts +8 -9
  133. package/src/core/websocket/useMarimoKernelConnection.tsx +21 -21
  134. package/src/mount.tsx +2 -2
  135. package/src/plugins/core/__test__/registerReactComponent.test.ts +55 -0
  136. package/src/plugins/core/registerReactComponent.tsx +3 -1
  137. package/src/stories/cell.stories.tsx +2 -2
  138. package/src/stories/layout/vertical/one-column.stories.tsx +5 -5
  139. package/src/stories/progress-stages.stories.tsx +62 -0
  140. package/src/stories/runtime-existing.stories.tsx +44 -0
  141. package/src/stories/runtime-maintenance.stories.tsx +40 -0
  142. package/src/stories/runtime-pixi.stories.tsx +28 -0
  143. package/src/stories/{sandbox.stories.tsx → runtime-story.tsx} +191 -152
  144. package/src/stories/runtime-uv.stories.tsx +56 -0
  145. package/dist/assets/cell-link-BeZAiE1D.js +0 -1
  146. package/dist/assets/code-visibility-B5QjA0ie.js +0 -1
  147. package/dist/assets/feedback-button-JqvnTSfN.js +0 -1
  148. package/dist/assets/index-CF8Gfz1R.css +0 -2
  149. package/dist/assets/packages-panel-CDDChziK.js +0 -1
  150. package/dist/assets/panels-CU7deLqc.js +0 -4
  151. package/dist/assets/sandbox-panel-D5bRunTM.js +0 -1
  152. package/dist/assets/state-Bo8h64Rn.js +0 -1
  153. package/src/components/editor/chrome/panels/sandbox-toggle.tsx +0 -52
@@ -10,7 +10,7 @@ import { connectionAtom } from "@/core/network/connection";
10
10
  import { useRequestClient } from "@/core/network/requests";
11
11
  import type { UsageResponse } from "@/core/network/types";
12
12
  import { isWasm } from "@/core/wasm/utils";
13
- import { WebSocketState } from "@/core/websocket/types";
13
+ import { ConnectionState } from "@/core/websocket/types";
14
14
  import { useAsyncData } from "@/hooks/useAsyncData";
15
15
  import { useInterval } from "@/hooks/useInterval";
16
16
  import { cn } from "@/utils/cn";
@@ -29,7 +29,7 @@ export const MachineStats: React.FC = () => {
29
29
  if (isWasm()) {
30
30
  return null;
31
31
  }
32
- if (connection.state !== WebSocketState.OPEN) {
32
+ if (connection.state !== ConnectionState.OPEN) {
33
33
  return null;
34
34
  }
35
35
  return getUsageStats();
@@ -21,7 +21,7 @@ import {
21
21
  getConnectionTooltip,
22
22
  isAppInteractionDisabled,
23
23
  } from "@/core/websocket/connection-utils";
24
- import { WebSocketState } from "@/core/websocket/types";
24
+ import { ConnectionState } from "@/core/websocket/types";
25
25
  import { cn } from "@/utils/cn";
26
26
  import { Functions } from "@/utils/functions";
27
27
  import {
@@ -43,7 +43,7 @@ interface ControlsProps {
43
43
  onTogglePresenting: () => void;
44
44
  onInterrupt: () => void;
45
45
  onRun: () => void;
46
- connectionState: WebSocketState;
46
+ connectionState: ConnectionState;
47
47
  running: boolean;
48
48
  appConfig: AppConfig;
49
49
  }
@@ -60,7 +60,7 @@ export const Controls = ({
60
60
  const undoLabel = useAtomValue(undoLabelAtom);
61
61
  const needsRun = useAtomValue(needsRunAtom);
62
62
  const { undoDeleteCell } = useCellActions();
63
- const closed = connectionState === WebSocketState.CLOSED;
63
+ const closed = connectionState === ConnectionState.CLOSED;
64
64
 
65
65
  let undoControl: JSX.Element | null = null;
66
66
  if (!closed && undoAvailable) {
@@ -25,7 +25,7 @@ import { requestClientAtom } from "@/core/network/requests";
25
25
  import { filenameAtom } from "@/core/saving/file-state";
26
26
  import { store } from "@/core/state/jotai";
27
27
  import { isWasm } from "@/core/wasm/utils";
28
- import { WebSocketState } from "@/core/websocket/types";
28
+ import { ConnectionState } from "@/core/websocket/types";
29
29
  import {
30
30
  DEFAULT_EXPORT_OPTIONS,
31
31
  exportOptionsAtom,
@@ -111,7 +111,7 @@ describe("NotebookMenuDropdown", () => {
111
111
  store.set(requestClientAtom, MockRequestClient.create());
112
112
  store.set(filenameAtom, "/project/notebook.py");
113
113
  store.set(viewStateAtom, { mode: "edit", cellAnchor: null });
114
- store.set(connectionAtom, { state: WebSocketState.OPEN });
114
+ store.set(connectionAtom, { state: ConnectionState.OPEN });
115
115
  store.set(kioskModeAtom, false);
116
116
  store.set(layoutStateAtom, {
117
117
  selectedLayout: "vertical",
@@ -10,7 +10,7 @@ import { viewStateAtom } from "@/core/mode";
10
10
  import {
11
11
  type ConnectionStatus,
12
12
  WebSocketClosedReason,
13
- WebSocketState,
13
+ ConnectionState,
14
14
  } from "@/core/websocket/types";
15
15
  import { StatusOverlay } from "../status";
16
16
 
@@ -40,7 +40,7 @@ describe("StatusOverlay disconnect indicator", () => {
40
40
  const onReconnect = vi.fn();
41
41
  const { getByTestId } = renderOverlay(
42
42
  {
43
- state: WebSocketState.CLOSED,
43
+ state: ConnectionState.CLOSED,
44
44
  code: WebSocketClosedReason.KERNEL_DISCONNECTED,
45
45
  reason: "kernel not found",
46
46
  },
@@ -57,7 +57,7 @@ describe("StatusOverlay disconnect indicator", () => {
57
57
 
58
58
  it("renders a disabled button when no onReconnect is provided", () => {
59
59
  const { getByTestId } = renderOverlay({
60
- state: WebSocketState.CLOSED,
60
+ state: ConnectionState.CLOSED,
61
61
  code: WebSocketClosedReason.KERNEL_DISCONNECTED,
62
62
  reason: "kernel not found",
63
63
  });
@@ -68,7 +68,7 @@ describe("StatusOverlay disconnect indicator", () => {
68
68
 
69
69
  it("leaves editor startup failures to the inline notice", () => {
70
70
  const { queryByTestId } = renderOverlay({
71
- state: WebSocketState.CLOSED,
71
+ state: ConnectionState.CLOSED,
72
72
  code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,
73
73
  reason: "Failed to start kernel sandbox",
74
74
  });
@@ -1,7 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import React, { type PropsWithChildren } from "react";
4
- import { type ConnectionStatus, WebSocketState } from "@/core/websocket/types";
4
+ import { type ConnectionStatus, ConnectionState } from "@/core/websocket/types";
5
5
  import { Disconnected } from "../Disconnected";
6
6
 
7
7
  interface Props {
@@ -17,7 +17,7 @@ export const AppHeader: React.FC<PropsWithChildren<Props>> = ({
17
17
  return (
18
18
  <div className={className}>
19
19
  {children}
20
- {connection.state === WebSocketState.CLOSED && (
20
+ {connection.state === ConnectionState.CLOSED && (
21
21
  <Disconnected reason={connection.reason} />
22
22
  )}
23
23
  </div>
@@ -10,7 +10,7 @@ import { viewStateAtom } from "@/core/mode";
10
10
  import {
11
11
  type ConnectionStatus,
12
12
  WebSocketClosedReason,
13
- WebSocketState,
13
+ ConnectionState,
14
14
  } from "@/core/websocket/types";
15
15
  import { cn } from "@/utils/cn";
16
16
 
@@ -21,10 +21,10 @@ export const StatusOverlay: React.FC<{
21
21
  }> = ({ connection, isRunning, onReconnect }) => {
22
22
  const { mode } = useAtomValue(viewStateAtom);
23
23
  const isClosed =
24
- connection.state === WebSocketState.CLOSED &&
24
+ connection.state === ConnectionState.CLOSED &&
25
25
  (mode === "read" ||
26
26
  connection.code !== WebSocketClosedReason.KERNEL_STARTUP_ERROR);
27
- const isOpen = connection.state === WebSocketState.OPEN;
27
+ const isOpen = connection.state === ConnectionState.OPEN;
28
28
  // Editor startup failures have their own recovery UI.
29
29
  const canReconnect =
30
30
  isClosed && connection.code === WebSocketClosedReason.KERNEL_DISCONNECTED;
@@ -0,0 +1,114 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import { AlertCircleIcon, CheckIcon, CircleIcon } from "lucide-react";
3
+ import type { ReactNode } from "react";
4
+ import { Spinner } from "@/components/icons/spinner";
5
+ import { cn } from "@/utils/cn";
6
+
7
+ export type ProgressState = "waiting" | "running" | "succeeded" | "failed";
8
+
9
+ export interface ProgressStage {
10
+ id: string;
11
+ state: ProgressState;
12
+ title: string;
13
+ description: string;
14
+ details?: ReactNode;
15
+ }
16
+
17
+ export function ProgressStatusIcon({
18
+ state,
19
+ variant = "icon",
20
+ }: {
21
+ state: ProgressState;
22
+ variant?: "icon" | "dot";
23
+ }) {
24
+ if (variant === "dot") {
25
+ return (
26
+ <span
27
+ aria-hidden={true}
28
+ className={cn(
29
+ "size-1.5 shrink-0 rounded-full",
30
+ {
31
+ waiting: "bg-muted-foreground",
32
+ running: "bg-muted-foreground motion-safe:animate-pulse",
33
+ succeeded: "bg-(--grass-9)",
34
+ failed: "bg-(--red-9)",
35
+ }[state],
36
+ )}
37
+ />
38
+ );
39
+ }
40
+ const Icon = {
41
+ waiting: CircleIcon,
42
+ running: Spinner,
43
+ succeeded: CheckIcon,
44
+ failed: AlertCircleIcon,
45
+ }[state];
46
+ return (
47
+ <Icon
48
+ aria-hidden={true}
49
+ className={cn(
50
+ "size-4 shrink-0",
51
+ {
52
+ waiting: "text-muted-foreground/50",
53
+ running: "motion-reduce:animate-none",
54
+ succeeded: "text-(--grass-11)",
55
+ failed: "text-(--red-11)",
56
+ }[state],
57
+ )}
58
+ />
59
+ );
60
+ }
61
+
62
+ export function ProgressStages({
63
+ stages,
64
+ label,
65
+ className,
66
+ }: {
67
+ stages: readonly ProgressStage[];
68
+ label: string;
69
+ className?: string;
70
+ }) {
71
+ return (
72
+ <ol aria-label={label} className={cn("space-y-6", className)}>
73
+ {stages.map((stage, index) => (
74
+ <li
75
+ key={stage.id}
76
+ aria-current={
77
+ stage.state === "running" || stage.state === "failed"
78
+ ? "step"
79
+ : undefined
80
+ }
81
+ className="relative flex items-start gap-3"
82
+ >
83
+ {index < stages.length - 1 && (
84
+ <span
85
+ aria-hidden={true}
86
+ className="absolute left-2 top-4.5 -bottom-6.5 border-l border-border"
87
+ />
88
+ )}
89
+ <span className="mt-0.5 text-muted-foreground">
90
+ <ProgressStatusIcon state={stage.state} />
91
+ </span>
92
+ <div className="min-w-0 flex-1">
93
+ <div
94
+ className={cn(
95
+ "text-sm",
96
+ stage.state === "failed"
97
+ ? "text-(--red-11)"
98
+ : stage.state === "waiting"
99
+ ? "text-muted-foreground"
100
+ : "text-foreground",
101
+ )}
102
+ >
103
+ {stage.title}
104
+ </div>
105
+ <p className="mt-1 text-xs text-muted-foreground">
106
+ {stage.description}
107
+ </p>
108
+ {stage.details}
109
+ </div>
110
+ </li>
111
+ ))}
112
+ </ol>
113
+ );
114
+ }
@@ -359,11 +359,111 @@ describe("NotebookLanguageServerClient", () => {
359
359
  return undefined;
360
360
  });
361
361
 
362
- notebookClient = new NotebookLanguageServerClient(mockClient, {}, () => ({
363
- [Cells.cell1]: new EditorView({ doc: "# this is a comment" }),
364
- [Cells.cell2]: new EditorView({ doc: "import math\nimport numpy" }),
365
- [Cells.cell3]: new EditorView({ doc: "print(math.sqrt(4))" }),
366
- }));
362
+ notebookClient = new NotebookLanguageServerClient(
363
+ mockClient,
364
+ {},
365
+ () => ({}),
366
+ );
367
+ });
368
+
369
+ describe("live editor snapshots", () => {
370
+ function createEditor(code: string) {
371
+ return new EditorView({
372
+ doc: code,
373
+ extensions: [
374
+ languageAdapterState.init(() => new PythonLanguageAdapter()),
375
+ languageMetadataField.init(() => ({})),
376
+ ],
377
+ });
378
+ }
379
+
380
+ it("sends edits and their removal without invalidating the notebook atom", async () => {
381
+ const cachedCodes = store.get(topologicalCodesAtom);
382
+ const editor = createEditor("print(math.sqrt(4))");
383
+ replaceNotebookEditors(notebookClient, () => ({ [Cells.cell3]: editor }));
384
+ const uri = CellDocumentUri.of(Cells.cell3);
385
+ try {
386
+ await notebookClient.textDocumentDidOpen({
387
+ textDocument: {
388
+ uri,
389
+ languageId: "python",
390
+ version: 1,
391
+ text: editor.state.doc.toString(),
392
+ },
393
+ });
394
+ for (const [index, code] of [
395
+ "math.missing()",
396
+ "print(math.sqrt(4))",
397
+ ].entries()) {
398
+ editor.dispatch({
399
+ changes: { from: 0, to: editor.state.doc.length, insert: code },
400
+ });
401
+ await notebookClient.textDocumentDidChange({
402
+ textDocument: { uri, version: index + 2 },
403
+ contentChanges: [{ text: code }],
404
+ });
405
+ expect(store.get(topologicalCodesAtom)).toEqual(cachedCodes);
406
+ expect(mockClient.textDocumentDidChange).toHaveBeenNthCalledWith(
407
+ index + 1,
408
+ {
409
+ textDocument: {
410
+ uri: notebookClient.documentUri,
411
+ version: index + 2,
412
+ },
413
+ contentChanges: [
414
+ {
415
+ text: `# this is a comment\nimport math\nimport numpy\n${code}`,
416
+ },
417
+ ],
418
+ },
419
+ );
420
+ }
421
+ } finally {
422
+ editor.destroy();
423
+ }
424
+ });
425
+
426
+ it("syncs pending edits before completion and uses their updated line offsets", async () => {
427
+ const editor = createEditor("import math\nimport numpy");
428
+ replaceNotebookEditors(notebookClient, () => ({ [Cells.cell2]: editor }));
429
+ try {
430
+ await notebookClient.textDocumentDidOpen({
431
+ textDocument: {
432
+ uri: CellDocumentUri.of(Cells.cell2),
433
+ languageId: "python",
434
+ version: 1,
435
+ text: editor.state.doc.toString(),
436
+ },
437
+ });
438
+ editor.dispatch({
439
+ changes: { from: editor.state.doc.length, insert: "\nextra = 1" },
440
+ });
441
+ mockClient.textDocumentCompletion.mockImplementation(async () => {
442
+ expect(mockClient.textDocumentDidChange).toHaveBeenCalledWith({
443
+ textDocument: { uri: notebookClient.documentUri, version: 2 },
444
+ contentChanges: [
445
+ {
446
+ text: "# this is a comment\nimport math\nimport numpy\nextra = 1\nprint(math.sqrt(4))",
447
+ },
448
+ ],
449
+ });
450
+ return null;
451
+ });
452
+ const params: LSP.CompletionParams = {
453
+ textDocument: { uri: CellDocumentUri.of(Cells.cell3) },
454
+ position: { line: 0, character: 11 },
455
+ };
456
+ await notebookClient.textDocumentCompletion(params);
457
+ expect(mockClient.textDocumentCompletion).toHaveBeenCalledWith({
458
+ textDocument: { uri: notebookClient.documentUri },
459
+ position: { line: 4, character: 11 },
460
+ });
461
+ await notebookClient.textDocumentCompletion(params);
462
+ expect(mockClient.textDocumentDidChange).toHaveBeenCalledTimes(1);
463
+ } finally {
464
+ editor.destroy();
465
+ }
466
+ });
367
467
  });
368
468
 
369
469
  describe("document lifecycle", () => {
@@ -1893,6 +1993,7 @@ describe("NotebookLanguageServerClient", () => {
1893
1993
  const isolatedNotebookClient = new NotebookLanguageServerClient(
1894
1994
  isolatedClient,
1895
1995
  {},
1996
+ () => ({}),
1896
1997
  );
1897
1998
  await isolatedNotebookClient.sync();
1898
1999
  isolatedNotebookClient.patchProcessNotification();
@@ -343,7 +343,21 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {
343
343
  }
344
344
 
345
345
  private getNotebookCode() {
346
- return store.get(topologicalCodesAtom);
346
+ const { cellIds, codes } = store.get(topologicalCodesAtom);
347
+ const editors = this.getNotebookEditors();
348
+ // EditorView edits do not invalidate the cached notebook atom.
349
+ return {
350
+ cellIds,
351
+ codes: Objects.fromEntries(
352
+ cellIds.map((id) => {
353
+ const editor = editors[id];
354
+ return [
355
+ id,
356
+ editor ? getEditorCodeAsPython(editor) : (codes[id] ?? ""),
357
+ ];
358
+ }),
359
+ ),
360
+ };
347
361
  }
348
362
 
349
363
  private assertCellDocumentUri(
@@ -870,7 +884,7 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {
870
884
  }
871
885
 
872
886
  public async textDocumentCompletion(params: LSP.CompletionParams) {
873
- const { lens } = this.snapshotter.getLatestSnapshot();
887
+ const { lens } = await this.sync();
874
888
 
875
889
  // Check if URI is valid
876
890
  if (!CellDocumentUri.is(params.textDocument.uri)) {
@@ -4,12 +4,12 @@ import { EditorState } from "@codemirror/state";
4
4
  import { EditorView } from "@codemirror/view";
5
5
  import { createStore } from "jotai";
6
6
  import { describe, expect, it } from "vitest";
7
- import { WebSocketState } from "@/core/websocket/types";
7
+ import { ConnectionState } from "@/core/websocket/types";
8
8
  import { connectionAtom } from "../../../network/connection";
9
9
  import { dynamicReadonly, isEditorReadonly } from "../extension";
10
10
 
11
11
  function makeStoreWithConnection(
12
- state: typeof WebSocketState.CONNECTING | typeof WebSocketState.OPEN,
12
+ state: typeof ConnectionState.CONNECTING | typeof ConnectionState.OPEN,
13
13
  ) {
14
14
  const store = createStore();
15
15
  store.set(connectionAtom, { state });
@@ -18,7 +18,7 @@ function makeStoreWithConnection(
18
18
 
19
19
  describe("dynamicReadonly", () => {
20
20
  it("should be readonly when connection is not OPEN", () => {
21
- const store = makeStoreWithConnection(WebSocketState.CONNECTING);
21
+ const store = makeStoreWithConnection(ConnectionState.CONNECTING);
22
22
  const state = EditorState.create({
23
23
  doc: "test",
24
24
  extensions: [dynamicReadonly(store)],
@@ -27,7 +27,7 @@ describe("dynamicReadonly", () => {
27
27
  });
28
28
 
29
29
  it("should be editable when connection is OPEN", async () => {
30
- const store = makeStoreWithConnection(WebSocketState.OPEN);
30
+ const store = makeStoreWithConnection(ConnectionState.OPEN);
31
31
  const state = EditorState.create({
32
32
  doc: "test",
33
33
  extensions: [dynamicReadonly(store)],
@@ -37,7 +37,7 @@ describe("dynamicReadonly", () => {
37
37
  });
38
38
 
39
39
  it("should toggle readonly when connection state changes", () => {
40
- const store = makeStoreWithConnection(WebSocketState.CONNECTING);
40
+ const store = makeStoreWithConnection(ConnectionState.CONNECTING);
41
41
  const state = EditorState.create({
42
42
  doc: "test",
43
43
  extensions: [dynamicReadonly(store)],
@@ -45,7 +45,7 @@ describe("dynamicReadonly", () => {
45
45
  const view = new EditorView({ state });
46
46
  expect(isEditorReadonly(state)).toBe(true);
47
47
  // Simulate connection opening
48
- store.set(connectionAtom, { state: WebSocketState.OPEN });
48
+ store.set(connectionAtom, { state: ConnectionState.OPEN });
49
49
  // The extension uses a plugin to update the state, so we need to create a view to trigger it
50
50
  view.requestMeasure();
51
51
  // The state should now be editable
@@ -7,7 +7,7 @@ import {
7
7
  isAppConnecting,
8
8
  } from "@/core/websocket/connection-utils";
9
9
  import { connectionAtom } from "../../network/connection";
10
- import { WebSocketState } from "../../websocket/types";
10
+ import { ConnectionState } from "../../websocket/types";
11
11
 
12
12
  /**
13
13
  * State effect for updating readonly status based on connection
@@ -111,7 +111,7 @@ export function dynamicReadonly(store: ReturnType<typeof createStore>) {
111
111
  // Subscribe to connectionAtom and manage listeners
112
112
  const unsubscribe = store.sub(connectionAtom, () => {
113
113
  const connection = store.get(connectionAtom);
114
- if (connection.state === WebSocketState.CONNECTING) {
114
+ if (connection.state === ConnectionState.CONNECTING) {
115
115
  attachListeners();
116
116
  } else {
117
117
  detachListeners();
@@ -2,7 +2,7 @@
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { connectionAtom } from "@/core/network/connection";
4
4
  import { store } from "@/core/state/jotai";
5
- import { WebSocketState } from "@/core/websocket/types";
5
+ import { ConnectionState } from "@/core/websocket/types";
6
6
  import {
7
7
  fetchDataSourceDiscovery,
8
8
  invalidateDataSourceDiscovery,
@@ -30,7 +30,7 @@ describe("fetchDataSourceDiscovery", () => {
30
30
  beforeEach(() => {
31
31
  // Discovery waits for the session's websocket connection to be open
32
32
  // before requesting, so it doesn't race a still-connecting session.
33
- store.set(connectionAtom, { state: WebSocketState.OPEN });
33
+ store.set(connectionAtom, { state: ConnectionState.OPEN });
34
34
  });
35
35
 
36
36
  afterEach(() => {
@@ -197,7 +197,11 @@ export const EditApp: React.FC<AppProps> = ({
197
197
  )}
198
198
  </div>
199
199
 
200
- <ConnectionNotice appConfig={appConfig} onRetry={reconnect} />
200
+ <ConnectionNotice
201
+ appConfig={appConfig}
202
+ onRetry={reconnect}
203
+ canOpenPackages={!hideControls}
204
+ />
201
205
 
202
206
  {/* Don't render until we have a single cell. NotStartedConnectionAlert
203
207
  still covers the "no remote runtime started" prompt. */}
@@ -16,7 +16,7 @@ import { connectionAtom } from "../network/connection";
16
16
  import { useRequestClient } from "../network/requests";
17
17
  import type { UpdateCellOutputsRequest } from "../network/types";
18
18
  import { VirtualFileTracker } from "../static/virtual-file-tracker";
19
- import { WebSocketState } from "../websocket/types";
19
+ import { ConnectionState } from "../websocket/types";
20
20
 
21
21
  const DELAY = 5000; // 5 seconds;
22
22
 
@@ -28,7 +28,7 @@ export function useAutoExport() {
28
28
  const htmlEnabled = appConfig.auto_download.includes("html");
29
29
  const ipynbEnabled = appConfig.auto_download.includes("ipynb");
30
30
 
31
- const isConnected = state === WebSocketState.OPEN;
31
+ const isConnected = state === ConnectionState.OPEN;
32
32
  const markdownDisabled = !markdownEnabled || !isConnected;
33
33
  const htmlDisabled = !htmlEnabled || !isConnected;
34
34
  const ipynbDisabled = !ipynbEnabled || !isConnected;
@@ -3,7 +3,7 @@
3
3
  import { afterEach, describe, expect, it } from "vitest";
4
4
  import { initialModeAtom } from "@/core/mode";
5
5
  import { store } from "@/core/state/jotai";
6
- import { WebSocketState } from "../../websocket/types";
6
+ import { ConnectionState } from "../../websocket/types";
7
7
  import { connectionAtom, waitForConnectionOpenIfNotebook } from "../connection";
8
8
 
9
9
  const NEVER = Symbol("never");
@@ -20,7 +20,7 @@ function settledOrNever(promise: Promise<unknown>) {
20
20
 
21
21
  describe("waitForConnectionOpenIfNotebook", () => {
22
22
  afterEach(() => {
23
- store.set(connectionAtom, { state: WebSocketState.NOT_STARTED });
23
+ store.set(connectionAtom, { state: ConnectionState.NOT_STARTED });
24
24
  store.set(initialModeAtom, undefined);
25
25
  });
26
26
 
@@ -39,7 +39,7 @@ describe("waitForConnectionOpenIfNotebook", () => {
39
39
  const promise = waitForConnectionOpenIfNotebook();
40
40
  await expect(settledOrNever(promise)).resolves.toBe(NEVER);
41
41
 
42
- store.set(connectionAtom, { state: WebSocketState.OPEN });
42
+ store.set(connectionAtom, { state: ConnectionState.OPEN });
43
43
  await expect(settledOrNever(promise)).resolves.not.toBe(NEVER);
44
44
  });
45
45
  });
@@ -5,7 +5,7 @@ import { sandboxAtom, sandboxSyncAtom } from "@/core/packages/sandbox-state";
5
5
  import {
6
6
  type ConnectionPhase,
7
7
  WebSocketClosedReason,
8
- WebSocketState,
8
+ ConnectionState,
9
9
  } from "@/core/websocket/types";
10
10
  import { connectionAtom } from "./connection";
11
11
 
@@ -37,7 +37,7 @@ export const connectionNoticeAtom = atom<ConnectionNotice | null>((get) => {
37
37
  if (
38
38
  sandbox &&
39
39
  (syncing || syncError !== null) &&
40
- connection.state === WebSocketState.OPEN
40
+ connection.state === ConnectionState.OPEN
41
41
  ) {
42
42
  return {
43
43
  kind: "sync",
@@ -56,7 +56,7 @@ export const connectionNoticeAtom = atom<ConnectionNotice | null>((get) => {
56
56
  error: syncError,
57
57
  };
58
58
  }
59
- if (connection.state === WebSocketState.CONNECTING) {
59
+ if (connection.state === ConnectionState.CONNECTING) {
60
60
  const messages = {
61
61
  "preparing-environment": {
62
62
  title: "Preparing environment…",
@@ -88,11 +88,11 @@ export const connectionNoticeAtom = atom<ConnectionNotice | null>((get) => {
88
88
  error: null,
89
89
  };
90
90
  }
91
- if (connection.state === WebSocketState.CLOSED) {
91
+ if (connection.state === ConnectionState.CLOSED) {
92
92
  const startupFailed =
93
93
  connection.code === WebSocketClosedReason.KERNEL_STARTUP_ERROR;
94
94
  const environmentFailed =
95
- startupFailed && connection.phase === "preparing-environment";
95
+ sandbox && startupFailed && connection.phase === "preparing-environment";
96
96
  return {
97
97
  kind: startupFailed ? "startup" : "connection",
98
98
  phase: connection.phase,
@@ -4,14 +4,14 @@ import { atomWithReducer } from "jotai/utils";
4
4
  import type { NotificationMessageData } from "../kernel/messages";
5
5
  import { isNotebookPage } from "../mode";
6
6
  import { waitFor } from "../state/jotai";
7
- import { type ConnectionStatus, WebSocketState } from "../websocket/types";
7
+ import { type ConnectionStatus, ConnectionState } from "../websocket/types";
8
8
 
9
9
  /**
10
10
  * Atom for storing the connection status.
11
11
  * Initialized to NOT_STARTED.
12
12
  */
13
13
  export const connectionAtom = atom<ConnectionStatus>({
14
- state: WebSocketState.NOT_STARTED,
14
+ state: ConnectionState.NOT_STARTED,
15
15
  });
16
16
 
17
17
  type StartupProgress = NotificationMessageData<"startup-progress">;
@@ -33,7 +33,7 @@ export const startupProgressAtom = atomWithReducer<
33
33
 
34
34
  export function waitForConnectionOpen() {
35
35
  return waitFor(connectionAtom, (value) => {
36
- return value.state === WebSocketState.OPEN;
36
+ return value.state === ConnectionState.OPEN;
37
37
  });
38
38
  }
39
39
 
@@ -53,28 +53,28 @@ export function waitForConnectionOpenIfNotebook() {
53
53
 
54
54
  export const isConnectingAtom = atom((get) => {
55
55
  const connection = get(connectionAtom);
56
- return connection.state === WebSocketState.CONNECTING;
56
+ return connection.state === ConnectionState.CONNECTING;
57
57
  });
58
58
 
59
59
  export const isConnectedAtom = atom((get) => {
60
60
  const connection = get(connectionAtom);
61
- return connection.state === WebSocketState.OPEN;
61
+ return connection.state === ConnectionState.OPEN;
62
62
  });
63
63
 
64
64
  export const canInteractWithAppAtom = atom((get) => {
65
65
  const connection = get(connectionAtom);
66
66
  return (
67
- connection.state === WebSocketState.OPEN ||
68
- connection.state === WebSocketState.NOT_STARTED
67
+ connection.state === ConnectionState.OPEN ||
68
+ connection.state === ConnectionState.NOT_STARTED
69
69
  );
70
70
  });
71
71
 
72
72
  export const isClosedAtom = atom((get) => {
73
73
  const connection = get(connectionAtom);
74
- return connection.state === WebSocketState.CLOSED;
74
+ return connection.state === ConnectionState.CLOSED;
75
75
  });
76
76
 
77
77
  export const isNotStartedAtom = atom((get) => {
78
78
  const connection = get(connectionAtom);
79
- return connection.state === WebSocketState.NOT_STARTED;
79
+ return connection.state === ConnectionState.NOT_STARTED;
80
80
  });