Repository navigation
feat: show last-used timestamp on API keys settings page - #1123
benthecarman wants to merge 1 commit into
Conversation
Track when each user API key last authenticated a request and surface it in the Research settings UI. - Add nullable user_api_keys.last_used_at (migration + schema + model) - Record usage in validate_openai_auth after successful API-key auth; throttled conditional update (max one write/minute/key), best-effort so auth never fails when the write errors - Return last_used_at from create/list API key responses - Extend ApiKey types in TypeScript and Rust SDKs (serde default keeps newer SDKs compatible with older backends) - Switch Research frontend @mapleai/sdk to local source per consumer version policy; re-pin to a published version before release
|
Hey Ben, thank you for this! It's a genuinely useful feature, and the "Last used" / "Never used" rows look great. The writeup and validation notes made it easy to review, too. Working through it made us realize we want "last used" to be the first piece of something bigger: per-key spend tracking and, eventually, budgets users can set on each key. To get there, we'd like the billing server to own per-key usage. The key would still live in the enclave, and only a non-secret key ID would cross over, rather than OpenSecret writing a timestamp during auth. So we're going to take a different approach and close this one. I've written up the direction in two issues, and your PR is credited as where it started:
Your UI work carries straight over to #1138. If you'd like to pick up any part of it, you'd be very welcome. Thanks again for kicking this off! Generated by Claude Code |
Summary
Track when each user API key last authenticated a request and show it in the Research Settings → API & credits → API keys page.
user_api_keys.last_used_at(nullable) via migration2026-10-10-000000_user_api_keys_last_used_atvalidate_openai_authafter successful API-key auth: throttled conditional update (max one write/minute/key), best-effort so auth never fails if the write errorslast_used_atadded to create/list API key responses and toApiKeytypes in both SDKs (#[serde(default)]keeps newer SDKs compatible with older backends)Last used <date>(clock icon) orNever usedScreenshot
Rendered from the real component with mocked SDK data; shows fresh, stale, and never-used states.
Validation
cargo check+cargo test --binson pinned 1.91.1: 787 passed / 0 failed / 31 ignored (DB-required);cargo fmt; security-invariant tests passcargo check; TS SDK prettier + tests (9 pre-existing live-backend failures, identical on unmodified tree)just installfrozen installReviewer notes
just diesel-migration-run-localand smokelast_used_atthrough a real API-key request (just desktop-dev); throttle granularity is 1 minute — tunablefile:../../../sdk) during development per the consumer version policy; publish@mapleai/sdkand re-pin before releaseNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.