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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(authorization): gate every local-only control-panel page on trusted locality
Max41ac9a9dd15a
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsxindex d1db72bc5..8c1474eb4 100644--- a/ui/src/components/AppShell.tsx+++ b/ui/src/components/AppShell.tsx@@ -32,7 +32,12 @@ import logoImg from '../assets/logo.png';import { getEnabledPlatforms, platformSupportsChannels } from '../lib/platforms';import { useViewportHeightVar } from '../lib/useViewportHeightVar';import { OrganizationShell } from '../features/organization/OrganizationShell';-import { isAdvancedSettingsPath, isMemorySettingsPath } from '../lib/adminNavigation';+import {+ adminLandingPath,+ isAdvancedSettingsPath,+ isLocalSystemPath,+ isMemorySettingsPath,+} from '../lib/adminNavigation';type ShellNavItem = {// Optional: a parent that only groups children (no page of its own) omits `to`@@ -343,24 +348,10 @@ export const AppShell: React.FC = () => {(path) => location.pathname === path || location.pathname.startsWith(`${path}/`),);// Owner is not enough for these: `can_manage_instance` stays true for a remote- // Instance owner, but these surfaces run on local-only routes. Harness opens- // entirely on `/api/harness/bootstrap`-style routes; the Library's Show Page- // controls (visibility, share rotation, icon upload) are local-only; the- // service page mutates runtime/local process state; and the platform/backend- // settings pages enter and validate IM credentials and agent CLI paths, whose- // config saves are protected fields rejected by the remote payload filter (or- // `POST /api/settings`, which is local-only). `can_use_system` is the- // trusted-local capability (not remote AND owner), so require it as well —- // otherwise a remote owner renders controls that dead-end in- // `remote_execution_disabled`. Messaging settings are excluded: its saves are- // restricted to remotely-mutable preference fields by the payload filter.- const localSystemPath =- location.pathname.startsWith('/admin/settings/service') ||- location.pathname.startsWith('/admin/settings/platforms') ||- location.pathname.startsWith('/admin/settings/backends') ||- ['/harness', '/apps/library'].some(- (path) => location.pathname === path || location.pathname.startsWith(`${path}/`),- );+ // Instance owner, but every one of them runs on local-only routes. The list+ // and its rationale live in `isLocalSystemPath` so this redirect and the+ // navigation entries below cannot drift apart.+ const localSystemPath = isLocalSystemPath(location.pathname);const resourceUseDenied =(location.pathname.startsWith('/skills') && !capabilities.can_use_skills) ||(location.pathname.startsWith('/vaults') && !capabilities.can_use_vault_secrets);@@ -450,13 +441,28 @@ export const AppShell: React.FC = () => {},];- const items: ShellNavItem[] = shellMode === 'admin' ? adminItems : [];+ // Second half of the trusted-local gate: a page the redirect above withholds+ // must not still be advertised, or a remote owner taps a nav entry and lands+ // back on the Workbench. Recurses into groups (平台凭据 is a child) and drops a+ // group left with nothing to open.+ const withoutLocalSystemEntries = (navItems: ShellNavItem[]): ShellNavItem[] =>+ navItems+ .filter((item) => !item.to || !isLocalSystemPath(item.to))+ .map((item) =>+ item.children ? { ...item, children: withoutLocalSystemEntries(item.children) } : item,+ )+ .filter((item) => item.to || item.onClick || (item.children?.length ?? 0) > 0);+ const visibleAdminItems = capabilities.can_use_system+ ? adminItems+ : withoutLocalSystemEntries(adminItems);++ const items: ShellNavItem[] = shellMode === 'admin' ? visibleAdminItems : [];// A bottom tab bar can't hold the nested admin nav, so mobile keeps a trimmed// bar with Workbench, Control Panel, and More (which opens the full nested nav// sheet). The Organization tab follows the same temporary visibility switch// as every other shell entry point. See ``adminMenuOpen``.- const adminMobileTabs: ShellNavItem[] = [+ const adminMobileTabsAll: ShellNavItem[] = [{ to: '/', label: t('nav.workbench'), icon: Sparkles, variant: 'workbench' },{ to: '/admin/dashboard', label: t('nav.dashboard'), icon: LayoutDashboard },...(ORGANIZATION_NAV_ENABLED@@ -470,14 +476,15 @@ export const AppShell: React.FC = () => {match: (pathname) => isAdvancedSettingsPath(pathname, memoryNavVisible),},];+ const adminMobileTabs = capabilities.can_use_system+ ? adminMobileTabsAll+ : withoutLocalSystemEntries(adminMobileTabsAll);// The More sheet shows the overflow: admin sections not already on the bottom// bar. Keep its filtering aligned with the currently visible primary tabs.- const adminBottomBarPaths = new Set([- '/admin/dashboard',- ...(ORGANIZATION_NAV_ENABLED ? ['/admin/organization/overview'] : []),- '/admin/settings/messaging',- ]);- const adminSheetItems = adminItems+ const adminBottomBarPaths = new Set(+ adminMobileTabs.map((item) => item.to).filter((to): to is string => !!to && to !== '/'),+ );+ const adminSheetItems = visibleAdminItems.filter((item) => !item.to || !adminBottomBarPaths.has(item.to))// Groups start expanded in the sheet (the sheet is transient — show the// children up front). The desktop sidebar keeps its collapse-by-default.@@ -609,7 +616,7 @@ export const AppShell: React.FC = () => {)}{shellMode === 'workbench' && capabilities.can_manage_instance && (<Link- to="/admin/dashboard"+ to={adminLandingPath(capabilities.can_use_system)}title={t('appShell.openControlPanel')}aria-label={t('appShell.openControlPanel')}className="group flex w-11 shrink-0 items-center justify-center rounded-lg border border-border-strong text-foreground transition-colors hover:bg-foreground/[0.04]"diff --git a/ui/src/features/organization/OrganizationShell.tsx b/ui/src/features/organization/OrganizationShell.tsxindex 893d9a6e1..1184c6d17 100644--- a/ui/src/features/organization/OrganizationShell.tsx+++ b/ui/src/features/organization/OrganizationShell.tsx@@ -21,6 +21,8 @@ import clsx from 'clsx';import { Button } from '@/components/ui/button';import { Select } from '@/components/ui/select';+import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';+import { adminLandingPath } from '@/lib/adminNavigation';import { useOrganization } from './context';import { OrganizationProvider } from './OrganizationProvider';@@ -35,9 +37,18 @@ const NAV = [{ path: '/admin/organization/resources', key: 'resources', icon: Building2 },] as const;+// Organization is the surface a REMOTE Instance owner lives in, and the+// Dashboard is trusted-local, so "back to control panel" has to resolve to an+// admin page this caller can actually open instead of bouncing to the Workbench.+function useBackToControlPanelPath(): string {+ const { capabilities } = useInstanceAuthorization();+ return adminLandingPath(capabilities.can_use_system);+}+function GateState() {const { t } = useTranslation();const { gate, signIn, retry } = useOrganization();+ const backToControlPanelPath = useBackToControlPanelPath();if (gate === 'loading' || gate === 'reauthorizing') {return (<div className="grid min-h-[100dvh] place-items-center bg-background p-6 text-center">@@ -95,7 +106,7 @@ function GateState() {const Icon = state.icon;return (<div className="min-h-[100dvh] bg-background p-4 md:p-8">- <Link to="/admin/dashboard" className="inline-flex items-center gap-2 text-[13px] text-muted hover:text-foreground">+ <Link to={backToControlPanelPath} className="inline-flex items-center gap-2 text-[13px] text-muted hover:text-foreground"><ArrowLeft className="size-4" />{t('organization.actions.backToControlPanel')}</Link>@@ -115,6 +126,7 @@ function OrganizationSidebar({ mobile = false, onNavigate }: { mobile?: boolean;const { t } = useTranslation();const location = useLocation();const navigate = useNavigate();+ const backToControlPanelPath = useBackToControlPanelPath();const {organizations,selectedOrganizationId,@@ -131,7 +143,7 @@ function OrganizationSidebar({ mobile = false, onNavigate }: { mobile?: boolean;};return (<div className="flex h-full flex-col bg-surface px-4 py-5">- <Link to="/admin/dashboard" className="flex items-center gap-2 text-[13px] text-muted hover:text-foreground" onClick={onNavigate}>+ <Link to={backToControlPanelPath} className="flex items-center gap-2 text-[13px] text-muted hover:text-foreground" onClick={onNavigate}><ArrowLeft className="size-4" />{t('organization.actions.backToControlPanel')}</Link>diff --git a/ui/src/lib/adminNavigation.test.ts b/ui/src/lib/adminNavigation.test.tsindex f0d1486b7..14c97d212 100644--- a/ui/src/lib/adminNavigation.test.ts+++ b/ui/src/lib/adminNavigation.test.ts@@ -1,6 +1,11 @@import { describe, expect, it } from 'vitest';-import { isAdvancedSettingsPath, isMemorySettingsPath } from './adminNavigation';+import {+ adminLandingPath,+ isAdvancedSettingsPath,+ isLocalSystemPath,+ isMemorySettingsPath,+} from './adminNavigation';describe('isAdvancedSettingsPath', () => {it('defers to the standalone Memory item when that item is visible', () => {@@ -27,6 +32,48 @@ describe('isAdvancedSettingsPath', () => {});});+describe('isLocalSystemPath', () => {+ it('covers every destination whose page runs entirely on local-only routes', () => {+ expect(isLocalSystemPath('/admin/dashboard')).toBe(true);+ expect(isLocalSystemPath('/admin/remote-access')).toBe(true);+ expect(isLocalSystemPath('/admin/settings/service')).toBe(true);+ expect(isLocalSystemPath('/admin/settings/platforms')).toBe(true);+ expect(isLocalSystemPath('/admin/settings/backends')).toBe(true);+ expect(isLocalSystemPath('/harness')).toBe(true);+ expect(isLocalSystemPath('/apps/library')).toBe(true);+ });++ it('matches nested paths under a gated destination', () => {+ expect(isLocalSystemPath('/admin/settings/platforms/slack')).toBe(true);+ expect(isLocalSystemPath('/harness/')).toBe(true);+ });++ it('leaves remotely usable destinations open', () => {+ expect(isLocalSystemPath('/admin/settings/messaging')).toBe(false);+ expect(isLocalSystemPath('/admin/settings/models')).toBe(false);+ expect(isLocalSystemPath('/admin/organization/overview')).toBe(false);+ expect(isLocalSystemPath('/')).toBe(false);+ });++ it('does not match a route that only shares a gated prefix', () => {+ expect(isLocalSystemPath('/admin/dashboards')).toBe(false);+ expect(isLocalSystemPath('/harness-status')).toBe(false);+ expect(isLocalSystemPath('/apps/library-picker')).toBe(false);+ });+});++describe('adminLandingPath', () => {+ it('opens the Dashboard for a trusted-local caller', () => {+ expect(adminLandingPath(true)).toBe('/admin/dashboard');+ });++ it('sends a remote owner to an admin page they can actually use', () => {+ const destination = adminLandingPath(false);+ expect(destination).toBe('/admin/settings/messaging');+ expect(isLocalSystemPath(destination)).toBe(false);+ });+});+describe('isMemorySettingsPath', () => {it('matches the Memory route and nested path boundaries', () => {expect(isMemorySettingsPath('/admin/settings/memory')).toBe(true);diff --git a/ui/src/lib/adminNavigation.ts b/ui/src/lib/adminNavigation.tsindex 1660205af..c9e0bd3be 100644--- a/ui/src/lib/adminNavigation.ts+++ b/ui/src/lib/adminNavigation.ts@@ -4,6 +4,46 @@ const matchesRoute = (pathname: string, route: string): boolean =>export const isMemorySettingsPath = (pathname: string): boolean =>matchesRoute(pathname, '/admin/settings/memory');+/**+ * Destinations whose whole page runs on routes the remote HTTP policy classifies+ * local-only. `can_manage_instance` stays true for a remote Instance owner, so+ * the owner check alone still renders them: the Dashboard immediately requests+ * `/api/doctor`, `/api/logs`, `/api/settings`, `/api/users` and drives+ * `/api/control`; Remote Access drives pair / start / stop / optimize / settings+ * / diagnose (only its status read is remote-permitted); the service, platform+ * and backend settings pages save protected config fields; Harness opens on+ * `/api/harness/bootstrap`; and the Library's Show Page controls are local-only.+ * They therefore need the trusted-local `can_use_system` capability on top,+ * otherwise a remote owner gets partial or empty state and every mutation ends+ * in `remote_execution_disabled`.+ *+ * This is the single source of truth for both halves of the gate — the route+ * redirect and the navigation entries that point at it — so a withheld page can+ * never still be advertised in the sidebar, mobile tabs or the More sheet.+ * Messaging settings are deliberately absent: the payload filter restricts their+ * saves to remotely-mutable preference fields, so they work remotely.+ */+const LOCAL_SYSTEM_ROUTES = [+ '/admin/dashboard',+ '/admin/remote-access',+ '/admin/settings/service',+ '/admin/settings/platforms',+ '/admin/settings/backends',+ '/harness',+ '/apps/library',+];++export const isLocalSystemPath = (pathname: string): boolean =>+ LOCAL_SYSTEM_ROUTES.some((route) => matchesRoute(pathname, route));++/**+ * Where the "Control Panel" entry points. A remote owner cannot open the+ * Dashboard, so send them to the first admin page they can actually use rather+ * than through a redirect that bounces them back to the Workbench.+ */+export const adminLandingPath = (canUseSystem: boolean): string =>+ canUseSystem ? '/admin/dashboard' : '/admin/settings/messaging';+export const isAdvancedSettingsPath = (pathname: string,memoryNavVisible: boolean,