A local-first multi-agent app development platform, built on PenguinHarness
Admin user backend: every account's last sign-in and lifetime cost
- Date: 2026-10-08
- Type: feature
- Scope:
server,web
The user backend's table showed who exists, what role they hold and when the account was created — nothing about whether it is used, or what it has cost. It now carries two read-only columns, both figures the server computes:
- Last sign-in (
UserInfo.lastLoginAt, theusers.last_login_atcolumn): stamped by the one path that verifies a password (AuthService.login), so an account an admin created and nobody ever signed into reads as never used rather than as today. The column is added to an existing database byopenDatabase's column guard; rows written before it read back as never signed in. - Lifetime cost (
UserInfo.totalCostUsd): the total of the Projects the account OWNS, every usage record ever written in them priced at the current rates — the cost center's cumulative figure, summed over the account's Projects. Pricing is per Project, so the sum is taken per Project (UsageQueries.lifetimeCost, the unfiltered grouped scanmodelTotalsalready ran). A Model with no price makes the figure a lower bound, which the response says (costUnpriced) and the table draws as a leading≥; with nothing priced at all the field is omitted and the cell shows—, rather than a zero the reader cannot tell from "ran for free".
The users page is the only page whose content is a wide table, so it asks PagedDialog for a
wider panel (PagedDialog.widthClass, defaulting to the shared width); six columns and two row
actions otherwise pushed 重置密码 / 删除 off the pane, reachable only by scrolling sideways.
Server
db/schema.ts/db/database.ts: theusers.last_login_atcolumn and itsensureColumnguard.db/repos/users.ts/mechanisms/identity.ts:touchLastLogin, and the column onUserRow.auth/service.ts: stamps the column on a successful password login and returns it in that login's own DTO.services/usage-service.ts/mechanisms/observability.ts:lifetimeCost(projectId)— one unfiltered grouped scan, folded with the same per-reference rate lookupqueryuses.services/admin-service.ts:listUsersis now async; it sums each account's owned Projects.http/routes/admin.ts: awaits the list.
Web
features/admin/admin-users-page.tsx: the two columns (currency follows the display preference).features/settings/settings-dialog.tsx: the users page's panel width.lib/strings.ts/lib/strings-en.ts: the column headers, the never-signed-in word and the cost column's tooltip.packages/uioverlays/paged-dialog: the optionalwidthClass.