Skip to content

feat(core,dashboard,cli): delete saved logins from MCP, REST, the dashboard and the CLI - #70

Open
arg1998 wants to merge 2 commits into
mainfrom
feat/saved-logins-delete
Open

arg1998 wants to merge 2 commits into
mainfrom
feat/saved-logins-delete

Conversation

@arg1998

@arg1998 arg1998 commented Nov 8, 2026

Copy link
Copy Markdown
Owner

What / why

Fixes #57. Part of #61. Stacked on #64 (fix/auth-state-names): the base is that branch until #64 merges, then this is rebased onto main.

Saved logins could be saved and restored but never deleted: AuthStateStore.remove() had no caller. This adds deletion everywhere an operator or agent works.

  • MCP: delete_saved_auth {name}. A new, additive tool (D-12; since: 0.3.0), destructive and idempotent. It deletes the caller's own snapshot of that name, either kind, together with its identity seed, and answers {name, deleted: true}.
    • A missing name and another principal's name answer the same AUTH_STATE_NOT_FOUND: No saved auth snapshot named '<name>'. …, so there is no oracle.
    • That error's details.kind is now optional, because this request names no kind.
    • The catalog is 44 tools. Goldens, generated tool docs and the counts in docs and specs are updated.
  • REST.
    • GET /auth-states (sessions:read) lists every principal's saved logins: name, kind, owner, size, saved_at, source_session_id, and source_session_slug (null once the session's record is gone).
    • DELETE /auth-states/{owner}/{name} (sessions:write) writes an operator_actions row (delete / auth_state / <owner>/<name>, with kind, size and source in the details). A missing login answers 404 AUTH_STATE_NOT_FOUND.
    • A new WS topic, auth-states, carries auth_state.changed (published by the store after every save and delete). OpenAPI and the API and WebSocket reference docs are regenerated.
  • Dashboard: a "Saved logins" page (sidebar, right above Vault).
    • The table shows name, kind (Cookies & storage / Full profile), owner, size, saved (relative, server-anchored RelativeTime) and the source session (a link while it exists, otherwise "· deleted").
    • It has search, client-side sort and paging, mobile cards, an empty state and a zero-results state.
    • Delete goes through the shared confirm dialog: Delete saved login <name>?, Owner: <owner>. … Sessions already restored from it keep running. A success toast follows, and the page refreshes live over the new topic.
  • CLI. browserhive saved-logins list | rm <name> [--owner <subject>] talks to a running server, like channels. Without --owner, rm deletes the one principal's login of that name, and stops naming the owners when several use it.
  • Docs and specs. The dashboard guide gets a "Saved logins" section, the CLI guide gets saved-logins, and the security guide notes that there is no automatic expiry. Spec 02 §3.11 and §6, spec 03 §4.6.1 and §6.6, spec 04 §12.7.1 and the nav order, spec 08 §7.1 and spec 12 are updated.

Changeset: minor.

Screenshots

Taken by driving the built server in headless Chromium, at desktop 1280×800 and phone (Pixel 7), in light and dark. They are in the owner's local scratchpad at scratchpad/security-fix-release/saved-logins-screens/:

  • desktop-light.png, desktop-dark.png, phone-light.png, phone-dark.png: the list (local logins plus two other principals, deleted source sessions, a login saved 47 days ago);
  • *-confirm.png: the delete confirmation;
  • empty-*.png: nothing saved;
  • zero-results-*.png: a search with no match.

Tests

  • Store:
    • listAll across principals, including a stray manifest that is not listed;
    • the operator's removeSnapshot of another owner (seed included; the other owner's login of the same name stays);
    • remove with a partial file set;
    • auth_state.changed on save and delete.
  • MCP:
    • delete, after which the list no longer shows it and a restore answers AUTH_STATE_NOT_FOUND; a second delete answers not-found; a bad name answers PATH_NOT_ALLOWED;
    • a foreign name answers the same not-found as a missing one and deletes nothing.
  • REST (routes/auth-states.test.ts, plus route-table and auth-matrix cases):
    • the list shape;
    • the declared scopes, and an agent token refused (403, nothing deleted);
    • an operator deleting another owner's login, with the audit row and its details;
    • 404 with no audit row;
    • 400 for a bad name.
  • CLI (test/cli/saved-logins.test.ts and help goldens): list and --json; owner lookup; ambiguous name; --owner with an encoded path; not found; missing argument.
  • Dashboard (SavedLoginsPage.test.tsx): rendering, link and "deleted", the empty state (axe-clean), the confirm text and DELETE only after confirming, live refetch on auth_state.changed, and the pure filter, sort and page.
  • e2e: the seed now also saves three logins, and saved-logins.e2e.ts lists them and deletes one per project through the dialog. Run locally against a fresh seeded daemon: 17 passed, 1 skipped (the known skip).

Checks

bun run check, bun run build, bun run package:check and bun run test:integration (70 pass, 4 skip, 0 fail) all pass.

Two pre-existing things noticed (not changed here)

  • remoteCall with --cookie is refused for mutating requests (ORIGIN_NOT_ALLOWED, the CSRF check). This hits saved-logins rm --cookie and channels test --cookie alike; --token works.
  • Authorizer.can() lets every operator principal through, so an operator API token issued with a scope subset is not actually limited, although spec 03 §3.5 says such tokens may be issued. authorizer.test.ts pins this as intended. The scope tests here therefore use agent tokens.

Snapshots of principals other than local now live in
auth-states/p/<sha256(subject)[:16]>/, so one principal saving a name
another uses creates its own snapshot instead of replacing theirs.
Restores require the caller's manifest of the requested kind, saving
either kind replaces the caller's other kind and identity seed, and
identity seeds are read and written per principal. Flat manifests with
a non-local owner move into their owner's directory on first access,
payloads first and the manifest last, so an interrupted move resumes.

Part of #61
…rd and the CLI

Agents get delete_saved_auth for their own snapshots. Operators get
GET /auth-states and an audited DELETE /auth-states/{owner}/{name},
a Saved logins dashboard page with a confirmed delete and live
refresh over a new auth-states topic, and browserhive saved-logins
list | rm.

Fixes #57
Base automatically changed from fix/auth-state-names to main November 8, 2026 21:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant