Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix(pair): use the latest release outside editable installs (#10966)

Kiran Gadhave2f6f8bad2582
diff --git a/frontend/src/__tests__/fixtures/pair-preview.ts b/frontend/src/__tests__/fixtures/pair-preview.ts
index decdd73c86..6c53e89ab0 100644
--- a/frontend/src/__tests__/fixtures/pair-preview.ts
+++ b/frontend/src/__tests__/fixtures/pair-preview.ts
@@ -6,7 +6,7 @@ import { pairPreviewSchema } from "@/core/config/pair";
// Read the Python-owned resource only in tests to check the shared contract.
export const PAIR_PREVIEW = pairPreviewSchema.parse({
- command: "uv run marimo",
+ command: "uvx marimo@latest",
templates: JSON.parse(
readFileSync(
path.resolve(
diff --git a/frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts b/frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts
index 12164c099c..d04582725c 100644
--- a/frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts
+++ b/frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts
@@ -129,7 +129,7 @@ describe("getTerminalCommand", () => {
PAIR_PREVIEW,
),
).toBe(
- String.raw`codex "$(MARIMO_PAIR_NEXT=1 uv run marimo pair prompt \
+ String.raw`codex "$(MARIMO_PAIR_NEXT=1 uvx marimo@latest pair prompt \
--url http://localhost:8000)"`,
);
} finally {
@@ -152,7 +152,7 @@ describe("getTerminalCommand", () => {
PAIR_PREVIEW,
),
).toBe(
- String.raw`${cli} "$(MARIMO_PAIR_NEXT=1 uv run marimo pair prompt \
+ String.raw`${cli} "$(MARIMO_PAIR_NEXT=1 uvx marimo@latest pair prompt \
--url http://localhost:8000 \
--file notebooks/example.py \
--session s_ab12cd \
@@ -264,8 +264,8 @@ describe("getRawPrompt", () => {
expect(getRawPrompt(connection, null, PAIR_PREVIEW)).toBe(
"Pair with me on this running marimo notebook.\n\n" +
`URL: http://localhost:8000\n${fields}\n` +
- "Run `uv run marimo pair --help` first.\n" +
- "Use `uv run marimo` for all marimo commands.\n\n" +
+ "Run `uvx marimo@latest pair --help` first.\n" +
+ "Use `uvx marimo@latest` for all marimo commands.\n\n" +
"Once connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).",
);
});
@@ -278,8 +278,8 @@ describe("getRawPrompt", () => {
"URL: http://localhost:8000\n" +
"File: notebooks/example.py\n" +
"Session: s_ab12cd\n\n" +
- "Run `uv run marimo pair --help` first.\n" +
- "Use `uv run marimo` for all marimo commands.\n\n" +
+ "Run `uvx marimo@latest pair --help` first.\n" +
+ "Use `uvx marimo@latest` for all marimo commands.\n\n" +
"Once connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).",
);
});
diff --git a/frontend/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx b/frontend/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx
index 0cdf45e3cc..4be3699474 100644
--- a/frontend/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx
+++ b/frontend/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx
@@ -203,7 +203,7 @@ describe("PairWithAgentModal", () => {
);
await waitFor(() =>
expect(copyToClipboard).toHaveBeenCalledWith(
- String.raw`claude "$(MARIMO_PAIR_NEXT=1 uv run marimo pair prompt \
+ String.raw`claude "$(MARIMO_PAIR_NEXT=1 uvx marimo@latest pair prompt \
--url http://localhost:8000/ \
--file notebook.py \
--session ${getSessionId()} \
diff --git a/marimo/_cli/pair/prompts.py b/marimo/_cli/pair/prompts.py
index 7271a02db3..dec5278406 100644
--- a/marimo/_cli/pair/prompts.py
+++ b/marimo/_cli/pair/prompts.py
@@ -6,8 +6,11 @@ from dataclasses import dataclass
from pathlib import Path
from marimo._utils.parse_dataclass import parse_raw
+from marimo._utils.versions import is_editable
-PAIR_COMMAND = "uv run marimo"
+
+def get_pair_command() -> str:
+ return "uv run marimo" if is_editable("marimo") else "uvx marimo@latest"
@dataclass(frozen=True)
@@ -35,7 +38,7 @@ def render_prompt(
) -> str:
templates = load_prompt_templates()
return templates.prompt.format(
- command=PAIR_COMMAND,
+ command=get_pair_command(),
url=url,
file=templates.file.format(file=file_path) if file_path else "",
session=(
diff --git a/marimo/_templates.py b/marimo/_templates.py
index b2239f8c5c..e9a7cf4763 100644
--- a/marimo/_templates.py
+++ b/marimo/_templates.py
@@ -12,7 +12,7 @@ from textwrap import dedent
from typing import TYPE_CHECKING, Any, Literal, cast
from marimo._ast.app_config import _AppConfig
-from marimo._cli.pair.prompts import PAIR_COMMAND, load_prompt_templates
+from marimo._cli.pair.prompts import get_pair_command, load_prompt_templates
from marimo._config.config import MarimoConfig, PartialMarimoConfig
from marimo._convert.common.filename import parse_title
from marimo._convert.converters import MarimoConvert
@@ -143,7 +143,7 @@ def _get_mount_config(
if is_env_true("MARIMO_PAIR_NEXT"):
pair_preview = ',\n "pairPreview": ' + json_script(
{
- "command": PAIR_COMMAND,
+ "command": get_pair_command(),
"templates": asdict(load_prompt_templates()),
}
)
diff --git a/tests/_cli/test_cli_pair.py b/tests/_cli/test_cli_pair.py
index 51bba2a054..25c0d23e06 100644
--- a/tests/_cli/test_cli_pair.py
+++ b/tests/_cli/test_cli_pair.py
@@ -41,6 +41,9 @@ TEST_URL = "https://localhost:8000?auth=tok123"
@pytest.fixture(autouse=True)
def _isolate_pair_preview(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.delenv("MARIMO_PAIR_NEXT", raising=False)
+ monkeypatch.setattr(
+ "marimo._cli.pair.prompts.is_editable", lambda _: False
+ )
class TestPairGroup:
@@ -1537,6 +1540,32 @@ Once you are connected, send a fun toast (mo.status.toast(...)) to the user insi
class TestPairPromptPreview:
+ @pytest.mark.parametrize(
+ ("editable", "command"),
+ [(True, "uv run marimo"), (False, "uvx marimo@latest")],
+ )
+ def test_prompt_uses_installation_command(
+ self, monkeypatch: pytest.MonkeyPatch, editable: bool, command: str
+ ) -> None:
+ monkeypatch.setattr(
+ "marimo._cli.pair.prompts.is_editable", lambda _: editable
+ )
+ result = _runner.invoke(
+ cli_main,
+ ["pair", "prompt", "--url", "http://localhost:2718"],
+ env={"MARIMO_PAIR_NEXT": "1"},
+ )
+
+ assert result.exit_code == 0
+ assert result.output == (
+ "Pair with me on this running marimo notebook.\n\n"
+ "URL: http://localhost:2718\n\n"
+ f"Run `{command} pair --help` first.\n"
+ f"Use `{command}` for all marimo commands.\n\n"
+ "Once connected, send a fun toast using `mo.status.toast(...)` "
+ "(`import marimo as mo`).\n"
+ )
+
def test_with_token_uses_private_file(self, tmp_path: Path) -> None:
token_dir = tmp_path / "tokens ' {command}"
with patch.object(commands, "_token_dir", return_value=token_dir):
@@ -1579,8 +1608,8 @@ Pair with me on this running marimo notebook.
URL: http://localhost:2718
Session: s_ab12cd
-Run `uv run marimo pair --help` first.
-Use `uv run marimo` for all marimo commands.
+Run `uvx marimo@latest pair --help` first.
+Use `uvx marimo@latest` for all marimo commands.
Once connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).
@@ -1609,8 +1638,8 @@ Pair with me on this running marimo notebook.
URL: http://localhost:2718
-Run `uv run marimo pair --help` first.
-Use `uv run marimo` for all marimo commands.
+Run `uvx marimo@latest pair --help` first.
+Use `uvx marimo@latest` for all marimo commands.
Once connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).
""")
@@ -1639,8 +1668,8 @@ URL: http://localhost:2718/{session}
File: {command}/it's notebook.py
Session: {file}
-Run `uv run marimo pair --help` first.
-Use `uv run marimo` for all marimo commands.
+Run `uvx marimo@latest pair --help` first.
+Use `uvx marimo@latest` for all marimo commands.
Once connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).
""")
@@ -1667,8 +1696,8 @@ Pair with me on this running marimo notebook.
URL: http://localhost:2718
File: notebook.py
-Run `uv run marimo pair --help` first.
-Use `uv run marimo` for all marimo commands.
+Run `uvx marimo@latest pair --help` first.
+Use `uvx marimo@latest` for all marimo commands.
Once connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).
""")
diff --git a/tests/_server/templates/test_templates_api.py b/tests/_server/templates/test_templates_api.py
index 0011bb0470..821fca8590 100644
--- a/tests/_server/templates/test_templates_api.py
+++ b/tests/_server/templates/test_templates_api.py
@@ -21,25 +21,32 @@ from tests._server.templates.utils import parse_mount_config
@pytest.mark.parametrize("flag", ["1", "true", " TRUE "])
+ ("editable", "command"),
+ [(True, "uv run marimo"), (False, "uvx marimo@latest")],
+)
def test_render_notebook_pair_preview(
- monkeypatch: pytest.MonkeyPatch, flag: str
+ monkeypatch: pytest.MonkeyPatch, flag: str, editable: bool, command: str
) -> None:
monkeypatch.setenv("MARIMO_PAIR_NEXT", flag)
+ monkeypatch.setattr(
+ "marimo._cli.pair.prompts.is_editable", lambda _: editable
+ )
html = render_notebook(
code="import marimo\napp = marimo.App()", mode="edit"
)
- assert parse_mount_config(html)["pairPreview"] == snapshot(
- {
- "command": "uv run marimo",
- "templates": {
+ assert parse_mount_config(html)["pairPreview"] == {
+ "command": command,
+ "templates": snapshot(
+ {
"prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{file}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.\n\nOnce connected, send a fun toast using `mo.status.toast(...)` (`import marimo as mo`).{authentication}",
"file": "File: {file}\n",
"session": "Session: {session}\n",
"token_file": "\n\nFor authenticated Pair commands, pass `--token-file {token_file}`.",
"token": "\n\nFor authenticated Pair commands, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.",
- },
- }
- )
+ }
+ ),
+ }
@pytest.mark.parametrize("flag", [None, "", "0", "false"])