Repository navigation
Description
Product impact
Primary loop layer: Docs-Tooling. The screenshot bytes are written correctly; the command subsequently reports failure or displays the wrong path.
Bug and reproduction
On main 92196a5d665f94b4b18e87cb67f3a5237a10a1e7, omi local screenshot 9 --output 'shot[/bold].jpg' writes the output and then raises Rich MarkupError while rendering the success message. Balanced Rich tags in the path instead disappear from the displayed filename. These are valid nested paths because closing markup tags contain /; the screenshot writer creates their parent directories.
The cause is the unescaped written path in commands/local.py's success message. The same module already imports rich.markup.escape. The patch below applies it to the path only.
Validation
- New regression matrix before the fix: 2 pretty-mode failures; both JSON controls pass.
- After the fix: all 8 screenshot-encoding tests pass.
- Full component suite:
.venv/bin/python -m pytest sdks/python-cli/tests --tb=short— 492 passed, 1 skipped, Python 3.13. make preflightwith the component venv on PATH and the prepared PR body — 12 checks pass. Black for both changed files andgit diff --checkpass.- Tests execute the actual CLI command with mocked Desktop HTTP responses and synthetic image bytes, assert exact saved bytes/path and exactly one HTTP call. No live Desktop app or private account data was used.
Proposed bounty
Following the contribution guide's invitation to suggest paid work: @josancamon19, would you consider US$25 upon acceptance and merge for this patch and regression coverage? This is a proposed reward, not an approved bounty or payment claim. The complete patch is supplied below for review; no PR has been opened yet. This is an AI-assisted contribution through Codex on behalf of the account owner.
Patch
diff --git a/sdks/python-cli/omi_cli/commands/local.py b/sdks/python-cli/omi_cli/commands/local.py
index 1f3ab88ec4..12f7296cf7 100644
--- a/sdks/python-cli/omi_cli/commands/local.py
+++ b/sdks/python-cli/omi_cli/commands/local.py
@@ -148,7 +148,7 @@ def screenshot(
written = _write_screenshot_result(result, output)
raw_metadata = result.get("metadata") if isinstance(result, Mapping) else None
metadata: Mapping[str, Any] = raw_metadata if isinstance(raw_metadata, Mapping) else {}
- ctx.renderer.success(f"Wrote screenshot to [bold]{written}[/bold].")
+ ctx.renderer.success(f"Wrote screenshot to [bold]{escape(str(written))}[/bold].")
ctx.renderer.emit(
{
"path": str(written),
diff --git a/sdks/python-cli/tests/test_local_screenshot_encoding.py b/sdks/python-cli/tests/test_local_screenshot_encoding.py
index ab5c2eb36f..3995aa7ac5 100644
--- a/sdks/python-cli/tests/test_local_screenshot_encoding.py
+++ b/sdks/python-cli/tests/test_local_screenshot_encoding.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import base64
import json
from pathlib import Path
from unittest.mock import patch
@@ -65,3 +66,34 @@ def test_screenshot_command_writes_multilingual_content(config_path: Path, cli_r
payload = json.loads(result.stdout)
assert payload["path"] == str(output)
assert payload["screenshot_id"] == "9"
+
+
+@pytest.mark.parametrize("output_name", ["shot[red]marked[/red].jpg", "shot[/bold].jpg"])
+@pytest.mark.parametrize("json_mode", [False, True])
+def test_screenshot_output_path_preserves_literal_markup(
+ config_path: Path, cli_runner, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, output_name: str, json_mode: bool
+):
+ _configure_local_profile(config_path)
+ # Closing Rich tags contain a slash, so these are valid nested output paths.
+ output = tmp_path / output_name
+ image_bytes = b"\xff\xd8synthetic screenshot\xff\xd9"
+ response = {"image_base64": base64.b64encode(image_bytes).decode("ascii"), "screenshot_id": "9"}
+ # Keep the status path on one line so its literal spelling can be checked.
+ monkeypatch.setenv("COLUMNS", "1000")
+
+ with respx.mock(base_url=FAKE_LOCAL_URL, assert_all_called=True) as router:
+ route = router.post("/v1/local/tool").mock(return_value=httpx.Response(200, json=_tool_response(response)))
+ args = ["--json"] if json_mode else []
+ result = cli_runner.invoke(app, [*args, "local", "screenshot", "9", "--output", str(output)])
+
+ assert result.exit_code == 0, repr(result.exception)
+ assert route.call_count == 1
+ assert output.read_bytes() == image_bytes
+ if json_mode:
+ assert result.stderr == ""
+ payload = json.loads(result.stdout)
+ assert payload["path"] == str(output)
+ assert payload["bytes"] == len(image_bytes)
+ assert payload["screenshot_id"] == "9"
+ else:
+ assert str(output) in result.stderrMetadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn review
Activity
fix(python-cli): escape screenshot output path in Rich success message (
test(python-cli): add regression test for screenshot output path mark…
test(python-cli): enforce clean escape contract on screenshot paths (B…
aryanorastar commentedon Sep 25, 2026
Fixed on main. local.py escapes the screenshot path in the success line.