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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(tasks): persist sqlite task updates
cyh063eb41527bc
diff --git a/core/scheduled_tasks.py b/core/scheduled_tasks.pyindex db7bf5c66..0bbeecc51 100644--- a/core/scheduled_tasks.py+++ b/core/scheduled_tasks.py@@ -416,6 +416,9 @@ class ScheduledTaskStore:task.run_at = run_attask.timezone = timezone_nametask.updated_at = _utc_now_iso()+ if self._sqlite is not None:+ self._sqlite.upsert_scheduled_task(task.to_dict())+ return taskself._save()return taskdiff --git a/tests/test_cli_task_command.py b/tests/test_cli_task_command.pyindex 1cd330ab5..c07d9b2c0 100644--- a/tests/test_cli_task_command.py+++ b/tests/test_cli_task_command.py@@ -581,6 +581,32 @@ def test_task_update_modifies_existing_task_without_changing_id(tmp_path: Path,assert payload["task"]["prompt"] == "updated"+def test_task_update_session_key_clears_previous_session_id(tmp_path: Path, capsys) -> None:+ store_path = tmp_path / "scheduled_tasks.json"+ store = cli.ScheduledTaskStore(store_path)+ task = store.add_task(+ session_key="",+ session_id="sesk8m4q2p7x",+ prompt="hello",+ schedule_type="cron",+ cron="0 * * * *",+ timezone_name="Asia/Shanghai",+ )+ parser = cli.build_parser()+ args = parser.parse_args(["task", "update", task.id, "--session-key", "slack::channel::C456"])++ with (+ patch("vibe.cli._ensure_config", return_value=_configured_v2({"slack"})),+ patch("vibe.cli._task_store", return_value=store),+ ):+ result = cli.cmd_task_update(args)++ assert result == 0+ payload = json.loads(capsys.readouterr().out)+ assert payload["task"]["session_id"] is None+ assert payload["task"]["session_key"] == "slack::channel::C456"++def test_task_update_replaces_post_to_with_deliver_key(tmp_path: Path, capsys) -> None:store_path = tmp_path / "scheduled_tasks.json"store = cli.ScheduledTaskStore(store_path)diff --git a/tests/test_cli_watch_command.py b/tests/test_cli_watch_command.pyindex 222dbfaf4..87ce60f60 100644--- a/tests/test_cli_watch_command.py+++ b/tests/test_cli_watch_command.py@@ -556,6 +556,40 @@ def test_watch_update_renames_and_retargets_watch(tmp_path: Path, capsys) -> Nonassert payload["watch"]["shell_command"] == "python3 wait_deploy.py"+def test_watch_update_session_key_clears_previous_session_id(tmp_path: Path, capsys) -> None:+ store = ManagedWatchStore(tmp_path / "watches.json")+ runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")+ watch = store.add_watch(+ name="Watch CI",+ session_key="",+ session_id="sesk8m4q2p7x",+ command=["python3", "wait.py"],+ shell_command=None,+ prefix=None,+ cwd=None,+ mode="once",+ timeout_seconds=600,+ lifetime_timeout_seconds=0,+ retry_exit_codes=[75],+ retry_delay_seconds=30,+ post_to=None,+ deliver_key=None,+ )+ args = _parse_watch_update([watch.id, "--session-key", "slack::channel::C456"])++ 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),+ ):+ result = cli.cmd_watch_update(args)++ assert result == 0+ payload = json.loads(capsys.readouterr().out)+ assert payload["watch"]["session_id"] is None+ assert payload["watch"]["session_key"] == "slack::channel::C456"++def test_watch_update_no_changes_returns_structured_error(tmp_path: Path) -> None:store = ManagedWatchStore(tmp_path / "watches.json")watch = store.add_watch(diff --git a/tests/test_scheduled_tasks.py b/tests/test_scheduled_tasks.pyindex bd3af4149..f867dd4d7 100644--- a/tests/test_scheduled_tasks.py+++ b/tests/test_scheduled_tasks.py@@ -114,6 +114,43 @@ def test_scheduled_task_store_uses_sqlite_when_path_is_default(tmp_path: Path, massert sqlite.get_scheduled_task(task.id)["prompt"] == "hello"+def test_sqlite_update_task_persists_changes(tmp_path: Path, monkeypatch) -> None:+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ store = ScheduledTaskStore()+ task = store.add_task(+ name="Hourly summary",+ session_key="slack::channel::C123",+ session_id="sesk8m4q2p7x",+ prompt="hello",+ schedule_type="cron",+ cron="0 * * * *",+ timezone_name="UTC",+ )++ store.update_task(+ task.id,+ name="Morning summary",+ session_key="slack::channel::C456",+ session_id=None,+ prompt="updated",+ schedule_type="cron",+ post_to=None,+ deliver_key=None,+ cron="*/30 * * * *",+ run_at=None,+ timezone_name="Asia/Shanghai",+ )+ reloaded = ScheduledTaskStore()+ saved = reloaded.get_task(task.id)++ assert saved is not None+ assert saved.name == "Morning summary"+ assert saved.session_id is None+ assert saved.session_key == "slack::channel::C456"+ assert saved.prompt == "updated"+ assert saved.cron == "*/30 * * * *"++def test_task_execution_store_uses_sqlite_runs_when_root_is_default(tmp_path: Path, monkeypatch) -> None:monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))store = TaskExecutionStore()diff --git a/vibe/cli.py b/vibe/cli.pyindex 1541ac51e..14248b16a 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -1241,8 +1241,15 @@ def cmd_task_update(args):required=False,help_command="vibe task update --help",)- session_id = session_id_update if session_id_update is not None else task.session_id- session_key = session_key_update if session_key_update else ("" if session_id_update else task.session_key)+ if session_id_update is not None:+ session_id = session_id_update+ session_key = ""+ elif session_key_update:+ session_id = None+ session_key = session_key_update+ else:+ session_id = task.session_id+ session_key = task.session_keyif getattr(args, "reset_delivery", False):post_to = Nonedeliver_key = None@@ -1629,8 +1636,15 @@ def cmd_watch_update(args):required=False,help_command="vibe watch update --help",)- session_id = session_id_update if session_id_update is not None else watch.session_id- session_key = session_key_update if session_key_update else ("" if session_id_update else watch.session_key)+ if session_id_update is not None:+ session_id = session_id_update+ session_key = ""+ elif session_key_update:+ session_id = None+ session_key = session_key_update+ else:+ session_id = watch.session_id+ session_key = watch.session_keyif getattr(args, "reset_delivery", False):post_to = Nonedeliver_key = None