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): gate local-only admin settings and Harness mobile tab on trusted locality

Max697ff841c5be
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index 27c842848..d1db72bc5 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -343,12 +343,21 @@ 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 Harness runs entirely on local-only routes (starting with
- // `/api/harness/bootstrap`) and the Library's Show Page controls (visibility,
- // share rotation, icon upload) are local-only too. `can_use_system` is the
- // trusted-local capability (not remote AND owner), so require it as well.
+ // 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}/`),
);
diff --git a/ui/src/components/workbench/CapabilityTabs.test.tsx b/ui/src/components/workbench/CapabilityTabs.test.tsx
new file mode 100644
index 000000000..280e0f773
--- /dev/null
+++ b/ui/src/components/workbench/CapabilityTabs.test.tsx
@@ -0,0 +1,46 @@
+import { renderToStaticMarkup } from 'react-dom/server';
+import { MemoryRouter } from 'react-router-dom';
+import { describe, expect, it } from 'vitest';
+
+import { CapabilityTabs } from './CapabilityTabs';
+import {
+ InstanceAuthorizationContext,
+ type InstanceAuthorizationValue,
+} from '../../context/InstanceAuthorizationContext';
+import { OWNER_INSTANCE_CAPABILITIES } from '../../lib/sessionInfo';
+
+function renderWith(context: InstanceAuthorizationValue, path = '/agents') {
+ return renderToStaticMarkup(
+ <InstanceAuthorizationContext.Provider value={context}>
+ <MemoryRouter initialEntries={[path]}>
+ <CapabilityTabs />
+ </MemoryRouter>
+ </InstanceAuthorizationContext.Provider>,
+ );
+}
+
+const localOwner: InstanceAuthorizationValue = {
+ remote: false,
+ instanceRole: 'owner',
+ capabilities: OWNER_INSTANCE_CAPABILITIES,
+};
+
+describe('CapabilityTabs', () => {
+ it('shows the Harness tab to a trusted-local owner', () => {
+ const markup = renderWith(localOwner);
+ expect(markup).toContain('workbench.modules.harness.title');
+ });
+
+ it('hides the Harness tab from a remote owner even though can_manage_agents is true', () => {
+ // A remote Instance owner keeps can_manage_agents, which is exactly why the
+ // Harness tab needs the trusted-local canUseHarness predicate on top of it:
+ // without it the tab navigates into the AppShell local-only redirect.
+ const remoteOwner: InstanceAuthorizationValue = {
+ ...localOwner,
+ remote: true,
+ };
+ const markup = renderWith(remoteOwner);
+ expect(markup).toContain('workbench.modules.agents.title');
+ expect(markup).not.toContain('workbench.modules.harness.title');
+ });
+});
diff --git a/ui/src/components/workbench/CapabilityTabs.tsx b/ui/src/components/workbench/CapabilityTabs.tsx
index 772b33221..a78532de1 100644
--- a/ui/src/components/workbench/CapabilityTabs.tsx
+++ b/ui/src/components/workbench/CapabilityTabs.tsx
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Activity, Bot, KeyRound, WandSparkles } from 'lucide-react';
import clsx from 'clsx';
import { useInstanceAuthorization } from '../../context/InstanceAuthorizationContext';
+import { canUseHarness } from '../../lib/remoteAuth';
const TABS = [
{ to: '/agents', icon: Bot, key: 'workbench.modules.agents.title' },
@@ -20,9 +21,15 @@ export const CapabilityTabs: React.FC = () => {
const { t } = useTranslation();
const { pathname } = useLocation();
const activeTabRef = useRef<HTMLAnchorElement | null>(null);
- const { capabilities } = useInstanceAuthorization();
+ const { capabilities, remote } = useInstanceAuthorization();
const tabs = TABS.filter(({ to }) => {
- if (to === '/agents' || to === '/harness') return capabilities.can_manage_agents;
+ // Harness is the exception to the owner check: its page opens entirely on
+ // local-only routes (`/api/harness/bootstrap`), so `can_manage_agents`
+ // (which stays true for a remote owner) would navigate a remote owner into
+ // the AppShell local-only redirect. The trusted-local `canUseHarness`
+ // predicate keeps the tab local-only, matching the desktop sidebar.
+ if (to === '/harness') return capabilities.can_manage_agents && canUseHarness({ remote });
+ if (to === '/agents') return capabilities.can_manage_agents;
if (to === '/skills') return capabilities.can_use_skills;
if (to === '/vaults') return capabilities.can_use_vault_secrets;
return false;