Skip to content

Commit c31c0da

Browse files
Accept Camofox environment wrapper launch
1 parent 54778d9 commit c31c0da

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎src/ulysses_runtime_management.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,18 @@ def _managed_tmux_start_steps(
10301030
launch: list[str],
10311031
label: str,
10321032
) -> list[dict[str, Any]]:
1033-
if launch != ["bash", "start.sh"]:
1033+
direct_start = launch == ["bash", "start.sh"]
1034+
env_start = (
1035+
len(launch) >= 4
1036+
and launch[0] == "env"
1037+
and launch[-2:] == ["bash", "start.sh"]
1038+
and all(
1039+
"=" in assignment
1040+
and KEY_RE.fullmatch(assignment.split("=", 1)[0]) is not None
1041+
for assignment in launch[1:-2]
1042+
)
1043+
)
1044+
if not (direct_start or env_start):
10341045
raise RuntimeJobError(
10351046
"interactive runtimes must launch the project-local start.sh"
10361047
)

‎tests/test_ulysses_runtime_management.py‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,17 @@ def test_json_document_redacts_provider_keys_and_validates_before_save(
295295
)
296296

297297

298+
@pytest.mark.parametrize(
299+
"launch",
300+
(
301+
["bash", "start.sh"],
302+
["env", "BROWSER_IDLE_TIMEOUT_MS=0", "bash", "start.sh"],
303+
),
304+
)
298305
def test_javascript_start_plan_requires_sandwich_and_uses_fixed_tmux(
299306
monkeypatch: pytest.MonkeyPatch,
300307
tmp_path: Path,
308+
launch: list[str],
301309
) -> None:
302310
runtime = tmp_path / "browser"
303311
runtime.mkdir()
@@ -307,7 +315,7 @@ def test_javascript_start_plan_requires_sandwich_and_uses_fixed_tmux(
307315
"category": "javascript",
308316
"root": runtime,
309317
"documents": (),
310-
"launch": ["bash", "start.sh"],
318+
"launch": launch,
311319
"tmux_session": "ulysses-example-browser",
312320
"ports": [],
313321
}
@@ -334,7 +342,23 @@ def test_javascript_start_plan_requires_sandwich_and_uses_fixed_tmux(
334342
"-c",
335343
str(runtime),
336344
]
337-
assert plan["steps"][0]["argv"][-2:] == ["bash", "start.sh"]
345+
assert plan["steps"][0]["argv"][-len(launch) :] == launch
346+
347+
348+
def test_javascript_start_plan_rejects_env_options_before_fixed_wrapper(
349+
tmp_path: Path,
350+
) -> None:
351+
with pytest.raises(
352+
manager.RuntimeJobError,
353+
match="must launch the project-local start.sh",
354+
):
355+
manager._managed_tmux_start_steps(
356+
{"id": "example.browser", "ports": []},
357+
session="ulysses-example-browser",
358+
root=tmp_path,
359+
launch=["env", "--ignore-environment", "bash", "start.sh"],
360+
label="Start managed tmux runtime",
361+
)
338362

339363

340364
def test_open_and_initialize_actions_use_project_root(

0 commit comments

Comments
 (0)