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): align pending fork UI state

cyha8a453333be5
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 1ce9c0b20..10cd88deb 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -1239,10 +1239,16 @@ const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultA
// Idle blank-backend rows with a native (legacy, pre-backfill) stay enabled:
// the server allows their one-time "initial pin".
const concreteBackend = session.agent_backend?.trim() || null;
- const backendLocked = Boolean(session.native_session_id) || working;
- const pinnedBackend = backendLocked ? concreteBackend : null;
+ const pendingForkBackend =
+ !session.native_session_id &&
+ session.metadata?.created_via === 'session_fork' &&
+ typeof session.metadata?.fork_source_backend === 'string'
+ ? session.metadata.fork_source_backend.trim() || null
+ : null;
+ const backendLocked = Boolean(session.native_session_id) || working || Boolean(pendingForkBackend);
+ const pinnedBackend = pendingForkBackend ?? (backendLocked ? concreteBackend : null);
const canClearToDefault = !backendLocked;
- const pickerDisabled = working && !concreteBackend;
+ const pickerDisabled = working && !concreteBackend && !pendingForkBackend;
const defaultRoute = defaultAgent
? {
agent_name: defaultAgent.name,
diff --git a/ui/src/context/WorkbenchProjectsContext.tsx b/ui/src/context/WorkbenchProjectsContext.tsx
index eea7fd577..7d1603e9f 100644
--- a/ui/src/context/WorkbenchProjectsContext.tsx
+++ b/ui/src/context/WorkbenchProjectsContext.tsx
@@ -322,6 +322,19 @@ export const WorkbenchProjectsProvider: React.FC<{ children: ReactNode }> = ({ c
}
}, [api, applyBootstrapSessions, queueReconcile, reconcileSessions]);
+ const refreshCachedSessionRow = useCallback(async (sessionId: string) => {
+ const needsRefresh = Object.values(sessionsRef.current).some((state) =>
+ state.sessions?.some((session) => session.id === sessionId && !session.native_session_id),
+ );
+ if (!needsRefresh) return;
+ try {
+ const updated = await api.getSession(sessionId, { cache: false });
+ setSessions((prev) => patchSessionRow(prev, sessionId, () => updated));
+ } catch {
+ /* best-effort: reconnect reconcile will refresh the row later */
+ }
+ }, [api]);
+
// Load the first page (append=false) or the next page (append=true) of a
// project's sessions, with dedupe + per-project serialisation.
const fetchSessions = useCallback(
@@ -405,10 +418,18 @@ export const WorkbenchProjectsProvider: React.FC<{ children: ReactNode }> = ({ c
setSessions((prev) =>
patchSessionRow(prev, session_id, (s) => (s.agent_status === agent_status ? s : { ...s, agent_status })),
);
+ if (agent_status !== 'running') void refreshCachedSessionRow(session_id);
+ },
+ onTurnEnd: ({ session_id }) => {
+ // The first turn can bind the native_session_id server-side, but the
+ // status event only carries the dot state. Refresh the cached row so
+ // actions gated on native binding, such as Fork session, unlock without
+ // waiting for a full sidebar reload.
+ void refreshCachedSessionRow(session_id);
},
});
return disconnect;
- }, [api, reconcileProjectTree, reconcileSessions]);
+ }, [api, reconcileProjectTree, reconcileSessions, refreshCachedSessionRow]);
const toggleExpanded = useCallback(
(projectId: string) => {