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.

Merge remote-tracking branch 'origin/master' into codex-integrate-org-into-master

Max240f70a64ace
diff --cc ui/src/components/workbench/ChatPage.tsx
index d78640739,69b21600f..f85657ba1
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@@ -203,11 -205,25 +206,29 @@@ export const ChatPage: React.FC = () =
// true })) — a general signal that this navigation must leave Show Page mode.
const showChatSignal = searchParams.get('view') === 'chat';
const api = useApi();
+ const { capabilities } = useInstanceAuthorization();
+ const [sessionCanChat, setSessionCanChat] = useState(false);
+ const canChat = capabilities.can_chat && sessionCanChat;
+ const canManageShowPage = capabilities.can_manage_instance && capabilities.can_use_system;
const { unreadBySession, markRead: markInboxRead } = useWorkbenchInbox();
+ const { focusedId: foregroundAppWindowId, focusCanvas } = useWindowManager();
+ const isDesktop = useIsDesktop();
+ const [pageActive, setPageActive] = useState(() => readPageActivity());
+ useEffect(() => {
+ const syncPageActivity = () => setPageActive(readPageActivity());
+ document.addEventListener('visibilitychange', syncPageActivity);
+ window.addEventListener('focus', syncPageActivity);
+ window.addEventListener('blur', syncPageActivity);
+ window.addEventListener('pageshow', syncPageActivity);
+ window.addEventListener('pagehide', syncPageActivity);
+ return () => {
+ document.removeEventListener('visibilitychange', syncPageActivity);
+ window.removeEventListener('focus', syncPageActivity);
+ window.removeEventListener('blur', syncPageActivity);
+ window.removeEventListener('pageshow', syncPageActivity);
+ window.removeEventListener('pagehide', syncPageActivity);
+ };
+ }, []);
// The mobile chat surface is a fixed full-screen flex column; this keeps the
// composer glued to the iOS keyboard (settle-then-correct; see the hook).
const chatSurfaceRef = useRef<HTMLDivElement>(null);
@@@ -1343,8 -1379,13 +1386,17 @@@
const bootstrap = await api.getSessionBootstrap(sessionId);
// Dropped if the user switched chats while this load was in flight.
if (sessionId !== sessionIdRef.current) return;
- setSession(bootstrap.session);
+ if (bootstrapIsCurrent()) {
+ setSession(bootstrap.session);
+ } else {
+ // A newer turn-end/activity read won the row race. Keep its route-bearing
+ // snapshot and repair a cold page if that read has not hydrated it yet.
+ void refreshSessionRow();
+ }
++ // Capability comes from the bootstrap payload, not the session-row race
++ // above — set it unconditionally so a lost row race can't strand the
++ // composer disabled for a member who can chat.
+ setSessionCanChat(Boolean(bootstrap.capabilities?.can_chat));
setAgents(bootstrap.agents);
setDefaultAgentName(bootstrap.default_agent_name);
setMessageFontSize(normalizeChatMessageFontSize(bootstrap.config?.ui?.chat_message_font_size));
@@@ -1581,19 -1630,8 +1642,19 @@@
void reconcile();
void refreshQueue();
void syncTurnState({ quiet: true });
- void refreshSessionRowUntilNativeBound();
+ void refreshSessionRow();
},
+ onAuthorizationChanged: () => {
+ const currentSessionId = sessionIdRef.current;
+ if (!currentSessionId) return;
+ setSessionCanChat(false);
+ void api.getSession(currentSessionId, { cache: false })
+ .then((nextSession) => {
+ setSession(nextSession);
+ void refresh();
+ })
+ .catch(() => goBack());
+ },
onConnectionState: (state) => {
const connected = state === 'connected';
setEventStreamConnected(connected);
@@@ -1605,7 -1643,7 +1666,7 @@@
},
});
return disconnect;
- }, [api, sessionId, appendMessage, reconcile, refresh, refreshQueue, syncTurnState, refreshSessionRowUntilNativeBound, markWorking, goBack, ingestActivityRow, scheduleActivityRefresh, dispatchLive]);
- }, [api, sessionId, appendMessage, reconcile, refreshQueue, syncTurnState, refreshSessionRow, markWorking, goBack, ingestActivityRow, scheduleActivityRefresh, dispatchLive]);
++ }, [api, sessionId, appendMessage, reconcile, refresh, refreshQueue, syncTurnState, refreshSessionRow, markWorking, goBack, ingestActivityRow, scheduleActivityRefresh, dispatchLive]);
// Mobile tabs (the common case for IM users) get backgrounded mid-turn; the
// SSE feed can be suspended without a clean reconnect, dropping the reply.
@@@ -2200,11 -2245,30 +2270,34 @@@
// against the cross-process event ordering. Owning this on the mounted route
// also keeps a canceled blocked navigation from clearing unread state early.
useEffect(() => {
- if (historicalWindow || !canChat) return;
++ // Org members without chat capability are viewers; viewing must not
++ // consume the owner's unread state.
++ if (!canChat) return;
+ if (!canMarkConversationRead({
+ pageActive,
+ sessionReady: !loading && session?.id === sessionId,
+ viewResolved: showPageViewResolved,
+ historicalWindow,
+ showPageActive,
+ foregroundAppWindow: isDesktop && foregroundAppWindowId !== null,
+ })) return;
if (sessionId && (unreadBySession[sessionId] ?? 0) > 0) {
void markInboxRead(sessionId);
}
- }, [sessionId, unreadBySession, markInboxRead, historicalWindow, canChat]);
+ }, [
+ sessionId,
+ unreadBySession,
+ markInboxRead,
+ loading,
+ session?.id,
+ showPageViewResolved,
+ historicalWindow,
+ pageActive,
+ showPageActive,
+ isDesktop,
+ foregroundAppWindowId,
++ canChat,
+ ]);
// The Workbench canvas creates the session and hands its first message over
// as router state. Replay it once through the compose path so the agent turn
@@@ -2242,15 -2303,20 +2332,18 @@@
// ``handleApiError`` resolved is Show-Page-worded, which is wrong for a
// rename or a re-route.
setError(isSessionArchivedError(err) ? t('chat.archived.editBlocked') : (errorMessage(err) ?? String(err)));
+ } finally {
+ finishPatch();
+ if (patchedId === sessionIdRef.current) void refreshSessionRow();
}
},
- [api, session, t],
+ [api, session, t, refreshSessionRow],
);
- // Session-level actions share the sidebar/mobile row model. The chat header
- // exposes them only on mobile and intentionally supplies no rename editor, so
- // Rename is absent from this surface. A read-only session yields no actions and
- // an inert requestArchive: every one of
- // them is refused server-side (409 archived / 403 reserved_session), so the
- // header withdraws the ⋯ rather than offering guaranteed failures.
+ // Session-level actions share the sidebar/mobile row model. A read-only or
+ // unauthorized session yields no actions and an inert requestArchive, so the
+ // header withdraws the menu rather than offering guaranteed failures.
+ const titleFieldRef = useRef<TitleFieldHandle | null>(null);
const {
actions: sessionActions,
archiveDialog: sessionArchiveDialog,
@@@ -2453,7 -2521,8 +2553,8 @@@
requests={vaultRequests}
onResolved={refreshVaultRequests}
onProvisionRequestHidden={markVaultRequestHidden}
+ onProvisionRequestDenied={denyVaultProvisionRequest}
- disabled={readOnly}
+ disabled={!writable}
>
{/* Mobile: a FIXED full-screen flex column (the AppShell brand header is
hidden on chat) so the composer has NO scrollable ancestor — that is what