Skip to content

Latest commit

 

History

History
238 lines (208 loc) · 13.2 KB

app.md

File metadata and controls

238 lines (208 loc) · 13.2 KB

Desktop app

Deadbolt's desktop UI (crates/app, binary deadbolt-ui), built in Rune.

Architecture

  • A thin client of the daemon. deadbolt-ui speaks the daemon's Unix socket protocol (crates/proto, crates/client) and starts the daemon if none runs. It holds no vault keys and reads no store files: unlock, items, devices, health, and pairing are all daemon requests. Quitting the app leaves the daemon and its unlock session running.
  • Separate headless CLI and UI binaries. deadbolt (crates/cli) never links Rune, wgpu, or winit. Users run deadbolt app (see One command), which locates and launches deadbolt-ui in its own process. On Linux, Rune loads Wayland, X11, and GPU drivers dynamically when a window opens.
  • Finding the daemon binary (crates/app/src/binary.rs). Inside .app/Contents/MacOS (after resolving symlinks), the app always uses ../Helpers/deadbolt; a missing helper fails closed without falling back. Outside a bundle, it checks DEADBOLT_BIN, a sibling deadbolt, then PATH and standard user/Homebrew/Cargo bin directories, verifying the Touch ID helper against deadbolt_enclave::SHA256.
  • Threads & live state. One worker thread (crates/app/src/daemon/worker.rs) sends daemon requests on a current-thread Tokio runtime, coalescing stale selection Gets and running read-ahead Peeks last across up to three concurrent item lanes. A second thread holds the daemon's watch stream open with exponential reconnect backoff (100 ms to 2 s, never auto-starting a stopped daemon). Locking or daemon exit immediately wipes cached values and returns to the lock screen; activate brings the main window forward.
  • Secrets in memory & clipboard. Passphrase and secret inputs use Rune's TextEdit::secure() (masked, no undo/copy/IME, macOS Secure Event Input while focused, wiped on exit or drop) and move through Zeroizing<String> buffers. Item secrets are fetched one item at a time (item-get); the 32-page read-ahead cache (crates/app/src/cache.rs) stores only non-secret fields and current TOTP codes, never secret values. Secret copies go through Tx::copy_secret (org.nspasteboard.ConcealedType on macOS) and clear after the configured timeout (10 s–5 min, default 30 s), on lock, or on quit.
  • Look & layout. Uses rune-theme-opencode (kit(dark), Inter + IBM Plex Mono) in rune_kit::shell::SplitView (crates/app/src/vault.rs, crates/app/src/vault/page.rs): immediate state changes (Tx::instant), ~0.15 s motion only where elements travel, no hover fades or focus rings, and zero layout reflow when async data arrives.

Screens

  • First run (crates/app/src/onboarding.rs): Create or Join on a dedicated worker thread. Create sets device name, vault name, and passphrase (checked with zxcvbn via deadbolt_proto::daemon::passphrase_strength; < 8 characters refused). Join sets up the device first, displays the single-use 5-minute five-word pairing code and copyable deadbolt approve <code> command (cleared from clipboard on pair, cancel, or close), and syncs the vault.
  • Unlock: Passphrase field plus Use Touch ID or Unlock with this Mac when quick unlock is ready (docs/touch-id.md). Auto-prompts once on focused launch, quick-panel summon, refocus after a background lock, or screen unlock while frontmost (Change::ScreenUnlocked), never right after an explicit ⌘L or frontmost idle lock. Explains expired or reset slots in place.
  • List & search: Search-first virtualized 46 pt rows showing kind icon, label, muted star for favorites, detail line, active risk dot, and ⌘1–9 on the selected row. Supports #tag (matching tag and tag/*), #"tag with spaces", and is:favorite queries; favorites sort first.
  • Item detail (crates/app/src/vault/page.rs): Schema-ordered fields, masked secrets (Show reveals in place via secure read-only labels), per-row Copy, Save… (0600) for file fields, live 3+3 TOTP codes (ItemCode polled once per period without delaying unlock_timeout), #tag chips, and health callouts.
  • Passkey: Shows Site, Username, Created, and Notes (private keys never leave the daemon; passkey fields are not editable in ⌘E).
  • Add / edit (crates/app/src/edit.rs): ⌘N opens with the filterable 17-type picker focused (edit/types.rs); ⌘E edits in place. Unrevealed OTP, secure-note body, and SSH private-key fields stay Kept until replaced or explicitly revealed via Show. edit/tags.rs edits tags with prefix completions. Emits a minimal ItemSet diff; concurrent remote edits surface a conflict banner with Show theirs.
  • Generate (crates/app/src/edit/generator.rs): Fills new logins from Command::Generate (24 chars with symbols by default; 16/20/24/32/64 and symbols controls; honors site rules when fixing a login).
  • Import (crates/app/src/import.rs): Drag-and-drop or ⇧⌘I for 1Password .1pux/.csv (including idempotent in-place re-import updates), Apple Passwords .csv, or Bitwarden .json with a secret-free dry-run preview before committing.
  • Security (crates/app/src/health.rs, docs/password-health.md): ⇧⌘H, ⌘K › Security, or the header risk count swaps in category tabs (1–6 plus 7 Ignored: Risks, Breached, Reused, Weak, 2FA, Passkeys), Check breaches, and per-finding Fix (↵), Open site (O), and Ignore (I).
  • Settings (crates/app/src/settings.rs): ⌘, edits config.toml settings via Command::SettingsSet (Quick unlock: Passphrase / Touch ID / With this Mac, Require passphrase interval, Auto-lock, Lock on sleep, Clear copied secrets, HIBP breach checks, Quick panel shortcut recorder) and shows Devices, Updates, Activity (crates/app/src/activity.rs), and Keyboard shortcuts.
  • Recently Deleted (crates/app/src/trash.rs): ⇧⌘⌫ lists soft-deleted items newest first, opens them read-only, and restores with ⌘R across all synced devices.

