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(ui): keep diagnostics from bouncing owners home

rkrkrkk9b0c38a3ba34
diff --git a/ui/src/App.remoteAuth.test.tsx b/ui/src/App.remoteAuth.test.tsx
index 79708e7d2..095890586 100644
--- a/ui/src/App.remoteAuth.test.tsx
+++ b/ui/src/App.remoteAuth.test.tsx
@@ -3,10 +3,12 @@
import { act, cleanup, render, screen, waitFor } from '@testing-library/react';
import { useLayoutEffect } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { MemoryRouter } from 'react-router-dom';
+import { MemoryRouter, Navigate, Route, Routes } from 'react-router-dom';
import { AuthGuard } from './App';
-import { DENIED_INSTANCE_CAPABILITIES } from './lib/sessionInfo';
+import { useInstanceAuthorization } from './context/InstanceAuthorizationContext';
+import { DENIED_INSTANCE_CAPABILITIES, OWNER_INSTANCE_CAPABILITIES } from './lib/sessionInfo';
+import { isOwnerOnlyPath } from './lib/adminNavigation';
import { reportRemoteAuthorizationState, REMOTE_AUTH_STATE_EVENT } from './lib/remoteAuth';
vi.hoisted(() => {
@@ -130,3 +132,69 @@ describe('AuthGuard remote authorization recovery', () => {
expect(screen.getByText('protected shell')).toBeTruthy();
});
});
+
+const CapabilityProbe = () => {
+ const { capabilities } = useInstanceAuthorization();
+ return <div>{capabilities.can_manage_instance ? 'owner-shell' : 'denied-shell'}</div>;
+};
+
+const OwnerOnlyGate = () => {
+ const { capabilities } = useInstanceAuthorization();
+ if (isOwnerOnlyPath('/admin/settings/diagnostics') && !capabilities.can_manage_instance) {
+ return <Navigate to="/" replace />;
+ }
+ return <div>diagnostics-page</div>;
+};
+
+describe('AuthGuard setup-bypass authorization', () => {
+ const localOwnerSession = {
+ remote: false as const,
+ instance_kind: 'personal' as const,
+ instance_role: 'owner' as const,
+ capabilities: OWNER_INSTANCE_CAPABILITIES,
+ };
+
+ it.each(['/admin/settings/diagnostics', '/admin/logs'])(
+ 'keeps the instance owner on %s instead of treating the setup bypass as denied',
+ async (path) => {
+ api.getAuthSession.mockResolvedValue(localOwnerSession);
+ api.getConfig.mockResolvedValue({
+ mode: 'v2',
+ setup_state: { needs_setup: false },
+ });
+
+ render(
+ <MemoryRouter initialEntries={[path]}>
+ <AuthGuard>
+ <CapabilityProbe />
+ </AuthGuard>
+ </MemoryRouter>,
+ );
+
+ expect(await screen.findByText('owner-shell')).toBeTruthy();
+ expect(screen.queryByText('denied-shell')).toBeNull();
+ },
+ );
+
+ it('lets an owner open Diagnostics from Advanced Settings without bouncing home', async () => {
+ api.getAuthSession.mockResolvedValue(localOwnerSession);
+ api.getConfig.mockResolvedValue({
+ mode: 'v2',
+ setup_state: { needs_setup: false },
+ });
+
+ render(
+ <MemoryRouter initialEntries={['/admin/settings/diagnostics']}>
+ <AuthGuard>
+ <Routes>
+ <Route path="/admin/settings/diagnostics" element={<OwnerOnlyGate />} />
+ <Route path="/" element={<div>workbench-home</div>} />
+ </Routes>
+ </AuthGuard>
+ </MemoryRouter>,
+ );
+
+ expect(await screen.findByText('diagnostics-page')).toBeTruthy();
+ expect(screen.queryByText('workbench-home')).toBeNull();
+ });
+});
diff --git a/ui/src/App.tsx b/ui/src/App.tsx
index 759c64afc..2df2674f4 100644
--- a/ui/src/App.tsx
+++ b/ui/src/App.tsx
@@ -504,8 +504,7 @@ export const AuthGuard = ({ children }: { children: ReactNode }) => {
if (guardStatus === 'access-blocked') {
return <AccessBlocked code={blockedCode} />;
}
- if (bypassSetupGuard) return children;
- if (guardStatus === 'needs-setup') {
+ if (guardStatus === 'needs-setup' && !bypassSetupGuard) {
if (location.pathname === '/setup' && authorizationSession) {
return <InstanceAuthorizationProvider session={authorizationSession}>{children}</InstanceAuthorizationProvider>;
}
@@ -526,6 +525,10 @@ export const AuthGuard = ({ children }: { children: ReactNode }) => {
return <Navigate to="/setup" replace />;
}
if (!authorizationSession) {
+ // Diagnostics / Logs remain reachable before a session exists so an
+ // unfinished install can still inspect doctor output. Once the session
+ // lands, wrap it so AppShell does not treat the owner as denied.
+ if (bypassSetupGuard) return children;
return <div className="min-h-screen flex items-center justify-center bg-bg text-text">{t('common.loading')}</div>;
}
return (