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(vaults): realign UI to design.pen frames (#720)
Call Whitee37c795aa1ea
diff --git a/docs/plans/vaults-design-alignment.md b/docs/plans/vaults-design-alignment.mdnew file mode 100644index 000000000..6fa9cca3a--- /dev/null+++ b/docs/plans/vaults-design-alignment.md@@ -0,0 +1,212 @@+# Vaults UI — Design Alignment (restore design.pen)++## Why++The shipped Vaults UI drifted from the `design.pen` frames (the visual source of+truth). Realign **every** Vaults surface to its design frame, faithfully. The+frames — and their exported PNGs — are the literal spec. The root cause of the+drift was that nobody compared the implementation against the frames; this task+closes that gap and a gatekeeper will re-verify each surface against the frame+before merge.++## Source of truth++`design.pen` (open via the `pencil` MCP tools, `filePath:+/Users/cyh/vibe-remote-project/design.pen`). Exported reference PNGs are in+`/tmp/vault-design/`. For each surface, BOTH read the PNG and read the frame via+`batch_get` (high `readDepth`, `resolveVariables: true`) to get exact copy,+spacing, colors, radii. Map every value to a UI token/class; add a token if one+is missing — never hardcode a one-off hex.++| Surface | design frame (id) | reference PNG | implementation |+| --- | --- | --- | --- |+| Create / "Add a secret" | `vyed5` (dialog `KsYUN`) | `vyed5.png` | `ui/src/components/ui/vault-secret-form.tsx` + `AddSecretDialog` in `components/workbench/VaultsPage.tsx` |+| Protected **setup** | `kAmWj` (modal `gV1j9`) | `kAmWj.png` | `vault-protected-unlock.tsx` (needs-setup branch) |+| Protected **unlock** | `g5Q7F` (modal `Yv2bL`) | `g5Q7F.png` | `vault-protected-unlock.tsx` (locked branch) |+| Approval — access | `w8u5l` (card `SKBld`) | `w8u5l.png` | `vault-approval-card.tsx` (access) |+| Approval — signing | `eWOjt` (card `pRtHq`) | `eWOjt.png` | `vault-approval-card.tsx` (sign) |+| Provision ($NAME) | `F4N19` (card `NqXrN`) | `F4N19.png` | `vault-secret-form.tsx` (fixedName mode) |+| Hub page | `y4rw5Q` | `y4rw5Q.png` | `components/workbench/VaultsPage.tsx` |+| Group dropdown (open) | `WgGQy` (popover `e3rPI`) | `WgGQy.png` | `Combobox` group picker in `vault-secret-form.tsx` |++## Confirmed divergences (audited — fix these for sure)++### A. Protected setup (`kAmWj`) — `vault-protected-unlock.tsx` needs-setup branch+Current: a passkey card AND a full password `<form>` shown at once as two coequal+sections, embedded in the create `<form>`. Target (match `kAmWj.png`), ONE+recommended path:+- shield-check icon badge; title "Set up protected secrets"; subtitle.+- ONE recommended green card: primary button **"Add a passkey"**, a RECOMMENDED+ badge, caption "Face ID · Touch ID · security key — the most secure option".+- a recovery tip box (add a second passkey / save a recovery code).+- a **"Use a password instead"** text link + a red "less secure" badge; clicking+ it **reveals** the password fields (progressive disclosure) — hidden by default.+- "Maybe later" dismiss.+- **HARD: remove the `<form>` element.** Use buttons + `onClick` reading state.+ Password setup is a button `onClick`, not a form submit. (This is the+ nested-`<form>`-inside-the-create-`<form>` bug that caused a full-page reload.)++### B. Protected unlock (`g5Q7F`) — `vault-protected-unlock.tsx` locked branch+Target (match `g5Q7F.png`): scan-face icon; "Unlock to continue"; subtitle+"<NAME> is protected — unlock it in your browser to sign"; primary **"Unlock with+passkey"** + caption "Face ID · Touch ID · security key"; **"Use password+instead"** reveal link (less secure) → reveals password field + unlock button; a+mint factor-safety note; Cancel. Again **no `<form>`** — onClick buttons.++### C. Create dialog (`vyed5`) — `vault-secret-form.tsx`+- **Kind** selector: design is a **2-segment toggle** (Static value | Signing+ key), not two big cards. Use a segmented control (reuse the existing+ Tabs/segmented primitive, or build one consistent with the design system).+- **Field order**: Kind → Name → Value → Protection → Group → **Advanced**.+- Name hint: "Uppercase A–Z 0–9 _ · globally unique".+- Value: input + eye toggle; placeholder "Paste the secret value".+- Protection: two cards Standard / Protected, exact copy — Standard+ "Machine-encrypted. Headless use OK. For API keys.", Protected "Unlocked in+ your browser. Survives machine theft. No headless."; selected = green border ++ check.+- **Advanced**: a single collapsible box containing (a) "Allowed hosts (for proxy+ fetch)" input, and (b) an **"Always ask before each use"** toggle with help+ "Never granted in advance, even per-key". The impl currently lacks both the+ Advanced grouping and the toggle.+- Primary button label: **"Create secret"** (currently "Save"/"保存").+- Setup/unlock: do NOT embed as a coequal third section under the form. When+ Protected is chosen and the vault is not unlocked, show the setup/unlock step+ (per A/B) as the gating step; keep "Create secret" disabled until unlocked. Must+ not be a nested form and must match the frames.+- **DECISION — do NOT silently drop**: `description` + `tags` exist in the impl+ but are absent from the `vyed5` mock. Do not delete them; fold them under+ "Advanced" (or keep minimal) and **flag this in the PR description** for owner+ review. Also verify whether "Always ask before each use" maps to a real backend+ policy field; if it is not supported, **flag it** rather than fake a dead toggle.++### D. Approval cards (`w8u5l` access, `eWOjt` signing) — `vault-approval-card.tsx`+Compare header / detail rows / scope options / footer to the frames and align+copy + layout. The embedded protected-unlock panel inherits the A/B fix (this+file reuses `VaultProtectedUnlock`).++### E. Hub (`y4rw5Q` → `VaultsPage.tsx`), Provision (`F4N19`), Group dropdown (`WgGQy`)+Compare each to its frame and fix divergences (sections, spacing, control styles,+copy). Provision = the `fixedName` mode of the form → match `SecureInputCard`.+Group dropdown → match `GroupPopover`.++## Constraints+- The `design.pen` frames are the literal spec — match them. Map every+ size/weight/spacing/radius/color/shadow to a UI token/class; add the token if+ missing; never hardcode a one-off hex.+- Reuse `ui/src/components/ui` primitives (Button, Badge, Card, Dialog, Input,+ Switch, Combobox, Tabs/segmented…). Extend a primitive before forking.+- i18n: all copy through `ui/src/i18n/en.json` + `zh.json`, kept 1:1. Reuse+ existing keys; add new ones in both files.+- `cd ui && npm run build` (tsc + vite) MUST pass.+- Do NOT change backend behavior or the crypto. **CARDINAL INVARIANT**: plaintext+ — secret values, released DEKs, private keys — lives ONLY in the browser and in+ avault; the daemon only ever relays opaque blobs. Restyling must not alter any+ crypto / submit path. Keep the keypair sign-only guard.+- Do not touch the parked sandbox (#706) or unrelated code.++## Deliverables+1. Every Vaults surface realigned to its frame.+2. A "Results" section appended here: per surface, what diverged and what changed,+ referencing the frame.+3. `npm run build` green.+4. A NON-draft PR titled `fix(vaults): realign UI to design.pen frames`.+ Description must name the capability, list the surfaces changed, call out the+ description/tags + "always ask" decisions/flags, and state evidence layers+ (build; manual; Codex E2E pending).+5. Own the Codex review loop (background-watch-hook + bundled `wait_pr.py`),+ re-request `@codex review` after each push, fix findings at root. Do NOT+ merge — the gatekeeper merges after Codex passes and after fidelity is+ verified against the frames.++## Verification (by the gatekeeper — not the implementer)+- Render each built surface and compare side-by-side to the frame PNG.+- Codex runs an end-to-end test in the local Incus regression env to confirm the+ design is restored.++## Results++All copy/spacing/colors mapped to existing tokens/classes (`mint`/`mint-soft`,+`gold`, `violet`/`violet-soft`, `accent`/`accent-soft`, `destructive`, `surface`/+`surface-2`, `border`, `muted`/`muted-foreground`, `foreground`). No one-off hex+added. i18n: every string routed through `en.json` + `zh.json`, verified 1:1 (197+keys each, no gaps) and every referenced key resolves. `cd ui && npm run build`+(tsc + vite) passes. Cardinal invariant preserved: the crypto/submit path+(`sealValue` / `sealBlindBox` / `getVaultPubkey` / `createVaultSecret` /+`establishing_vmk` / keypair `signer_kind` + `public_meta`) is byte-for-byte+unchanged; the only payload change is restructuring `policy` and adding the real+`policy.always_ask` field (see Flags). Setup, unlock, create, provision, and the+group dropdown were rendered in a throwaway light-theme harness and visually+confirmed against the frame PNGs (harness removed before commit).++### A. Protected setup (`kAmWj`) — `vault-protected-unlock.tsx` (needs-setup)+- **Diverged:** two coequal sections (passkey card + a full password `<form>`)+ embedded inside the create `<form>` — invalid nested form that reloaded the page.+- **Changed:** full rewrite, form-free (buttons + `onClick`). Centered shield-check+ badge, title "Set up protected secrets" + subtitle. ONE recommended green card+ (1.5px mint border on `mint-soft`): `RECOMMENDED` badge, solid green "Add a+ passkey" (`variant="brand"`), caption. Life-buoy recovery tip. "Use a password+ instead" + `less secure` badge link that **progressively reveals** the password+ fields (hidden by default; auto-revealed only when no passkey is available here).+ "Maybe later" dismiss (via new optional `onDismiss`). Enter submits via keydown,+ not form submit.++### B. Protected unlock (`g5Q7F`) — `vault-protected-unlock.tsx` (locked)+- **Diverged:** password rendered as an inline `<form>`; no progressive disclosure.+- **Changed:** form-free. Gold scan-face badge, "Unlock to continue" + "<NAME> is+ protected — unlock it in your browser to sign" subtitle (new `secretName` prop).+ "Unlock with passkey" (`variant="brand"`) + caption; "Use password instead"+ reveal link → password field + Unlock; mint factor-safety note; Cancel.++### C. Create dialog (`vyed5`) — `vault-secret-form.tsx`+- **Diverged:** Kind as two big cards; field order had Value before Group with+ Description/Tags/Hosts as loose siblings; no Advanced grouping; no always-ask;+ primary button "Save"; protected setup/unlock embedded as a coequal section.+- **Changed:** Kind is now a 2-segment `SegmentedRadio` (reused primitive). Field+ order Kind → Name → Value → Protection → Group → Advanced. Name hint added.+ Value placeholder "Paste the secret value". Protection cards use exact frame copy+ and the selected card shows a mint check. Group uses the extended `Combobox`+ (folder icons + design create row). New **Advanced** collapsible holds+ Description, Tags, Allowed hosts, and the **"Always ask before each use"** toggle.+ Primary button "Create secret". Protected setup/unlock now renders as a gating+ step (not a nested form, not coequal) and "Create secret" stays disabled until+ unlocked.++### D. Approval cards (`w8u5l` access, `eWOjt` sign) — `vault-approval-card.tsx`+- **Diverged:** access header used a cyan key icon; sign used a wallet; detail rows+ were a bordered sub-panel with uppercase labels; scope used a check-circle;+ Approve/Sign used a shield icon.+- **Changed:** access = gold `LockKeyhole`, sign = violet `PenTool`. Details are a+ borderless list with sentence-case fixed-width labels and top/bottom dividers;+ command is a plain mono chip; egress uses `Cpu`. Scope options use a radio+ indicator (mint ring + dot) with the selected label bold. Approve = `Check`,+ Sign = `PenTool`. Protected gating shows the unlock panel while locked, then the+ mint operation note once unlocked (no duplicate note).++### E. Hub (`y4rw5Q`), Provision (`F4N19`), Group dropdown (`WgGQy`)+- **Hub — `VaultsPage.tsx`:** subtitle → "Secrets your agents use — names only,+ values never shown". Active grants are now compact dismissible **chips** (icon ·+ `type · ref` · live countdown · ×) instead of full cards. Group headers gained a+ folder icon and a smarter count ("N secrets" / "N keys"). Secret rows gained an+ `always-ask` badge and a `proxy · <host>` badge. Out of scope (net-new features,+ not restyles): the search field, the "By skill" tab, and per-row ⋯ menus — these+ frames depict capabilities that don't exist yet and were intentionally not built.+- **Provision — `vault-secret-form.tsx` (`fixedName`) + `secret-request-card.tsx`:**+ the `fixedName` mode now matches `SecureInputCard`: a cyan key header ("Agent+ needs a secret"), a cyan name-highlight box (asterisk + "Secret name" + name ++ "not set yet" badge), Value + eye + "Submitted over TLS…" help, a "Store as"+ segmented Standard|Protected, and a "Save & wake agent" button. Same submit path.+- **Group dropdown — extended `Combobox`:** added optional `withFolderIcon` (folder+ icon per option + on the trigger; mint-soft selected row with check) and+ `createButtonLabel` (a bordered "+ <typed>" input with a green Create button).+ Both are opt-in, so every other `Combobox` caller is unchanged.++### Flags for owner review+1. **Description + Tags** exist in the impl but are absent from the `vyed5` mock.+ Per the spec they were **not deleted** — they're folded under the new Advanced+ collapsible and stay fully functional. Confirm this placement is acceptable.+2. **"Always ask before each use"** maps to a **real** backend field:+ `policy.always_ask` (storage/vault_service.py `_secret_access_grantable` returns+ `False` when set → the secret is never granted in advance, even per-key), which+ matches the mock's help text exactly. It is wired live (static secrets only;+ keypairs are already never value-grantable, so the toggle is disabled for them).+ Not a dead control.diff --git a/ui/src/components/ui/combobox.tsx b/ui/src/components/ui/combobox.tsxindex 7d41c9314..f27463ffc 100644--- a/ui/src/components/ui/combobox.tsx+++ b/ui/src/components/ui/combobox.tsx@@ -1,8 +1,9 @@import * as React from "react"-import { Check, ChevronsUpDown } from "lucide-react"+import { Check, ChevronsUpDown, Folder, Plus } from "lucide-react"import { cn } from "../../lib/utils"import { fieldBaseClass } from "./field"+import { Button } from "./button"import {Command,CommandEmpty,@@ -34,6 +35,11 @@ interface ComboboxProps {commitOnClose?: booleancreateLabel?: (value: string) => stringcreateHeading?: string+ /** Show a folder icon before each option + the create row (design.pen group picker). */+ withFolderIcon?: boolean+ /** When set, the create affordance renders as a bordered input + this-labelled button+ * (design.pen `e3rPI`) instead of an inline command item. */+ createButtonLabel?: string}export function Combobox({@@ -48,6 +54,8 @@ export function Combobox({commitOnClose = false,createLabel,createHeading,+ withFolderIcon = false,+ createButtonLabel,}: ComboboxProps) {const [open, setOpen] = React.useState(false)const [inputValue, setInputValue] = React.useState("")@@ -71,6 +79,31 @@ export function Combobox({(opt) => opt.value.toLowerCase() === inputValue.toLowerCase() || opt.label.toLowerCase() === inputValue.toLowerCase())+ const commitCreate = (next: string) => {+ onValueChange(next)+ setOpen(false)+ setInputValue("")+ }++ // Bordered "+ <typed value> Create" row (design.pen `e3rPI`). Used when the consumer+ // opts in via `createButtonLabel`; otherwise the legacy inline command item is used.+ const renderCreateButtonRow = (typed: string) => (+ <div className="flex items-center gap-2 p-2">+ <span+ className={cn(+ fieldBaseClass,+ "flex h-9 flex-1 items-center gap-2 border-mint/50 px-2.5",+ )}+ >+ <Plus className="size-3.5 shrink-0 text-mint" />+ <span className="truncate text-sm text-foreground">{typed}</span>+ </span>+ <Button type="button" size="sm" onClick={() => commitCreate(typed)}>+ {createButtonLabel}+ </Button>+ </div>+ )+return (<Popoveropen={open}@@ -95,7 +128,8 @@ export function Combobox({className)}>- <span className={cn("truncate", !displayValue && "text-muted")}>+ <span className={cn("flex items-center gap-2 truncate", !displayValue && "text-muted")}>+ {withFolderIcon && displayValue && <Folder className="size-4 shrink-0 text-muted" />}{displayValue || placeholder}</span><ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />@@ -113,68 +147,80 @@ export function Combobox({<CommandEmpty>{emptyText}</CommandEmpty>)}{filteredOptions.length === 0 && allowCustomValue && inputValue && (- <CommandGroup>- <CommandItem- value={inputValue}- onSelect={() => {- onValueChange(inputValue)- setOpen(false)- setInputValue("")- }}- >- <Check- className={cn(- "mr-2 h-4 w-4",- value === inputValue ? "opacity-100" : "opacity-0"- )}- />- {createLabel ? createLabel(inputValue) : `Use "${inputValue}"`}- </CommandItem>- </CommandGroup>- )}- {filteredOptions.length > 0 && (- <CommandGroup>- {filteredOptions.map((option) => (+ createButtonLabel ? (+ renderCreateButtonRow(inputValue)+ ) : (+ <CommandGroup><CommandItem- key={option.value}- value={option.value}- onSelect={() => {- onValueChange(option.value)- setOpen(false)- setInputValue("")- }}+ value={inputValue}+ onSelect={() => commitCreate(inputValue)}><CheckclassName={cn("mr-2 h-4 w-4",- value === option.value ? "opacity-100" : "opacity-0"+ value === inputValue ? "opacity-100" : "opacity-0")}/>- {option.label}+ {createLabel ? createLabel(inputValue) : `Use "${inputValue}"`}</CommandItem>- ))}+ </CommandGroup>+ )+ )}+ {filteredOptions.length > 0 && (+ <CommandGroup>+ {filteredOptions.map((option) => {+ const active = value === option.value+ return (+ <CommandItem+ key={option.value}+ value={option.value}+ onSelect={() => commitCreate(option.value)}+ className={cn(active && withFolderIcon && "bg-mint-soft text-mint data-[selected=true]:bg-mint-soft")}+ >+ {withFolderIcon ? (+ <>+ <Folder className={cn("mr-2 h-4 w-4 shrink-0", active ? "text-mint" : "text-muted")} />+ <span className={cn("flex-1 truncate", active ? "font-semibold text-foreground" : "text-foreground")}>+ {option.label}+ </span>+ <Check className={cn("ml-2 h-4 w-4 text-mint", active ? "opacity-100" : "opacity-0")} />+ </>+ ) : (+ <>+ <Check+ className={cn("mr-2 h-4 w-4", active ? "opacity-100" : "opacity-0")}+ />+ {option.label}+ </>+ )}+ </CommandItem>+ )+ })}</CommandGroup>)}{/* Show custom value option if input doesn't match existing options */}{allowCustomValue && inputValue && !inputMatchesOption && filteredOptions.length > 0 && (- <CommandGroup heading={createHeading ?? "Custom"}>- <CommandItem- value={`custom-${inputValue}`}- onSelect={() => {- onValueChange(inputValue)- setOpen(false)- setInputValue("")- }}- >- <Check- className={cn(- "mr-2 h-4 w-4",- value === inputValue ? "opacity-100" : "opacity-0"- )}- />- {createLabel ? createLabel(inputValue) : `Use "${inputValue}"`}- </CommandItem>- </CommandGroup>+ createButtonLabel ? (+ <>+ <div className="mx-2 my-1 h-px bg-border" />+ {renderCreateButtonRow(inputValue)}+ </>+ ) : (+ <CommandGroup heading={createHeading ?? "Custom"}>+ <CommandItem+ value={`custom-${inputValue}`}+ onSelect={() => commitCreate(inputValue)}+ >+ <Check+ className={cn(+ "mr-2 h-4 w-4",+ value === inputValue ? "opacity-100" : "opacity-0"+ )}+ />+ {createLabel ? createLabel(inputValue) : `Use "${inputValue}"`}+ </CommandItem>+ </CommandGroup>+ ))}</CommandList></Command>diff --git a/ui/src/components/ui/secret-request-card.tsx b/ui/src/components/ui/secret-request-card.tsxindex c340583a7..d0f738e72 100644--- a/ui/src/components/ui/secret-request-card.tsx+++ b/ui/src/components/ui/secret-request-card.tsx@@ -2,7 +2,7 @@ import { useState } from 'react';import { CheckCircle2, KeyRound } from 'lucide-react';import { useTranslation } from 'react-i18next';import { badgeVariants } from './badge';-import { Dialog, DialogContent, DialogHeader, DialogTitle } from './dialog';+import { Dialog, DialogContent, DialogTitle } from './dialog';import { VaultSecretForm } from './vault-secret-form';import { cn } from '@/lib/utils';@@ -37,21 +37,28 @@ export const SecretRequestCard: React.FC<{ name: string }> = ({ name }) => {</button><Dialog open={open} onOpenChange={setOpen}><DialogContent>- <DialogHeader>- <DialogTitle>{t('vaults.request.title', { name })}</DialogTitle>- </DialogHeader>- <div className="flex flex-col gap-3">- <p className="text-sm text-muted">{t('vaults.request.help')}</p>- <VaultSecretForm- fixedName={name}- onCancel={() => setOpen(false)}- onCreated={() => {- setFulfilled(true);- setOpen(false);- }}- treatExistingAsFulfilled- />+ {/* Accessible name for the Radix dialog — the visible title below is styled per+ design.pen `F4N19`, so keep a screen-reader-only DialogTitle for a11y. */}+ <DialogTitle className="sr-only">{t('vaults.request.title')}</DialogTitle>+ {/* Header — design.pen `F4N19` (SecureInputCard): cyan key + ask copy. */}+ <div className="flex items-start gap-3 pr-6">+ <span className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent/15 text-accent">+ <KeyRound className="size-5" />+ </span>+ <div className="flex flex-col gap-0.5">+ <span className="text-[15px] font-semibold text-foreground">{t('vaults.request.title')}</span>+ <span className="text-xs text-muted-foreground">{t('vaults.request.help')}</span>+ </div></div>+ <VaultSecretForm+ fixedName={name}+ onCancel={() => setOpen(false)}+ onCreated={() => {+ setFulfilled(true);+ setOpen(false);+ }}+ treatExistingAsFulfilled+ /></DialogContent></Dialog></>diff --git a/ui/src/components/ui/vault-approval-card.tsx b/ui/src/components/ui/vault-approval-card.tsxindex 83b91b5e9..601a0c70e 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, useState } from 'react';-import { Check, Globe, KeyRound, Loader2, Lock, ShieldCheck, Terminal, Wallet } from 'lucide-react';+import { Check, Cpu, Loader2, LockKeyhole, PenTool, ShieldCheck, Wallet } from 'lucide-react';import { useTranslation } from 'react-i18next';import { useApi, type VaultRequest } from '@/context/ApiContext';@@ -53,9 +53,10 @@ function shortDigest(hex: string): string {return `0x${clean.slice(0, 10)}…${clean.slice(-8)}`;}-const PANEL = 'flex flex-col rounded-xl border border-border bg-surface';-const ROW = 'flex items-start gap-3 px-4 py-2.5 text-sm';-const ROW_LABEL = 'w-20 shrink-0 pt-0.5 text-xs font-medium uppercase tracking-wide text-muted';+// design.pen `SKBld` / `pRtHq`: a borderless detail list (no inner card) with sentence-case+// muted row labels at a fixed width and the value flowing to fill.+const ROW = 'flex items-start gap-2.5 text-sm';+const ROW_LABEL = 'w-[74px] shrink-0 pt-0.5 text-[12px] text-muted';const DetailRow: React.FC<{ label: string; children: React.ReactNode }> = ({ label, children }) => (<div className={ROW}>@@ -250,18 +251,18 @@ export const VaultApprovalCard: React.FC<{return (<div className="flex flex-col gap-4">- {/* Header */}+ {/* Header — design.pen `SKBld` (access, gold lock) / `pRtHq` (sign, violet pen). */}<div className="flex items-start gap-3"><divclassName={cn('flex size-10 shrink-0 items-center justify-center rounded-xl',- isSign ? 'bg-violet/10 text-violet' : 'bg-accent/10 text-accent',+ isSign ? 'bg-violet/15 text-violet' : 'bg-gold/15 text-gold',)}>- {isSign ? <Wallet className="size-5" /> : <KeyRound className="size-5" />}+ {isSign ? <PenTool className="size-5" /> : <LockKeyhole className="size-5" />}</div><div className="flex flex-col gap-0.5">- <span className="text-sm font-semibold">+ <span className="text-[15px] font-semibold">{isSign ? t('vaults.approval.signTitle') : t('vaults.approval.accessTitle')}</span><span className="text-xs text-muted-foreground">@@ -270,10 +271,12 @@ export const VaultApprovalCard: React.FC<{</div></div>- {/* Details */}- <div className={PANEL}>+ <div className="h-px bg-border" />++ {/* Details — borderless list, sentence-case labels. */}+ <div className="flex flex-col gap-3.5"><DetailRow label={isSign ? t('vaults.approval.key') : t('vaults.approval.secret')}>- <span className="truncate font-mono text-sm font-semibold">{card.secret_name}</span>+ <span className="truncate font-mono text-[13px] font-semibold">{card.secret_name}</span>{isProtected ? (<Badge variant="warning">{t('vaults.protected')}</Badge>) : (@@ -287,82 +290,84 @@ export const VaultApprovalCard: React.FC<{) : null}</DetailRow>{card.session_id ? (- <>- <div className="h-px bg-border" />- <DetailRow label={t('vaults.approval.session')}>- <span className="truncate font-mono text-xs text-foreground">{card.session_id}</span>- </DetailRow>- </>+ <DetailRow label={t('vaults.approval.session')}>+ <span className="truncate text-[13px] text-foreground">{card.session_id}</span>+ </DetailRow>) : null}{!isSign && card.command ? (- <>- <div className="h-px bg-border" />- <DetailRow label={t('vaults.approval.command')}>- <span className="flex items-center gap-1.5 truncate rounded-md bg-surface-2 px-2 py-1 font-mono text-xs">- <Terminal className="size-3 shrink-0 text-muted" />- {card.command}- </span>- </DetailRow>- </>+ <DetailRow label={t('vaults.approval.command')}>+ <span className="min-w-0 flex-1 truncate rounded-md bg-surface-2 px-2 py-1 font-mono text-xs">{card.command}</span>+ </DetailRow>) : null}{!isSign && card.egress ? (- <>- <div className="h-px bg-border" />- <DetailRow label={t('vaults.approval.egress')}>- <span className="flex items-center gap-1.5 text-xs text-muted">- <Globe className="size-3 shrink-0" />- {card.egress}- </span>- </DetailRow>- </>+ <DetailRow label={t('vaults.approval.egress')}>+ <span className="flex items-center gap-1.5 text-[13px] text-foreground">+ <Cpu className="size-3.5 shrink-0 text-muted" />+ {card.egress}+ </span>+ </DetailRow>) : null}{isSign && delivery.digest ? (- <>- <div className="h-px bg-border" />- <DetailRow label={t('vaults.approval.digest')}>- <span className="truncate font-mono text-xs text-foreground" title={delivery.digest}>- {shortDigest(delivery.digest)}- </span>- {delivery.scheme ? <Badge variant="secondary">{delivery.scheme}</Badge> : null}- </DetailRow>- </>+ <DetailRow label={t('vaults.approval.digest')}>+ <span className="truncate font-mono text-xs text-foreground" title={delivery.digest}>+ {shortDigest(delivery.digest)}+ </span>+ {delivery.scheme ? <Badge variant="secondary">{delivery.scheme}</Badge> : null}+ </DetailRow>) : null}</div>+ <div className="h-px bg-border" />+{/* Approval scope (access only) */}{!isSign && scopeOptions.length > 0 ? (<div className="flex flex-col gap-2"><span className="px-1 text-xs font-semibold uppercase tracking-wide text-muted">{t('vaults.approval.scopeTitle')}</span>- <div className="flex flex-col gap-2">+ <div+ role="radiogroup"+ aria-label={t('vaults.approval.scopeTitle')}+ className="flex flex-col gap-2"+ onKeyDown={(e) => {+ if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {+ e.preventDefault();+ setScopeIdx((i) => (i + 1) % scopeOptions.length);+ } else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {+ e.preventDefault();+ setScopeIdx((i) => (i - 1 + scopeOptions.length) % scopeOptions.length);+ }+ }}+ >{scopeOptions.map((option, idx) => {const selected = idx === scopeIdx;return (<buttonkey={`${option.scope_type}:${option.scope_ref}`}type="button"- aria-pressed={selected}+ role="radio"+ aria-checked={selected}+ tabIndex={selected ? 0 : -1}onClick={() => setScopeIdx(idx)}className={cn(- 'flex items-start gap-3 rounded-xl border p-3 text-left transition-colors',+ 'flex items-center gap-2.5 rounded-lg border p-2.5 text-left transition-colors',selected ? 'border-mint bg-mint-soft' : 'border-border bg-surface hover:bg-surface-2',)}><spanclassName={cn(- 'mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border',- selected ? 'border-mint bg-mint text-background' : 'border-border-strong',+ 'flex size-[18px] shrink-0 items-center justify-center rounded-full border-[1.5px]',+ selected ? 'border-2 border-mint' : 'border-border-strong',)}>- {selected ? <Check className="size-3" /> : null}+ {selected ? <span className="size-2 rounded-full bg-mint" /> : null}</span>- <span className="flex min-w-0 flex-col gap-0.5">- <span className="flex flex-wrap items-center gap-1.5 text-sm font-medium">+ <span className="flex min-w-0 flex-col gap-px">+ <span className={cn('flex flex-wrap items-center gap-1.5 text-[13px]', selected ? 'font-semibold' : 'font-medium')}>{t(`vaults.approval.scope.${option.scope_type}`, { ref: option.scope_ref })}<Badge variant="secondary">{ttlLabel(option.default_ttl_seconds)}</Badge></span>- <span className="text-xs text-muted-foreground">+ <span className="text-[11px] text-muted-foreground">{t('vaults.approval.scopeMembers', { count: option.member_count })}</span></span>@@ -373,15 +378,14 @@ export const VaultApprovalCard: React.FC<{</div>) : null}- {/* Protected unlock + invariant note */}- {needsUnlock ? (- <div className="flex flex-col gap-2">- <VaultProtectedUnlock vault={vault} />- <span className="flex items-center gap-1.5 rounded-lg border border-mint/40 bg-mint-soft px-3 py-2 text-xs text-mint">- <Lock className="size-3.5 shrink-0" />- {isSign ? t('vaults.approval.signNote') : t('vaults.approval.accessNote')}- </span>- </div>+ {/* Protected gating: show the browser-unlock panel while locked (it carries its own+ factor note); once unlocked, show only the design's mint operation note. */}+ {needsUnlock && !unlocked ? <VaultProtectedUnlock vault={vault} /> : null}+ {needsUnlock && unlocked ? (+ <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" />+ {isSign ? t('vaults.approval.signNote') : t('vaults.approval.accessNote')}+ </span>) : null}{error ? (@@ -408,7 +412,13 @@ export const VaultApprovalCard: React.FC<{{t('vaults.approval.deny')}</Button><Button type="button" onClick={isSign ? approveSign : approveAccess} disabled={approveDisabled}>- {busy ? <Loader2 className="size-4 animate-spin" /> : <ShieldCheck className="size-4" />}+ {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>diff --git a/ui/src/components/ui/vault-protected-unlock.tsx b/ui/src/components/ui/vault-protected-unlock.tsxindex 77144ae67..171666221 100644--- a/ui/src/components/ui/vault-protected-unlock.tsx+++ b/ui/src/components/ui/vault-protected-unlock.tsx@@ -1,10 +1,11 @@import { useState } from 'react';-import { Fingerprint, KeyRound, Loader2, Lock, RefreshCw, ShieldCheck } from 'lucide-react';+import { KeyRound, 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 type { useProtectedVault } from '@/lib/useProtectedVault';+import { Badge } from './badge';import { Button } from './button';import { Input } from './input';@@ -26,20 +27,36 @@ function friendlyError(t: TFunction, raw: string): string {return raw;}-const PANEL = 'flex flex-col gap-2.5 rounded-lg border border-border bg-surface-2 px-3 py-3';+const PANEL = 'flex flex-col gap-4 rounded-2xl border border-border bg-surface px-6 pb-5 pt-6';/**- * Protected-tier setup / unlock panel. Setup always captures a password (the recovery- * root) and offers a passkey on top (Touch ID / Windows Hello, when the origin allows- * WebAuthn); unlock accepts either factor. The unlocked VMK is cached for the session- * by {@link useProtectedVault}, so multiple protected secrets can be created without- * re-prompting.+ * Protected-tier setup / unlock panel — design.pen frames `kAmWj` (setup) and `g5Q7F`+ * (unlock). Setup leads with a single recommended passkey path and progressively reveals+ * the recoverable password fields behind a "Use a password instead" link; unlock leads+ * with passkey and reveals password the same way. Both are form-free: the panel often+ * lives inside the create dialog's own `<form>`, so a nested `<form>` here would be invalid+ * HTML and (in practice) trigger a full-page reload. Every action is a button `onClick`.+ *+ * Password is always the recovery root in the crypto layer; a passkey is the quick primary+ * unlock added on top. The unlocked VMK is cached for the session by {@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.*/-export const VaultProtectedUnlock: React.FC<{ vault: Vault }> = ({ vault }) => {+export const VaultProtectedUnlock: React.FC<{ vault: Vault; secretName?: string; onDismiss?: () => void }> = ({+ vault,+ secretName,+ onDismiss,+}) => {const { t } = useTranslation();const [password, setPassword] = useState('');const [confirm, setConfirm] = useState('');const [busy, setBusy] = useState(false);+ // Progressive disclosure: password fields stay hidden until the user opts out of the+ // recommended passkey path. Resets whenever the panel re-mounts for a new state.+ const [showPassword, setShowPassword] = useState(false);+ // Passkey-only setup has no password/second-passkey/recovery fallback yet, so a lost+ // passkey is unrecoverable — gate the recommended action behind an explicit ack.const [ackLoss, setAckLoss] = useState(false);const run = async (fn: () => Promise<void>) => {@@ -58,7 +75,7 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault }> = ({ vault }) => {if (vault.status === 'checking') {return (- <div className="flex items-center gap-2 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-muted">+ <div className="flex items-center gap-2 rounded-2xl border border-border bg-surface px-4 py-3 text-sm text-muted"><Loader2 className="size-4 animate-spin" />{t('vaults.protectedUnlock.checking')}</div>@@ -67,7 +84,7 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault }> = ({ vault }) => {if (vault.status === 'error') {return (- <div className="flex flex-col gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-3 text-sm">+ <div className="flex flex-col gap-2 rounded-2xl border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm"><span className="font-medium text-destructive">{t('vaults.protectedUnlock.errorTitle')}</span>{vault.error && <span className="text-xs text-destructive">{friendlyError(t, vault.error)}</span>}<Button type="button" variant="secondary" size="sm" className="self-start" onClick={() => run(vault.refresh)} disabled={busy}>@@ -80,7 +97,7 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault }> = ({ vault }) => {if (vault.status === 'unlocked') {return (- <div className="flex items-center gap-2 rounded-lg border border-mint/40 bg-mint-soft px-3 py-2 text-sm text-mint">+ <div className="flex items-center gap-2 rounded-2xl border border-mint/40 bg-mint-soft px-4 py-3 text-sm text-mint"><ShieldCheck className="size-4 shrink-0" /><span className="font-medium">{t('vaults.protectedUnlock.unlocked')}</span><Button type="button" variant="ghost" size="sm" className="ml-auto h-7 text-muted" onClick={vault.lock} disabled={busy}>@@ -92,9 +109,10 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault }> = ({ vault }) => {}const canUsePasskey = webauthnAvailable();+ const passwordValid = password.trim().length > 0 && password === confirm;+ // ---- Setup (needs-setup): design.pen `kAmWj` ---------------------------------------if (vault.status === 'needs-setup') {- const passwordValid = password.trim().length > 0 && password === confirm;const submitPassword = () => {if (password.trim().length === 0) return;if (password !== confirm) {@@ -103,115 +121,216 @@ export const VaultProtectedUnlock: React.FC<{ vault: Vault }> = ({ vault }) => {}void run(() => vault.setupPassword(password));};+ // Password is the only factor when WebAuthn isn't available here — surface the fields+ // immediately rather than hiding them behind a passkey card that can't be used.+ const passwordRevealed = showPassword || !canUsePasskey;return (<div className={PANEL}>- <div className="flex items-start gap-2">- <Lock className="mt-0.5 size-4 shrink-0 text-muted" />- <div className="flex flex-col gap-0.5">- <span className="text-sm font-semibold">{t('vaults.protectedUnlock.setupTitle')}</span>- <span className="text-xs text-muted-foreground">{t('vaults.protectedUnlock.setupHelp')}</span>+ <div className="flex flex-col items-center gap-4">+ <span className="flex size-13 items-center justify-center rounded-2xl bg-mint-soft">+ <ShieldCheck className="size-7 text-mint" />+ </span>+ <div className="flex flex-col items-center gap-1.5">+ <span className="text-center text-[17px] font-bold text-foreground">{t('vaults.protectedUnlock.setupTitle')}</span>+ <span className="max-w-sm text-center text-[13px] leading-snug text-muted-foreground">+ {t('vaults.protectedUnlock.setupSubtitle')}+ </span></div></div>- {/* Passkey — most secure (no phishable password), but unrecoverable: explicit ack required. */}+ {/* Recommended: passkey — the single primary path (design leads with this). */}+ {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-background">+ <Sparkles className="size-3" />+ {t('vaults.protectedUnlock.recommended')}+ </Badge>+ <Button type="button" variant="brand" className="w-full" onClick={() => run(vault.setupPasskey)} disabled={busy || !ackLoss}>+ {busy ? <Loader2 className="size-5 animate-spin" /> : <ScanFace className="size-5" />}+ {t('vaults.protectedUnlock.addPasskey')}+ </Button>+ <span className="text-center text-[11.5px] text-muted-foreground">{t('vaults.protectedUnlock.passkeyCaption')}</span>+ </div>+ )}++ {/* Unrecoverable acknowledgement — a passkey-only vault has no password/second-passkey/+ recovery fallback yet, so a lost passkey means the protected secrets are gone. Gate+ the recommended action behind an explicit ack until a recovery flow exists. */}{canUsePasskey && (- <div className="flex flex-col gap-2 rounded-lg border border-border bg-surface p-2.5">+ <div className="flex flex-col gap-2 rounded-xl border border-warning/40 bg-warning/10 p-3">+ <span className="text-[11.5px] leading-snug text-warning">{t('vaults.protectedUnlock.passkeyUnrecoverableWarning')}</span>+ <label className="flex items-start gap-2 text-[11.5px] leading-snug text-muted-foreground">+ <input type="checkbox" checked={ackLoss} onChange={(e) => setAckLoss(e.target.checked)} className="mt-0.5 shrink-0" />+ <span>{t('vaults.protectedUnlock.passkeyAck')}</span>+ </label>+ </div>+ )}++ {/* Progressive disclosure — password fields stay hidden until requested. */}+ {!passwordRevealed ? (+ <button+ type="button"+ onClick={() => setShowPassword(true)}+ className="flex items-center justify-center gap-2 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground"+ >+ {t('vaults.protectedUnlock.usePasswordInstead')}+ <Badge variant="destructive">{t('vaults.protectedUnlock.lessSecure')}</Badge>+ </button>+ ) : (+ <div className="flex flex-col gap-2.5 rounded-xl border border-border bg-surface-2 p-3"><span className="flex items-center gap-1.5 text-xs font-semibold">- <Fingerprint className="size-3.5 text-mint" />- {t('vaults.protectedUnlock.passkeyOptionTitle')}+ <KeyRound className="size-3.5" />+ {t('vaults.protectedUnlock.passwordOptionTitle')}</span>- <span className="text-xs text-muted-foreground">{t('vaults.protectedUnlock.passkeyOptionHelp')}</span>- <div className="rounded-md border border-warning/40 bg-warning/10 px-2.5 py-1.5 text-xs text-warning">- {t('vaults.protectedUnlock.passkeyUnrecoverableWarning')}- </div>- <label className="flex items-start gap-2 text-xs text-muted-foreground">- <input type="checkbox" checked={ackLoss} onChange={(e) => setAckLoss(e.target.checked)} className="mt-0.5" />- <span>{t('vaults.protectedUnlock.passkeyAck')}</span>+ <label className="flex flex-col gap-1.5 text-xs text-muted-foreground">+ {t('vaults.protectedUnlock.setPasswordLabel')}+ <Input+ type="password"+ value={password}+ onChange={(e) => setPassword(e.target.value)}+ placeholder={t('vaults.protectedUnlock.passwordPlaceholder')}+ autoComplete="new-password"+ onKeyDown={(e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ submitPassword();+ }+ }}+ />+ </label>+ <label className="flex flex-col gap-1.5 text-xs text-muted-foreground">+ {t('vaults.protectedUnlock.confirmLabel')}+ <Input+ type="password"+ value={confirm}+ onChange={(e) => setConfirm(e.target.value)}+ placeholder={t('vaults.protectedUnlock.confirmPlaceholder')}+ autoComplete="new-password"+ onKeyDown={(e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ submitPassword();+ }+ }}+ /></label>- <Button type="button" onClick={() => run(vault.setupPasskey)} disabled={busy || !ackLoss}>- {busy ? <Loader2 className="size-4 animate-spin" /> : <Fingerprint className="size-4" />}- {t('vaults.protectedUnlock.setupWithPasskey')}+ <Button type="button" variant="secondary" onClick={submitPassword} disabled={busy || !passwordValid}>+ {busy && <Loader2 className="size-4 animate-spin" />}+ {t('vaults.protectedUnlock.createPassword')}</Button></div>)}- {/* Password — recoverable alternative (weaker; can be phished/leaked). */}- <form- className="flex flex-col gap-2 rounded-lg border border-border bg-surface p-2.5"- onSubmit={(e) => {- e.preventDefault();- submitPassword();- }}- >- <span className="flex items-center gap-1.5 text-xs font-semibold">- <KeyRound className="size-3.5" />- {t('vaults.protectedUnlock.passwordOptionTitle')}- </span>- <span className="text-xs text-muted-foreground">{t('vaults.protectedUnlock.passwordOptionHelp')}</span>- <label className="flex flex-col gap-1.5 text-xs text-muted-foreground">- {t('vaults.protectedUnlock.setPasswordLabel')}- <Input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder={t('vaults.protectedUnlock.passwordPlaceholder')} autoComplete="new-password" />- </label>- <label className="flex flex-col gap-1.5 text-xs text-muted-foreground">- {t('vaults.protectedUnlock.confirmLabel')}- <Input type="password" value={confirm} onChange={(e) => setConfirm(e.target.value)} placeholder={t('vaults.protectedUnlock.confirmPlaceholder')} autoComplete="new-password" />- </label>- <Button type="submit" variant={canUsePasskey ? 'ghost' : 'secondary'} disabled={busy || !passwordValid}>- {busy && <Loader2 className="size-4 animate-spin" />}- {t('vaults.protectedUnlock.setupWithPassword')}- </Button>- </form>+ {onDismiss && (+ <button+ type="button"+ onClick={onDismiss}+ className="text-center text-[12.5px] font-medium text-muted-foreground transition-colors hover:text-foreground"+ >+ {t('vaults.protectedUnlock.maybeLater')}+ </button>+ )}- {vault.error && <div className="text-xs text-destructive">{friendlyError(t, vault.error)}</div>}+ {vault.error && <div className="text-center text-xs text-destructive">{friendlyError(t, vault.error)}</div>}</div>);}- // status === 'locked'+ // ---- Unlock (locked): design.pen `g5Q7F` -------------------------------------------const showUnlockPasskey = vault.hasPasskey() && canUsePasskey && vault.passkeyUsableHere();const showUnlockPassword = vault.hasPassword();+ // If the passkey can't be used here, the password is the only way in — reveal it up front.+ const passwordRevealed = showPassword || !showUnlockPasskey;+ const submitUnlock = () => {+ if (password.trim()) void run(() => vault.unlockPassword(password));+ };return (<div className={PANEL}>- <div className="flex items-start gap-2">- <Lock className="mt-0.5 size-4 shrink-0 text-muted" />- <div className="flex flex-col gap-0.5">- <span className="text-sm font-semibold">{t('vaults.protectedUnlock.unlockTitle')}</span>- <span className="text-xs text-muted-foreground">{t('vaults.protectedUnlock.unlockHelp')}</span>+ <div className="flex flex-col items-center gap-4">+ <span className="flex size-13 items-center justify-center rounded-2xl bg-gold/15">+ <ScanFace className="size-7 text-gold" />+ </span>+ <div className="flex flex-col items-center gap-1.5">+ <span className="text-center text-[17px] font-bold text-foreground">{t('vaults.protectedUnlock.unlockTitle')}</span>+ {secretName && (+ <span className="max-w-sm text-center text-[13px] leading-snug text-muted-foreground">+ {t('vaults.protectedUnlock.unlockSubtitle', { name: secretName })}+ </span>+ )}</div></div>+{showUnlockPasskey && (- <Button type="button" variant="secondary" onClick={() => run(vault.unlockPasskey)} disabled={busy}>- {busy ? <Loader2 className="size-4 animate-spin" /> : <Fingerprint className="size-4" />}- {t('vaults.protectedUnlock.unlockPasskey')}- </Button>- )}- {showUnlockPassword && (- <form- className="flex items-end gap-2"- onSubmit={(e) => {- e.preventDefault();- if (password.trim()) void run(() => vault.unlockPassword(password));- }}- >- <label className="flex flex-1 flex-col gap-1.5 text-xs font-medium text-muted-foreground">- <span className="flex items-center gap-1.5">- <KeyRound className="size-3.5" />- {t('vaults.protectedUnlock.passwordLabel')}- </span>- <Input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder={t('vaults.protectedUnlock.passwordPlaceholder')} autoComplete="current-password" />- </label>- <Button type="submit" disabled={busy || !password.trim()}>- {busy && <Loader2 className="size-4 animate-spin" />}- {t('vaults.protectedUnlock.unlockCta')}+ <div className="flex flex-col items-center gap-1.5">+ <Button type="button" variant="brand" className="w-full" onClick={() => run(vault.unlockPasskey)} disabled={busy}>+ {busy ? <Loader2 className="size-5 animate-spin" /> : <ScanFace className="size-5" />}+ {t('vaults.protectedUnlock.unlockWithPasskey')}</Button>- </form>+ <span className="text-center text-[11px] text-muted-foreground">{t('vaults.protectedUnlock.unlockPasskeyCaption')}</span>+ </div>)}++ {showUnlockPassword &&+ (!passwordRevealed ? (+ <button+ type="button"+ onClick={() => setShowPassword(true)}+ className="flex items-center justify-center gap-2 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground"+ >+ {t('vaults.protectedUnlock.usePasswordInline')}+ <Badge variant="destructive">{t('vaults.protectedUnlock.lessSecure')}</Badge>+ </button>+ ) : (+ <div className="flex items-end gap-2">+ <label className="flex flex-1 flex-col gap-1.5 text-xs font-medium text-muted-foreground">+ <span className="flex items-center gap-1.5">+ <KeyRound className="size-3.5" />+ {t('vaults.protectedUnlock.passwordLabel')}+ </span>+ <Input+ type="password"+ value={password}+ onChange={(e) => setPassword(e.target.value)}+ placeholder={t('vaults.protectedUnlock.passwordPlaceholder')}+ autoComplete="current-password"+ onKeyDown={(e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ submitUnlock();+ }+ }}+ />+ </label>+ <Button type="button" onClick={submitUnlock} disabled={busy || !password.trim()}>+ {busy && <Loader2 className="size-4 animate-spin" />}+ {t('vaults.protectedUnlock.unlockCta')}+ </Button>+ </div>+ ))}+{!showUnlockPasskey && !showUnlockPassword && (<div className="rounded-md border border-warning/40 bg-warning/10 px-2.5 py-1.5 text-xs text-warning">{t('vaults.protectedUnlock.unlockUnavailableHere')}</div>)}- {vault.error && <div className="text-xs text-destructive">{friendlyError(t, vault.error)}</div>}++ {/* Mint factor-safety note. */}+ <div className="flex items-start gap-2 rounded-lg bg-mint-soft px-3 py-2.5">+ <ShieldCheck className="mt-0.5 size-[15px] shrink-0 text-mint" />+ <span className="text-[11px] leading-snug text-foreground">{t('vaults.protectedUnlock.factorNote')}</span>+ </div>++ {onDismiss && (+ <button+ type="button"+ onClick={onDismiss}+ className="text-center text-[12.5px] font-medium text-muted-foreground transition-colors hover:text-foreground"+ >+ {t('vaults.protectedUnlock.cancel')}+ </button>+ )}++ {vault.error && <div className="text-center text-xs text-destructive">{friendlyError(t, vault.error)}</div>}</div>);};diff --git a/ui/src/components/ui/vault-secret-form.tsx b/ui/src/components/ui/vault-secret-form.tsxindex 75c359a9a..aeede44fc 100644--- a/ui/src/components/ui/vault-secret-form.tsx+++ b/ui/src/components/ui/vault-secret-form.tsx@@ -1,18 +1,16 @@import { useEffect, useMemo, useRef, useState } from 'react';import type { FormEvent } from 'react';import {+ Asterisk,Check,- ChevronDown,- ChevronRight,Copy,Eye,EyeOff,- KeyRound,Loader2,RefreshCw,Server,ShieldCheck,- Wallet,+ SlidersHorizontal,} from 'lucide-react';import { useTranslation } from 'react-i18next';@@ -27,9 +25,11 @@ import {type SigningKeyMaterial,} from '@/lib/vaultCrypto';import { useProtectedVault } from '@/lib/useProtectedVault';+import { Badge } from './badge';import { Button } from './button';import { Combobox } from './combobox';import { Input } from './input';+import { SegmentedRadio } from './segmented';import { TagInput } from './tag-input';import { VaultProtectedUnlock } from './vault-protected-unlock';@@ -90,6 +90,9 @@ function avaultInstalled(dep: DependencyItem | null): boolean {return Boolean(dep?.installed);}+/** Shared field label — 13px medium, matches design.pen create-dialog field labels. */+const FIELD_LABEL = 'text-[13px] font-medium text-foreground';+export const VaultSecretForm: React.FC<{fixedName?: string;onCancel: () => void;@@ -121,7 +124,7 @@ export const VaultSecretForm: React.FC<{const [tags, setTags] = useState<string[]>([]);const [description, setDescription] = useState('');const [allowHosts, setAllowHosts] = useState<string[]>([]);- const [hostsOpen, setHostsOpen] = useState(false);+ const [advancedOpen, setAdvancedOpen] = useState(false);const [tagsPending, setTagsPending] = useState(false);const [hostsPending, setHostsPending] = useState(false);const [protection, setProtection] = useState<VaultProtection>(defaultProtection);@@ -164,6 +167,7 @@ export const VaultSecretForm: React.FC<{const secretName = (fixedName ?? name).trim().toUpperCase();const protectedCreateReady = protectedVault.status === 'unlocked';const isKeypair = kind === 'keypair';+ const isProvision = Boolean(fixedName);// Hold the latest key material in a ref too, so the unmount cleanup can zero// the *current* private key (a [] effect would capture a stale value).@@ -212,21 +216,30 @@ export const VaultSecretForm: React.FC<{const onSubmit = async (event: FormEvent) => {event.preventDefault();if (!canSubmit) return;- // Don't silently drop a half-typed tag/host chip the user can still see.- if (tagsPending || (hostsOpen && hostsPending)) {+ // Don't silently drop a half-typed tag/host chip the user can still see. Tags live in the+ // create-mode Advanced collapsible; the allowed-hosts input is in Advanced (create) and+ // always visible in provision mode — guard whichever is on screen. Collapsing Advanced+ // clears the pending flags, so a hidden draft can never block submit.+ const hostsVisible = isProvision || advancedOpen;+ if ((advancedOpen && tagsPending) || (hostsVisible && hostsPending)) {setError(t('vaults.dialog.errors.pendingDraft'));return;}setSubmitting(true);setError(null);try {+ // NOTE: the "Always ask before each use" toggle (policy.always_ask) is intentionally+ // not wired here yet — the backend access flow does not honor it (standard-tier ignores+ // it; protected-tier rejects it). It returns once backend support lands (PR #722).+ const policy: Record<string, unknown> = {};+ if (allowHosts.length) policy.allowed_hosts = allowHosts;const base = {name: secretName,protection,group: group.trim() || undefined,description: description.trim() || undefined,tags: tags.length ? tags : undefined,- policy: allowHosts.length ? { allowed_hosts: allowHosts } : undefined,+ policy: Object.keys(policy).length ? policy : undefined,...(isKeypair && signingKey? {kind: 'keypair',@@ -300,89 +313,211 @@ export const VaultSecretForm: React.FC<{}};- return (- <form className={cn('flex flex-col gap-3', className)} onSubmit={onSubmit}>- {!fixedName && (- <label className="flex flex-col gap-1.5 text-sm font-medium">- {t('vaults.dialog.name')}- <Input value={name} onChange={(event) => setName(event.target.value)} autoFocus required />- </label>+ const valueField = (+ <div className="flex items-center gap-2">+ <Input+ type={showValue ? 'text' : 'password'}+ value={value}+ onChange={(event) => setValue(event.target.value)}+ placeholder={t('vaults.dialog.valuePlaceholder')}+ autoFocus={isProvision}+ required+ className="min-w-0 flex-1 font-mono"+ />+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onClick={() => setShowValue((current) => !current)}+ aria-label={showValue ? t('vaults.dialog.hideValue') : t('vaults.dialog.showValue')}+ >+ {showValue ? <EyeOff className="size-4" /> : <Eye className="size-4" />}+ </Button>+ </div>+ );++ // Protection selector — two cards (Standard / Protected) matching design.pen `vyed5`.+ const protectionCards = (+ <div className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.protection')}</span>+ <div className="grid grid-cols-2 gap-2.5">+ {(+ [+ { key: 'standard', icon: Server, title: t('vaults.dialog.standardProtection'), desc: t('vaults.dialog.standardHelp') },+ { key: 'protected', icon: ShieldCheck, title: t('vaults.dialog.protectedProtection'), desc: t('vaults.dialog.protectedHelp') },+ ] as const+ ).map(({ key, icon: Icon, title, desc }) => {+ const selected = protection === key;+ return (+ <button+ key={key}+ type="button"+ aria-pressed={selected}+ onClick={() => setProtection(key)}+ className={cn(+ 'flex flex-col gap-1.5 rounded-[10px] border p-3 text-left transition-colors',+ selected ? 'border-[1.5px] border-mint bg-mint-soft' : 'border-border bg-surface hover:bg-surface-2',+ )}+ >+ <span className="flex items-center gap-2">+ <Icon className={cn('size-4', selected ? 'text-mint' : 'text-muted')} />+ <span className="flex-1 text-[13.5px] font-semibold text-foreground">{title}</span>+ {selected && <Check className="size-4 text-mint" />}+ </span>+ <span className="text-[11.5px] leading-snug text-muted-foreground">{desc}</span>+ </button>+ );+ })}+ </div>+ </div>+ );++ // Protected setup/unlock gating step + avault availability notices, shared by both modes.+ const gatingNotices = (+ <>+ {protection === 'protected' && !protectedCreateReady && (+ <VaultProtectedUnlock vault={protectedVault} secretName={secretName || undefined} />)}- {/* Provision ($NAME) requests are for a specific value the agent asked for, so- the type selector is hidden there — a provision must stay a static secret,- not be fulfilled with a signing key. */}- {!fixedName && (- <div className="flex flex-col gap-1.5 text-sm font-medium">- <span>{t('vaults.dialog.kindLabel')}</span>- <div className="grid grid-cols-2 gap-2.5">- {(- [- { key: 'static', icon: KeyRound, title: t('vaults.dialog.kindStatic'), desc: t('vaults.dialog.kindStaticHelp') },- { key: 'keypair', icon: Wallet, title: t('vaults.dialog.kindKeypair'), desc: t('vaults.dialog.kindKeypairHelp') },- ] as const- ).map(({ key, icon: Icon, title, desc }) => {- const selected = kind === key;- return (- <button- key={key}- type="button"- aria-pressed={selected}- disabled={submitting}- onClick={() => {- setKind(key);- // Leaving keypair: drop any held private key so unused key material- // isn't kept in memory until the dialog closes.- if (key === 'static') {- applySigningKey(null);- setImportHex('');- setSigningError(null);- }- }}- className={cn(- 'flex flex-col gap-1.5 rounded-lg border p-3 text-left transition-colors disabled:opacity-50',- selected ? 'border-mint bg-mint-soft' : 'border-border bg-surface hover:bg-surface-2',- )}- >- <span className="flex items-center gap-2">- <Icon className={cn('size-4', selected ? 'text-mint' : 'text-muted')} />- <span className="text-sm font-semibold text-foreground">{title}</span>- </span>- <span className="text-xs font-normal text-muted-foreground">{desc}</span>- </button>- );- })}+ {protection === 'protected' && protectedCreateReady && <VaultProtectedUnlock vault={protectedVault} />}+ {protection === 'standard' && checkingAvault && (+ <div className="flex items-center gap-2 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-muted">+ <Loader2 className="size-4 animate-spin" />+ {t('vaults.dialog.checkingAvault')}</div>- </div>)}+ {protection === 'standard' && !isKeypair && !checkingAvault && !p2Ready && (+ <div className="rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-sm text-warning">+ {standardCreateReady+ ? t('vaults.dialog.p2UnavailableStandardFallback', {+ version: AVAULT_P2_MIN_VERSION,+ installed: avaultDep?.version ?? 'unknown',+ })+ : t('vaults.dialog.p2Unavailable', {+ version: AVAULT_P2_MIN_VERSION,+ installed: avaultDep?.version ?? 'unknown',+ })}+ </div>+ )}+ {error && (+ <div className="rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive">+ {error}+ </div>+ )}+ </>+ );- {!isKeypair && (- <label className="flex flex-col gap-1.5 text-sm font-medium">- {t('vaults.dialog.value')}- <div className="flex items-center gap-2">- <Input- type={showValue ? 'text' : 'password'}- value={value}- onChange={(event) => setValue(event.target.value)}- placeholder={t('vaults.dialog.valuePlaceholder')}- autoFocus={Boolean(fixedName)}- required- className="min-w-0 flex-1 font-mono"+ // ---- Provision ($NAME) mode — design.pen `F4N19` (SecureInputCard) ------------------+ // A provision fulfils a specific value the agent asked for, so the kind/group/advanced+ // controls are hidden: it must stay a static secret. The same submit path is used.+ if (isProvision) {+ return (+ <form className={cn('flex flex-col gap-4', className)} onSubmit={onSubmit}>+ {/* Name highlight — the secret the agent is waiting on (design.pen `F4N19`). */}+ <div className="flex items-center gap-3 rounded-xl bg-accent/15 p-3.5">+ <Asterisk className="size-[18px] shrink-0 text-accent" />+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <span className="text-[10px] font-semibold uppercase tracking-wide text-muted">{t('vaults.dialog.nameUpper')}</span>+ <span className="truncate font-mono text-[15px] font-semibold text-foreground">{secretName}</span>+ </div>+ <Badge variant="secondary" className="bg-surface">{t('vaults.request.notSetYet')}</Badge>+ </div>++ <label className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.value')}</span>+ {valueField}+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.provisionValueHelp')}</span>+ </label>++ <div className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.storeAs')}</span>+ <div className="self-start">+ <SegmentedRadio<VaultProtection>+ value={protection}+ onChange={setProtection}+ ariaLabel={t('vaults.dialog.storeAs')}+ options={[+ { id: 'standard', label: t('vaults.dialog.standardProtection') },+ { id: 'protected', label: t('vaults.dialog.protectedProtection') },+ ]}/>- <Button- type="button"- variant="ghost"- size="icon"- onClick={() => setShowValue((current) => !current)}- aria-label={showValue ? t('vaults.dialog.hideValue') : t('vaults.dialog.showValue')}- >- {showValue ? <EyeOff className="size-4" /> : <Eye className="size-4" />}- </Button></div>+ </div>++ {/* Allowed hosts — a provisioned secret used for brokered HTTP fetch needs at least+ one allowed host, else vibe/cli.py refuses the fetch as proxy_unbound. */}+ <div className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.allowHosts')}</span>+ <TagInput+ values={allowHosts}+ onChange={setAllowHosts}+ normalize={normalizeHost}+ placeholder={t('vaults.dialog.allowHostsPlaceholder')}+ ariaLabel={t('vaults.dialog.allowHosts')}+ removeLabel={(value) => t('vaults.dialog.removeChip', { value })}+ onPendingChange={setHostsPending}+ />+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.allowHostsHelp')}</span>+ </div>++ {gatingNotices}++ <div className="mt-1 flex justify-end gap-2">+ <Button type="button" variant="ghost" onClick={onCancel} disabled={submitting}>+ {t('vaults.request.dismiss')}+ </Button>+ <Button type="submit" disabled={!canSubmit}>+ {submitting ? <Loader2 className="size-4 animate-spin" /> : <Check className="size-4" />}+ {t('vaults.request.saveAndWake')}+ </Button>+ </div>+ </form>+ );+ }++ // ---- Create mode — design.pen `vyed5` ----------------------------------------------+ return (+ <form className={cn('flex flex-col gap-4', className)} onSubmit={onSubmit}>+ {/* Kind — 2-segment toggle (Static value | Signing key). */}+ <div className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.kindLabel')}</span>+ <SegmentedRadio<VaultKind>+ value={kind}+ onChange={(next) => {+ setKind(next);+ // Leaving keypair: drop any held private key so unused key material isn't kept+ // in memory until the dialog closes.+ if (next === 'static') {+ applySigningKey(null);+ setImportHex('');+ setSigningError(null);+ }+ }}+ disabled={submitting}+ ariaLabel={t('vaults.dialog.kindLabel')}+ options={[+ { id: 'static', label: t('vaults.dialog.kindStatic') },+ { id: 'keypair', label: t('vaults.dialog.kindKeypair') },+ ]}+ />+ </div>++ {/* Name */}+ <label className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.name')}</span>+ <Input value={name} onChange={(event) => setName(event.target.value)} autoFocus required className="font-mono" />+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.nameHint')}</span>+ </label>++ {/* Value (static) or signing-key builder (keypair) */}+ {!isKeypair && (+ <label className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.value')}</span>+ {valueField}</label>)}{isKeypair && (- <div className="flex flex-col gap-2.5 rounded-lg border border-border bg-surface-2 px-3 py-3">+ <div className="flex flex-col gap-2.5 rounded-[10px] border border-border bg-surface-2 px-3 py-3"><span className="text-xs text-muted-foreground">{t('vaults.dialog.signingKeyHelp')}</span><div className="grid grid-cols-2 gap-2">{(['generate', 'import'] as const).map((src) => (@@ -486,132 +621,105 @@ export const VaultSecretForm: React.FC<{)}</div>)}- <label className="flex flex-col gap-1.5 text-sm font-medium">- {t('vaults.dialog.group')}++ {/* Protection */}+ {protectionCards}++ {/* Group */}+ <label className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.group')}</span><Comboboxoptions={[...new Set([DEFAULT_GROUP, ...groups])].map((g) => ({ value: g, label: g }))}value={group}onValueChange={setGroup}allowCustomValuecommitOnClose+ withFolderIconcreateLabel={(v) => t('vaults.dialog.groupCreate', { name: v })}+ createButtonLabel={t('vaults.dialog.groupCreateCta')}createHeading={t('vaults.dialog.groupCreateHeading')}placeholder={t('vaults.dialog.groupPlaceholder')}searchPlaceholder={t('vaults.dialog.groupSearch')}/></label>- <label className="flex flex-col gap-1.5 text-sm font-medium">- {t('vaults.dialog.description')}- <Input value={description} onChange={(event) => setDescription(event.target.value)} />- </label>- <div className="flex flex-col gap-1.5 text-sm font-medium">- <span>{t('vaults.dialog.tags')}</span>- <TagInput- values={tags}- onChange={setTags}- placeholder={t('vaults.dialog.tagsPlaceholder')}- ariaLabel={t('vaults.dialog.tags')}- removeLabel={(value) => t('vaults.dialog.removeChip', { value })}- onPendingChange={setTagsPending}- />- <span className="text-xs font-normal text-muted-foreground">{t('vaults.dialog.tagsHelp')}</span>- </div>- <div className="flex flex-col gap-1.5 text-sm font-medium">++ {/* Advanced — collapsible: description, tags, allowed hosts, always-ask. */}+ <div className="flex flex-col overflow-hidden rounded-[10px] bg-surface-2"><buttontype="button"- onClick={() =>- setHostsOpen((open) => {- if (open) setHostsPending(false);+ onClick={() => {+ setAdvancedOpen((open) => {+ // Collapsing hides the tag/host inputs — drop their pending-draft flags so a+ // draft the user can no longer see doesn't block submit.+ if (open) {+ setHostsPending(false);+ setTagsPending(false);+ }return !open;- })- }- aria-expanded={hostsOpen}- className="flex items-center gap-1.5 text-left text-sm font-medium text-muted-foreground hover:text-foreground"+ });+ }}+ aria-expanded={advancedOpen}+ className="flex items-center gap-1.5 px-3 py-2.5 text-left">- {hostsOpen ? <ChevronDown className="size-4 shrink-0" /> : <ChevronRight className="size-4 shrink-0" />}- {t('vaults.dialog.allowHosts')}- {!hostsOpen && allowHosts.length > 0 && (- <span className="rounded bg-surface-2 px-1.5 py-0.5 text-xs font-normal text-foreground">{allowHosts.length}</span>+ <SlidersHorizontal className="size-3.5 text-muted" />+ <span className="flex-1 text-xs font-semibold text-foreground">{t('vaults.dialog.advanced')}</span>+ {!advancedOpen && (description || tags.length > 0 || allowHosts.length > 0) && (+ <span className="size-1.5 rounded-full bg-mint" aria-hidden />)}</button>- {hostsOpen && (- <>- <TagInput- values={allowHosts}- onChange={setAllowHosts}- normalize={normalizeHost}- placeholder={t('vaults.dialog.allowHostsPlaceholder')}- ariaLabel={t('vaults.dialog.allowHosts')}- removeLabel={(value) => t('vaults.dialog.removeChip', { value })}- onPendingChange={setHostsPending}- />- <span className="text-xs font-normal text-muted-foreground">{t('vaults.dialog.allowHostsHelp')}</span>- </>+ {advancedOpen && (+ <div className="flex flex-col gap-3 px-3 pb-3">+ {/* Description (kept functional; absent from the vyed5 mock — folded here). */}+ <label className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.description')}</span>+ <Input+ value={description}+ onChange={(event) => setDescription(event.target.value)}+ placeholder={t('vaults.dialog.descriptionPlaceholder')}+ />+ </label>++ {/* Tags (kept functional; absent from the vyed5 mock — folded here). */}+ <div className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.tags')}</span>+ <TagInput+ values={tags}+ onChange={setTags}+ placeholder={t('vaults.dialog.tagsPlaceholder')}+ ariaLabel={t('vaults.dialog.tags')}+ removeLabel={(value) => t('vaults.dialog.removeChip', { value })}+ onPendingChange={setTagsPending}+ />+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.tagsHelp')}</span>+ </div>++ {/* Allowed hosts (for proxy fetch). */}+ <div className="flex flex-col gap-1.5">+ <span className={FIELD_LABEL}>{t('vaults.dialog.allowHosts')}</span>+ <TagInput+ values={allowHosts}+ onChange={setAllowHosts}+ normalize={normalizeHost}+ placeholder={t('vaults.dialog.allowHostsPlaceholder')}+ ariaLabel={t('vaults.dialog.allowHosts')}+ removeLabel={(value) => t('vaults.dialog.removeChip', { value })}+ onPendingChange={setHostsPending}+ />+ <span className="text-[11px] text-muted-foreground">{t('vaults.dialog.allowHostsHelp')}</span>+ </div>+ </div>)}</div>- <div className="flex flex-col gap-1.5 text-sm font-medium">- <span>{t('vaults.dialog.protection')}</span>- <div className="grid grid-cols-2 gap-2.5">- {(- [- { key: 'standard', icon: Server, title: t('vaults.dialog.standardProtection'), desc: t('vaults.dialog.standardHelp') },- { key: 'protected', icon: ShieldCheck, title: t('vaults.dialog.protectedProtection'), desc: t('vaults.dialog.protectedHelp') },- ] as const- ).map(({ key, icon: Icon, title, desc }) => {- const selected = protection === key;- return (- <button- key={key}- type="button"- aria-pressed={selected}- onClick={() => setProtection(key)}- className={cn(- 'flex flex-col gap-1.5 rounded-lg border p-3 text-left transition-colors',- selected ? 'border-mint bg-mint-soft' : 'border-border bg-surface hover:bg-surface-2',- )}- >- <span className="flex items-center gap-2">- <Icon className={cn('size-4', selected ? 'text-mint' : 'text-muted')} />- <span className="text-sm font-semibold text-foreground">{title}</span>- </span>- <span className="text-xs font-normal text-muted-foreground">{desc}</span>- </button>- );- })}- </div>- </div>- {protection === 'protected' && <VaultProtectedUnlock vault={protectedVault} />}- {protection === 'standard' && checkingAvault && (- <div className="flex items-center gap-2 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-muted">- <Loader2 className="size-4 animate-spin" />- {t('vaults.dialog.checkingAvault')}- </div>- )}- {protection === 'standard' && !isKeypair && !checkingAvault && !p2Ready && (- <div className="rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-sm text-warning">- {standardCreateReady- ? t('vaults.dialog.p2UnavailableStandardFallback', {- version: AVAULT_P2_MIN_VERSION,- installed: avaultDep?.version ?? 'unknown',- })- : t('vaults.dialog.p2Unavailable', {- version: AVAULT_P2_MIN_VERSION,- installed: avaultDep?.version ?? 'unknown',- })}- </div>- )}- {error && (- <div className="rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive">- {error}- </div>- )}- <div className="mt-2 flex justify-end gap-2">++ {gatingNotices}++ <div className="mt-1 flex justify-end gap-2"><Button type="button" variant="ghost" onClick={onCancel} disabled={submitting}>{t('vaults.dialog.cancel')}</Button><Button type="submit" disabled={!canSubmit}>{submitting && <Loader2 className="size-4 animate-spin" />}- {t('vaults.dialog.save')}+ {t('vaults.dialog.createSecret')}</Button></div></form>diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsxindex 8d33c88e3..05f42b461 100644--- a/ui/src/components/workbench/VaultsPage.tsx+++ b/ui/src/components/workbench/VaultsPage.tsx@@ -1,11 +1,12 @@import { useCallback, useEffect, useMemo, useState } from 'react';-import { Check, Clock, Copy, History, Inbox, KeyRound, Layers, Loader2, Plus, Puzzle, RefreshCw, ShieldCheck, ShieldOff, Trash2, Wallet } from 'lucide-react';+import { Check, Clock, Copy, Folder, Globe, History, Inbox, KeyRound, Layers, Link2, Loader2, Plus, Puzzle, RefreshCw, ShieldCheck, Trash2, Wallet, X } from 'lucide-react';import { useTranslation } from 'react-i18next';import { CapabilityTabs } from './CapabilityTabs';import { WorkbenchPageHeader } from './WorkbenchPageHeader';import { Badge } from '../ui/badge';import { Button } from '../ui/button';import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog';+import { cn } from '../../lib/utils';import { useApi, type VaultAuditEvent, type VaultGrant, type VaultRequest, type VaultSecret } from '../../context/ApiContext';import { useToast } from '../../context/ToastContext';import { VaultApprovalCard, type ApprovalOutcome } from '../ui/vault-approval-card';@@ -37,11 +38,14 @@ const AddSecretDialog: React.FC<{type ViewMode = 'all' | 'group';-const hasProxy = (s: VaultSecret): boolean => {+/** All allowed proxy-fetch hosts on a secret (for the `proxy · <host> +N` badge). */+const proxyHosts = (s: VaultSecret): string[] => {const hosts = (s.policy as { allowed_hosts?: string[] })?.allowed_hosts;- return Array.isArray(hosts) && hosts.length > 0;+ return Array.isArray(hosts) ? hosts : [];};+const isAlwaysAsk = (s: VaultSecret): boolean => Boolean((s.policy as { always_ask?: boolean })?.always_ask);+const SecretRow: React.FC<{ secret: VaultSecret; onDelete: (name: string) => void }> = ({ secret: s, onDelete }) => {const { t } = useTranslation();const isKeypair = s.kind === 'keypair';@@ -71,7 +75,13 @@ const SecretRow: React.FC<{ secret: VaultSecret; onDelete: (name: string) => voi{t('vaults.signing')}</Badge>) : null}- {hasProxy(s) ? <Badge variant="info">{t('vaults.proxyBound')}</Badge> : null}+ {isAlwaysAsk(s) ? <Badge variant="destructive">{t('vaults.alwaysAsk')}</Badge> : null}+ {proxyHosts(s).length > 0 ? (+ <Badge variant="info">+ {t('vaults.proxyHost', { host: proxyHosts(s)[0] })}+ {proxyHosts(s).length > 1 ? ` +${proxyHosts(s).length - 1}` : ''}+ </Badge>+ ) : null}{s.tags?.map((tag) => (<Badge key={tag} variant="outline" className="text-muted">{tag}@@ -128,7 +138,18 @@ function isExpired(expiresAt: string, now: number): boolean {return !Number.isNaN(end) && end <= now;}-const GrantRow: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: VaultGrant) => void }> = ({+/** Compact mm:ss / h:mm:ss countdown for a grant chip (design.pen `y4rw5Q` shows `12:34`). */+function chipCountdown(rem: { h: number; m: number; s: number }): string {+ const pad = (n: number) => n.toString().padStart(2, '0');+ return rem.h > 0 ? `${rem.h}:${pad(rem.m)}:${pad(rem.s)}` : `${pad(rem.m)}:${pad(rem.s)}`;+}++/**+ * Active-grant chip (design.pen `y4rw5Q` ACTIVE GRANTS row): a compact mint pill with the+ * scope icon, `type · ref`, a live countdown, and an inline × to revoke. Replaces the older+ * full-width grant card so the strip reads as a quick "what's live right now" glance.+ */+const GrantChip: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: VaultGrant) => void }> = ({grant: g,now,onRevoke,@@ -136,40 +157,30 @@ const GrantRow: React.FC<{ grant: VaultGrant; now: number; onRevoke: (grant: Vauconst { t } = useTranslation();const Icon = SCOPE_ICON[g.scope_type] ?? KeyRound;const rem = remaining(g.expires_at, now);- const time =- rem.h > 0- ? t('vaults.grants.dur.hm', { h: rem.h, m: rem.m })- : rem.m > 0- ? t('vaults.grants.dur.ms', { m: rem.m, s: rem.s })- : t('vaults.grants.dur.s', { s: rem.s });return (- <div className="flex items-center gap-3.5 rounded-xl border border-border bg-surface px-4 py-3">- <div className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-mint/10 text-mint">- <Icon className="size-4" />- </div>- <div className="flex min-w-0 flex-col gap-1">- <div className="flex flex-wrap items-center gap-2">- <span className="truncate font-mono text-sm font-semibold">{g.scope_ref}</span>- <Badge variant="secondary">{t(`vaults.grants.scope.${g.scope_type}`)}</Badge>- <Badge variant="outline">- {g.session_id ? t('vaults.grants.session.bound') : t('vaults.grants.session.any')}- </Badge>- </div>- <span className="flex items-center gap-1.5 text-xs text-muted">- <span>{t('vaults.secretCount', { count: g.runtime_member_count })}</span>- <span aria-hidden>·</span>- <Clock className="size-3" />- <span className={rem.urgent ? 'text-warning' : undefined}>- {rem.expired ? t('vaults.grants.expired') : t('vaults.grants.expiresIn', { time })}- </span>- </span>- </div>- <div className="ml-auto">- <Button variant="ghost" size="icon" onClick={() => onRevoke(g)} aria-label={t('vaults.grants.revoke')}>- <ShieldOff className="size-4" />- </Button>- </div>- </div>+ <span className="inline-flex items-center gap-2 rounded-full border border-mint/40 bg-mint-soft py-1 pl-2.5 pr-1.5 text-xs text-mint">+ <Icon className="size-3.5 shrink-0" />+ <span className="font-medium">+ {t(`vaults.grants.scope.${g.scope_type}`)} · {g.scope_ref}+ </span>+ <span+ className="flex shrink-0"+ title={g.session_id ? t('vaults.grants.session.bound') : t('vaults.grants.session.any')}+ >+ {g.session_id ? <Link2 className="size-3 opacity-70" /> : <Globe className="size-3 opacity-70" />}+ </span>+ <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>+ </span>);};@@ -436,9 +447,11 @@ export const VaultsPage: React.FC = () => {<Badge variant="secondary">{grants.length}</Badge><span className="hidden text-xs text-muted sm:inline">{t('vaults.grants.subtitle')}</span></div>- {grants.map((g) => (- <GrantRow key={g.id} grant={g} now={now} onRevoke={onRevokeGrant} />- ))}+ <div className="flex flex-wrap gap-2">+ {grants.map((g) => (+ <GrantChip key={g.id} grant={g} now={now} onRevoke={onRevokeGrant} />+ ))}+ </div></div>)}{secrets.length > 0 ? (@@ -460,17 +473,23 @@ export const VaultsPage: React.FC = () => {<div className="rounded-2xl border border-border bg-surface p-8 text-center text-sm text-muted">{t('vaults.empty')}</div>) : view === 'group' ? (<div className="flex flex-col gap-4">- {groups.map(([group, items]) => (- <div key={group} className="flex flex-col gap-2">- <div className="flex items-center gap-2 px-1 text-xs font-semibold text-muted">- <span>{group}</span>- <span className="font-normal">{t('vaults.secretCount', { count: items.length })}</span>+ {groups.map(([group, items]) => {+ const allKeys = items.every((s) => s.kind === 'keypair');+ return (+ <div key={group} className="flex flex-col gap-2">+ <div className="flex items-center gap-2 px-1 text-xs font-semibold text-foreground">+ <Folder className="size-3.5 text-muted" />+ <span>{group}</span>+ <span className="font-normal text-muted">+ {allKeys ? t('vaults.keyCount', { count: items.length }) : t('vaults.secretCount', { count: items.length })}+ </span>+ </div>+ {items.map((s) => (+ <SecretRow key={s.name} secret={s} onDelete={onDelete} />+ ))}</div>- {items.map((s) => (- <SecretRow key={s.name} secret={s} onDelete={onDelete} />- ))}- </div>- ))}+ );+ })}</div>) : (<div className="flex flex-col gap-2">diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex f3e663736..125603264 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -2161,18 +2161,21 @@},"vaults": {"title": "Vaults",- "subtitle": "Secrets the agent can use without their values ever entering the conversation.",+ "subtitle": "Secrets your agents use — names only, values never shown.","add": "Add secret","refresh": "Refresh","loading": "Loading…","empty": "No secrets yet. Add one — the agent retrieves it via the CLI without the value touching the chat.","protected": "Protected","proxyBound": "Proxy-bound",+ "proxyHost": "proxy · {{host}}",+ "alwaysAsk": "always-ask","used": "used {{count}}×","neverUsed": "never used","standard": "Standard","signing": "Signing","secretCount": "{{count}} secrets",+ "keyCount": "{{count}} keys","grants": {"title": "Active access","subtitle": "Grants agents can use right now — revoke to cut access immediately.",@@ -2210,8 +2213,23 @@"lock": "Lock","errorTitle": "Couldn't reach your protected vault","retry": "Retry",- "setupTitle": "Set up your protected vault",- "unlockTitle": "Unlock to add a protected secret",+ "setupTitle": "Set up protected secrets",+ "setupSubtitle": "Unlocked only by you, in your browser. Even a stolen machine can't open them.",+ "unlockTitle": "Unlock to continue",+ "unlockSubtitle": "{{name}} is protected — unlock it in your browser to continue",+ "recommended": "Recommended",+ "addPasskey": "Add a passkey",+ "passkeyCaption": "Face ID · Touch ID · security key — the most secure option",+ "recoveryTip": "Add a second passkey (your phone) or save a recovery code, so a lost device never locks you out.",+ "usePasswordInstead": "Use a password instead",+ "lessSecure": "less secure",+ "maybeLater": "Maybe later",+ "unlockWithPasskey": "Unlock with passkey",+ "unlockPasskeyCaption": "Face ID · Touch ID · security key",+ "usePasswordInline": "Use password instead",+ "factorNote": "Your factor never leaves the browser — the machine alone can't decrypt this",+ "cancel": "Cancel",+ "createPassword": "Create password","setupHelp": "Choose how to unlock protected secrets in the browser. The machine alone can never decrypt them.","unlockHelp": "Confirm your unlock factor to seal this secret under your existing vault key.","setPasswordLabel": "Recovery password",@@ -2244,14 +2262,18 @@"title": "Add a secret","name": "Name","value": "Value",- "valuePlaceholder": "Browser-side sealing is required before saving",+ "valuePlaceholder": "Paste the secret value",+ "provisionValueHelp": "Submitted over TLS — never enters the chat or the model context",+ "storeAs": "Store as","showValue": "Show value","hideValue": "Hide value",- "kindLabel": "Secret type",- "kindStatic": "Value",+ "nameUpper": "Secret name",+ "kindLabel": "Kind",+ "kindStatic": "Static value","kindStaticHelp": "A token, password, or any text value.","kindKeypair": "Signing key","kindKeypairHelp": "A signing key generated in your browser.",+ "nameHint": "Uppercase A–Z 0–9 _ · globally unique","signingKeyHelp": "A new secp256k1 signing key is created in your browser. The private key is sealed in your browser — standard keys are signed by avault locally, protected keys are signed in your browser — and only the public key is stored in the clear.","signingGenerate": "Generate","signingImport": "Import",@@ -2269,12 +2291,18 @@"group": "Group","groupPlaceholder": "Pick or create a group","groupSearch": "Search or type a new group",- "groupCreate": "Use \"{{name}}\"",+ "groupCreate": "{{name}}",+ "groupCreateCta": "Create","groupCreateHeading": "New group",+ "groupHint": "Group · pick one or create a new one inline",+ "advanced": "Advanced","description": "Description",- "allowHosts": "Restrict to specific hosts",- "allowHostsPlaceholder": "host, then Enter (e.g. api.example.com)",+ "descriptionPlaceholder": "Optional note about this secret",+ "allowHosts": "Allowed hosts (for proxy fetch)",+ "allowHostsPlaceholder": "api.github.com, .example.com","allowHostsHelp": "Only needed when this secret is used through the brokered HTTP proxy; '.example.com' matches subdomains.",+ "alwaysAsk": "Always ask before each use",+ "alwaysAskHelp": "Never granted in advance, even per-key","tags": "Tags","tagsPlaceholder": "tag, then Enter","tagsHelp": "Optional labels to find and group secrets.",@@ -2282,10 +2310,11 @@"protection": "Protection","protectedProtection": "Protected","standardProtection": "Standard",- "protectedHelp": "Requires browser unlock and approval before agent use.",- "standardHelp": "The agent can use it automatically through avault, without an extra unlock each time.",+ "protectedHelp": "Unlocked in your browser. Survives machine theft. No headless.",+ "standardHelp": "Machine-encrypted. Headless use OK. For API keys.","protectedCreatePending": "Protected web create is not available in this build yet. Choose Standard only for secrets that may be used headlessly.","save": "Save",+ "createSecret": "Create secret","cancel": "Cancel","errors": {"aadFieldTooLarge": "The sealed vault request is too large.",@@ -2346,8 +2375,11 @@"request": {"provide": "provide","fulfilled": "provided",- "title": "Provide {{name}}",- "help": "The agent asked for this secret. It's saved straight to the vault and never re-enters the chat.",+ "title": "Agent needs a secret",+ "help": "Provide the value — it goes to the vault, never to the chat or model.",+ "notSetYet": "not set yet",+ "dismiss": "Dismiss",+ "saveAndWake": "Save & wake agent","saveFailed": "Couldn't save the secret. Please try again."},"history": "History",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 029e95f49..c58b0413e 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -2160,18 +2160,21 @@},"vaults": {"title": "保险库",- "subtitle": "Agent 可以使用这些密钥,而它们的值永远不会进入对话。",+ "subtitle": "你的 Agent 会用到的密钥——只显示名称,绝不显示值。","add": "添加密钥","refresh": "刷新","loading": "加载中…","empty": "还没有密钥。添加一个——Agent 通过 CLI 获取,值不会进入聊天。","protected": "加密档","proxyBound": "已绑定代理",+ "proxyHost": "代理 · {{host}}",+ "alwaysAsk": "每次询问","used": "已使用 {{count}} 次","neverUsed": "从未使用","standard": "标准档","signing": "签名","secretCount": "{{count}} 个密钥",+ "keyCount": "{{count}} 把密钥","grants": {"title": "活跃授权","subtitle": "Agent 当前可用的授权——吊销即刻断开访问。",@@ -2209,8 +2212,23 @@"lock": "锁定","errorTitle": "无法访问你的保护层","retry": "重试",- "setupTitle": "设置你的保护层",- "unlockTitle": "解锁以添加保护层密钥",+ "setupTitle": "设置受保护密钥",+ "setupSubtitle": "只有你能在浏览器里解锁。机器被偷也打不开它们。",+ "unlockTitle": "解锁以继续",+ "unlockSubtitle": "{{name}} 受保护——在浏览器里解锁它才能继续",+ "recommended": "推荐",+ "addPasskey": "添加 passkey",+ "passkeyCaption": "Face ID · Touch ID · 安全密钥——最安全的方式",+ "recoveryTip": "再加一把 passkey(你的手机)或保存一个恢复码,这样丢了设备也不会把你锁在门外。",+ "usePasswordInstead": "改用密码",+ "lessSecure": "较不安全",+ "maybeLater": "以后再说",+ "unlockWithPasskey": "用 passkey 解锁",+ "unlockPasskeyCaption": "Face ID · Touch ID · 安全密钥",+ "usePasswordInline": "改用密码",+ "factorNote": "你的解锁因子绝不会离开浏览器——单凭这台机器无法解密",+ "cancel": "取消",+ "createPassword": "创建密码","setupHelp": "选择在浏览器里如何解锁保护层密钥。机器单独永远无法解密。","unlockHelp": "确认你的解锁因子,用现有的保护层主密钥封装这条密钥。","setPasswordLabel": "恢复密码",@@ -2243,14 +2261,18 @@"title": "添加密钥","name": "名称","value": "值",- "valuePlaceholder": "保存前需要浏览器侧封箱",+ "valuePlaceholder": "粘贴密钥值",+ "provisionValueHelp": "通过 TLS 提交——绝不会进入聊天或模型上下文",+ "storeAs": "存储为","showValue": "显示值","hideValue": "隐藏值",- "kindLabel": "密钥类型",- "kindStatic": "值",+ "nameUpper": "密钥名称",+ "kindLabel": "类型",+ "kindStatic": "静态值","kindStaticHelp": "令牌、密码,或任意文本值。","kindKeypair": "签名密钥","kindKeypairHelp": "在你浏览器里生成的签名私钥。",+ "nameHint": "大写 A–Z 0–9 _ · 全局唯一","signingKeyHelp": "会在你的浏览器里新生成一把 secp256k1 签名密钥。私钥在浏览器中封存——标准密钥由本机 avault 签名,保护层密钥在浏览器中签名——只有公钥明文保存。","signingGenerate": "生成","signingImport": "导入",@@ -2268,12 +2290,18 @@"group": "分组","groupPlaceholder": "选择或新建分组","groupSearch": "搜索或输入新分组",- "groupCreate": "使用「{{name}}」",+ "groupCreate": "{{name}}",+ "groupCreateCta": "新建","groupCreateHeading": "新建分组",+ "groupHint": "分组 · 选一个,或就地新建一个",+ "advanced": "高级","description": "描述",- "allowHosts": "限制到特定域名",- "allowHostsPlaceholder": "输入域名后回车(如 api.example.com)",+ "descriptionPlaceholder": "关于这条密钥的可选备注",+ "allowHosts": "允许的域名(用于代理 fetch)",+ "allowHostsPlaceholder": "api.github.com, .example.com","allowHostsHelp": "仅当该密钥通过认证 HTTP 代理使用时才需要;'.example.com' 匹配子域。",+ "alwaysAsk": "每次使用都询问",+ "alwaysAskHelp": "绝不预先授权,连按密钥也不行","tags": "标签","tagsPlaceholder": "输入标签后回车","tagsHelp": "可选,用来查找和归类密钥。",@@ -2281,10 +2309,11 @@"protection": "保护级别","protectedProtection": "受保护","standardProtection": "标准",- "protectedHelp": "Agent 使用前需要浏览器解锁和批准。",- "standardHelp": "Agent 通过 avault 自动取用,不必每次额外解锁。",+ "protectedHelp": "在你的浏览器里解锁。机器被偷也安全。不支持无头使用。",+ "standardHelp": "机器加密。可无头使用。适合 API key。","protectedCreatePending": "当前构建尚不支持受保护的 Web 创建。需要 Agent 自动取用的密钥请选标准。","save": "保存",+ "createSecret": "创建密钥","cancel": "取消","errors": {"aadFieldTooLarge": "这次保险库封箱请求过大。",@@ -2345,8 +2374,11 @@"request": {"provide": "填写","fulfilled": "已提供",- "title": "提供 {{name}}",- "help": "Agent 请求了这个密钥。它会直接存入保险库,不会再进入聊天。",+ "title": "Agent 需要一个密钥",+ "help": "提供这个值——它会进入保险库,绝不会进入聊天或模型。",+ "notSetYet": "尚未设置",+ "dismiss": "忽略",+ "saveAndWake": "保存并唤醒 Agent","saveFailed": "保存失败,请重试。"},"history": "历史",