feat(account): add quota trend chart and multi-account risk gate

- Gate multi-account login, import, switch, backup quota polling, and vault controls behind explicit risk consent (accountSwitchRiskAccepted), restricting unaccepted sessions to active-account quota viewing
- Add collinear-compressed per-account quota history tracking and a full-bleed 184px AccountQuotaTrendCard supporting cycle, preset, all-time, and custom ranges with cycle-boundary pre-reset filtering and isolated impulse spike sanitization
- Unify Account tab controls onto shared SegmentedControl, CustomSelect, CustomDateTimePicker, .ctx-risk-mask, and global status/button primitives while removing bespoke .account-* CSS and balancing card padding
This commit is contained in:
fish
2026-11-25 03:42:33 +09:00
parent 1330b31ef7
commit e520efe84e
20 changed files with 4103 additions and 1235 deletions
+9 -1
View File
@@ -11,6 +11,10 @@ import {
resolveGoogleCredential,
retrieveCredentialQuota,
} from './account-oauth.mjs';
import {
recordAccountQuotaSnapshot,
removeAccountQuotaHistory,
} from './account-quota-history.mjs';
import {
checkVaultUnlockCooldown,
createVaultSecurityMetadata,
@@ -36,7 +40,7 @@ const ACCOUNT_ERRORS = new Set([
'oauthUnavailable', 'quotaUnavailable',
'switchStartFailed', 'clientCloseFailed', 'clientRestartFailed',
'vaultLocked', 'wrongPassword', 'invalidPassword', 'passwordRateLimited',
'vaultDecryptFailed', 'invalidActionNonce',
'vaultDecryptFailed', 'invalidActionNonce', 'riskNotAccepted',
]);
const ALLOWED_ACTIONS = new Set([
@@ -717,6 +721,7 @@ export async function handleAccountCredentialAction(
if (action === 'remove') {
const activeSec = await ensureUnlockedVaultContext();
clearTransientAccessTokens(email);
removeAccountQuotaHistory(email);
return publicList(
await runStore({
action,
@@ -806,6 +811,9 @@ export async function handleAccountCredentialAction(
expectedCredential: expectedCredForQuota,
quota: quotaPayload,
});
if (useDiskSigCache) {
recordAccountQuotaSnapshot(email, pools, fetchedAt, { isActiveHost: false });
}
return { email, pools, fetchedAt, ...tierMeta };
}