Skip to content

Commit cd0e302

Browse files
committed
fix: show usage update time
1 parent 1484711 commit cd0e302

5 files changed

Lines changed: 49 additions & 3 deletions

File tree

admin/handler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ type accountResponse struct {
410410
ProxyURL string `json:"proxy_url"`
411411
CreatedAt string `json:"created_at"`
412412
UpdatedAt string `json:"updated_at"`
413+
CodexUsageUpdatedAt string `json:"codex_usage_updated_at,omitempty"`
413414
ActiveRequests int64 `json:"active_requests"`
414415
TotalRequests int64 `json:"total_requests"`
415416
LastUsedAt string `json:"last_used_at"`
@@ -534,6 +535,7 @@ func (h *Handler) ListAccounts(c *gin.Context) {
534535
BaseConcurrencyEffective: effectiveBaseConcurrency(row.BaseConcurrencyOverride, int64(h.store.GetMaxConcurrency())),
535536
CreatedAt: row.CreatedAt.Format(time.RFC3339),
536537
UpdatedAt: row.UpdatedAt.Format(time.RFC3339),
538+
CodexUsageUpdatedAt: row.GetCredential("codex_usage_updated_at"),
537539
}
538540
if acc, ok := accountMap[row.ID]; ok {
539541
acc.Mu().RLock()

frontend/src/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@
227227
"requests": "Requests(7d)",
228228
"usage": "Usage",
229229
"updatedAt": "Updated",
230+
"recordUpdatedAt": "Record updated",
231+
"recordUpdatedAtShort": "Record",
232+
"usageUpdatedAt": "Usage updated",
233+
"usageUpdatedAtShort": "Usage",
234+
"noUsageUpdatedAt": "None",
230235
"importTime": "Import Time",
231236
"actions": "Actions",
232237
"test": "Test",

frontend/src/locales/zh.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@
227227
"requests": "请求(7d)",
228228
"usage": "用量",
229229
"updatedAt": "更新时间",
230+
"recordUpdatedAt": "记录更新时间",
231+
"recordUpdatedAtShort": "记录",
232+
"usageUpdatedAt": "用量更新时间",
233+
"usageUpdatedAtShort": "用量",
234+
"noUsageUpdatedAt": "",
230235
"importTime": "导入时间",
231236
"actions": "操作",
232237
"test": "测试",

frontend/src/pages/Accounts.tsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
APIKeyRow,
2020
OpsOverviewResponse,
2121
AccountGroup,
22+
SystemSettings,
2223
} from "../types";
2324
import { getErrorMessage } from "../utils/error";
2425
import { formatCompactEmail } from "../lib/utils";
@@ -401,36 +402,47 @@ export default function Accounts() {
401402
const { confirm, confirmDialog } = useConfirmDialog();
402403

403404
const loadAccounts = useCallback(async () => {
404-
const [accountsResponse, apiKeysResponse, opsOverview, groupsResponse] =
405+
const [
406+
accountsResponse,
407+
apiKeysResponse,
408+
opsOverview,
409+
groupsResponse,
410+
settings,
411+
] =
405412
await Promise.all([
406413
api.getAccounts(),
407414
api.getAPIKeys(),
408415
api.getOpsOverview().catch((): OpsOverviewResponse | null => null),
409416
api.listAccountGroups().catch(() => ({ groups: [] })),
417+
api.getSettings().catch((): SystemSettings | null => null),
410418
]);
411419
setAllGroups(groupsResponse.groups ?? []);
412420
return {
413421
accounts: accountsResponse.accounts ?? [],
414422
apiKeys: apiKeysResponse.keys ?? [],
415423
opsOverview,
424+
lazyMode: settings?.lazy_mode ?? false,
416425
};
417426
}, []);
418427

419428
const { data, loading, error, reload, reloadSilently } = useDataLoader<{
420429
accounts: AccountRow[];
421430
apiKeys: APIKeyRow[];
422431
opsOverview: OpsOverviewResponse | null;
432+
lazyMode: boolean;
423433
}>({
424434
initialData: {
425435
accounts: [],
426436
apiKeys: [],
427437
opsOverview: null,
438+
lazyMode: false,
428439
},
429440
load: loadAccounts,
430441
});
431442
const accounts = data.accounts;
432443
const apiKeys = data.apiKeys;
433444
const opsOverview = data.opsOverview;
445+
const lazyMode = data.lazyMode;
434446
const usageReloadAttemptsRef = useRef<Map<number, number>>(new Map());
435447

436448
useEffect(() => {
@@ -2855,8 +2867,29 @@ export default function Accounts() {
28552867
</TableCell>
28562868
)}
28572869
{visibleColumns.updatedAt && (
2858-
<TableCell className="text-[14px] text-muted-foreground">
2859-
{formatRelativeTime(account.updated_at)}
2870+
<TableCell className="text-[13px] text-muted-foreground whitespace-nowrap">
2871+
{lazyMode ? (
2872+
<div className="space-y-0.5 leading-tight">
2873+
<div title={t("accounts.recordUpdatedAt")}>
2874+
<span className="mr-1 text-[11px] text-muted-foreground/70">
2875+
{t("accounts.recordUpdatedAtShort")}
2876+
</span>
2877+
{formatRelativeTime(account.updated_at)}
2878+
</div>
2879+
<div title={t("accounts.usageUpdatedAt")}>
2880+
<span className="mr-1 text-[11px] text-muted-foreground/70">
2881+
{t("accounts.usageUpdatedAtShort")}
2882+
</span>
2883+
{account.codex_usage_updated_at
2884+
? formatRelativeTime(
2885+
account.codex_usage_updated_at,
2886+
)
2887+
: t("accounts.noUsageUpdatedAt")}
2888+
</div>
2889+
</div>
2890+
) : (
2891+
formatRelativeTime(account.updated_at)
2892+
)}
28602893
</TableCell>
28612894
)}
28622895
{visibleColumns.actions && (

frontend/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export interface AccountRow {
6565
proxy_url: string
6666
created_at: ISODateString
6767
updated_at: ISODateString
68+
codex_usage_updated_at?: ISODateString
6869
active_requests?: number
6970
total_requests?: number
7071
last_used_at?: ISODateString

0 commit comments

Comments
 (0)