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 Workbench controls on remote instances

Max16252405b5bb
diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.py
index 1dc16fa1d..9f7ca1a1b 100644
--- a/tests/test_instance_authorization.py
+++ b/tests/test_instance_authorization.py
@@ -242,6 +242,84 @@ def test_remote_http_policy_keeps_approved_management_and_read_surfaces(
assert http_authorization_policy(method, path).remote_access == expected
+ ("gate", "method", "path", "expected"),
+ [
+ # canManageSkills: read-only catalog remotely, every mutation local.
+ ("canManageSkills", "GET", "/api/skills", REMOTE_HTTP_ALLOWED),
+ ("canManageSkills", "POST", "/api/skills", REMOTE_HTTP_LOCAL_ONLY),
+ ("canManageSkills", "POST", "/api/skills/askill/update", REMOTE_HTTP_LOCAL_ONLY),
+ ("canManageSkills", "DELETE", "/api/skills/askill", REMOTE_HTTP_LOCAL_ONLY),
+ (
+ "canManageSkills",
+ "POST",
+ "/api/dependencies/askill/install",
+ REMOTE_HTTP_LOCAL_ONLY,
+ ),
+ # canManageVaultSecrets: inventory and audit reads stay remote, mutations
+ # and key material do not.
+ ("canManageVaultSecrets", "GET", "/api/vault/secrets", REMOTE_HTTP_ALLOWED),
+ ("canManageVaultSecrets", "GET", "/api/vault/settings", REMOTE_HTTP_ALLOWED),
+ ("canManageVaultSecrets", "GET", "/api/vault/grants", REMOTE_HTTP_ALLOWED),
+ ("canManageVaultSecrets", "POST", "/api/vault/secrets", REMOTE_HTTP_LOCAL_ONLY),
+ (
+ "canManageVaultSecrets",
+ "PATCH",
+ "/api/vault/secrets/prod",
+ REMOTE_HTTP_LOCAL_ONLY,
+ ),
+ (
+ "canManageVaultSecrets",
+ "DELETE",
+ "/api/vault/secrets/prod",
+ REMOTE_HTTP_LOCAL_ONLY,
+ ),
+ ("canManageVaultSecrets", "POST", "/api/vault/vmk", REMOTE_HTTP_LOCAL_ONLY),
+ # canUseHarness: the page cannot even bootstrap remotely.
+ ("canUseHarness", "GET", "/api/harness/bootstrap", REMOTE_HTTP_LOCAL_ONLY),
+ # canArchiveProjects: list and rename stay remote, archive does not.
+ ("canArchiveProjects", "GET", "/api/projects", REMOTE_HTTP_ALLOWED),
+ (
+ "canArchiveProjects",
+ "PATCH",
+ "/api/projects/proj-1",
+ REMOTE_HTTP_PAYLOAD_FILTERED,
+ ),
+ ("canArchiveProjects", "DELETE", "/api/projects/proj-1", REMOTE_HTTP_LOCAL_ONLY),
+ # canEditProjectInstructions: AGENTS.md reads remotely, saves locally.
+ (
+ "canEditProjectInstructions",
+ "GET",
+ "/api/projects/proj-1/agents-md",
+ REMOTE_HTTP_ALLOWED,
+ ),
+ (
+ "canEditProjectInstructions",
+ "PUT",
+ "/api/projects/proj-1/agents-md",
+ REMOTE_HTTP_LOCAL_ONLY,
+ ),
+ # canEditAgentDefinitions: catalog reads remotely, definition writes locally.
+ ("canEditAgentDefinitions", "GET", "/api/agents", REMOTE_HTTP_ALLOWED),
+ ("canEditAgentDefinitions", "POST", "/api/agents", REMOTE_HTTP_LOCAL_ONLY),
+ ],
+)
+def test_local_only_workbench_gates_match_the_remote_http_policy(
+ gate,
+ method,
+ path,
+ expected,
+) -> None:
+ """Pin the endpoint classifications the Workbench UI gates are derived from.
+
+ `can_manage_instance` / `can_manage_agents` / `can_manage_projects` stay true
+ for a remote Instance owner, so `ui/src/lib/remoteAuth.ts` adds a locality
+ check for every control whose endpoint is local-only. If one of these routes
+ is reclassified, that UI gate is stale and must be revisited with it.
+ """
+ assert http_authorization_policy(method, path).remote_access == expected, gate
+
+
def test_workbench_event_policy_filters_privileged_and_unknown_events() -> None:
viewer = _remote_context("viewer")
editor = _remote_context("editor")
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index 9379194f4..23cca1dda 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -307,7 +307,16 @@ export const AppShell: React.FC = () => {
['/agents', '/harness', '/apps/library'].some(
(path) => location.pathname === path || location.pathname.startsWith(`${path}/`),
);
- const localSystemPath = location.pathname.startsWith('/admin/settings/service');
+ // 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.
+ const localSystemPath =
+ location.pathname.startsWith('/admin/settings/service') ||
+ ['/harness', '/apps/library'].some(
+ (path) => location.pathname === path || location.pathname.startsWith(`${path}/`),
+ );
const resourceUseDenied =
(location.pathname.startsWith('/skills') && !capabilities.can_use_skills) ||
(location.pathname.startsWith('/vaults') && !capabilities.can_use_vault_secrets);
diff --git a/ui/src/components/ui/vault-approval-card.tsx b/ui/src/components/ui/vault-approval-card.tsx
index f7626b1ae..8a343e16d 100644
--- a/ui/src/components/ui/vault-approval-card.tsx
+++ b/ui/src/components/ui/vault-approval-card.tsx
@@ -10,6 +10,8 @@ import {
type VaultSignedOperationContext,
type VaultSourceSelector,
} from '@/context/ApiContext';
+import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';
+import { canManageVaultSecrets } from '@/lib/remoteAuth';
import { partitionTags } from '@/lib/vaultTags';
import { useProtectedVault, type ProtectedUnlockMaterial } from '@/lib/useProtectedVault';
import { SigningAddressList } from './signing-address-list';
@@ -114,6 +116,7 @@ export const VaultApprovalCard: React.FC<{
const { t } = useTranslation();
const api = useApi();
const vault = useProtectedVault();
+ const { remote } = useInstanceAuthorization();
// The request is passed in already hydrated by the UI-audience inbox list
// (`getVaultRequests`, #708), so `card.secret_unlock_material` /
@@ -357,7 +360,13 @@ export const VaultApprovalCard: React.FC<{
);
}
- const approveDisabled = busy || (!isSign && !option);
+ // Approve / deny / sign all drive local-only Vault routes, and
+ // `can_manage_instance` stays true for a remote Instance owner, so a remote
+ // approver would only reach `remote_execution_disabled`. Show the request
+ // read-only there instead — this card also renders inside the chat transcript,
+ // which a remote viewer can read.
+ const canApprove = canManageVaultSecrets({ remote });
+ const approveDisabled = busy || !canApprove || (!isSign && !option);
return (
<div className="flex min-w-0 flex-col gap-4">
@@ -563,7 +572,7 @@ export const VaultApprovalCard: React.FC<{
</span>
) : null}
<div className="ml-auto flex items-center gap-2">
- <Button type="button" variant="outline" onClick={deny} disabled={busy}>
+ <Button type="button" variant="outline" onClick={deny} disabled={busy || !canApprove}>
{t('vaults.approval.deny')}
</Button>
<Button type="button" onClick={isSign ? approveSign : approveAccess} disabled={approveDisabled}>
diff --git a/ui/src/components/workbench/ProjectsPage.tsx b/ui/src/components/workbench/ProjectsPage.tsx
index 5a4c39a0e..cfb5f0f3d 100644
--- a/ui/src/components/workbench/ProjectsPage.tsx
+++ b/ui/src/components/workbench/ProjectsPage.tsx
@@ -25,6 +25,7 @@ import { useInstanceAuthorization } from '../../context/InstanceAuthorizationCon
import type { ProjectSessionsState } from '../../context/WorkbenchProjectsContext';
import type { WorkbenchProject, WorkbenchSession } from '../../context/ApiContext';
import { formatRelativeTime } from '../../lib/relativeTime';
+import { canArchiveProjects, canEditProjectInstructions } from '../../lib/remoteAuth';
import { canCreateLocalProject } from '../../lib/sessionInfo';
import { Badge } from '../ui/badge';
import { Button } from '../ui/button';
@@ -81,7 +82,14 @@ const MobileProjectRow: React.FC<{
}> = ({ project, open, state, onToggle }) => {
const { t } = useTranslation();
const navigate = useNavigate();
- const { capabilities } = useInstanceAuthorization();
+ const { capabilities, remote } = useInstanceAuthorization();
+ // Rename and the Project settings are remote-permitted; archiving is not
+ // (`DELETE /api/projects/{id}` is local-only) even though
+ // `can_manage_projects` stays true for a remote Instance owner.
+ const canArchive = capabilities.can_manage_projects && canArchiveProjects({ remote });
+ // Reading a project's AGENTS.md is remote-permitted but saving it is not, and
+ // this surface is an editor with no read-only mode, so it stays local.
+ const canEditAgentsMd = capabilities.can_manage_projects && canEditProjectInstructions({ remote });
const { renameProject, archiveProject, createSessionForProject } = useWorkbenchProjectsTree();
const [menuOpen, setMenuOpen] = useState(false);
// Guards against a double-tap creating two sessions before navigation unmounts.
@@ -212,7 +220,7 @@ const MobileProjectRow: React.FC<{
>
{t('workbench.projectSettings')}
</MenuItem>
- {project.folder_path && (
+ {project.folder_path && canEditAgentsMd && (
<MenuItem
icon={FileText}
onClick={() => {
@@ -223,7 +231,7 @@ const MobileProjectRow: React.FC<{
{t('workbench.projectEditAgents')}
</MenuItem>
)}
- <MenuItem
+ {canArchive && <MenuItem
icon={Archive}
danger
onClick={async () => {
@@ -234,7 +242,7 @@ const MobileProjectRow: React.FC<{
}}
>
{t('workbench.projectArchive')}
- </MenuItem>
+ </MenuItem>}
</>}
</PopoverContent>
</Popover>}
diff --git a/ui/src/components/workbench/SkillsPage.tsx b/ui/src/components/workbench/SkillsPage.tsx
index e9a2d4019..df3d254e2 100644
--- a/ui/src/components/workbench/SkillsPage.tsx
+++ b/ui/src/components/workbench/SkillsPage.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { ChevronDown, Compass, Download, Funnel, Info, Loader2, Plus, RefreshCw, Search, Terminal, WandSparkles } from 'lucide-react';
+import { ChevronDown, Compass, Download, Funnel, Info, Loader2, Lock, Plus, RefreshCw, Search, Terminal, WandSparkles } from 'lucide-react';
import clsx from 'clsx';
import { useApi } from '../../context/ApiContext';
@@ -18,6 +18,8 @@ import { ProjectPicker } from './skills/ProjectPicker';
import { AddSkillDialog } from './skills/AddSkillDialog';
import { BrowseRegistryDialog } from './skills/BrowseRegistryDialog';
import { errorMessage } from '@/lib/errorMessage';
+import { Badge } from '../ui/badge';
+import { canManageSkills } from '../../lib/remoteAuth';
import { useInstanceAuthorization } from '../../context/InstanceAuthorizationContext';
const skillKey = (s: SkillBrief) => `${s.scope}:${s.name}`;
@@ -26,8 +28,12 @@ export const SkillsPage: React.FC = () => {
const { t } = useTranslation();
const api = useApi();
const { showToast } = useToast();
- const { capabilities } = useInstanceAuthorization();
- const canManage = capabilities.can_manage_instance;
+ const { capabilities, remote } = useInstanceAuthorization();
+ // `can_manage_instance` stays true for a remote Instance owner, but every Skill
+ // mutation (add / upload / registry search / dependency install / update /
+ // remove) and the `askill` update check are local-only, so a remote viewer gets
+ // the read-only catalog `GET /api/skills` already permits.
+ const canManage = capabilities.can_manage_instance && canManageSkills({ remote });
const [scope, setScope] = useState<SkillScope>('global');
const [projects, setProjects] = useState<WorkbenchProject[]>([]);
@@ -284,14 +290,23 @@ export const SkillsPage: React.FC = () => {
<BackendFilter value={backendFilter} onChange={setBackendFilter} />
- {canManage ? <Button type="button" variant="outline" size="xs" onClick={() => setShowBrowse(true)}>
- <Compass className="size-3.5 text-cyan" />
- {t('skills.browseRegistry')}
- </Button> : null}
- {canManage ? <Button type="button" variant="brand" size="xs" onClick={() => setShowAdd(true)}>
- <Plus />
- {t('skills.addSkill')}
- </Button> : null}
+ {canManage ? (
+ <>
+ <Button type="button" variant="outline" size="xs" onClick={() => setShowBrowse(true)}>
+ <Compass className="size-3.5 text-cyan" />
+ {t('skills.browseRegistry')}
+ </Button>
+ <Button type="button" variant="brand" size="xs" onClick={() => setShowAdd(true)}>
+ <Plus />
+ {t('skills.addSkill')}
+ </Button>
+ </>
+ ) : remote ? (
+ <Badge variant="secondary" title={t('skills.remoteReadOnlyHint')}>
+ <Lock className="size-3" />
+ {t('skills.remoteReadOnly')}
+ </Badge>
+ ) : null}
</div>
{scope === 'project' && activeProject?.folder_path ? (
diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsx
index 72f403b82..d5ef4e872 100644
--- a/ui/src/components/workbench/VaultsPage.tsx
+++ b/ui/src/components/workbench/VaultsPage.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
-import { AlertTriangle, Clock, Copy, Eye, Globe, History, Inbox, KeyRound, Link2, Loader2, MoreHorizontal, Pencil, Plus, Puzzle, RefreshCw, Settings, ShieldCheck, Tag, Trash2, Wallet, X } from 'lucide-react';
+import { AlertTriangle, Clock, Copy, Eye, Globe, History, Inbox, KeyRound, Link2, Loader2, Lock, MoreHorizontal, Pencil, Plus, Puzzle, RefreshCw, Settings, ShieldCheck, Tag, Trash2, Wallet, X } from 'lucide-react';
import type { TFunction } from 'i18next';
import { useTranslation } from 'react-i18next';
import { CapabilityTabs } from './CapabilityTabs';
@@ -21,6 +21,7 @@ import { vaultRequestSessionDisplay } from '../ui/vault-request-session';
import { VaultRequestSessionLink } from '../ui/vault-request-session-link';
import { VaultSecretDialog } from '../ui/vault-secret-dialog';
import { VaultSettingsDialog } from '../ui/vault-settings-dialog';
+import { canManageVaultSecrets } from '../../lib/remoteAuth';
import { useProtectedVault } from '../../lib/useProtectedVault';
import { useVaultRequestRefresh } from '../../lib/useVaultRequestRefresh';
import { useInstanceAuthorization } from '../../context/InstanceAuthorizationContext';
@@ -231,7 +232,9 @@ function describeGrant(g: VaultGrant, t: TFunction): { Icon: typeof KeyRound; la
* and an inline × to revoke. A grant is a fixed protected set keyed by grant_id — the chip
* summarizes its `source_selector`, never a group.
*/
-const GrantChip: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: VaultGrant) => void }> = ({
+// ``onRevoke`` is omitted when revocation is unavailable (remote access: the
+// revoke route is local-only), which renders the chip read-only.
+const GrantChip: React.FC<{ grant: VaultGrant; now: number; onRevoke?: (grant: VaultGrant) => void }> = ({
grant: g,
now,
onRevoke,
@@ -260,14 +263,16 @@ const GrantChip: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: Va
<span className={cn('font-mono tabular-nums', rem.urgent ? 'text-warning' : 'text-mint/80')}>
{rem.expired ? t('vaults.grants.expired') : chipCountdown(rem)}
</span>
- <button
- type="button"
- onClick={() => onRevoke(g)}
- aria-label={t('vaults.grants.revoke')}
- className="flex size-4 items-center justify-center rounded-full text-mint/70 transition-colors hover:bg-mint/15 hover:text-mint"
- >
- <X className="size-3" />
- </button>
+ {onRevoke ? (
+ <button
+ type="button"
+ onClick={() => onRevoke(g)}
+ aria-label={t('vaults.grants.revoke')}
+ className="flex size-4 items-center justify-center rounded-full text-mint/70 transition-colors hover:bg-mint/15 hover:text-mint"
+ >
+ <X className="size-3" />
+ </button>
+ ) : null}
</span>
);
};
@@ -484,8 +489,15 @@ export const VaultsPage: React.FC = () => {
const api = useApi();
const { showToast } = useToast();
const vault = useProtectedVault();
- const { capabilities } = useInstanceAuthorization();
- const canManage = capabilities.can_manage_instance;
+ const { capabilities, remote } = useInstanceAuthorization();
+ // `can_manage_instance` stays true for a remote Instance owner, but every Vault
+ // mutation (create / edit / delete / reveal, settings save, request fulfil or
+ // deny, grant revoke, sign) and every key-material read the lock indicator
+ // needs (`vmk`, `pubkey`, `sandbox/root-metadata`) is local-only. Remote owners
+ // therefore keep the reads the policy permits — inventory, tags, settings,
+ // grants, audit — and lose the controls that would dead-end.
+ const canManage = capabilities.can_manage_instance && canManageVaultSecrets({ remote });
+ const canReadVaultState = capabilities.can_manage_instance;
const [searchParams, setSearchParams] = useSearchParams();
const [secrets, setSecrets] = useState<VaultSecret[]>([]);
const [grants, setGrants] = useState<VaultGrant[]>([]);
@@ -523,7 +535,7 @@ export const VaultsPage: React.FC = () => {
} finally {
setLoading(false);
}
- if (!canManage) {
+ if (!canReadVaultState) {
setGrants([]);
return;
}
@@ -536,7 +548,7 @@ export const VaultsPage: React.FC = () => {
} catch {
setGrants([]);
}
- }, [api, canManage]);
+ }, [api, canReadVaultState]);
useEffect(() => {
refresh();
@@ -734,7 +746,7 @@ export const VaultsPage: React.FC = () => {
actions={
<>
{canManage ? <VaultLockIndicator className="max-sm:order-last max-sm:w-full max-sm:justify-between" /> : null}
- {canManage ? <Button
+ {canReadVaultState ? <Button
variant={showAudit ? 'secondary' : 'ghost'}
size="icon"
className="max-sm:border max-sm:border-border max-sm:bg-surface"
@@ -761,10 +773,17 @@ export const VaultsPage: React.FC = () => {
>
<RefreshCw className="size-4" />
</Button>
- {canManage ? <Button className="max-sm:flex-1" onClick={() => setAdding(true)}>
- <Plus className="size-4" />
- {t('vaults.add')}
- </Button> : null}
+ {canManage ? (
+ <Button className="max-sm:flex-1" onClick={() => setAdding(true)}>
+ <Plus className="size-4" />
+ {t('vaults.add')}
+ </Button>
+ ) : remote ? (
+ <Badge variant="secondary" title={t('vaults.remoteReadOnlyHint')}>
+ <Lock className="size-3" />
+ {t('vaults.remoteReadOnly')}
+ </Badge>
+ ) : null}
</>
}
/>
@@ -772,7 +791,7 @@ export const VaultsPage: React.FC = () => {
<div className="rounded-xl border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive">{error}</div>
)}
{canManage ? <PendingRequestsSection onResolved={refresh} focusRequestId={focusRequestId} onFocusRequestOpened={clearFocusedRequest} /> : null}
- {canManage && grants.length > 0 && (
+ {canReadVaultState && grants.length > 0 && (
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2 px-1">
<ShieldCheck className="size-4 text-mint" />
@@ -782,7 +801,7 @@ export const VaultsPage: React.FC = () => {
</div>
<div className="flex flex-wrap gap-2">
{grants.map((g) => (
- <GrantChip key={g.id} grant={g} now={now} onRevoke={onRevokeGrant} />
+ <GrantChip key={g.id} grant={g} now={now} onRevoke={canManage ? onRevokeGrant : undefined} />
))}
</div>
</div>
diff --git a/ui/src/components/workbench/WorkbenchSidebar.tsx b/ui/src/components/workbench/WorkbenchSidebar.tsx
index a53ab17f4..ee8d044d4 100644
--- a/ui/src/components/workbench/WorkbenchSidebar.tsx
+++ b/ui/src/components/workbench/WorkbenchSidebar.tsx
@@ -37,6 +37,7 @@ import { SESSION_ROW_MENU_POSITION_CLASS, sessionRowActionPaddingClass } from '.
import { SessionActionMenuContent, SessionActionsTrigger } from './sessionActions';
import { useSessionActions } from './useSessionActions';
import { formatRelativeTime } from '../../lib/relativeTime';
+import { canArchiveProjects, canEditProjectInstructions, canUseHarness } from '../../lib/remoteAuth';
import { canCreateLocalProject } from '../../lib/sessionInfo';
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from '../ui/popover';
import { Button } from '../ui/button';
@@ -394,6 +395,12 @@ const ProjectRow: React.FC<{
canChat: boolean;
canManageMetadata: boolean;
canManageProjects: boolean;
+ /** Archiving is local-only (`DELETE /api/projects/{id}`), unlike rename. */
+ canArchive: boolean;
+ /** The Editor app is a trusted-local surface. */
+ canOpenInEditor: boolean;
+ /** Saving a project's AGENTS.md is local-only; the dialog has no read-only mode. */
+ canEditAgentsMd: boolean;
unreadBySession: Record<string, number>;
onRename: (next: string) => Promise<void>;
onArchive: () => Promise<void>;
@@ -411,6 +418,9 @@ const ProjectRow: React.FC<{
canChat,
canManageMetadata,
canManageProjects,
+ canArchive,
+ canOpenInEditor,
+ canEditAgentsMd,
unreadBySession,
onRename,
onArchive,
@@ -532,7 +542,7 @@ const ProjectRow: React.FC<{
<Settings2 className="size-3 text-muted" />
{t('workbench.projectSettings')}
</button>
- {project.folder_path && (
+ {project.folder_path && canEditAgentsMd && (
<button
type="button"
onClick={() => {
@@ -545,7 +555,7 @@ const ProjectRow: React.FC<{
{t('workbench.projectEditAgents')}
</button>
)}
- {project.folder_path && (
+ {project.folder_path && canOpenInEditor && (
<button
type="button"
onClick={() => {
@@ -560,20 +570,22 @@ const ProjectRow: React.FC<{
{t('workbench.projectOpenInEditor')}
</button>
)}
- <button
- type="button"
- onClick={async () => {
- setMenuOpen(false);
- const ok = window.confirm(
- t('workbench.projectArchiveConfirm', { name: project.display_name }),
- );
- if (ok) await onArchive();
- }}
- className="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12px] text-pink transition hover:bg-pink/[0.08]"
- >
- <Archive className="size-3" />
- {t('workbench.projectArchive')}
- </button>
+ {canArchive && (
+ <button
+ type="button"
+ onClick={async () => {
+ setMenuOpen(false);
+ const ok = window.confirm(
+ t('workbench.projectArchiveConfirm', { name: project.display_name }),
+ );
+ if (ok) await onArchive();
+ }}
+ className="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12px] text-pink transition hover:bg-pink/[0.08]"
+ >
+ <Archive className="size-3" />
+ {t('workbench.projectArchive')}
+ </button>
+ )}
</PopoverContent>
</Popover>}
{canChat && <button
@@ -648,10 +660,14 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp
const { t } = useTranslation();
const navigate = useNavigate();
const authorizeRouteAction = useUnsavedChangesActionGuard();
- const { capabilities } = useInstanceAuthorization();
+ const { capabilities, remote } = useInstanceAuthorization();
const canCreateProject = canCreateLocalProject(capabilities);
const capabilityNav = CAPABILITY_NAV.filter(({ to }) => {
- if (to === '/agents' || to === '/harness') return capabilities.can_manage_agents;
+ // Harness is trusted-local: the page opens on `/api/harness/bootstrap` and
+ // every task/watch/run route it drives is local-only, while
+ // `can_manage_agents` stays true for a remote Instance owner.
+ 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;
@@ -911,6 +927,9 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp
canChat={capabilities.can_chat && project.capabilities.can_chat}
canManageMetadata={project.capabilities.can_chat}
canManageProjects={capabilities.can_manage_projects}
+ canArchive={capabilities.can_manage_projects && canArchiveProjects({ remote })}
+ canOpenInEditor={capabilities.can_use_files}
+ canEditAgentsMd={capabilities.can_manage_projects && canEditProjectInstructions({ remote })}
unreadBySession={unreadBySession}
onRename={(next) => renameProject(project.id, next)}
onArchive={() => archiveProject(project.id)}
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index b1ece7c9e..0a46f5db8 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -704,7 +704,7 @@ export type ApiContextType = {
opts?: { limit?: number; includeArchived?: boolean },
) => Promise<MessageSearchResult>;
sendSessionMessage: (sessionId: string, payload: { text?: string; content?: Record<string, unknown>; metadata?: Record<string, unknown>; author_id?: string; author_name?: string }) => Promise<WorkbenchMessage>;
- markSessionRead: (sessionId: string, untilMessageId?: string) => Promise<{ updated: number; unread_counts: Record<string, number>; unread_by_session: Record<string, number> }>;
+ markSessionRead: (sessionId: string, untilMessageId?: string, opts?: { handleError?: boolean }) => Promise<{ updated: number; unread_counts: Record<string, number>; unread_by_session?: Record<string, number> }>;
cancelSession: (
sessionId: string,
) => Promise<{
@@ -3232,10 +3232,11 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
},
sendSessionMessage: (sessionId, payload) =>
postJson(`/api/sessions/${encodeURIComponent(sessionId)}/messages`, payload),
- markSessionRead: (sessionId, untilMessageId) =>
+ markSessionRead: (sessionId, untilMessageId, opts) =>
postJson(
`/api/sessions/${encodeURIComponent(sessionId)}/mark-read`,
untilMessageId ? { until_message_id: untilMessageId } : {},
+ opts,
),
cancelSession: async (sessionId) => {
const { res, payloadJson } = await requestJson(`/api/sessions/${encodeURIComponent(sessionId)}/cancel`, {
diff --git a/ui/src/context/WorkbenchInboxProvider.tsx b/ui/src/context/WorkbenchInboxProvider.tsx
index 5df6b1506..68f873176 100644
--- a/ui/src/context/WorkbenchInboxProvider.tsx
+++ b/ui/src/context/WorkbenchInboxProvider.tsx
@@ -113,11 +113,19 @@ export const WorkbenchInboxProvider = ({ children }: { children: ReactNode }) =>
const markRead = useCallback(
async (sessionId: string, untilMessageId?: string) => {
- const result = await api.markSessionRead(sessionId, untilMessageId);
+ // Clearing unread is best-effort, so a failure must not raise an error
+ // toast: `POST /api/sessions/{id}/mark-read` is local-only, and a remote
+ // viewer reading a session it is allowed to read auto-clears unread on
+ // view. The mark-read CONTROLS are already trusted-local (`can_chat`);
+ // this keeps the automatic write from surfacing
+ // `remote_execution_disabled` to a legitimate remote reader.
+ const result = await api.markSessionRead(sessionId, untilMessageId, { handleError: false });
// The unread map is authoritative for badges; the card's unread styling
// derives from it, so clearing here clears the dot without touching the
- // feed order (a read doesn't change last activity).
- applyUnreadMap(result.unread_by_session ?? {});
+ // feed order (a read doesn't change last activity). A rejected write
+ // carries no map — leave the badges as they are rather than blanking them.
+ if (!result?.unread_by_session) return;
+ applyUnreadMap(result.unread_by_session);
},
[api, applyUnreadMap],
);
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index ff6773845..c2adcb6a1 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -2837,6 +2837,8 @@
"discardConfirm": "You have unsaved changes. Close and discard them?"
},
"skills": {
+ "remoteReadOnly": "Read-only",
+ "remoteReadOnlyHint": "The Skill catalog is read-only over remote access. Open Avibe on the machine to add, update, or remove Skills.",
"title": "Skills",
"subtitle": "Manage global and project skills across your agent backends · powered by askill.",
"scopeGlobal": "Global",
@@ -3350,6 +3352,8 @@
}
},
"vaults": {
+ "remoteReadOnly": "Read-only",
+ "remoteReadOnlyHint": "The Vault is read-only over remote access. Open Avibe on the machine to add, edit, reveal, or approve secrets.",
"title": "Vaults",
"subtitle": "Give your AI agents secrets — their values never enter the context.",
"add": "Add secret",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 5ae15c01c..7a19e02a4 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -2837,6 +2837,8 @@
"discardConfirm": "有未保存的修改,确定关闭并丢弃吗?"
},
"skills": {
+ "remoteReadOnly": "只读",
+ "remoteReadOnlyHint": "远程访问下技能目录为只读。请在运行 Avibe 的机器上打开以添加、更新或移除技能。",
"title": "技能",
"subtitle": "跨各 Agent 后端管理全局与项目级技能 · 基于 askill。",
"scopeGlobal": "全局",
@@ -3350,6 +3352,8 @@
}
},
"vaults": {
+ "remoteReadOnly": "只读",
+ "remoteReadOnlyHint": "远程访问下 Vault 为只读。请在运行 Avibe 的机器上打开以添加、编辑、查看或审批密钥。",
"title": "保险库",
"subtitle": "为你的 AI Agent 提供密钥,永不进入上下文。",
"add": "添加密钥",
diff --git a/ui/src/lib/remoteAuth.test.ts b/ui/src/lib/remoteAuth.test.ts
index ee125c29b..0fe6426f8 100644
--- a/ui/src/lib/remoteAuth.test.ts
+++ b/ui/src/lib/remoteAuth.test.ts
@@ -8,7 +8,12 @@ const platform = vi.hoisted(() => ({
vi.mock('./platform', () => platform);
import {
+ canArchiveProjects,
canEditAgentDefinitions,
+ canEditProjectInstructions,
+ canManageSkills,
+ canManageVaultSecrets,
+ canUseHarness,
checkRemoteAuthForPath,
deferRemoteAuthRedirect,
remoteLoginPath,
@@ -26,6 +31,28 @@ describe('agent definition editing', () => {
});
});
+// Every Workbench control whose endpoint the remote HTTP policy classifies
+// local-only needs this locality check on top of its capability, because
+// `can_manage_instance` / `can_manage_agents` / `can_manage_projects` stay true
+// for a remote Instance owner.
+describe('local-only workbench controls', () => {
+ const predicates = {
+ canManageSkills,
+ canManageVaultSecrets,
+ canUseHarness,
+ canArchiveProjects,
+ canEditProjectInstructions,
+ };
+
+ it.each(Object.entries(predicates))('keeps %s available on a local instance', (_name, predicate) => {
+ expect(predicate({ remote: false })).toBe(true);
+ });
+
+ it.each(Object.entries(predicates))('withholds %s on a remote instance', (_name, predicate) => {
+ expect(predicate({ remote: true })).toBe(false);
+ });
+});
+
describe('remote auth navigation', () => {
beforeEach(() => {
platform.isIosDevice.mockReturnValue(false);
diff --git a/ui/src/lib/remoteAuth.ts b/ui/src/lib/remoteAuth.ts
index 4b7a430e8..51708ea99 100644
--- a/ui/src/lib/remoteAuth.ts
+++ b/ui/src/lib/remoteAuth.ts
@@ -28,6 +28,24 @@ export function isSetupCheckBypassed(path: string): boolean {
return SETUP_CHECK_BYPASS_PATHS.has(path);
}
+/**
+ * Locality half of a Workbench control gate.
+ *
+ * `can_manage_instance` / `can_manage_agents` / `can_manage_projects` stay true
+ * for a remote Instance owner, so a role check alone still renders controls whose
+ * endpoints the remote HTTP policy classifies local-only — they dead-end in
+ * `remote_execution_disabled`. Every predicate below is that missing locality
+ * check; combine it with the capability that already guards the surface locally
+ * (`canManageSkills({ remote }) && capabilities.can_manage_instance`), the same
+ * shape as the trusted-local capabilities the backend derives
+ * (`can_use_system` = not remote and owner).
+ */
+type RemoteContext = { remote: boolean };
+
+function isTrustedLocal(context: RemoteContext): boolean {
+ return !context.remote;
+}
+
/**
* Agent definition editing is local-only. The remote HTTP policy permits Agent
* detail reads and organization onboarding, and `/api/global-prompts` is local
@@ -36,10 +54,58 @@ export function isSetupCheckBypassed(path: string): boolean {
* read-only Agent catalog; onboarding stays available because it is separately
* permitted.
*/
-export function canEditAgentDefinitions(context: { remote: boolean }): boolean {
- return !context.remote;
+export function canEditAgentDefinitions(context: RemoteContext): boolean {
+ return isTrustedLocal(context);
+}
+
+/**
+ * Skill management is local-only: `GET /api/skills` is the only remote-permitted
+ * Skill route, while add / upload / preview / registry search / dependency
+ * install / update / remove are all local. Remote instances therefore get a
+ * read-only Skill catalog.
+ */
+export function canManageSkills(context: RemoteContext): boolean {
+ return isTrustedLocal(context);
+}
+
+/**
+ * Vault management is local-only. The inventory, tags, settings, pending
+ * requests, grants and audit reads are remote-permitted, but every mutation
+ * (create / edit / delete a secret, reveal, settings save, request fulfil/deny,
+ * grant revoke, sign) and every key-material read (`vmk`, `pubkey`,
+ * `sandbox/root-metadata`, WebAuthn factor options) is local. Remote instances
+ * therefore get a read-only Vault.
+ */
+export function canManageVaultSecrets(context: RemoteContext): boolean {
+ return isTrustedLocal(context);
+}
+
+/**
+ * Harness is local-only: the page opens on `/api/harness/bootstrap` and every
+ * task / watch / run route it drives is local, so the whole surface — route and
+ * navigation entry — is unavailable remotely.
+ */
+export function canUseHarness(context: RemoteContext): boolean {
+ return isTrustedLocal(context);
+}
+
+/**
+ * Archiving a Project is local-only (`DELETE /api/projects/{id}`), unlike the
+ * remote-permitted Project list, create and rename.
+ */
+export function canArchiveProjects(context: RemoteContext): boolean {
+ return isTrustedLocal(context);
}
+/**
+ * Reading a Project's `AGENTS.md` is remote-permitted but saving it is
+ * local-only, so remote viewers get the instructions read-only.
+ */
+export function canEditProjectInstructions(context: RemoteContext): boolean {
+ return isTrustedLocal(context);
+}
+
+
export async function checkRemoteAuthForPath<Session extends RemoteSession>(
path: string,
getSession: () => Promise<Session>,