Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

test(watch): lock zero timeout CLI round-trip (#1486)

rkrkrkk0a4982782083
diff --git a/docs/CLI.md b/docs/CLI.md
index 1c264b959..a768b5225 100644
--- a/docs/CLI.md
+++ b/docs/CLI.md
@@ -436,6 +436,8 @@ for one-shot session creation. `vibe watch remove` hides the watch from manageme
views while preserving existing run history in SQLite. Prefer `vibe watch`
over ad-hoc `nohup` jobs when the
user wants a managed background task with a guaranteed follow-up message.
+`--timeout` defaults to 21600 seconds; an explicit `--timeout 0` disables the
+per-cycle timeout, while any positive value is persisted unchanged.
### `vibe version`
diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.md
index 93d771157..9781c2149 100644
--- a/docs/CLI_ZH.md
+++ b/docs/CLI_ZH.md
@@ -378,6 +378,8 @@ watch 与 `vibe task`、`vibe agent run` 共用 `--session-id`、`--create-sessi
`--same-scope` 和 `--scope-id` 语义;`--create-session-per-run`
只属于 `vibe task` 和 `vibe watch` 这类 stored definitions。需要可管理、可暂停、可查看的
后台等待任务时,优先使用 `vibe watch`,不要随手起 `nohup`。
+`--timeout` 默认是 21600 秒;显式传入 `--timeout 0` 会关闭单次 cycle 的
+超时限制,任何正数值都会原样持久化。
### `vibe version`
diff --git a/tests/test_cli_watch_command.py b/tests/test_cli_watch_command.py
index 187b86dea..6a4766d84 100644
--- a/tests/test_cli_watch_command.py
+++ b/tests/test_cli_watch_command.py
@@ -101,6 +101,7 @@ def test_watch_add_help_mentions_shell_and_lifetime_timeout(capsys) -> None:
assert exc.value.code == 0
captured = capsys.readouterr()
+ normalized_help = " ".join(captured.out.split())
assert "Pass either --shell '<command>' or a command after '--'." in captured.out
assert "--lifetime-timeout" in captured.out
assert "vibe watch add --session-id sesk8m4q2p7x --message 'The export finished. Inspect it and continue.'" in captured.out
@@ -114,6 +115,7 @@ def test_watch_add_help_mentions_shell_and_lifetime_timeout(capsys) -> None:
assert "a once Watch ends and a forever Watch re-arms" in captured.out
assert "A once waiter that is still waiting must use a retry exit code" in captured.out
assert "If this is your first time using this command, read this whole help entry before creating a watch." in captured.out
+ assert "Use 0 for no per-cycle timeout" in normalized_help
assert "--same-scope" in captured.out
assert "--scope-id" in captured.out
assert "--post-to" not in captured.out
@@ -802,6 +804,59 @@ def test_watch_add_creates_exec_watch_with_retry_codes(tmp_path: Path, capsys) -
assert payload["definition"]["retry_exit_codes"] == [1, 75]
+ ("timeout_args", "expected_timeout"),
+ [
+ pytest.param([], 21600, id="omitted-default"),
+ pytest.param(["--timeout", "0"], 0, id="explicit-unlimited"),
+ pytest.param(["--timeout", "90.5"], 90.5, id="positive"),
+ ],
+)
+def test_watch_add_timeout_round_trips_through_persisted_read(
+ tmp_path: Path,
+ capsys,
+ timeout_args: list[str],
+ expected_timeout: float,
+) -> None:
+ store = ManagedWatchStore()
+ runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")
+ args = _parse_watch_add(
+ [
+ "--session-key",
+ "slack::channel::C123",
+ *timeout_args,
+ "--shell",
+ "exit 75",
+ ]
+ )
+
+ with (
+ patch("vibe.cli._ensure_config", return_value=_configured_v2({"slack"})),
+ patch("vibe.cli._watch_store", return_value=store),
+ patch("vibe.cli._watch_runtime_store", return_value=runtime_store),
+ patch(
+ "vibe.cli._wait_for_watch_startup",
+ side_effect=lambda *args, **kwargs: _startup_ok(
+ store, runtime_store, args[2]
+ ),
+ ),
+ ):
+ assert cli.cmd_watch_add(args) == 0
+
+ payload = json.loads(capsys.readouterr().out)
+ watch_id = payload["definition"]["id"]
+ reloaded_store = ManagedWatchStore()
+ try:
+ reloaded = reloaded_store.get_watch(watch_id)
+ assert reloaded is not None
+ assert reloaded.timeout_seconds == expected_timeout
+ finally:
+ if store.sqlite_backend is not None:
+ store.sqlite_backend.close()
+ if reloaded_store.sqlite_backend is not None:
+ reloaded_store.sqlite_backend.close()
+
+
def test_watch_add_persists_absolute_cwd(tmp_path: Path, capsys, monkeypatch: pytest.MonkeyPatch) -> None:
store = ManagedWatchStore(tmp_path / "watches.json")
runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")