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.

fix(storage): preserve failed imported run status

cyh8dd8053cf4f3
diff --git a/storage/importer.py b/storage/importer.py
index 47011a930..81b47a344 100644
--- a/storage/importer.py
+++ b/storage/importer.py
@@ -535,7 +535,7 @@ def _import_task_requests(conn: Connection, root: Path) -> int:
if not item:
continue
ok = item.get("ok")
- run_status = "failed" if status == "completed" and ok is False else status
+ run_status = "failed" if status_dir == "completed" and ok is False else status
created_at = item.get("created_at") or item.get("completed_at") or _utc_now_iso()
conn.execute(
agent_runs.insert().values(
diff --git a/tests/test_sqlite_state_migration.py b/tests/test_sqlite_state_migration.py
index 50b69b261..9c08aa6c2 100644
--- a/tests/test_sqlite_state_migration.py
+++ b/tests/test_sqlite_state_migration.py
@@ -410,22 +410,43 @@ def test_ensure_sqlite_state_imports_background_json(tmp_path: Path) -> None:
),
encoding="utf-8",
)
+ completed = state_dir / "task_requests" / "completed"
+ completed.mkdir(parents=True)
+ (completed / "hook-2.json").write_text(
+ json.dumps(
+ {
+ "id": "hook-2",
+ "request_type": "hook_send",
+ "created_at": "2026-05-15T00:00:00+00:00",
+ "completed_at": "2026-05-15T00:01:00+00:00",
+ "session_id": "sesk8m4q2p7x",
+ "session_key": "slack::channel::C123",
+ "prompt": "failed",
+ "ok": False,
+ "error": "boom",
+ }
+ ),
+ encoding="utf-8",
+ )
report = ensure_sqlite_state(db_path=db_path, state_dir=state_dir, primary_platform="slack")
assert report.counts["background_scheduled_tasks"] == 1
assert report.counts["background_watches"] == 1
- assert report.counts["background_runs_imported"] == 1
+ assert report.counts["background_runs_imported"] == 2
with sqlite3.connect(db_path) as conn:
tasks = conn.execute(
"select definition_type, session_id, legacy_session_key from run_definitions order by id"
).fetchall()
- runs = conn.execute("select run_type, status, session_id from agent_runs").fetchall()
+ runs = conn.execute("select id, run_type, status, session_id, error from agent_runs order by id").fetchall()
assert tasks == [
("scheduled", "sesk8m4q2p7x", "slack::channel::C123"),
("watch", "sesk8m4q2p7x", "slack::channel::C123"),
]
- assert runs == [("hook_send", "queued", "sesk8m4q2p7x")]
+ assert runs == [
+ ("hook-1", "hook_send", "queued", "sesk8m4q2p7x", None),
+ ("hook-2", "hook_send", "failed", "sesk8m4q2p7x", "boom"),
+ ]
def test_custom_state_paths_do_not_bootstrap_default_home(tmp_path: Path, monkeypatch) -> None: