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(workbench): address Codex P2s on default-agent routing, rename refresh, sidebar fetch

cyhb5d1cd5a0771
diff --git a/tests/test_ui_session_stream.py b/tests/test_ui_session_stream.py
index 5207582a0..e246e7f51 100644
--- a/tests/test_ui_session_stream.py
+++ b/tests/test_ui_session_stream.py
@@ -154,29 +154,22 @@ def test_non_stream_route_unchanged(isolated_state, tmp_path):
assert payload["text"] == "no stream"
-def test_create_session_defaults_backend_to_config(isolated_state, tmp_path):
- """POST /api/sessions with no ``agent_backend`` falls back to the
- configured ``agents.default_backend`` instead of erroring or pinning
- a hard-coded backend. This is what the Workbench canvas relies on so a
- plain "new chat" routes through the user's configured default.
+def test_create_session_without_backend_defers_to_default_agent(isolated_state, tmp_path):
+ """POST /api/sessions with no ``agent_backend`` must NOT stamp a concrete
+ backend onto the session. A stamped backend is treated by message_handler
+ as an explicit override and bypasses default Vibe Agent resolution, so a
+ plain "new chat" leaves the backend empty and lets the shared resolver
+ pick the configured default agent at dispatch time.
"""
- from core.services import settings as settings_service
from storage import projects_service
from storage.db import create_sqlite_engine
- from vibe.runtime import default_config
from vibe.ui_server import app
engine = create_sqlite_engine()
with engine.begin() as conn:
project = projects_service.create_project(conn, folder_path=str(tmp_path))
- # Seed a config on disk (the UI server's bare load_config() requires the
- # file to exist) and read back the default the route should fall back to.
- expected_backend = settings_service.load_config(
- default_factory=default_config
- ).agents.default_backend
-
client = app.test_client()
headers = csrf_headers(client)
response = client.post(
@@ -185,7 +178,8 @@ def test_create_session_defaults_backend_to_config(isolated_state, tmp_path):
headers=headers,
)
assert response.status_code == 201
- assert response.get_json()["agent_backend"] == expected_backend
+ # Empty/absent backend — resolution is deferred to dispatch, not pinned here.
+ assert not response.get_json().get("agent_backend")
def test_cancel_route_proxies_to_internal_socket(isolated_state, tmp_path):
diff --git a/ui/src/components/workbench/AgentsPage.tsx b/ui/src/components/workbench/AgentsPage.tsx
index 524862197..f3cffc387 100644
--- a/ui/src/components/workbench/AgentsPage.tsx
+++ b/ui/src/components/workbench/AgentsPage.tsx
@@ -162,6 +162,12 @@ export const AgentsPage: React.FC = () => {
refresh();
};
+ // After a rename (clone-then-delete) the list is stale: the old name lingers
+ // and the new one is missing. Refresh and re-select the renamed agent.
+ const onRenamed = (newName: string) => {
+ refresh().then(() => selectAgent(newName));
+ };
+
const onDelete = async () => {
if (!selected || isSystemAgent(selected)) return;
const confirmed = window.confirm(t('agents.deleteConfirm', { name: selected.name }));
@@ -315,6 +321,7 @@ export const AgentsPage: React.FC = () => {
isDefault={defaultName === selected.name}
onChange={updateField}
onSetDefault={onSetDefault}
+ onRenamed={onRenamed}
onDelete={onDelete}
onClose={() => setSelected(null)}
/>
@@ -459,6 +466,7 @@ interface DetailProps {
isDefault: boolean;
onChange: (patch: Partial<VibeAgentFull>) => void;
onSetDefault: () => Promise<void>;
+ onRenamed: (newName: string) => void;
onDelete: () => void;
onClose: () => void;
}
@@ -468,7 +476,7 @@ interface DetailProps {
// System Prompt (collapsible) → footer Run / Delete. Name is editable
// for user agents (rename = create-then-delete since backend keeps name
// as the immutable reference id). System agents lock the name.
-const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, onChange, onSetDefault, onDelete, onClose }) => {
+const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, onChange, onSetDefault, onRenamed, onDelete, onClose }) => {
const { t } = useTranslation();
const api = useApi();
const { showToast } = useToast();
@@ -553,9 +561,9 @@ const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, onChange, o
} else {
showToast('Agent renamed', 'success');
}
- // Parent will refresh the list; the cloned agent shows up as the
- // newly-selected detail row.
- onClose();
+ // Refresh the list and re-select the renamed agent so the old name
+ // drops out and the clone shows as the selected detail row.
+ onRenamed(trimmed);
} catch (err: any) {
showToast(err?.message ?? String(err), 'error');
setName(agent.name);
diff --git a/ui/src/components/workbench/WorkbenchSidebar.tsx b/ui/src/components/workbench/WorkbenchSidebar.tsx
index 149ed200b..5b9a15c24 100644
--- a/ui/src/components/workbench/WorkbenchSidebar.tsx
+++ b/ui/src/components/workbench/WorkbenchSidebar.tsx
@@ -423,22 +423,33 @@ export const WorkbenchSidebar: React.FC = () => {
next.add(projectId);
return next;
});
+ // Whether this project's session list is already cached. If not, we must
+ // NOT seed a partial cache below: toggleExpanded treats any cached entry
+ // as "already loaded" and would never fetch the project's existing
+ // sessions, making them vanish until a full refresh.
+ const alreadyLoaded = sessionsByProject[projectId] !== undefined;
try {
- // Omit agent_backend so the server routes through the configured
- // agents.default_backend (and the project's stored agent/model
- // defaults) rather than a hard-coded backend.
+ // Omit agent_backend so the server defers to the configured default
+ // Vibe Agent rather than pinning a hard-coded backend.
const session = await api.createSession({ project_id: projectId });
- // Optimistically prepend so the user sees it before refetch lands.
- setSessionsByProject((prev) => {
- const existing = prev[projectId] ?? [];
- return { ...prev, [projectId]: [session, ...existing] };
- });
+ if (alreadyLoaded) {
+ // Optimistically prepend so the user sees it before any refetch.
+ setSessionsByProject((prev) => ({
+ ...prev,
+ [projectId]: [session, ...(prev[projectId] ?? [])],
+ }));
+ }
setExpanded((prev) => {
if (prev.has(projectId)) return prev;
const next = new Set(prev);
next.add(projectId);
return next;
});
+ if (!alreadyLoaded) {
+ // Load the full list (which now includes the new session) instead of
+ // seeding a one-item cache that hides the pre-existing sessions.
+ fetchSessions(projectId);
+ }
navigate(`/chat/${encodeURIComponent(session.id)}`);
} catch (err: any) {
// No toast service available here without prop drilling — fall back
@@ -452,7 +463,7 @@ export const WorkbenchSidebar: React.FC = () => {
});
}
},
- [api, navigate],
+ [api, navigate, fetchSessions, sessionsByProject],
);
const onSessionMarkRead = useCallback(
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index b9c653691..9f00967c1 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -2739,14 +2739,13 @@ def sessions_create():
agent_backend = (payload.get("agent_backend") or "").strip()
if not project_id:
return jsonify({"error": "project_id is required"}), 400
- if not agent_backend:
- # Honor the configured global default (agents.default_backend) when the
- # caller doesn't pin a backend. A plain "new chat" from the Workbench
- # canvas should route through whatever the user configured (OpenCode by
- # default), not a hard-coded backend.
- from core.services import settings as settings_service
-
- agent_backend = settings_service.load_config().agents.default_backend
+ # When the caller doesn't pin a backend/agent (a plain "new chat"), leave
+ # agent_backend empty rather than stamping a concrete backend onto the
+ # session. A stamped backend is treated by message_handler as an explicit
+ # legacy override and bypasses resolve_vibe_agent_for_context(), so the
+ # user's configured default Vibe Agent (and its model/system prompt) would
+ # be ignored. Leaving it empty lets the shared resolver pick the default
+ # Vibe Agent — including default_agent_name — at dispatch time.
scope_id = _project_to_scope_id(project_id)
engine = _projects_engine()