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(cli-ui): bootstrap scope routing state

cyh1edfccf0355d
diff --git a/tests/test_cli_task_command.py b/tests/test_cli_task_command.py
index 30c636a77..8ab40cdf7 100644
--- a/tests/test_cli_task_command.py
+++ b/tests/test_cli_task_command.py
@@ -1002,6 +1002,32 @@ def test_default_agent_pointer_is_created(tmp_path: Path) -> None:
assert agent_store.get_default_agent().backend == "codex"
+def test_resolve_agent_for_target_bootstraps_sqlite_before_scope_lookup(tmp_path: Path) -> None:
+ db_path = tmp_path / "fresh-state" / "vibe.sqlite"
+ default_agent = SimpleNamespace(name="default", backend="codex")
+ fake_store = SimpleNamespace(
+ require=lambda name: (_ for _ in ()).throw(ValueError(f"agent '{name}' not found")),
+ get_default_agent=lambda: default_agent,
+ close=lambda: None,
+ )
+
+ with (
+ patch("vibe.cli._agent_store", return_value=fake_store),
+ patch("vibe.cli.paths.get_state_dir", return_value=db_path.parent),
+ patch("vibe.cli.paths.get_sqlite_state_path", return_value=db_path),
+ ):
+ agent = cli._resolve_agent_for_target(
+ agent_name=None,
+ session_id=None,
+ session_key="slack::channel::C123",
+ help_command="vibe task add --help",
+ )
+
+ assert agent is default_agent
+ with sqlite3.connect(db_path) as conn:
+ assert conn.execute("select count(*) from scope_settings").fetchone()[0] == 0
+
+
def test_task_add_rejects_deprecated_prompt_argument() -> None:
args = _parse_task_add(
[
diff --git a/ui/src/components/shared/RoutingConfigPanel.tsx b/ui/src/components/shared/RoutingConfigPanel.tsx
index 22f73e093..bf43e6d2b 100644
--- a/ui/src/components/shared/RoutingConfigPanel.tsx
+++ b/ui/src/components/shared/RoutingConfigPanel.tsx
@@ -102,7 +102,7 @@ export const RoutingConfigPanel: React.FC<RoutingConfigPanelProps> = ({
const defaultVibeAgent = vibeAgents.find((agent) => agent.name === defaultAgentName) || null;
const inheritedVibeAgent = selectedVibeAgent || defaultVibeAgent;
const hasSelectedVibeAgent = selectedVibeAgent !== null;
- const effectiveBackend = selectedVibeAgent?.backend || value.routing.agent_backend || defaultBackend;
+ const effectiveBackend = selectedVibeAgent?.backend || value.routing.agent_backend || defaultVibeAgent?.backend || defaultBackend;
const getOpenCodeReasoningOptions = (modelKey: string) => {
const lookup = opencodeOptions?.reasoning_options || {};
diff --git a/vibe/cli.py b/vibe/cli.py
index 54a3fe55e..f1e87622e 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -944,11 +944,16 @@ def _agent_store() -> VibeAgentStore:
return VibeAgentStore()
-def _session_service():
+def _ensure_cli_sqlite_state() -> None:
from storage.importer import ensure_sqlite_state, resolve_primary_platform_from_config
- from storage.sessions_service import SQLiteSessionsService
ensure_sqlite_state(primary_platform=resolve_primary_platform_from_config(paths.get_state_dir()))
+
+
+def _session_service():
+ from storage.sessions_service import SQLiteSessionsService
+
+ _ensure_cli_sqlite_state()
return SQLiteSessionsService(paths.get_sqlite_state_path())
@@ -1174,6 +1179,7 @@ def _resolve_scope_agent_name(session_key: str) -> Optional[str]:
except ValueError:
return None
scope_id = make_scope_id(parsed.platform, parsed.scope_type, parsed.scope_id)
+ _ensure_cli_sqlite_state()
engine = create_sqlite_engine(paths.get_sqlite_state_path())
try:
with engine.connect() as conn: