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(vault): hand protected passkey steps to the browser in the desktop app (#2289)
Call Whitef0867b86f1f8
diff --git a/ui/src/components/ui/vault-approval-card.tsx b/ui/src/components/ui/vault-approval-card.tsxindex 17f2ba3e8..a30128f4f 100644--- a/ui/src/components/ui/vault-approval-card.tsx+++ b/ui/src/components/ui/vault-approval-card.tsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react';-import { Check, Copy, Globe, KeyRound, Link2, Loader2, LockKeyhole, PenTool, Puzzle, ShieldCheck, Tag, Wallet } from 'lucide-react';+import { Check, Copy, ExternalLink, Globe, KeyRound, Link2, Loader2, LockKeyhole, PenTool, Puzzle, ShieldCheck, Tag, Wallet } from 'lucide-react';import { useTranslation } from 'react-i18next';import {@@ -13,6 +13,8 @@ import {import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';import { partitionTags } from '@/lib/vaultTags';import { useProtectedVault, type ProtectedUnlockMaterial } from '@/lib/useProtectedVault';+import { openVaultsInBrowser, vaultPasskeyNeedsBrowser } from '@/lib/vaultBrowserHandoff';+import { vaultApprovalNeedsPasskey } from '@/lib/vaultRequestPlacement';import { openVaultAuthorizationWindow } from '@/lib/vaultSandboxClient';import { SigningAddressList } from './signing-address-list';import { type BlindBox, type SignatureResult, type SignatureScheme } from '@/lib/vaultCrypto';@@ -220,9 +222,10 @@ export const VaultApprovalCard: React.FC<{const schemeAddresses = useMemo(() => addressesForScheme(delivery.scheme, signAddresses), [delivery.scheme, signAddresses]);const hasSchemeAddress = Object.values(schemeAddresses).some(Boolean);- // A request needs the sandbox protected-approval ceremony when it touches protected- // key material: a protected sign, or an access whose fixed set includes protected members.- const needsProtectedApproval = isSign ? isProtected : protectedNames.length > 0;+ const needsProtectedApproval = useMemo(() => vaultApprovalNeedsPasskey(request), [request]);+ // Where passkeys can't run, the approver finishes this request in the browser instead; nothing+ // (no binding contexts, no sandbox ceremony) starts here.+ const approveInBrowser = needsProtectedApproval && vaultPasskeyNeedsBrowser();useEffect(() => {if (needsProtectedApproval) void vault.refresh();@@ -521,14 +524,17 @@ export const VaultApprovalCard: React.FC<{{needsProtectedApproval ? (<span className="flex items-start gap-2 rounded-lg bg-mint-soft px-3 py-2.5 text-[11.5px] text-foreground"><ShieldCheck className="mt-0.5 size-[15px] shrink-0 text-mint-ink" />- {isSign ? t('vaults.approval.signNote') : t('vaults.approval.accessNote')}+ {approveInBrowser+ ? t('vaults.approval.browserNote')+ : isSign ? t('vaults.approval.signNote') : t('vaults.approval.accessNote')}</span>) : null}{/* Agent access duration (access only) — the approver picks how long the agent may use theset (protocol v2 §7.1). "授权时长 / Agent access duration" language (§8): this is what the- agent receives, distinct from the browser unlock window; never a countdown pill. */}- {!isSign ? (+ agent receives, distinct from the browser unlock window; never a countdown pill. It is chosen+ where the approval happens, so a browser handoff leaves it to the browser. */}+ {!isSign && !approveInBrowser ? (<div className="flex flex-col gap-1.5"><span className="text-[13px] font-medium text-foreground">{t('vaults.approval.grantDuration')}</span><SegmentedRadio<GrantDurationChoice>@@ -584,16 +590,30 @@ export const VaultApprovalCard: React.FC<{<Button type="button" variant="outline" onClick={deny} disabled={busy || !canApprove}>{t('vaults.approval.deny')}</Button>- <Button type="button" onClick={isSign ? approveSign : approveAccess} disabled={approveDisabled}>- {busy ? (- <Loader2 className="size-4 animate-spin" />- ) : isSign ? (- <PenTool className="size-4" />- ) : (- <Check className="size-4" />- )}- {isSign ? t('vaults.approval.sign') : t('vaults.approval.approve')}- </Button>+ {approveInBrowser ? (+ <Button+ type="button"+ onClick={() => {+ openVaultsInBrowser({ kind: 'request', requestId: request.id });+ onCancel();+ }}+ disabled={approveDisabled}+ >+ <ExternalLink className="size-4" />+ {t('vaults.approval.continueInBrowser')}+ </Button>+ ) : (+ <Button type="button" onClick={isSign ? approveSign : approveAccess} disabled={approveDisabled}>+ {busy ? (+ <Loader2 className="size-4 animate-spin" />+ ) : isSign ? (+ <PenTool className="size-4" />+ ) : (+ <Check className="size-4" />+ )}+ {isSign ? t('vaults.approval.sign') : t('vaults.approval.approve')}+ </Button>+ )}</div></div></div>diff --git a/ui/src/components/ui/vault-chat-requests.tsx b/ui/src/components/ui/vault-chat-requests.tsxindex c4833ef4f..2a8e30d0b 100644--- a/ui/src/components/ui/vault-chat-requests.tsx+++ b/ui/src/components/ui/vault-chat-requests.tsx@@ -4,7 +4,8 @@ import { useTranslation } from 'react-i18next';import { cn } from '@/lib/utils';import type { VaultRequest } from '@/context/ApiContext';-import { isVaultApprovalRequest } from '@/lib/vaultRequestPlacement';+import { openVaultsInBrowser, vaultPasskeyNeedsBrowser } from '@/lib/vaultBrowserHandoff';+import { isVaultApprovalRequest, vaultApprovalNeedsPasskey } from '@/lib/vaultRequestPlacement';import { buttonVariants } from './button-variants';import { VaultApprovalDialog } from './vault-approval-dialog';import { VaultRequestCard } from './vault-request-card';@@ -102,13 +103,14 @@ export const VaultApprovalFloat: React.FC<{ offscreen: VaultRequest[]; pending:}, [pending, reviewing]);const oldestOffscreen = offscreen.length > 0 ? offscreen[offscreen.length - 1] : null;+ const reviewInBrowser = oldestOffscreen != null && vaultPasskeyNeedsBrowser() && vaultApprovalNeedsPasskey(oldestOffscreen);return (<>{oldestOffscreen ? (<div className="mx-3 mb-1"><buttontype="button"- onClick={() => setReviewing(oldestOffscreen)}+ onClick={() => (reviewInBrowser ? openVaultsInBrowser({ kind: 'request', requestId: oldestOffscreen.id }) : setReviewing(oldestOffscreen))}className="flex w-full items-center gap-2.5 rounded-xl border border-gold/40 bg-gold/[0.08] px-3 py-2.5 text-left transition-colors hover:bg-gold/[0.12]"><span className="flex size-7 shrink-0 items-center justify-center rounded-lg bg-gold/15 text-gold-ink">@@ -119,7 +121,7 @@ export const VaultApprovalFloat: React.FC<{ offscreen: VaultRequest[]; pending:</span>{/* Decorative pill — the whole bar is the button, so this must not be interactive. */}<span className={cn(buttonVariants({ size: 'sm' }), 'pointer-events-none shrink-0')} aria-hidden="true">- {t('vaults.requests.review')}+ {reviewInBrowser ? t('vaults.requests.reviewInBrowser') : t('vaults.requests.review')}</span></button></div>diff --git a/ui/src/components/ui/vault-protected-unlock.tsx b/ui/src/components/ui/vault-protected-unlock.tsxindex cf7ac5a68..04c76f282 100644--- a/ui/src/components/ui/vault-protected-unlock.tsx+++ b/ui/src/components/ui/vault-protected-unlock.tsx@@ -1,9 +1,10 @@import { useState } from 'react';-import { Loader2, Lock, RefreshCw, ScanFace, ShieldCheck, Sparkles } from 'lucide-react';+import { ExternalLink, Loader2, Lock, RefreshCw, ScanFace, ShieldCheck, Sparkles } from 'lucide-react';import { useTranslation } from 'react-i18next';import type { TFunction } from 'i18next';import { webauthnAvailable } from '@/lib/useProtectedVault';+import { vaultPasskeyNeedsBrowser } from '@/lib/vaultBrowserHandoff';import type { useProtectedVault } from '@/lib/useProtectedVault';import { Badge } from './badge';import { Button } from './button';@@ -36,13 +37,15 @@ const PANEL = 'flex flex-col gap-4 rounded-2xl border border-border bg-surface p* {@link useProtectedVault}.** `secretName` is shown in the unlock subtitle ("<NAME> is protected …"); it is optional- * because the create-dialog gating step has no single secret name yet.+ * because the create-dialog gating step has no single secret name yet. Where passkeys can't run,+ * setup and unlock continue in the browser, where `onContinueInBrowser` reopens the caller's flow.*/-export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string; onDismiss?: () => void }> = ({- vault,- secretName,- onDismiss,-}) => {+export const VaultProtectedUnlock: React.FC<{+ vault: Vault;+ secretName?: string;+ onContinueInBrowser?: () => void;+ onDismiss?: () => void;+}> = ({ vault, secretName, onContinueInBrowser, onDismiss }) => {const { t } = useTranslation();const [busy, setBusy] = useState(false);// Passkey-only setup has no recovery fallback yet, so a lost passkey is@@ -97,6 +100,16 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string;}const canUsePasskey = webauthnAvailable();+ const inBrowser = vaultPasskeyNeedsBrowser();+ const browserHandoff = (+ <div className="flex flex-col items-center gap-2.5">+ <span className="text-center text-[12px] leading-snug text-muted-foreground">{t('vaults.protectedUnlock.browserNote')}</span>+ <Button type="button" variant="brand" className="w-full" onClick={onContinueInBrowser}>+ <ExternalLink className="size-5" />+ {t('vaults.protectedUnlock.openInBrowser')}+ </Button>+ </div>+ );// ---- Setup (needs-setup): design.pen `kAmWj` ---------------------------------------if (vault.status === 'needs-setup') {@@ -116,7 +129,7 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string;{/* Ack sits ABOVE the button: the natural order is read-the-risk → check → the(now-enabled) Add-Passkey button right below it. The button gates on `ackLoss`. */}- {canUsePasskey && (+ {canUsePasskey && !inBrowser && (<div className="flex flex-col gap-2 rounded-xl border border-gold/40 bg-gold/10 p-3"><span className="text-[11.5px] leading-snug text-gold-ink">{t('vaults.protectedUnlock.passkeyUnrecoverableWarning')}</span><label className="flex items-start gap-2 text-[11.5px] leading-snug text-muted-foreground">@@ -126,7 +139,9 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string;</div>)}- {canUsePasskey ? (+ {inBrowser ? (+ browserHandoff+ ) : canUsePasskey ? (<div className="flex flex-col items-center gap-2.5 rounded-xl border-[1.5px] border-mint bg-mint-soft p-4"><Badge variant="success" className="border-transparent bg-mint uppercase tracking-wide text-primary-foreground"><Sparkles className="size-3" />@@ -160,7 +175,7 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string;}// ---- Unlock (locked): design.pen `g5Q7F` -------------------------------------------- const showUnlockPasskey = vault.hasPasskey() && canUsePasskey && vault.passkeyUsableHere();+ const showUnlockPasskey = !inBrowser && vault.hasPasskey() && canUsePasskey && vault.passkeyUsableHere();return (<div className={PANEL}><div className="flex flex-col items-center gap-4">@@ -187,11 +202,13 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string;</div>)}- {!showUnlockPasskey && (- <div className="rounded-md border border-gold/40 bg-gold/10 px-2.5 py-1.5 text-xs text-gold-ink">- {t('vaults.protectedUnlock.unlockUnavailableHere')}- </div>- )}+ {inBrowser+ ? browserHandoff+ : !showUnlockPasskey && (+ <div className="rounded-md border border-gold/40 bg-gold/10 px-2.5 py-1.5 text-xs text-gold-ink">+ {t('vaults.protectedUnlock.unlockUnavailableHere')}+ </div>+ )}{/* Mint factor-safety note. */}<div className="flex items-start gap-2 rounded-lg bg-mint-soft px-3 py-2.5">diff --git a/ui/src/components/ui/vault-request-card.tsx b/ui/src/components/ui/vault-request-card.tsxindex 2c9bb70fa..07d86653a 100644--- a/ui/src/components/ui/vault-request-card.tsx+++ b/ui/src/components/ui/vault-request-card.tsx@@ -1,9 +1,11 @@import { createContext, useCallback, useContext, useMemo, useState } from 'react';import type { ReactNode } from 'react';-import { ArrowRight, KeyRound, LockKeyhole, PenTool, Wallet } from 'lucide-react';+import { ArrowRight, ExternalLink, KeyRound, LockKeyhole, PenTool, Wallet } from 'lucide-react';import { useTranslation } from 'react-i18next';import type { VaultRequest } from '@/context/ApiContext';+import { openVaultsInBrowser, vaultPasskeyNeedsBrowser } from '@/lib/vaultBrowserHandoff';+import { vaultApprovalNeedsPasskey } from '@/lib/vaultRequestPlacement';import { partitionTags } from '@/lib/vaultTags';import { Badge } from './badge';import { Button } from './button';@@ -109,6 +111,9 @@ export const VaultRequestCard: React.FC<{ request: VaultRequest; onResolved: ()source_selector?: { env?: string[]; tags?: string[] };};const isProtected = card.protection === 'protected' || (card.protected_secret_names?.length ?? 0) > 0;+ // An approval that needs a passkey this app can't use is reviewed once, in the browser, instead+ // of in a dialog that could only send it there.+ const reviewInBrowser = type !== 'provision' && vaultPasskeyNeedsBrowser() && vaultApprovalNeedsPasskey(request);// A selector-based access request matches multiple secrets, so `secret_name` is null and the// members/selector live on the card. Fall back to those so the card is never nameless.const { name, extra } = useMemo(() => {@@ -152,12 +157,13 @@ export const VaultRequestCard: React.FC<{ request: VaultRequest; onResolved: ()size="sm"className="shrink-0"onClick={() => {- if (externallyOwnedProvision) provisionDialog.open(request);+ if (reviewInBrowser) openVaultsInBrowser({ kind: 'request', requestId: request.id });+ else if (externallyOwnedProvision) provisionDialog.open(request);else setOpen(true);}}>- {meta.action}- <ArrowRight className="size-3.5" />+ {reviewInBrowser ? t('vaults.requests.reviewInBrowser') : meta.action}+ {reviewInBrowser ? <ExternalLink className="size-3.5" /> : <ArrowRight className="size-3.5" />}</Button></div>diff --git a/ui/src/components/ui/vault-secret-dialog.tsx b/ui/src/components/ui/vault-secret-dialog.tsxindex 1358a4075..6c95d1aef 100644--- a/ui/src/components/ui/vault-secret-dialog.tsx+++ b/ui/src/components/ui/vault-secret-dialog.tsx@@ -1,5 +1,5 @@import { KeyRound, Pencil } from 'lucide-react';-import { useState } from 'react';+import { useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import type { VaultRequest, VaultRequestSpec, VaultSecret } from '@/context/ApiContext';@@ -25,6 +25,9 @@ export const VaultSecretDialog: React.FC<{request?: VaultRequest | null;/** An existing secret to edit (value-free metadata); mutually exclusive with create/provide. */editSecret?: VaultSecret | null;+ /** Start on the Protected tier even when a provision request defaults to Standard: a browser+ * handoff carries the user's choice of Protected. It can only raise the tier, never lower it. */+ startProtected?: boolean;/** Rendered in place of the form (loading / ambiguous-provision notices from callers). */notice?: React.ReactNode;onCancel?: () => void;@@ -41,6 +44,7 @@ export const VaultSecretDialog: React.FC<{name,request,editSecret,+ startProtected = false,notice,onCancel,cancelLabel,@@ -52,9 +56,18 @@ export const VaultSecretDialog: React.FC<{const { t } = useTranslation();const [denyConfirmationOpen, setDenyConfirmationOpen] = useState(false);const card = (request?.card ?? null) as { default_protection?: unknown; spec?: VaultRequestSpec } | null;- const requestSpec = (card?.spec ?? null) as VaultRequestSpec | null;- const defaultProtection =- card?.default_protection === 'standard' || card?.default_protection === 'protected' ? card.default_protection : undefined;+ const cardSpec = (card?.spec ?? null) as VaultRequestSpec | null;+ // The form starts on the spec's tier before `defaultProtection`, and the card derives its default+ // from that same spec, so a handoff's Protected must replace the tier in both.+ const requestSpec = useMemo(+ () => (cardSpec && startProtected ? { ...cardSpec, protection: 'protected' as const } : cardSpec),+ [cardSpec, startProtected],+ );+ const defaultProtection = startProtected+ ? 'protected'+ : card?.default_protection === 'standard' || card?.default_protection === 'protected'+ ? card.default_protection+ : undefined;const fixedName = name ?? request?.secret_name ?? undefined;const isProvide = Boolean(fixedName);const isEdit = Boolean(editSecret);diff --git a/ui/src/components/ui/vault-secret-form.tsx b/ui/src/components/ui/vault-secret-form.tsxindex 8276e4a7e..fbc44934f 100644--- a/ui/src/components/ui/vault-secret-form.tsx+++ b/ui/src/components/ui/vault-secret-form.tsx@@ -39,6 +39,7 @@ import {type SigningKeyMaterial,} from '@/lib/vaultCrypto';import { useProtectedVault } from '@/lib/useProtectedVault';+import { openVaultsInBrowser } from '@/lib/vaultBrowserHandoff';import { Badge } from './badge';import { Button } from './button';import { Input } from './input';@@ -930,11 +931,21 @@ export const VaultSecretForm: React.FC<{</div>) : null;+ // Where passkeys can't run, the browser reopens this flow on the Protected tier the user is on: the+ // provision request itself, or an Add for the same name. This form stays open, so the user may+ // still switch to Standard here.+ const continueInBrowser = () =>+ openVaultsInBrowser(+ provisionRequestId+ ? { kind: 'request', requestId: provisionRequestId, startProtected: true }+ : { kind: 'add', name: fixedName },+ );+// Protected setup/unlock gating step + avault availability notices, shared by both modes.const gatingNotices = (<>{protection === 'protected' && !protectedCreateReady && (- <VaultProtectedUnlock vault={protectedVault} secretName={secretName || undefined} />+ <VaultProtectedUnlock vault={protectedVault} secretName={secretName || undefined} onContinueInBrowser={continueInBrowser} />)}{protection === 'protected' && protectedCreateReady && <VaultProtectedUnlock vault={protectedVault} />}{protection === 'standard' && checkingAvault && (diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsxindex b536b61f7..b4a728ca8 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, Lock, MoreHorizontal, Pencil, Plus, Puzzle, RefreshCw, Settings, ShieldCheck, Tag, Trash2, Wallet, X } from 'lucide-react';+import { AlertTriangle, Clock, Copy, ExternalLink, 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';@@ -23,6 +23,13 @@ import { VaultRequestSessionLink } from '../ui/vault-request-session-link';import { VaultSecretDialog } from '../ui/vault-secret-dialog';import { VaultSettingsDialog } from '../ui/vault-settings-dialog';import { useProtectedVault } from '../../lib/useProtectedVault';+import {+ openVaultsInBrowser,+ readVaultBrowserStep,+ vaultPasskeyNeedsBrowser,+ withoutVaultBrowserStep,+} from '../../lib/vaultBrowserHandoff';+import { vaultApprovalNeedsPasskey } from '../../lib/vaultRequestPlacement';import { openVaultAuthorizationWindow } from '../../lib/vaultSandboxClient';import { useVaultRequestRefresh } from '../../lib/useVaultRequestRefresh';import {@@ -45,14 +52,17 @@ const SecretRow: React.FC<{onDelete: (secret: VaultSecret) => void;onReveal: (secret: VaultSecret) => void;canManage: boolean;-}> = ({ secret: s, onEdit, onDelete, onReveal, canManage }) => {+ menuOpen: boolean;+ onMenuOpenChange: (open: boolean) => void;+}> = ({ secret: s, onEdit, onDelete, onReveal, canManage, menuOpen, onMenuOpenChange: setMenuOpen }) => {const { t } = useTranslation();- const [menuOpen, setMenuOpen] = useState(false);const isKeypair = s.kind === 'keypair';const isProtected = s.protection === 'protected';// Reveal is only meaningful for a protected static secret: its plaintext lives sealed and can be// shown in-sandbox. Standard values aren't sandbox-sealed, and a keypair has no plaintext value.const canReveal = isProtected && !isKeypair;+ // The sandbox reveal needs its authorization window, which only a browser can pair with.+ const revealInBrowser = canReveal && vaultPasskeyNeedsBrowser();// Skills are stored as reserved `skill:<name>` tags; render them as their own chips.const { tags, skills } = useMemo(() => partitionTags(s.tags), [s.tags]);return (@@ -110,7 +120,23 @@ const SecretRow: React.FC<{</Button></PopoverTrigger><PopoverContent align="end" className="w-44 p-1" role="menu">- {canReveal ? (+ {revealInBrowser ? (+ <>+ <button+ type="button"+ role="menuitem"+ onClick={() => {+ setMenuOpen(false);+ openVaultsInBrowser({ kind: 'reveal', secretName: s.name });+ }}+ className="flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm text-foreground transition-colors hover:bg-surface-2"+ >+ <ExternalLink className="size-4 text-muted" />+ {t('vaults.reveal.showInBrowser')}+ </button>+ <div className="my-1 h-px bg-border" />+ </>+ ) : canReveal ? (<>{/* Reveal opens the value inside the sandbox frame; the plaintext is never returnedto Avibe. "Copy value" leads to the same sandbox card, where copying is the@@ -292,6 +318,7 @@ const RequestRow: React.FC<{ request: VaultRequest; onReview: (request: VaultReqconst isProtected = card.protection === 'protected';const Icon = isSign || card.kind === 'keypair' ? Wallet : KeyRound;const session = vaultRequestSessionDisplay(r);+ const reviewInBrowser = !isProvision && vaultPasskeyNeedsBrowser() && vaultApprovalNeedsPasskey(r);return (<div className="flex items-center gap-3.5 rounded-xl border border-gold/40 bg-gold/[0.06] px-4 py-3"><div className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-gold/10 text-gold-ink">@@ -317,9 +344,16 @@ const RequestRow: React.FC<{ request: VaultRequest; onReview: (request: VaultReq</span></div><div className="ml-auto">- <Button size="sm" onClick={() => onReview(r)}>- {isProvision ? t('vaults.request.provide') : t('vaults.requests.review')}- </Button>+ {reviewInBrowser ? (+ <Button size="sm" onClick={() => openVaultsInBrowser({ kind: 'request', requestId: r.id })}>+ {t('vaults.requests.reviewInBrowser')}+ <ExternalLink className="size-3.5" />+ </Button>+ ) : (+ <Button size="sm" onClick={() => onReview(r)}>+ {isProvision ? t('vaults.request.provide') : t('vaults.requests.review')}+ </Button>+ )}</div></div>);@@ -334,14 +368,17 @@ const RequestRow: React.FC<{ request: VaultRequest; onReview: (request: VaultReqconst PendingRequestsSection: React.FC<{onResolved: () => void;focusRequestId?: string | null;+ /** Open a focused provision request on the Protected tier (the desktop app's handoff). */+ focusStartProtected?: boolean;onFocusRequestOpened?: () => void;-}> = ({ onResolved, focusRequestId, onFocusRequestOpened }) => {+}> = ({ onResolved, focusRequestId, focusStartProtected = false, onFocusRequestOpened }) => {const { t } = useTranslation();const api = useApi();const { showToast } = useToast();const [requests, setRequests] = useState<VaultRequest[]>([]);const [reviewing, setReviewing] = useState<VaultRequest | null>(null);const [provisioning, setProvisioning] = useState<VaultRequest | null>(null);+ const [provisionStartsProtected, setProvisionStartsProtected] = useState(false);const load = useCallback(async () => {try {@@ -374,10 +411,11 @@ const PendingRequestsSection: React.FC<{return () => window.clearTimeout(timer);}, [requests, load]);- const openRequest = useCallback((request: VaultRequest) => {+ const openRequest = useCallback((request: VaultRequest, startProtected = false) => {const type = requestReviewType(request);if (type === 'provision') {setProvisioning(request);+ setProvisionStartsProtected(startProtected);} else {setReviewing(request);}@@ -387,9 +425,9 @@ const PendingRequestsSection: React.FC<{if (!focusRequestId) return;const request = requests.find((r) => r.id === focusRequestId);if (!request) return;- openRequest(request);+ openRequest(request, focusStartProtected);onFocusRequestOpened?.();- }, [focusRequestId, onFocusRequestOpened, openRequest, requests]);+ }, [focusRequestId, focusStartProtected, onFocusRequestOpened, openRequest, requests]);const handleOutcome = useCallback((outcome: ApprovalOutcome) => {@@ -443,7 +481,7 @@ const PendingRequestsSection: React.FC<{<RequestRowkey={r.id}request={r}- onReview={openRequest}+ onReview={(request) => openRequest(request)}/>))}<VaultApprovalDialog request={reviewing} onResolved={handleOutcome} onClose={() => setReviewing(null)} />@@ -454,6 +492,7 @@ const PendingRequestsSection: React.FC<{if (!o) setProvisioning(null);}}request={provisioning}+ startProtected={provisionStartsProtected}onCancel={() => setProvisioning(null)}cancelLabel={t('vaults.approval.close')}onDeny={() => denyProvisionRequest(provisioning)}@@ -500,7 +539,8 @@ export const VaultsPage: React.FC = () => {const [grants, setGrants] = useState<VaultGrant[]>([]);const [loading, setLoading] = useState(false);const [error, setError] = useState<string | null>(null);- const [adding, setAdding] = useState(false);+ // The Add dialog while open: a new secret, or one resumed from the desktop app's handoff.+ const [adding, setAdding] = useState<{ name?: string; startProtected: boolean } | null>(null);const [showSettings, setShowSettings] = useState(false);const [showAudit, setShowAudit] = useState(false);const [audit, setAudit] = useState<VaultAuditEvent[]>([]);@@ -508,19 +548,30 @@ export const VaultsPage: React.FC = () => {const [activeSkills, setActiveSkills] = useState<string[]>([]);const [now, setNow] = useState(() => Date.now());const [eventBridgeConnected, setEventBridgeConnected] = useState(false);- const focusRequestId = searchParams.get('request_id')?.trim() || null;-- const clearFocusedRequest = useCallback(() => {- setSearchParams(- (prev) => {- const next = new URLSearchParams(prev);- next.delete('request_id');- return next;- },- { replace: true },- );+ // A request linked from IM, or a step the desktop app handed to this browser (`openVaultsInBrowser`),+ // resumed below; each drops the step from the URL once resumed so a reload doesn't resume it again.+ const step = useMemo(() => readVaultBrowserStep(searchParams), [searchParams]);+ // The secret whose row menu is open; a reveal handed off from the desktop app reopens it.+ const [menuSecret, setMenuSecret] = useState<string | null>(null);++ const clearStep = useCallback(() => {+ setSearchParams((prev) => withoutVaultBrowserStep(prev), { replace: true });}, [setSearchParams]);+ useEffect(() => {+ if (!canManage || step?.kind !== 'add') return;+ setAdding({ name: step.name, startProtected: true });+ clearStep();+ }, [canManage, step, clearStep]);++ // A reveal continues from its row's menu once the list holds the secret: the sandbox window it+ // opens needs a click in this browser.+ useEffect(() => {+ if (!canManage || step?.kind !== 'reveal' || !secrets.some((s) => s.name === step.secretName)) return;+ setMenuSecret(step.secretName);+ clearStep();+ }, [canManage, step, secrets, clearStep]);+const refresh = useCallback(async () => {setLoading(true);setError(null);@@ -765,7 +816,7 @@ export const VaultsPage: React.FC = () => {<RefreshCw className="size-4" /></Button>{canManage ? (- <Button className="max-sm:flex-1" onClick={() => setAdding(true)}>+ <Button className="max-sm:flex-1" onClick={() => setAdding({ startProtected: false })}><Plus className="size-4" />{t('vaults.add')}</Button>@@ -781,7 +832,14 @@ export const VaultsPage: React.FC = () => {{error && (<div className="rounded-xl border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive-ink">{error}</div>)}- {canManage ? <PendingRequestsSection onResolved={refresh} focusRequestId={focusRequestId} onFocusRequestOpened={clearFocusedRequest} /> : null}+ {canManage ? (+ <PendingRequestsSection+ onResolved={refresh}+ focusRequestId={step?.kind === 'request' ? step.requestId : null}+ focusStartProtected={step?.kind === 'request' && step.startProtected}+ onFocusRequestOpened={clearStep}+ />+ ) : null}{canReadVaultState && grants.length > 0 && (<div className="flex flex-col gap-2"><div className="flex items-center gap-2 px-1">@@ -848,6 +906,8 @@ export const VaultsPage: React.FC = () => {onDelete={onDelete}onReveal={revealSecret}canManage={canManage}+ menuOpen={s.name === menuSecret}+ onMenuOpenChange={(open) => setMenuSecret(open ? s.name : null)}/>))}</div>@@ -872,14 +932,16 @@ export const VaultsPage: React.FC = () => {)}{canManage ? <VaultSettingsDialog open={showSettings} onOpenChange={setShowSettings} /> : null}{canManage ? <VaultSecretDialog- open={adding}+ open={adding != null}+ name={adding?.name}+ startProtected={adding?.startProtected}onOpenChange={(o) => {- if (!o) setAdding(false);+ if (!o) setAdding(null);}}onCreated={(name, reason) => {- if (reason === 'already_exists') return;- setAdding(false);- showToast(t('vaults.created', { name }), 'success');+ setAdding(null);+ // Only an Add for a name an agent asked for treats an existing secret as provided.+ if (reason !== 'already_exists') showToast(t('vaults.created', { name }), 'success');refresh();}}/> : null}diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 4a2169e4c..886f391f3 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -4823,6 +4823,7 @@"reveal": {"show": "Show value","copy": "Copy value",+ "showInBrowser": "Show in browser","errors": {"contextFailed": "Couldn't prepare the reveal. Please try again.","unavailable": "Reveal isn't available for this secret yet."@@ -4857,6 +4858,8 @@"passkeyUnrecoverableWarning": "This passkey is the only key. Lose it and the protected secrets can't be recovered — there is no backup.","passkeyAck": "I understand: if I lose this passkey, these secrets can't be recovered.","unlockUnavailableHere": "Protected vaults need a passkey. Open Vaults from localhost or your avibe.bot address; raw IP addresses like 127.0.0.1 can't use WebAuthn.",+ "browserNote": "Passkeys don't work in the desktop app. Continue in your browser, on this same Avibe, and fill in this secret there.",+ "openInBrowser": "Open in browser","errors": {"prfUnavailable": "This passkey/browser doesn't support the PRF extension needed for encryption. Try a platform passkey (Touch ID / Windows Hello).","cancelled": "Passkey prompt was cancelled.",@@ -4955,6 +4958,7 @@"subtitle": "An agent is waiting — approve or deny from this device.","reviewTitle": "Review request","review": "Review",+ "reviewInBrowser": "Review in browser","waiting": "Waiting for approval","waitingForValue": "Waiting for value","access": "Use secret",@@ -4999,6 +5003,8 @@"ttlHours": "{{count}} h","accessNote": "Unlocked in your browser — the secret's value is never shown to the AI or the chat.","signNote": "The private key never leaves your browser — only the signature is returned.",+ "browserNote": "This needs your passkey, which the desktop app can't use. Review and approve it in your browser.",+ "continueInBrowser": "Continue in browser","errors": {"failed": "Couldn't complete the approval. Please try again.","loadFailed": "Couldn't load this request. It may have been handled already.",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 6393ca5f2..a41f3f6c4 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -4823,6 +4823,7 @@"reveal": {"show": "查看值","copy": "复制值",+ "showInBrowser": "在浏览器中查看","errors": {"contextFailed": "无法准备查看,请重试。","unavailable": "此保护档暂不支持查看。"@@ -4857,6 +4858,8 @@"passkeyUnrecoverableWarning": "这个 passkey 就是唯一的钥匙,丢了它,保护档里的密钥就再也找不回来了(没有备用恢复方式)。","passkeyAck": "我明白:一旦丢失 passkey,这些密钥无法找回。","unlockUnavailableHere": "保护层保险库需要 passkey。请从 localhost 或你的 avibe.bot 地址打开 Vaults;127.0.0.1 这类原始 IP 无法使用 WebAuthn。",+ "browserNote": "桌面端无法使用 passkey。请在浏览器中继续(同一个 Avibe),在那里填写这个密钥。",+ "openInBrowser": "在浏览器中打开","errors": {"prfUnavailable": "这个 passkey/浏览器不支持加密所需的 PRF 扩展。请改用平台 passkey(Touch ID / Windows Hello)。","cancelled": "passkey 提示被取消了。",@@ -4955,6 +4958,7 @@"subtitle": "有 Agent 正在等待——在本设备上批准或拒绝。","reviewTitle": "审阅请求","review": "审阅",+ "reviewInBrowser": "在浏览器中审阅","waiting": "等待批准","waitingForValue": "等待填写","access": "使用密钥",@@ -4999,6 +5003,8 @@"ttlHours": "{{count}} 小时","accessNote": "在你的浏览器里解锁——密钥的值绝不会展示给 AI 或聊天。","signNote": "私钥绝不会离开你的浏览器——只返回签名。",+ "browserNote": "这一步需要 passkey,而桌面端无法使用 passkey。请在浏览器中审阅并批准。",+ "continueInBrowser": "在浏览器中继续","errors": {"failed": "批准未能完成,请重试。","loadFailed": "无法加载该请求,它可能已被处理。",diff --git a/ui/src/lib/vaultBrowserHandoff.test.tsx b/ui/src/lib/vaultBrowserHandoff.test.tsxnew file mode 100644index 000000000..b34cee382--- /dev/null+++ b/ui/src/lib/vaultBrowserHandoff.test.tsx@@ -0,0 +1,291 @@+// @vitest-environment jsdom++import { createInstance } from 'i18next';+import { cleanup, render, screen, within } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import type { ReactElement } from 'react';+import { I18nextProvider, initReactI18next } from 'react-i18next';+import { MemoryRouter } from 'react-router-dom';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import type { VaultRequest, VaultSecret } from '@/context/ApiContext';+import { VaultApprovalCard } from '@/components/ui/vault-approval-card';+import { VaultRequestCard } from '@/components/ui/vault-request-card';+import { VaultSecretForm } from '@/components/ui/vault-secret-form';+import { VaultsPage } from '@/components/workbench/VaultsPage';+import en from '@/i18n/en.json';++const api = vi.hoisted(() => ({+ connectWorkbenchEvents: vi.fn(),+ createVaultAgentBindingsBatch: vi.fn(),+ createVaultRevealContext: vi.fn(),+ denyVaultRequest: vi.fn(),+ fulfillVaultAccessRequest: vi.fn(),+ getVaultGrants: vi.fn(),+ getVaultRequests: vi.fn(),+ getVaultSettings: vi.fn(),+ listDependencies: vi.fn(),+ listSkills: vi.fn(),+ listVaultSecrets: vi.fn(),+ signVaultDigest: vi.fn(),+}));+const vault = vi.hoisted(() => ({+ status: 'needs-setup',+ error: null,+ setError: vi.fn(),+ refresh: vi.fn(),+ lock: vi.fn(),+ hasPasskey: vi.fn(),+ passkeyUsableHere: vi.fn(),+ setupPasskey: vi.fn(),+ unlockPasskey: vi.fn(),+ approveProtectedRelease: vi.fn(),+ signProtectedRequest: vi.fn(),+ revealProtectedValue: vi.fn(),+}));++vi.mock('@/context/ApiContext', () => ({ useApi: () => api }));+vi.mock('@/context/ToastContext', () => ({ useToast: () => ({ showToast: vi.fn() }) }));+vi.mock('@/context/InstanceAuthorizationContext', () => ({+ useInstanceAuthorization: () => ({ capabilities: { can_use_vault_secrets: true } }),+}));+vi.mock('@/lib/useProtectedVault', () => ({+ useProtectedVault: () => vault,+ useVaultLock: () => ({ unlocked: false, remainingMs: 0, lockNow: vi.fn() }),+ webauthnAvailable: () => true,+}));+// Workbench navigation, not part of the Vaults step (and it scrolls, which jsdom lacks).+vi.mock('@/components/workbench/CapabilityTabs', () => ({ CapabilityTabs: () => null }));++const i18n = createInstance();+void i18n.use(initReactI18next).init({+ lng: 'en',+ fallbackLng: 'en',+ resources: { en: { translation: en } },+ interpolation: { escapeValue: false },+});++const envelope = { ciphertext: 'c2VhbGVk', nonce: 'bm9uY2U=', wrap_meta: '{}' };+const pending = { requester: {}, status: 'pending', message_id: null, created_at: '2026-09-30T00:00:00Z', decided_at: null, expires_at: null };++const protectedAccess = {+ ...pending,+ id: 'vrq_access',+ request_type: 'access',+ secret_name: 'OPENAI_API_KEY',+ delivery: {},+ card: {+ request_type: 'access',+ protection: 'protected',+ secret_names: ['OPENAI_API_KEY'],+ protected_secret_names: ['OPENAI_API_KEY'],+ grant_options: [{ grant_id: 'grant_1', unlock_material: [{ name: 'OPENAI_API_KEY', kind: 'static', envelope }] }],+ },+} satisfies VaultRequest;++const protectedSign = {+ ...pending,+ id: 'vrq_sign',+ request_type: 'sign',+ secret_name: 'TREASURY_KEY',+ delivery: {+ digest: 'ab'.repeat(32),+ scheme: 'ecdsa-secp256k1-recoverable',+ signing_context: { chain_id: 1 },+ operation_context: { payload: 'e30', signature: 'c2ln' },+ },+ card: {+ request_type: 'sign',+ kind: 'keypair',+ protection: 'protected',+ secret_name: 'TREASURY_KEY',+ secret_unlock_material: { name: 'TREASURY_KEY', kind: 'keypair', envelope },+ },+} satisfies VaultRequest;++// The agent suggested Standard; the user answers on Protected. Shaped like the backend's+// `_secure_input_card`, which derives `default_protection` from the spec it also carries.+const standardSpec = { protection: 'standard' as const };+const standardProvision = {+ ...pending,+ id: 'vrq_provision',+ request_type: 'provision',+ secret_name: 'WALLET_PASSWORD',+ delivery: {},+ card: {+ card_type: 'secure_input',+ request_id: 'vrq_provision',+ secret_name: 'WALLET_PASSWORD',+ protection_options: ['standard', 'protected'],+ default_protection: 'standard',+ value: null,+ spec: standardSpec,+ },+} satisfies VaultRequest;++const protectedSecret: VaultSecret = {+ name: 'SEED_PHRASE',+ tags: [],+ kind: 'static',+ protection: 'protected',+ signer_kind: null,+ source: 'user',+ policy: {},+ last_used_at: null,+ use_count: 0,+ created_at: '2026-09-30T00:00:00Z',+ updated_at: '2026-09-30T00:00:00Z',+};++type Click = { role: 'button' | 'menuitem'; name: RegExp };+const approve: Click = { role: 'button', name: /^(approve|sign|continue in browser)$/i };+const protectedTier: Click = { role: 'button', name: /^protected/i };+const openInBrowser: Click = { role: 'button', name: /add a passkey|unlock with passkey|open in browser/i };++const resumedDialog = () => screen.findByRole('dialog');+const expectApprovalButton = async (name: RegExp) => {+ expect(within(await resumedDialog()).getByRole('button', { name })).toBeTruthy();+};+const expectProtectedForm = async (fixedName?: string) => {+ const dialog = within(await resumedDialog());+ expect(dialog.getByRole('button', { name: protectedTier.name }).getAttribute('aria-pressed')).toBe('true');+ if (fixedName) expect(dialog.getAllByText(fixedName).length).toBeGreaterThan(0);+};++const cases: Array<{+ surface: string;+ desktop: () => ReactElement;+ clicks: Click[];+ requests?: VaultRequest[];+ secrets?: VaultSecret[];+ vaultStatus?: string;+ resumed: () => Promise<void>;+}> = [+ {+ surface: 'protected access approval',+ desktop: () => <VaultApprovalCard request={protectedAccess} onResolved={vi.fn()} onCancel={vi.fn()} />,+ clicks: [approve],+ requests: [protectedAccess],+ resumed: () => expectApprovalButton(/^approve$/i),+ },+ {+ surface: 'protected sign approval',+ desktop: () => <VaultApprovalCard request={protectedSign} onResolved={vi.fn()} onCancel={vi.fn()} />,+ clicks: [approve],+ requests: [protectedSign],+ resumed: () => expectApprovalButton(/^sign$/i),+ },+ {+ surface: 'chat request card review',+ desktop: () => <VaultRequestCard request={protectedAccess} onResolved={vi.fn()} />,+ clicks: [{ role: 'button', name: /^review/i }],+ requests: [protectedAccess],+ resumed: () => expectApprovalButton(/^approve$/i),+ },+ {+ surface: 'Add switched to Protected',+ desktop: () => <VaultSecretForm onCancel={vi.fn()} onCreated={vi.fn()} />,+ clicks: [protectedTier, openInBrowser],+ resumed: () => expectProtectedForm(),+ },+ {+ surface: 'provision request answered on Protected over its Standard default',+ desktop: () => (+ <VaultSecretForm+ fixedName="WALLET_PASSWORD"+ provisionRequestId="vrq_provision"+ requestSpec={standardSpec}+ defaultProtection="standard"+ onCancel={vi.fn()}+ onCreated={vi.fn()}+ />+ ),+ clicks: [protectedTier, openInBrowser],+ requests: [standardProvision],+ vaultStatus: 'locked',+ resumed: () => expectProtectedForm('WALLET_PASSWORD'),+ },+ {+ // An agent's `$WALLET_PASSWORD` ask whose request lookup found nothing: only the name identifies it.+ surface: 'secret an agent asked for by name, with no pending request',+ desktop: () => <VaultSecretForm fixedName="WALLET_PASSWORD" onCancel={vi.fn()} onCreated={vi.fn()} />,+ clicks: [protectedTier, openInBrowser],+ resumed: () => expectProtectedForm('WALLET_PASSWORD'),+ },+ {+ surface: 'protected secret reveal',+ desktop: () => <VaultsPage />,+ clicks: [+ { role: 'button', name: /^more actions$/i },+ { role: 'menuitem', name: /^show in browser$/i },+ ],+ secrets: [protectedSecret],+ resumed: async () => {+ expect(await screen.findByRole('menuitem', { name: /^show value$/i })).toBeTruthy();+ },+ },+];++const ceremonies = [vault.setupPasskey, vault.unlockPasskey, vault.approveProtectedRelease, vault.signProtectedRequest, vault.revealProtectedValue];++function renderAt(path: string, ui: ReactElement) {+ return render(+ <I18nextProvider i18n={i18n}>+ <MemoryRouter initialEntries={[path]}>{ui}</MemoryRouter>+ </I18nextProvider>,+ );+}++beforeEach(() => {+ vault.hasPasskey.mockReturnValue(true);+ vault.passkeyUsableHere.mockReturnValue(true);+ for (const call of Object.values(api)) call.mockResolvedValue({ ok: true, items: [], secrets: [], deps: [], skills: [] });+ api.connectWorkbenchEvents.mockReturnValue(() => undefined);+ api.getVaultGrants.mockResolvedValue({ grants: [] });+});++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+ vi.restoreAllMocks();+ delete (window as { __AVIBE_DESKTOP_SHELL__?: true }).__AVIBE_DESKTOP_SHELL__;+});++// Contract: in the desktop shell, whose WKWebView can't run WebAuthn and whose new windows never+// pair with the sandbox, every surface that would start a protected passkey step instead opens the+// same Workbench's Vaults page in the browser and starts nothing here; the browser's Vaults page+// resumes that same step (the request, a Protected Add for the same name, or the secret's reveal)+// and stops at the click that begins it. Each surface encodes its own step while Vaults decodes+// them all, so a step the page can't resume, or resumes with a lost part (a provision answer back+// on the request's Standard default, a reveal on a bare list, an agent's name dropped from Add),+// strands the user in the browser; only a round trip through both ends catches that.+describe('desktop shell protected-vault browser handoff', () => {+ it.each(cases)('$surface resumes in the browser without starting a passkey step', async (c) => {+ const user = userEvent.setup();+ vault.status = c.vaultStatus ?? 'needs-setup';+ api.getVaultRequests.mockResolvedValue({ requests: c.requests ?? [] });+ api.listVaultSecrets.mockResolvedValue({ secrets: c.secrets ?? [] });+ const open = vi.spyOn(window, 'open').mockReturnValue(null);++ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { configurable: true, value: true });+ renderAt('/vaults', c.desktop());+ for (const click of c.clicks) await user.click(await screen.findByRole(click.role, { name: click.name }));++ expect(open).toHaveBeenCalledTimes(1);+ const target = new URL(String(open.mock.calls[0][0]));+ expect(target.origin).toBe(window.location.origin);+ expect(target.pathname).toBe('/vaults');+ expect(screen.queryByRole('dialog')).toBeNull();++ cleanup();+ delete (window as { __AVIBE_DESKTOP_SHELL__?: true }).__AVIBE_DESKTOP_SHELL__;+ renderAt(`${target.pathname}${target.search}`, <VaultsPage />);+ await c.resumed();++ expect(open).toHaveBeenCalledTimes(1);+ for (const ceremony of ceremonies) expect(ceremony).not.toHaveBeenCalled();+ expect(api.createVaultAgentBindingsBatch).not.toHaveBeenCalled();+ expect(api.createVaultRevealContext).not.toHaveBeenCalled();+ expect(api.signVaultDigest).not.toHaveBeenCalled();+ });+});diff --git a/ui/src/lib/vaultBrowserHandoff.ts b/ui/src/lib/vaultBrowserHandoff.tsnew file mode 100644index 000000000..f1e3b20c3--- /dev/null+++ b/ui/src/lib/vaultBrowserHandoff.ts@@ -0,0 +1,60 @@+import { isDesktopShell } from './desktopShell';+import { openLinkInNewContext } from './pwaNavigation';++/**+ * Whether this document must hand protected-vault passkey steps to the user's+ * browser. The desktop shell's WKWebView offers WebAuthn only to apps holding a+ * matching associated-domains entitlement, and the shell sends every new window+ * to the system browser, so the sandbox's top-level authorization window never+ * reaches its opener. Setup, unlock, protected approvals, and reveals therefore+ * run in the same local Workbench opened in the browser.+ */+export function vaultPasskeyNeedsBrowser(): boolean {+ return isDesktopShell();+}++/**+ * A Vaults step the desktop app hands to the browser, where the Vaults page resumes it at the point+ * the user left and stops at the first click the step needs (a passkey prompt or the sandbox window+ * only starts from one). What identifies the step travels, and so does a choice of the Protected+ * tier; the draft stays behind, and above all a secret value never appears in a URL.+ */+export type VaultBrowserStep =+ /** Review or answer a pending request; `startProtected` reopens a provision answer on Protected. */+ | { kind: 'request'; requestId: string; startProtected?: boolean }+ /** Add a new protected secret, fixed to `name` when an agent asked for it by name. */+ | { kind: 'add'; name?: string }+ /** Show a protected secret's value. */+ | { kind: 'reveal'; secretName: string };++// `request_id` is also the deep link Avibe sends to IM (`vault_request_url`).+const STEP_PARAMS = ['request_id', 'protection', 'add', 'name', 'reveal'];++/** Opens Vaults in the user's browser on `step`. */+export function openVaultsInBrowser(step: VaultBrowserStep): void {+ const url = new URL('/vaults', window.location.origin);+ const params =+ step.kind === 'request'+ ? { request_id: step.requestId, ...(step.startProtected ? { protection: 'protected' } : {}) }+ : step.kind === 'add'+ ? { add: 'protected', ...(step.name ? { name: step.name } : {}) }+ : { reveal: step.secretName };+ for (const [key, value] of Object.entries(params)) url.searchParams.set(key, value);+ openLinkInNewContext(url.toString());+}++/** The step a Vaults URL carries, whether the desktop app handed it off or IM linked to a request. */+export function readVaultBrowserStep(params: URLSearchParams): VaultBrowserStep | null {+ const requestId = params.get('request_id')?.trim();+ if (requestId) return { kind: 'request', requestId, startProtected: params.get('protection') === 'protected' };+ if (params.get('add') === 'protected') return { kind: 'add', name: params.get('name')?.trim() || undefined };+ const secretName = params.get('reveal')?.trim();+ return secretName ? { kind: 'reveal', secretName } : null;+}++/** `params` without a step, so a step resumed once doesn't resume again on reload. */+export function withoutVaultBrowserStep(params: URLSearchParams): URLSearchParams {+ const next = new URLSearchParams(params);+ for (const key of STEP_PARAMS) next.delete(key);+ return next;+}diff --git a/ui/src/lib/vaultRequestPlacement.ts b/ui/src/lib/vaultRequestPlacement.tsindex 22e6cdbf5..030082f52 100644--- a/ui/src/lib/vaultRequestPlacement.ts+++ b/ui/src/lib/vaultRequestPlacement.ts@@ -17,6 +17,22 @@ export function isVaultApprovalRequest(request: VaultRequest): boolean {return type === 'access' || type === 'sign';}+/**+ * Whether approving this request runs the sandbox's protected ceremony: a protected sign, or an+ * access whose fixed set includes protected members. Provision requests never approve.+ */+export function vaultApprovalNeedsPasskey(request: VaultRequest): boolean {+ const type = vaultRequestType(request);+ if (type === 'provision') return false;+ const card = (request.card ?? {}) as {+ protection?: string | null;+ protected_secret_names?: string[];+ grant_options?: Array<{ unlock_material?: unknown[] }>;+ };+ if (type === 'sign') return card.protection === 'protected';+ return (card.grant_options?.[0]?.unlock_material?.length ?? 0) > 0 || (card.protected_secret_names?.length ?? 0) > 0;+}+export type VaultProvisionPlacement = {byMessageId: Map<string, VaultRequest[]>;/** Requests of the transcript's latest turn whose owning reply has not landed. */