Keyboard

crates/app/src/keys.rs (SHORTCUTS, verified by tests/app/keymap.rs) works regardless of which control holds focus:

Key Action
typing Filters the list (#tag, is:favorite, plain words); unfocused printable keys (except J, K, O) return to search
↑ ↓, J K Move selection (J/K when search is unfocused)
⌘1–9 Select the first nine visible rows
↵ / ⇧↵ / ⌥↵ Copy primary field / login username / current TOTP code
O, ⌘O Open item's http(s) URL or passkey RP
⇥ Step into item fields (↑↓ move, ↵ copy, Space show/hide, Esc back)
⌘F Focus search (and reopen a hidden sidebar)
⌘D Toggle favorite on selected item or open form
⌘K / ? Open Actions palette (including Filter by tag…) / shortcut sheet
⇧⌘H / ⌘, / ⇧⌘⌫ Security / Settings / Recently Deleted
⇧⌘B, ⌃⌘S Toggle sidebar
⇧⌘I Import Passwords…
⌘N / ⌘E / ⌘⌫ New item (⌃⇥/⌘T switch type) / Edit item / Delete item
⌘S, ⌘⏎, ⏎ Save form (⏎ inserts newline in multi-line fields); Esc cancels
⇧⌘Space Summon Quick Panel globally (configurable in Settings)
⌘L / ⌘Q Lock vault / Quit app

Motion

Rune suppresses first-paint animations, honors system --reduced-motion, and retargets springs mid-flight:

Change Motion
Whole-screen swap (lock ↔ vault, item ↔ form, import) Blur (σ 1.5), scale .96, fade (.3/0 in, .24–.25/0 out)
Typing filter, Esc, selection change, ⌘K, ? Instant (Tx::instant); read-ahead pages swap in place, holding up to 0.15 s on cache miss
Synced row additions / removals Surviving rows slide (.4/0); entering/leaving rows fade in place
Copy notice & TOTP rollover Notice rises 12 pt (.3/0); changing digits roll via RollingText (tabular figures); period/countdown bars run on linear render-thread tweens
Delete confirm Trash button morphs into dim red confirm (.3/0, fade under reduced motion)
Vault created or joined Keyhole bolt throws into strike (.3/.3), ember flash cools over 1.1 s, vault opens at 1.5 s

Quick panel

⇧⌘Space (Ctrl+Shift+Space off macOS, saved in app-shortcut) toggles a borderless, non-activating 688×448 WindowOptions::launcher_panel window (crates/app/src/panel/, 640×400 card inset 24 pt with macOS window shadow off so WindowServer draws no outer rectangular frame; verified by tests/app/window_server.rs with -- --ignored) centered 160 pt below the top of the pointer's display.

  • Flow: Summon -> type query -> ⏎ copies primary field (⇧⏎ username, ⌥⏎ TOTP), rolls footer into "Copied, clears in 0:30" for 1.1 s, then fades out and wipes every query and item value from memory.
  • Programmatic approvals (panel/ask.rs): Also renders deadbolt ask confirmation cards (such as brokered command requests, above an inline unlock prompt when locked).
  • --panel flag: Starts hidden without a Dock icon for background shortcut use and headless panel tests; opening the main window restores the Dock icon and macOS app menu. Off macOS, where native menus are Unsupported, the main window footer keeps a clickable Quick panel hint (window::entry).

Run, test, snapshot

cargo build -p deadbolt-cli && cargo run --release -p deadbolt-app
cargo build -p deadbolt-cli -p deadbolt-app && target/debug/deadbolt app
cargo test -p deadbolt-cli -p deadbolt-app
cargo test -p deadbolt-app --test app panel::
crates/app/scripts/snap.sh
crates/app/scripts/hold-down.sh out.mp4
cargo run -p deadbolt-app -- --scene copied --at 2.4 --snap copied.png
cargo run -p deadbolt-app -- --window panel --scene filtering --snap panel.png

Tooling runs (--snap, --tree, --trace, --frames, --script, --scene, defined in crates/app/src/scenes.rs) use synthetic fixtures only, never touch the real daemon, clipboard, global shortcuts, or app-shortcut.

One command

Users run deadbolt in a terminal for the CLI, or deadbolt app (or bare deadbolt launched outside a TTY with a display and without SSH_CONNECTION or DEADBOLT_NO_UI=1; crates/cli/src/app.rs) to open deadbolt-ui.

  • Discovery order (app::find_ui): DEADBOLT_UI_BIN; enclosing Deadbolt.app bundle (linking ~/Applications/Deadbolt.app if needed); sibling deadbolt-ui; /Applications/Deadbolt.app or ~/Applications/Deadbolt.app; Launch Services anomaly.deadbolt; PATH.
  • Single window activation: Outside macOS open, deadbolt app sends app-activate (forwarding XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID) so an already-running main window comes forward instead of spawning a duplicate; a 5 s watchers::STARTING reservation serializes double-clicks. On first Linux launch, desktop::ensure installs ~/.local/share/applications/anomaly.deadbolt.desktop and its icon (deadbolt desktop install / uninstall).

One bundle, one daemon

Deadbolt.app/Contents/
  Info.plist                 anomaly.deadbolt; version from Cargo
  MacOS/Deadbolt             deadbolt-ui, signed as anomaly.deadbolt
  Helpers/deadbolt           headless CLI & background daemon
  Helpers/deadbolt-enclave   Secure Enclave Touch ID helper (anomaly.deadbolt.enclave)
  Resources/Deadbolt.icns    generated headlessly

deadbolt_client::ensure_running ensures the app and CLI share one daemon without fighting:

Running daemon protocol Client action
Matches DAEMON_PROTOCOL_VERSION Reuses the running daemon regardless of which install started it
Older Stops it cleanly, then starts this client's deadbolt binary
Newer Refuses without stopping it and advises updating this client or running deadbolt debug daemon stop

Once unlocked, if no deadbolt CLI is on PATH (or a bundle symlink broke after moving the app), a quiet card in the vault offers Install… / Repair… (crates/app/src/install.rs), linking Contents/Helpers/deadbolt into writable ~/.local/bin, /opt/homebrew/bin, or /usr/local/bin (or showing the exact sudo ln -sfh command without ever invoking sudo).

Shipping the app

hivemind run --kind cargo --fetch .lab-output -- bash crates/app/scripts/bundle.sh
hivemind run --kind cargo --fetch .lab-output -- bash crates/app/scripts/bundle.sh --universal

Release builds (docs/releasing.md) compile against a Developer ID-signed DEADBOLT_ENCLAVE_PREBUILT helper so deadbolt and deadbolt-ui pin its exact signed bytes, then sign, notarize, and staple Deadbolt.app for the desktop release manifest, GitHub releases, and Homebrew cask.

Open decisions

  • Menu-bar item: whether to add an optional macOS menu-bar extra alongside the main window and ⇧⌘Space quick panel.
  • ⌘C in the vault list: whether ⌘C with an empty search selection should copy the selected item's primary secret.
  • Strict weak-passphrase gate: onboarding currently refuses passphrases under 8 characters and warns on low zxcvbn scores; whether to refuse Weak scores outright.