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(vault): skip sandbox warmup in desktop handoffs (#2931)

Call White40cca9b1912a
diff --git a/ui/src/components/ui/vault-approval-card.tsx b/ui/src/components/ui/vault-approval-card.tsx
index 2d75cc8ff..6b0a0c79e 100644
--- a/ui/src/components/ui/vault-approval-card.tsx
+++ b/ui/src/components/ui/vault-approval-card.tsx
@@ -273,10 +273,10 @@ export const VaultApprovalCard: React.FC<{
const preparing = !isDelete && !busy && (!sandboxReady || bindings.pending);
useEffect(() => {
- if (needsProtectedApproval) void vault.refresh();
+ if (needsProtectedApproval && !approveInBrowser) void vault.refresh();
// vault.refresh is stable (useCallback); only re-check when protected handling becomes required.
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [needsProtectedApproval]);
+ }, [needsProtectedApproval, approveInBrowser]);
const finish = useCallback(
(run: () => Promise<void>) => {
diff --git a/ui/src/components/ui/vault-secret-fields-editor.tsx b/ui/src/components/ui/vault-secret-fields-editor.tsx
index ad985c123..de11d3cd1 100644
--- a/ui/src/components/ui/vault-secret-fields-editor.tsx
+++ b/ui/src/components/ui/vault-secret-fields-editor.tsx
@@ -5,7 +5,7 @@ import { useApi, type VaultFieldValuePayload, type VaultSecret } from '@/context
import { sealBlindBox, standardCreateBlindBoxContext } from '@/lib/vaultCrypto';
import { vaultErrorMessage } from '@/lib/vaultErrors';
import { useProtectedVault } from '@/lib/useProtectedVault';
-import { openVaultsInBrowser } from '@/lib/vaultBrowserHandoff';
+import { openVaultsInBrowser, vaultPasskeyNeedsBrowser } from '@/lib/vaultBrowserHandoff';
import { MAX_VAULT_FIELDS, vaultDefaultField, vaultFieldNameIssue, vaultFieldNames, vaultRecordName } from '@/lib/vaultFields';
import { Button } from './button';
import {
@@ -74,14 +74,15 @@ export function VaultSecretFieldsEditor({
const fields = vaultFieldNames(current);
const defaultField = vaultDefaultField(current);
const isProtected = current.protection === 'protected';
+ const passkeyNeedsBrowser = vaultPasskeyNeedsBrowser();
const locked = disabled || busy;
const fieldsCorrupt = current.fields_state === 'corrupt';
const fieldMutationLocked = locked || fieldsCorrupt;
const canWriteValue = !isProtected || vault.status === 'unlocked';
useEffect(() => {
- if (isProtected) void refresh();
- }, [isProtected, refresh]);
+ if (isProtected && !passkeyNeedsBrowser) void refresh();
+ }, [isProtected, passkeyNeedsBrowser, refresh]);
const hasErrorCode = (result: unknown, code: string): boolean =>
typeof result === 'object' && result !== null && 'code' in result && result.code === code;
diff --git a/ui/src/components/ui/vault-secret-form.tsx b/ui/src/components/ui/vault-secret-form.tsx
index c89a1a407..4d0ae5c2f 100644
--- a/ui/src/components/ui/vault-secret-form.tsx
+++ b/ui/src/components/ui/vault-secret-form.tsx
@@ -43,7 +43,7 @@ import {
import { vaultErrorMessage } from '@/lib/vaultErrors';
import { useProtectedVault } from '@/lib/useProtectedVault';
import { MAX_VAULT_FIELDS, VAULT_FIELD_PATTERN, vaultFieldNameIssue, vaultRecordName } from '@/lib/vaultFields';
-import { openVaultsInBrowser } from '@/lib/vaultBrowserHandoff';
+import { openVaultsInBrowser, vaultPasskeyNeedsBrowser } from '@/lib/vaultBrowserHandoff';
import { Badge } from './badge';
import { Button } from './button';
import { Input } from './input';
@@ -282,15 +282,16 @@ export const VaultSecretForm: React.FC<{
}, [api]);
const protectedVault = useProtectedVault();
+ const passkeyNeedsBrowser = vaultPasskeyNeedsBrowser();
// The vault status the current protected keypair was generated under. A transition away from
// 'unlocked' (manual/auto lock, or an abandoned fresh setup that discards the VMK) means the
// held envelope is sealed to a VMK that's no longer active — see the render-phase reset below.
const [keypairSessionStatus, setKeypairSessionStatus] = useState(protectedVault.status);
useEffect(() => {
- if (protection === 'protected') void protectedVault.refresh();
+ if (protection === 'protected' && !passkeyNeedsBrowser) void protectedVault.refresh();
// protectedVault.refresh is stable (useCallback); only re-check when the tier changes.
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [protection]);
+ }, [protection, passkeyNeedsBrowser]);
// Seed editable fields from an agent's request spec ONCE per distinct request. The chat
// page rebuilds the request object on every poll/re-render, so keying this on the
diff --git a/ui/src/lib/vaultBrowserHandoff.test.tsx b/ui/src/lib/vaultBrowserHandoff.test.tsx
index bbd3f478a..f2580d680 100644
--- a/ui/src/lib/vaultBrowserHandoff.test.tsx
+++ b/ui/src/lib/vaultBrowserHandoff.test.tsx
@@ -320,6 +320,9 @@ describe('desktop shell protected-vault browser handoff', () => {
expect(api.createVaultAgentBindingsBatch).not.toHaveBeenCalled();
expect(api.createVaultRevealContext).not.toHaveBeenCalled();
expect(useVaultSandboxWarm).not.toHaveBeenCalledWith(true);
+ // The desktop shell must not even warm or refresh the protected sandbox before handing the
+ // flow to the browser; WKWebView cannot pair with the sandbox authorization surface.
+ expect(vault.refresh).not.toHaveBeenCalled();
cleanup();
delete (window as { __AVIBE_DESKTOP_SHELL__?: true }).__AVIBE_DESKTOP_SHELL__;