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): close remote owner review gaps

Maxbafc99b0046f
diff --git a/ui/src/App.tsx b/ui/src/App.tsx
index a61deca6a..a41eb38c9 100644
--- a/ui/src/App.tsx
+++ b/ui/src/App.tsx
@@ -56,6 +56,7 @@ import {
isSetupCheckBypassed,
remoteLoginPath,
REMOTE_AUTH_REQUIRED_EVENT,
+ shouldBypassSetupForRemoteOwner,
shouldDeferRemoteAuthRedirect,
} from './lib/remoteAuth';
import { useIsDesktop } from './lib/useIsDesktop';
@@ -318,7 +319,15 @@ const AuthGuard = ({ children }: { children: ReactNode }) => {
const setupReady = typeof setupState?.needs_setup === 'boolean'
? setupState.needs_setup === false
: hasConfiguredPlatformCredentials(config);
- setGuardStatus(!config || !config.mode || !setupReady ? 'needs-setup' : 'ready');
+ if (!config || !config.mode || !setupReady) {
+ if (shouldBypassSetupForRemoteOwner(session)) {
+ setGuardStatus('ready');
+ return;
+ }
+ setGuardStatus('needs-setup');
+ return;
+ }
+ setGuardStatus('ready');
});
}).catch(async (error) => {
if (cancelled) return;
diff --git a/ui/src/components/AppShell.test.tsx b/ui/src/components/AppShell.test.tsx
new file mode 100644
index 000000000..7b34ded10
--- /dev/null
+++ b/ui/src/components/AppShell.test.tsx
@@ -0,0 +1,84 @@
+/* @vitest-environment jsdom */
+
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { cleanup, render, screen } from '@testing-library/react';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+
+import { AppShell } from './AppShell';
+
+vi.hoisted(() => {
+ vi.stubGlobal(
+ 'matchMedia',
+ vi.fn().mockImplementation((query: string) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: vi.fn(),
+ removeListener: vi.fn(),
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ dispatchEvent: vi.fn(),
+ })),
+ );
+});
+
+const api = vi.hoisted(() => ({
+ getConfig: vi.fn(),
+ getMemorySettings: vi.fn(),
+}));
+const status = vi.hoisted(() => ({ state: 'ready' as const }));
+const inbox = vi.hoisted(() => ({ totalUnread: 0 }));
+const instanceAuth = vi.hoisted(() => ({
+ remote: true,
+ capabilities: {
+ can_manage_instance: true,
+ can_use_system: false,
+ can_manage_agents: false,
+ can_manage_projects: false,
+ can_use_skills: false,
+ can_use_vault_secrets: false,
+ can_use_files: false,
+ can_use_terminal: false,
+ },
+}));
+
+vi.mock('../context/ApiContext', () => ({ useApi: () => api }));
+vi.mock('../context/StatusContext', () => ({ useStatus: () => ({ status }) }));
+vi.mock('../context/WorkbenchInboxContext', () => ({ useWorkbenchInbox: () => inbox }));
+vi.mock('../context/InstanceAuthorizationContext', () => ({ useInstanceAuthorization: () => instanceAuth }));
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+beforeEach(() => {
+ api.getConfig.mockResolvedValue({ platforms: { enabled: [] } });
+ api.getMemorySettings.mockResolvedValue({
+ status: 'failed',
+ error: 'memory_settings_remote_only',
+ });
+});
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe('AppShell setup recovery', () => {
+ it('shows the remote-owner recovery card instead of the wizard', async () => {
+ render(
+ <MemoryRouter initialEntries={['/setup']}>
+ <Routes>
+ <Route element={<AppShell />}>
+ <Route path="/setup" element={<div data-testid="wizard">wizard</div>} />
+ </Route>
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ expect(await screen.findByText('setup.remoteOwner.title')).toBeTruthy();
+ expect(screen.getByRole('link', { name: 'setup.remoteOwner.action' }).getAttribute('href')).toBe(
+ '/admin/settings/messaging',
+ );
+ expect(screen.queryByTestId('wizard')).toBeNull();
+ });
+});
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index 8c1474eb4..0d99fa2b1 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -19,6 +19,7 @@ import { VersionBadge } from './VersionBadge';
import { WorkbenchSidebar } from './workbench/WorkbenchSidebar';
import { AppsLauncher } from './AppsLauncher';
import { ErrorBoundary } from './ui/error-boundary';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card';
import { WindowManagerProvider } from '../context/WindowManagerProvider';
import { DockProvider } from '../context/DockProvider';
import { ShowPageDragProvider } from '../context/ShowPageDragProvider';
@@ -231,7 +232,7 @@ export const AppShell: React.FC = () => {
const { t } = useTranslation();
const { status } = useStatus();
const { totalUnread } = useWorkbenchInbox();
- const { capabilities } = useInstanceAuthorization();
+ const { capabilities, remote } = useInstanceAuthorization();
const api = useApi();
const location = useLocation();
const [enabledPlatforms, setEnabledPlatforms] = useState<string[]>([]);
@@ -337,6 +338,27 @@ export const AppShell: React.FC = () => {
return <OrganizationShell />;
}
+ if (location.pathname === '/setup' && remote && capabilities.can_manage_instance) {
+ return (
+ <main className="flex min-h-screen items-center justify-center bg-background p-4 text-foreground">
+ <Card className="w-full max-w-md">
+ <CardHeader>
+ <CardTitle>{t('setup.remoteOwner.title')}</CardTitle>
+ <CardDescription>{t('setup.remoteOwner.body')}</CardDescription>
+ </CardHeader>
+ <CardContent className="space-y-4">
+ <p className="text-sm leading-relaxed text-muted">{t('setup.remoteOwner.hint')}</p>
+ <Button asChild>
+ <Link to={adminLandingPath(capabilities.can_use_system)}>
+ {t('setup.remoteOwner.action')}
+ </Link>
+ </Button>
+ </CardContent>
+ </Card>
+ </main>
+ );
+ }
+
const hasChannelPlatforms = enabledPlatforms.some((platform) => platformSupportsChannels(config, platform));
const modelHubEnabled = modelHubEnabledFromConfig(config);
const isRunning = status.state === 'running';
diff --git a/ui/src/components/settings/SettingsMemoryPage.test.tsx b/ui/src/components/settings/SettingsMemoryPage.test.tsx
index 25b5c0766..710972055 100644
--- a/ui/src/components/settings/SettingsMemoryPage.test.tsx
+++ b/ui/src/components/settings/SettingsMemoryPage.test.tsx
@@ -58,8 +58,16 @@ vi.mock('./memory/MemoryLogPanel', async (loadOriginal) => {
};
});
-vi.mock('./memory/MemoryProfilePanel', () => ({ MemoryProfilePanel: () => null }));
-vi.mock('./memory/MemorySearchPanel', () => ({ MemorySearchPanel: () => null }));
+vi.mock('./memory/MemoryProfilePanel', () => ({
+ MemoryProfilePanel: ({ enabled }: { enabled: boolean }) => (
+ <div data-testid="memory-profile-enabled">{String(enabled)}</div>
+ ),
+}));
+vi.mock('./memory/MemorySearchPanel', () => ({
+ MemorySearchPanel: ({ enabled }: { enabled: boolean }) => (
+ <div data-testid="memory-search-enabled">{String(enabled)}</div>
+ ),
+}));
vi.mock('./memory/MemorySettingsPanel', () => ({ MemorySettingsPanel: () => null }));
const endpoint = {
@@ -290,4 +298,25 @@ describe('SettingsMemoryPage remote administration gate', () => {
expect(await screen.findByText('memory.remoteUnavailable.title')).toBeTruthy();
expect(screen.queryByRole('radio', { name: 'memory.tabs.status' })).toBeNull();
});
+
+ it('derives profile/search enablement from the permitted status read when settings stay local-only', async () => {
+ api.getMemorySettings.mockResolvedValue({
+ status: 'failed',
+ error: 'remote_execution_disabled',
+ });
+ api.getMemoryStatus.mockResolvedValue(readyStatus());
+ api.listDependencies.mockResolvedValue({ ok: true, deps: [{ id: 'memory-runtime', installed: true, status: 'ready' }] });
+ const user = userEvent.setup();
+
+ renderRemoteOwner();
+
+ expect(await screen.findByRole('radio', { name: 'memory.tabs.profile' })).toBeTruthy();
+ expect(screen.queryByText('memory.remoteUnavailable.title')).toBeNull();
+
+ await user.click(screen.getByRole('radio', { name: 'memory.tabs.profile' }));
+ expect(screen.getByTestId('memory-profile-enabled').textContent).toBe('true');
+
+ await user.click(screen.getByRole('radio', { name: 'memory.tabs.search' }));
+ expect(screen.getByTestId('memory-search-enabled').textContent).toBe('true');
+ });
});
diff --git a/ui/src/components/settings/SettingsMemoryPage.tsx b/ui/src/components/settings/SettingsMemoryPage.tsx
index 408480615..cd8ba37b5 100644
--- a/ui/src/components/settings/SettingsMemoryPage.tsx
+++ b/ui/src/components/settings/SettingsMemoryPage.tsx
@@ -78,6 +78,10 @@ export const SettingsMemoryPage: React.FC = () => {
// Forbidden is the backend's "this is not a direct-loopback browser" verdict, and it is
// sticky per resource, so the static state never flickers away on a later request.
const remoteUnavailable = settingsRead.forbidden || statusRead.forbidden || failuresRead.forbidden;
+ // `settings` is local-only, so remote owners derive the broad enablement bit
+ // from the permitted status read instead of letting profile/search stay
+ // permanently "disabled" just because the settings payload is absent.
+ const memoryEnabled = settings?.enabled ?? (statusRead.loaded && status ? status.state !== 'disabled' : false);
// Dependency readiness comes from the authoritative Dependencies source (plan §5), NOT the
// memory status: after a failed enable the backend rolls the setting back to disabled and a
@@ -183,7 +187,7 @@ export const SettingsMemoryPage: React.FC = () => {
// rather than on a panel whose reads and writes it cannot make.
const activeTab = tabs.some((entry) => entry.id === tab) ? tab : 'status';
- const setupStage = memorySetupStage(runtimeInstalled, settings?.enabled ?? null);
+ const setupStage = memorySetupStage(runtimeInstalled, memoryEnabled);
const runtimeRecoveryAvailable = memoryRuntimeRecoveryAvailable(runtimeInstalled, settings !== null);
// Setup and runtime recovery exist to save settings, so they are unreachable
// for a principal that cannot administer Memory at all.
@@ -298,9 +302,9 @@ export const SettingsMemoryPage: React.FC = () => {
/>
)}
- {activeTab === 'profile' && <MemoryProfilePanel enabled={!!settings?.enabled} />}
+ {activeTab === 'profile' && <MemoryProfilePanel enabled={memoryEnabled} />}
- {activeTab === 'search' && <MemorySearchPanel enabled={!!settings?.enabled} />}
+ {activeTab === 'search' && <MemorySearchPanel enabled={memoryEnabled} />}
{activeTab === 'log' && settings ? (
<MemoryLogPanel
diff --git a/ui/src/components/workbench/VaultsPage.test.tsx b/ui/src/components/workbench/VaultsPage.test.tsx
new file mode 100644
index 000000000..75516cd28
--- /dev/null
+++ b/ui/src/components/workbench/VaultsPage.test.tsx
@@ -0,0 +1,99 @@
+/* @vitest-environment jsdom */
+
+import type { ReactNode } from 'react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { cleanup, render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { MemoryRouter } from 'react-router-dom';
+
+import { InstanceAuthorizationContext } from '../../context/InstanceAuthorizationContext';
+import { OWNER_INSTANCE_CAPABILITIES } from '../../lib/sessionInfo';
+import { VaultsPage } from './VaultsPage';
+
+const api = vi.hoisted(() => ({
+ connectWorkbenchEvents: vi.fn(() => () => undefined),
+ getVaultAudit: vi.fn(),
+ getVaultGrants: vi.fn(),
+ listVaultSecrets: vi.fn(),
+}));
+const showToast = vi.hoisted(() => vi.fn());
+const revealProtectedValue = vi.hoisted(() => vi.fn());
+const remoteOwner = {
+ remote: true,
+ instanceRole: 'owner' as const,
+ capabilities: {
+ ...OWNER_INSTANCE_CAPABILITIES,
+ can_use_system: false,
+ },
+};
+
+vi.mock('../../context/ApiContext', async (loadOriginal) => {
+ const original = await loadOriginal<typeof import('../../context/ApiContext')>();
+ return { ...original, useApi: () => api };
+});
+
+vi.mock('../../context/ToastContext', () => ({
+ useToast: () => ({ showToast }),
+}));
+
+vi.mock('../../lib/useProtectedVault', () => ({
+ useProtectedVault: () => ({ revealProtectedValue }),
+}));
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock('./CapabilityTabs', () => ({
+ CapabilityTabs: () => <div data-testid="capability-tabs" />,
+}));
+
+vi.mock('./WorkbenchPageHeader', () => ({
+ WorkbenchPageHeader: ({ title, actions }: { title: ReactNode; actions?: ReactNode }) => (
+ <div>
+ <h1>{title}</h1>
+ <div>{actions}</div>
+ </div>
+ ),
+}));
+
+function renderPage() {
+ return render(
+ <InstanceAuthorizationContext.Provider value={remoteOwner}>
+ <MemoryRouter initialEntries={['/vaults']}>
+ <VaultsPage />
+ </MemoryRouter>
+ </InstanceAuthorizationContext.Provider>,
+ );
+}
+
+beforeEach(() => {
+ api.listVaultSecrets.mockResolvedValue({ secrets: [] });
+ api.getVaultGrants.mockResolvedValue({ grants: [] });
+ api.getVaultAudit.mockResolvedValue({
+ events: [{ id: 'audit-1', event: 'grant_created', secret_name: 'alpha', ts: '2026-08-11T00:00:00Z' }],
+ });
+});
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe('VaultsPage remote audit history', () => {
+ it('keeps the History button reachable for a remote owner and loads audit rows', async () => {
+ const user = userEvent.setup();
+
+ renderPage();
+
+ const history = await screen.findByRole('button', { name: 'vaults.history' });
+ expect(screen.queryByRole('button', { name: 'vaults.add' })).toBeNull();
+
+ await user.click(history);
+
+ await waitFor(() => expect(api.getVaultAudit).toHaveBeenCalledWith({ limit: 50 }));
+ expect(await screen.findByText('vaults.audit.title')).toBeTruthy();
+ expect(await screen.findByText('grant_created')).toBeTruthy();
+ expect(await screen.findByText('alpha')).toBeTruthy();
+ });
+});
diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsx
index d5ef4e872..238747e50 100644
--- a/ui/src/components/workbench/VaultsPage.tsx
+++ b/ui/src/components/workbench/VaultsPage.tsx
@@ -861,7 +861,7 @@ export const VaultsPage: React.FC = () => {
))}
</div>
)}
- {canManage && showAudit && (
+ {canReadVaultState && showAudit && (
<div className="rounded-2xl border border-border bg-surface p-4">
<div className="mb-2 text-sm font-semibold">{t('vaults.audit.title')}</div>
{audit.length === 0 ? (
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 9781e6fdc..aa36416a8 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -3642,7 +3642,13 @@
"subtitle": "A personal memory distilled from your Workbench and private-IM messages — plus durable facts your Agent records while working for you. Review it, search it, or clear it here.",
"setup": {
"runtimeRequired": "Install the Memory runtime first",
- "runtimeRequiredHint": "Install or repair Memory from Dependencies. You can still disable Memory or clear stored data below."
+ "runtimeRequiredHint": "Install or repair Memory from Dependencies. You can still disable Memory or clear stored data below.",
+ "remoteOwner": {
+ "title": "Finish setup on the local machine",
+ "body": "This instance still needs a local setup pass. Remote owners can't use the wizard here because it needs direct access to the machine.",
+ "hint": "Open the Control Panel to keep working, or complete setup on the machine itself.",
+ "action": "Open Control Panel"
+ }
},
"tabs": {
"status": "Status",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 72e0f487d..6916c43ba 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -3642,7 +3642,13 @@
"subtitle": "从你的 Workbench 和私聊消息中提炼出的个人记忆,以及 Agent 在为你工作时记录的长期事实。你可以在这里查看、搜索或清除。",
"setup": {
"runtimeRequired": "请先安装记忆运行时",
- "runtimeRequiredHint": "请前往依赖页面安装或修复记忆运行时。你仍可在下方停用记忆或清除已存储的数据。"
+ "runtimeRequiredHint": "请前往依赖页面安装或修复记忆运行时。你仍可在下方停用记忆或清除已存储的数据。",
+ "remoteOwner": {
+ "title": "请在本地机器完成设置",
+ "body": "这台实例仍需要一次本地设置。远程所有者无法在这里使用向导,因为它需要直接访问机器。",
+ "hint": "请打开控制面板继续操作,或者在机器本机上完成设置。",
+ "action": "打开控制面板"
+ }
},
"tabs": {
"status": "状态",
diff --git a/ui/src/lib/remoteAuth.test.ts b/ui/src/lib/remoteAuth.test.ts
index 3f37ff037..c3596e39c 100644
--- a/ui/src/lib/remoteAuth.test.ts
+++ b/ui/src/lib/remoteAuth.test.ts
@@ -20,6 +20,7 @@ import {
checkRemoteAuthForPath,
deferRemoteAuthRedirect,
remoteLoginPath,
+ shouldBypassSetupForRemoteOwner,
REMOTE_AUTH_REQUIRED_EVENT,
shouldDeferRemoteAuthRedirect,
} from './remoteAuth';
@@ -132,3 +133,29 @@ describe('remote auth navigation', () => {
expect(dispatchEvent.mock.calls[0]?.[0].type).toBe(REMOTE_AUTH_REQUIRED_EVENT);
});
});
+
+describe('setup bypass for remote owners', () => {
+ it('bypasses the setup wizard only for an authenticated remote owner', () => {
+ expect(
+ shouldBypassSetupForRemoteOwner({
+ remote: true,
+ authenticated: true,
+ capabilities: { can_manage_instance: true },
+ }),
+ ).toBe(true);
+ expect(
+ shouldBypassSetupForRemoteOwner({
+ remote: true,
+ authenticated: true,
+ capabilities: { can_manage_instance: false },
+ }),
+ ).toBe(false);
+ expect(
+ shouldBypassSetupForRemoteOwner({
+ remote: false,
+ authenticated: true,
+ capabilities: { can_manage_instance: true },
+ }),
+ ).toBe(false);
+ });
+});
diff --git a/ui/src/lib/remoteAuth.ts b/ui/src/lib/remoteAuth.ts
index 7b52d6d52..1c42f7a02 100644
--- a/ui/src/lib/remoteAuth.ts
+++ b/ui/src/lib/remoteAuth.ts
@@ -41,6 +41,10 @@ export function isSetupCheckBypassed(path: string): boolean {
* (`can_use_system` = not remote and owner).
*/
type RemoteContext = { remote: boolean };
+type RemoteSetupSession = RemoteContext & {
+ authenticated?: boolean;
+ capabilities?: { can_manage_instance?: boolean };
+};
function isTrustedLocal(context: RemoteContext): boolean {
return !context.remote;
@@ -128,6 +132,14 @@ export function canAdministerMemory(context: RemoteContext): boolean {
return isTrustedLocal(context);
}
+/**
+ * Remote owners can skip the global setup wizard: the wizard is a local-only
+ * flow, while the remote shell has its own recovery surface.
+ */
+export function shouldBypassSetupForRemoteOwner(session: RemoteSetupSession | null | undefined): boolean {
+ return !!session?.remote && session.authenticated === true && session.capabilities?.can_manage_instance === true;
+}
+
/**
* Registering and testing a Web Push subscription is local-only: the endpoint is
* caller-supplied and this host later fetches it, so a remote subscription would