Compare commits

...

14 Commits

28 changed files with 1072 additions and 513 deletions
+1
View File
@@ -0,0 +1 @@
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Codex</title><path d="M19.503 0H4.496A4.496 4.496 0 000 4.496v15.007A4.496 4.496 0 004.496 24h15.007A4.496 4.496 0 0024 19.503V4.496A4.496 4.496 0 0019.503 0z" fill="#fff"></path><path d="M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z" fill="url(#lobe-icons-codex-fill)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-codex-fill" x1="12" x2="12" y1="3" y2="21"><stop stop-color="#B1A7FF"></stop><stop offset=".5" stop-color="#7A9DFF"></stop><stop offset="1" stop-color="#3941FF"></stop></linearGradient></defs></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

-25
View File
@@ -1,25 +0,0 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="256.000000pt" height="256.000000pt" viewBox="0 0 256.000000 256.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,256.000000) scale(0.100000,-0.100000)"
fill="#FFFFFF" stroke="none">
<path d="M1107 2290 c-316 -57 -615 -283 -748 -565 -68 -144 -91 -241 -96
-406 -6 -156 7 -249 49 -374 87 -254 291 -478 542 -596 146 -68 226 -84 426
-84 152 0 186 3 260 23 182 50 327 136 465 277 147 150 245 334 282 529 23
123 14 344 -20 456 -35 116 -69 190 -134 290 -131 200 -340 354 -578 426 -78
23 -111 27 -245 30 -85 1 -177 -1 -203 -6z m362 -216 c91 -21 224 -86 310
-152 133 -101 249 -275 293 -439 16 -60 21 -108 21 -203 0 -152 -21 -240 -88
-368 -130 -253 -350 -407 -634 -443 -393 -50 -777 214 -882 607 -30 110 -30
296 0 408 72 270 282 489 552 576 130 41 287 47 428 14z"/>
<path d="M849 1637 c-31 -24 -52 -67 -46 -95 3 -15 35 -78 71 -139 36 -61 66
-115 66 -119 0 -5 -30 -58 -66 -119 -36 -60 -68 -123 -70 -140 -7 -42 26 -90
70 -105 31 -10 42 -9 72 7 31 15 51 43 125 173 93 162 101 188 73 243 -50 97
-169 289 -185 297 -25 14 -91 12 -110 -3z"/>
<path d="M1353 1139 c-42 -12 -73 -53 -73 -96 0 -27 8 -43 35 -70 l34 -34 216
3 217 3 30 34 c26 29 29 40 25 73 -7 49 -29 75 -76 88 -45 12 -364 12 -408 -1z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

-25
View File
@@ -1,25 +0,0 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="256.000000pt" height="256.000000pt" viewBox="0 0 256.000000 256.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,256.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1107 2290 c-316 -57 -615 -283 -748 -565 -68 -144 -91 -241 -96
-406 -6 -156 7 -249 49 -374 87 -254 291 -478 542 -596 146 -68 226 -84 426
-84 152 0 186 3 260 23 182 50 327 136 465 277 147 150 245 334 282 529 23
123 14 344 -20 456 -35 116 -69 190 -134 290 -131 200 -340 354 -578 426 -78
23 -111 27 -245 30 -85 1 -177 -1 -203 -6z m362 -216 c91 -21 224 -86 310
-152 133 -101 249 -275 293 -439 16 -60 21 -108 21 -203 0 -152 -21 -240 -88
-368 -130 -253 -350 -407 -634 -443 -393 -50 -777 214 -882 607 -30 110 -30
296 0 408 72 270 282 489 552 576 130 41 287 47 428 14z"/>
<path d="M849 1637 c-31 -24 -52 -67 -46 -95 3 -15 35 -78 71 -139 36 -61 66
-115 66 -119 0 -5 -30 -58 -66 -119 -36 -60 -68 -123 -70 -140 -7 -42 26 -90
70 -105 31 -10 42 -9 72 7 31 15 51 43 125 173 93 162 101 188 73 243 -50 97
-169 289 -185 297 -25 14 -91 12 -110 -3z"/>
<path d="M1353 1139 c-42 -12 -73 -53 -73 -96 0 -27 8 -43 35 -70 l34 -34 216
3 217 3 30 34 c26 29 29 40 25 73 -7 49 -29 75 -76 88 -45 12 -364 12 -408 -1z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

+9 -77
View File
@@ -31,7 +31,6 @@ import {
useNotificationStore,
useThemeStore,
} from '@/stores';
import { versionApi } from '@/services/api';
import { triggerHeaderRefresh } from '@/hooks/useHeaderRefresh';
import { LANGUAGE_LABEL_KEYS, LANGUAGE_ORDER } from '@/utils/constants';
import { isSupportedLanguage } from '@/utils/language';
@@ -70,12 +69,6 @@ const headerIcons = {
<path d="M21 3v5h-5" />
</svg>
),
update: (
<svg {...headerIconProps}>
<path d="M12 19V5" />
<path d="m5 12 7-7 7 7" />
</svg>
),
menu: (
<svg {...headerIconProps}>
<path d="M4 7h16" />
@@ -209,39 +202,12 @@ const THEME_CARDS: Array<{
},
];
const parseVersionSegments = (version?: string | null) => {
if (!version) return null;
const cleaned = version.trim().replace(/^v/i, '');
if (!cleaned) return null;
const parts = cleaned
.split(/[^0-9]+/)
.filter(Boolean)
.map((segment) => Number.parseInt(segment, 10))
.filter(Number.isFinite);
return parts.length ? parts : null;
};
const compareVersions = (latest?: string | null, current?: string | null) => {
const latestParts = parseVersionSegments(latest);
const currentParts = parseVersionSegments(current);
if (!latestParts || !currentParts) return null;
const length = Math.max(latestParts.length, currentParts.length);
for (let i = 0; i < length; i++) {
const l = latestParts[i] || 0;
const c = currentParts[i] || 0;
if (l > c) return 1;
if (l < c) return -1;
}
return 0;
};
export function MainLayout() {
const { t } = useTranslation();
const { showNotification } = useNotificationStore();
const location = useLocation();
const apiBase = useAuthStore((state) => state.apiBase);
const serverVersion = useAuthStore((state) => state.serverVersion);
const connectionStatus = useAuthStore((state) => state.connectionStatus);
const logout = useAuthStore((state) => state.logout);
@@ -256,7 +222,6 @@ export function MainLayout() {
const [sidebarOpen, setSidebarOpen] = useState(false);
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
const [checkingVersion, setCheckingVersion] = useState(false);
const [languageMenuOpen, setLanguageMenuOpen] = useState(false);
const [themeMenuOpen, setThemeMenuOpen] = useState(false);
const [brandExpanded, setBrandExpanded] = useState(true);
@@ -542,39 +507,6 @@ export function MainLayout() {
showNotification(t('notification.data_refreshed'), 'success');
};
const handleVersionCheck = async () => {
setCheckingVersion(true);
try {
const data = await versionApi.checkLatest();
const latestRaw = data?.['latest-version'] ?? data?.latest_version ?? data?.latest ?? '';
const latest = typeof latestRaw === 'string' ? latestRaw : String(latestRaw ?? '');
const comparison = compareVersions(latest, serverVersion);
if (!latest) {
showNotification(t('system_info.version_check_error'), 'error');
return;
}
if (comparison === null) {
showNotification(t('system_info.version_current_missing'), 'warning');
return;
}
if (comparison > 0) {
showNotification(t('system_info.version_update_available', { version: latest }), 'warning');
} else {
showNotification(t('system_info.version_is_latest'), 'success');
}
} catch (error: unknown) {
const message =
error instanceof Error ? error.message : typeof error === 'string' ? error : '';
const suffix = message ? `: ${message}` : '';
showNotification(`${t('system_info.version_check_error')}${suffix}`, 'error');
} finally {
setCheckingVersion(false);
}
};
return (
<div className="app-shell">
<header className="main-header" ref={headerRef}>
@@ -632,15 +564,6 @@ export function MainLayout() {
>
{headerIcons.refresh}
</Button>
<Button
variant="ghost"
size="sm"
onClick={handleVersionCheck}
loading={checkingVersion}
title={t('system_info.version_check_button')}
>
{headerIcons.update}
</Button>
<div
className={`language-menu ${languageMenuOpen ? 'open' : ''}`}
ref={languageMenuRef}
@@ -759,6 +682,15 @@ export function MainLayout() {
</header>
<div className="main-body">
<button
type="button"
className={`sidebar-backdrop ${sidebarOpen ? 'visible' : ''}`}
onClick={() => setSidebarOpen(false)}
aria-label={t('common.close')}
aria-hidden={!sidebarOpen}
tabIndex={sidebarOpen ? 0 : -1}
/>
<aside
className={`sidebar ${sidebarOpen ? 'open' : ''} ${sidebarCollapsed ? 'collapsed' : ''}`}
>
@@ -3,8 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/Button';
import { Card } from '@/components/ui/Card';
import { ToggleSwitch } from '@/components/ui/ToggleSwitch';
import iconCodexLight from '@/assets/icons/codex_light.svg';
import iconCodexDark from '@/assets/icons/codex_drak.svg';
import iconCodex from '@/assets/icons/codex.svg';
import type { ProviderKeyConfig } from '@/types';
import { maskApiKey } from '@/utils/format';
import {
@@ -25,7 +24,6 @@ interface CodexSectionProps {
loading: boolean;
disableControls: boolean;
isSwitching: boolean;
resolvedTheme: string;
onAdd: () => void;
onEdit: (index: number) => void;
onDelete: (index: number) => void;
@@ -39,7 +37,6 @@ export function CodexSection({
loading,
disableControls,
isSwitching,
resolvedTheme,
onAdd,
onEdit,
onDelete,
@@ -72,11 +69,7 @@ export function CodexSection({
<Card
title={
<span className={styles.cardTitle}>
<img
src={resolvedTheme === 'dark' ? iconCodexDark : iconCodexLight}
alt=""
className={styles.cardTitleIcon}
/>
<img src={iconCodex} alt="" className={styles.cardTitleIcon} />
{t('ai_providers.codex_title')}
</span>
}
@@ -6,8 +6,7 @@ import { useThemeStore } from '@/stores';
import iconGemini from '@/assets/icons/gemini.svg';
import iconOpenaiLight from '@/assets/icons/openai-light.svg';
import iconOpenaiDark from '@/assets/icons/openai-dark.svg';
import iconCodexLight from '@/assets/icons/codex_light.svg';
import iconCodexDark from '@/assets/icons/codex_drak.svg';
import iconCodex from '@/assets/icons/codex.svg';
import iconClaude from '@/assets/icons/claude.svg';
import iconVertex from '@/assets/icons/vertex.svg';
import iconAmp from '@/assets/icons/amp.svg';
@@ -23,7 +22,7 @@ interface ProviderNavItem {
const PROVIDERS: ProviderNavItem[] = [
{ id: 'gemini', label: 'Gemini', getIcon: () => iconGemini },
{ id: 'codex', label: 'Codex', getIcon: (theme) => (theme === 'dark' ? iconCodexDark : iconCodexLight) },
{ id: 'codex', label: 'Codex', getIcon: () => iconCodex },
{ id: 'claude', label: 'Claude', getIcon: () => iconClaude },
{ id: 'vertex', label: 'Vertex', getIcon: () => iconVertex },
{ id: 'ampcode', label: 'Ampcode', getIcon: () => iconAmp },
+316 -50
View File
@@ -20,13 +20,17 @@ import type {
CodexUsageWindow,
CodexQuotaWindow,
CodexUsagePayload,
GeminiCliCodeAssistPayload,
GeminiCliCredits,
GeminiCliParsedBucket,
GeminiCliQuotaBucketState,
GeminiCliQuotaState,
GeminiCliUserTier,
KimiQuotaRow,
KimiQuotaState,
} from '@/types';
import { apiCallApi, authFilesApi, getApiCallErrorMessage } from '@/services/api';
import { useQuotaStore } from '@/stores';
import {
ANTIGRAVITY_QUOTA_URLS,
ANTIGRAVITY_REQUEST_HEADERS,
@@ -37,6 +41,7 @@ import {
CODEX_USAGE_URL,
CODEX_REQUEST_HEADERS,
GEMINI_CLI_QUOTA_URL,
GEMINI_CLI_CODE_ASSIST_URL,
GEMINI_CLI_REQUEST_HEADERS,
KIMI_USAGE_URL,
KIMI_REQUEST_HEADERS,
@@ -49,6 +54,7 @@ import {
parseClaudeUsagePayload,
parseCodexUsagePayload,
parseGeminiCliQuotaPayload,
parseGeminiCliCodeAssistPayload,
parseKimiUsagePayload,
resolveCodexChatgptAccountId,
resolveCodexPlanType,
@@ -78,6 +84,11 @@ type QuotaUpdater<T> = T | ((prev: T) => T);
type QuotaType = 'antigravity' | 'claude' | 'codex' | 'gemini-cli' | 'kimi';
const DEFAULT_ANTIGRAVITY_PROJECT_ID = 'bamboo-precept-lgxtn';
const geminiCliSupplementaryRequestIds = new Map<string, number>();
const geminiCliSupplementaryCache = new Map<
string,
{ requestId: number; tierLabel: string | null; tierId: string | null; creditBalance: number | null }
>();
export interface QuotaStore {
antigravityQuota: Record<string, AntigravityQuotaState>;
@@ -427,10 +438,181 @@ const fetchCodexQuota = async (
return { planType: planTypeFromUsage ?? planTypeFromFile, windows };
};
const GEMINI_CLI_G1_CREDIT_TYPE = 'GOOGLE_ONE_AI';
const GEMINI_CLI_TIER_LABELS: Record<string, string> = {
'free-tier': 'tier_free',
'legacy-tier': 'tier_legacy',
'standard-tier': 'tier_standard',
'g1-pro-tier': 'tier_pro',
'g1-ultra-tier': 'tier_ultra',
};
const resolveGeminiCliTierLabel = (
payload: GeminiCliCodeAssistPayload | null,
t: TFunction
): string | null => {
if (!payload) return null;
const currentTier: GeminiCliUserTier | null | undefined =
payload.currentTier ?? payload.current_tier;
const paidTier: GeminiCliUserTier | null | undefined =
payload.paidTier ?? payload.paid_tier;
const rawId = normalizeStringValue(paidTier?.id) ?? normalizeStringValue(currentTier?.id);
if (!rawId) return null;
const tierId = rawId.toLowerCase();
const labelKey = GEMINI_CLI_TIER_LABELS[tierId];
return labelKey ? t(`gemini_cli_quota.${labelKey}`) : rawId;
};
const resolveGeminiCliTierId = (
payload: GeminiCliCodeAssistPayload | null
): string | null => {
if (!payload) return null;
const currentTier: GeminiCliUserTier | null | undefined =
payload.currentTier ?? payload.current_tier;
const paidTier: GeminiCliUserTier | null | undefined =
payload.paidTier ?? payload.paid_tier;
const rawId = normalizeStringValue(paidTier?.id) ?? normalizeStringValue(currentTier?.id);
return rawId ? rawId.toLowerCase() : null;
};
const resolveGeminiCliCreditBalance = (
payload: GeminiCliCodeAssistPayload | null
): number | null => {
if (!payload) return null;
const paidTier: GeminiCliUserTier | null | undefined =
payload.paidTier ?? payload.paid_tier;
const currentTier: GeminiCliUserTier | null | undefined =
payload.currentTier ?? payload.current_tier;
const tier = paidTier ?? currentTier;
if (!tier) return null;
const credits: GeminiCliCredits[] =
tier.availableCredits ?? tier.available_credits ?? [];
let total = 0;
let found = false;
for (const credit of credits) {
const creditType = normalizeStringValue(credit.creditType ?? credit.credit_type);
if (creditType !== GEMINI_CLI_G1_CREDIT_TYPE) continue;
const amount = normalizeNumberValue(credit.creditAmount ?? credit.credit_amount);
if (amount !== null) {
total += amount;
found = true;
}
}
return found ? total : null;
};
const fetchGeminiCliCodeAssist = async (
authIndex: string,
projectId: string,
t: TFunction
): Promise<{ tierLabel: string | null; tierId: string | null; creditBalance: number | null }> => {
try {
const result = await apiCallApi.request({
authIndex,
method: 'POST',
url: GEMINI_CLI_CODE_ASSIST_URL,
header: { ...GEMINI_CLI_REQUEST_HEADERS },
data: JSON.stringify({
cloudaicompanionProject: projectId,
metadata: {
ideType: 'IDE_UNSPECIFIED',
platform: 'PLATFORM_UNSPECIFIED',
pluginType: 'GEMINI',
duetProject: projectId,
},
}),
});
if (result.statusCode < 200 || result.statusCode >= 300) {
return { tierLabel: null, tierId: null, creditBalance: null };
}
const payload = parseGeminiCliCodeAssistPayload(result.body ?? result.bodyText);
return {
tierLabel: resolveGeminiCliTierLabel(payload, t),
tierId: resolveGeminiCliTierId(payload),
creditBalance: resolveGeminiCliCreditBalance(payload),
};
} catch {
return { tierLabel: null, tierId: null, creditBalance: null };
}
};
const readGeminiCliSupplementarySnapshot = (
fileName: string,
requestId: number
): { tierLabel: string | null; tierId: string | null; creditBalance: number | null } => {
const cached = geminiCliSupplementaryCache.get(fileName);
if (!cached || cached.requestId !== requestId) {
return { tierLabel: null, tierId: null, creditBalance: null };
}
return {
tierLabel: cached.tierLabel,
tierId: cached.tierId,
creditBalance: cached.creditBalance,
};
};
const scheduleGeminiCliSupplementaryRefresh = (
fileName: string,
authIndex: string,
projectId: string,
t: TFunction
): number => {
const requestId = (geminiCliSupplementaryRequestIds.get(fileName) ?? 0) + 1;
geminiCliSupplementaryRequestIds.set(fileName, requestId);
geminiCliSupplementaryCache.delete(fileName);
void (async () => {
const supplementary = await fetchGeminiCliCodeAssist(authIndex, projectId, t);
if (geminiCliSupplementaryRequestIds.get(fileName) !== requestId) {
return;
}
geminiCliSupplementaryCache.set(fileName, { requestId, ...supplementary });
useQuotaStore.getState().setGeminiCliQuota((prev) => {
const current = prev[fileName];
if (!current || current.status !== 'success') {
return prev;
}
if (
current.tierLabel === supplementary.tierLabel &&
current.tierId === supplementary.tierId &&
current.creditBalance === supplementary.creditBalance
) {
return prev;
}
return {
...prev,
[fileName]: {
...current,
tierLabel: supplementary.tierLabel,
tierId: supplementary.tierId,
creditBalance: supplementary.creditBalance,
},
};
});
})();
return requestId;
};
const fetchGeminiCliQuota = async (
file: AuthFileItem,
t: TFunction
): Promise<GeminiCliQuotaBucketState[]> => {
): Promise<{
fileName: string;
supplementaryRequestId: number;
buckets: GeminiCliQuotaBucketState[];
tierLabel: string | null;
tierId: string | null;
creditBalance: number | null;
}> => {
const rawAuthIndex = file['auth_index'] ?? file.authIndex;
const authIndex = normalizeAuthIndex(rawAuthIndex);
if (!authIndex) {
@@ -442,21 +624,19 @@ const fetchGeminiCliQuota = async (
throw new Error(t('gemini_cli_quota.missing_project_id'));
}
const result = await apiCallApi.request({
const quotaResponse = await apiCallApi.request({
authIndex,
method: 'POST',
url: GEMINI_CLI_QUOTA_URL,
header: { ...GEMINI_CLI_REQUEST_HEADERS },
data: JSON.stringify({ project: projectId }),
});
if (result.statusCode < 200 || result.statusCode >= 300) {
throw createStatusError(getApiCallErrorMessage(result), result.statusCode);
if (quotaResponse.statusCode < 200 || quotaResponse.statusCode >= 300) {
throw createStatusError(getApiCallErrorMessage(quotaResponse), quotaResponse.statusCode);
}
const payload = parseGeminiCliQuotaPayload(result.body ?? result.bodyText);
const payload = parseGeminiCliQuotaPayload(quotaResponse.body ?? quotaResponse.bodyText);
const buckets = Array.isArray(payload?.buckets) ? payload?.buckets : [];
if (buckets.length === 0) return [];
const parsedBuckets = buckets
.map((bucket) => {
@@ -487,7 +667,26 @@ const fetchGeminiCliQuota = async (
})
.filter((bucket): bucket is GeminiCliParsedBucket => bucket !== null);
return buildGeminiCliQuotaBuckets(parsedBuckets);
const builtBuckets = buildGeminiCliQuotaBuckets(parsedBuckets);
const supplementaryRequestId = scheduleGeminiCliSupplementaryRefresh(
file.name,
authIndex,
projectId,
t
);
const supplementarySnapshot = readGeminiCliSupplementarySnapshot(
file.name,
supplementaryRequestId
);
return {
fileName: file.name,
supplementaryRequestId,
buckets: builtBuckets,
tierLabel: supplementarySnapshot.tierLabel,
tierId: supplementarySnapshot.tierId,
creditBalance: supplementarySnapshot.creditBalance,
};
};
const renderAntigravityItems = (
@@ -527,6 +726,8 @@ const renderAntigravityItems = (
});
};
const PREMIUM_GEMINI_CLI_TIER_IDS = new Set(['g1-ultra-tier']);
const renderCodexItems = (
quota: CodexQuotaState,
t: TFunction,
@@ -540,6 +741,7 @@ const renderCodexItems = (
const getPlanLabel = (pt?: string | null): string | null => {
const normalized = normalizePlanType(pt);
if (!normalized) return null;
if (normalized === 'pro') return t('codex_quota.plan_pro');
if (normalized === 'plus') return t('codex_quota.plan_plus');
if (normalized === 'team') return t('codex_quota.plan_team');
if (normalized === 'free') return t('codex_quota.plan_free');
@@ -547,15 +749,17 @@ const renderCodexItems = (
};
const planLabel = getPlanLabel(planType);
const isPremiumPlan = normalizePlanType(planType) === 'pro';
const nodes: ReactNode[] = [];
if (planLabel) {
const valueClass = isPremiumPlan ? styleMap.premiumPlanValue : styleMap.codexPlanValue;
nodes.push(
h(
'div',
{ key: 'plan', className: styleMap.codexPlan },
h('span', { className: styleMap.codexPlanLabel }, t('codex_quota.plan_label')),
h('span', { className: styleMap.codexPlanValue }, planLabel)
h('span', { className: valueClass }, planLabel)
)
);
}
@@ -605,50 +809,89 @@ const renderGeminiCliItems = (
helpers: QuotaRenderHelpers
): ReactNode => {
const { styles: styleMap, QuotaProgressBar } = helpers;
const { createElement: h } = React;
const { createElement: h, Fragment } = React;
const buckets = quota.buckets ?? [];
const tierLabel = quota.tierLabel ?? null;
const tierId = quota.tierId ?? null;
const creditBalance = quota.creditBalance ?? null;
const isPremiumTier = tierId !== null && PREMIUM_GEMINI_CLI_TIER_IDS.has(tierId);
const nodes: ReactNode[] = [];
if (buckets.length === 0) {
return h('div', { className: styleMap.quotaMessage }, t('gemini_cli_quota.empty_buckets'));
}
return buckets.map((bucket) => {
const fraction = bucket.remainingFraction;
const clamped = fraction === null ? null : Math.max(0, Math.min(1, fraction));
const percent = clamped === null ? null : Math.round(clamped * 100);
const percentLabel = percent === null ? '--' : `${percent}%`;
const remainingAmountLabel =
bucket.remainingAmount === null || bucket.remainingAmount === undefined
? null
: t('gemini_cli_quota.remaining_amount', {
count: bucket.remainingAmount,
});
const titleBase =
bucket.modelIds && bucket.modelIds.length > 0 ? bucket.modelIds.join(', ') : bucket.label;
const title = bucket.tokenType ? `${titleBase} (${bucket.tokenType})` : titleBase;
const resetLabel = formatQuotaResetTime(bucket.resetTime);
return h(
'div',
{ key: bucket.id, className: styleMap.quotaRow },
if (tierLabel) {
const valueClass = isPremiumTier ? styleMap.premiumPlanValue : styleMap.codexPlanValue;
nodes.push(
h(
'div',
{ className: styleMap.quotaRowHeader },
h('span', { className: styleMap.quotaModel, title }, bucket.label),
{ key: 'tier', className: styleMap.codexPlan },
h('span', { className: styleMap.codexPlanLabel }, t('gemini_cli_quota.tier_label')),
h('span', { className: valueClass }, tierLabel)
)
);
}
if (creditBalance !== null) {
nodes.push(
h(
'div',
{ key: 'credits', className: styleMap.codexPlan },
h('span', { className: styleMap.codexPlanLabel }, t('gemini_cli_quota.credit_label')),
h(
'span',
{ className: styleMap.codexPlanValue },
t('gemini_cli_quota.credit_amount', { count: creditBalance })
)
)
);
}
if (buckets.length === 0) {
nodes.push(
h('div', { key: 'empty', className: styleMap.quotaMessage }, t('gemini_cli_quota.empty_buckets'))
);
return h(Fragment, null, ...nodes);
}
nodes.push(
...buckets.map((bucket) => {
const fraction = bucket.remainingFraction;
const clamped = fraction === null ? null : Math.max(0, Math.min(1, fraction));
const percent = clamped === null ? null : Math.round(clamped * 100);
const percentLabel = percent === null ? '--' : `${percent}%`;
const remainingAmountLabel =
bucket.remainingAmount === null || bucket.remainingAmount === undefined
? null
: t('gemini_cli_quota.remaining_amount', {
count: bucket.remainingAmount,
});
const titleBase =
bucket.modelIds && bucket.modelIds.length > 0 ? bucket.modelIds.join(', ') : bucket.label;
const title = bucket.tokenType ? `${titleBase} (${bucket.tokenType})` : titleBase;
const resetLabel = formatQuotaResetTime(bucket.resetTime);
return h(
'div',
{ key: bucket.id, className: styleMap.quotaRow },
h(
'div',
{ className: styleMap.quotaMeta },
h('span', { className: styleMap.quotaPercent }, percentLabel),
remainingAmountLabel
? h('span', { className: styleMap.quotaAmount }, remainingAmountLabel)
: null,
h('span', { className: styleMap.quotaReset }, resetLabel)
)
),
h(QuotaProgressBar, { percent, highThreshold: 60, mediumThreshold: 20 })
);
});
{ className: styleMap.quotaRowHeader },
h('span', { className: styleMap.quotaModel, title }, bucket.label),
h(
'div',
{ className: styleMap.quotaMeta },
h('span', { className: styleMap.quotaPercent }, percentLabel),
remainingAmountLabel
? h('span', { className: styleMap.quotaAmount }, remainingAmountLabel)
: null,
h('span', { className: styleMap.quotaReset }, resetLabel)
)
),
h(QuotaProgressBar, { percent, highThreshold: 60, mediumThreshold: 20 })
);
})
);
return h(Fragment, null, ...nodes);
};
const buildClaudeQuotaWindows = (
@@ -927,7 +1170,17 @@ export const CODEX_CONFIG: QuotaConfig<
renderQuotaItems: renderCodexItems,
};
export const GEMINI_CLI_CONFIG: QuotaConfig<GeminiCliQuotaState, GeminiCliQuotaBucketState[]> = {
export const GEMINI_CLI_CONFIG: QuotaConfig<
GeminiCliQuotaState,
{
fileName: string;
supplementaryRequestId: number;
buckets: GeminiCliQuotaBucketState[];
tierLabel: string | null;
tierId: string | null;
creditBalance: number | null;
}
> = {
type: 'gemini-cli',
i18nPrefix: 'gemini_cli_quota',
cardIdleMessageKey: 'quota_management.card_idle_hint',
@@ -936,8 +1189,21 @@ export const GEMINI_CLI_CONFIG: QuotaConfig<GeminiCliQuotaState, GeminiCliQuotaB
fetchQuota: fetchGeminiCliQuota,
storeSelector: (state) => state.geminiCliQuota,
storeSetter: 'setGeminiCliQuota',
buildLoadingState: () => ({ status: 'loading', buckets: [] }),
buildSuccessState: (buckets) => ({ status: 'success', buckets }),
buildLoadingState: () => ({ status: 'loading', buckets: [], tierLabel: null, tierId: null, creditBalance: null }),
buildSuccessState: (data) => {
const supplementarySnapshot = readGeminiCliSupplementarySnapshot(
data.fileName,
data.supplementaryRequestId
);
return {
status: 'success',
buckets: data.buckets,
tierLabel: supplementarySnapshot.tierLabel ?? data.tierLabel,
tierId: supplementarySnapshot.tierId ?? data.tierId,
creditBalance: supplementarySnapshot.creditBalance ?? data.creditBalance,
};
},
buildErrorState: (message, status) => ({
status: 'error',
buckets: [],
+46 -119
View File
@@ -334,19 +334,10 @@ export function IconLayoutDashboard({ size = 20, ...props }: IconProps) {
export function IconSidebarDashboard({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<rect x="3.75" y="4.5" width="16.5" height="15" rx="1.5" />
<path d="M3.75 9.25h16.5" />
<path d="M10.5 9.25V19.5" />
<rect
x="6.1"
y="12.1"
width="2.3"
height="2.3"
rx="0.35"
fill="currentColor"
fillOpacity="0.16"
/>
<polyline points="13.1 15.8 15.2 13.6 16.8 15 18.35 11.95" />
<rect x="3" y="3" width="7.5" height="8" rx="1.5" />
<rect x="13.5" y="3" width="7.5" height="5" rx="1.5" fill="currentColor" fillOpacity="0.12" />
<rect x="3" y="14" width="7.5" height="7" rx="1.5" fill="currentColor" fillOpacity="0.12" />
<rect x="13.5" y="11" width="7.5" height="10" rx="1.5" />
</svg>
);
}
@@ -354,18 +345,10 @@ export function IconSidebarDashboard({ size = 20, ...props }: IconProps) {
export function IconSidebarConfig({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<path d="M5 8h14" />
<path d="M5 16h14" />
<path d="M9 6.1 10.9 8 9 9.9 7.1 8Z" fill="currentColor" fillOpacity="0.16" />
<rect
x="13.6"
y="14.1"
width="2.9"
height="2.9"
rx="0.45"
fill="currentColor"
fillOpacity="0.16"
/>
<path d="M4 8h16" />
<path d="M4 16h16" />
<circle cx="9.5" cy="8" r="2.8" fill="currentColor" fillOpacity="0.12" />
<circle cx="15" cy="16" r="2.8" fill="currentColor" fillOpacity="0.12" />
</svg>
);
}
@@ -373,13 +356,12 @@ export function IconSidebarConfig({ size = 20, ...props }: IconProps) {
export function IconSidebarProviders({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<path d="M12 4.7 14.8 7.5 12 10.3 9.2 7.5Z" fill="currentColor" fillOpacity="0.16" />
<rect x="4.6" y="13" width="3.8" height="3.8" rx="0.5" />
<rect x="15.6" y="13" width="3.8" height="3.8" rx="0.5" />
<rect x="10.1" y="16.5" width="3.8" height="3.8" rx="0.5" />
<path d="M12 10.3v6.2" />
<path d="M12 10.3 6.5 13" />
<path d="M12 10.3 17.5 13" />
<circle cx="12" cy="5.5" r="2.8" fill="currentColor" fillOpacity="0.12" />
<circle cx="5.5" cy="18.5" r="2.8" />
<circle cx="18.5" cy="18.5" r="2.8" />
<path d="M10.2 7.8 7 16.2" />
<path d="M13.8 7.8 17 16.2" />
<path d="M8.3 18.5h7.4" />
</svg>
);
}
@@ -387,12 +369,9 @@ export function IconSidebarProviders({ size = 20, ...props }: IconProps) {
export function IconSidebarAuthFiles({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<path d="M7 4.5h7l3 3v11a2.5 2.5 0 0 1-2.5 2.5H7.5A2.5 2.5 0 0 1 5 18.5V7a2.5 2.5 0 0 1 2-2.5Z" />
<path d="M14 4.5v3h3" />
<path d="M8.4 10.9h5.7" />
<path d="M8.4 14.2h4.4" />
<path d="M15.9 14.6 18.3 17 15.9 19.4 13.5 17Z" fill="currentColor" fillOpacity="0.16" />
<path d="m14.9 17 0.9 0.9 1.8-1.9" />
<path d="M7 3h7l4 4v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z" />
<path d="M14 3v4h4" fill="currentColor" fillOpacity="0.12" />
<path d="M9 13l2 2 4-4" />
</svg>
);
}
@@ -400,11 +379,13 @@ export function IconSidebarAuthFiles({ size = 20, ...props }: IconProps) {
export function IconSidebarOauth({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<path d="M4.5 8.5h8.2" />
<polyline points="10.1 5.6 13 8.5 10.1 11.4" />
<path d="M19.5 15.5h-8.2" />
<polyline points="13.9 12.6 11 15.5 13.9 18.4" />
<path d="M12 9.4 14.6 12 12 14.6 9.4 12Z" fill="currentColor" fillOpacity="0.16" />
<path
d="M12 3l8 4v5c0 5.25-3.4 8.25-8 10-4.6-1.75-8-4.75-8-10V7Z"
fill="currentColor"
fillOpacity="0.08"
/>
<circle cx="12" cy="11" r="1.5" fill="currentColor" stroke="none" />
<path d="M12 12.5v2.5" />
</svg>
);
}
@@ -412,12 +393,8 @@ export function IconSidebarOauth({ size = 20, ...props }: IconProps) {
export function IconSidebarQuota({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<path d="M5 16.8a7 7 0 0 1 14 0" />
<path d="m7.3 13.8 1.4-1.4" />
<path d="M12 11V9" />
<path d="m16.7 13.8-1.4-1.4" />
<path d="M12 16.8 15.5 12.4" />
<path d="M12 15.2 13.6 16.8 12 18.4 10.4 16.8Z" fill="currentColor" stroke="none" />
<circle cx="12" cy="12" r="8" />
<path d="M12 12V4a8 8 0 0 1 8 8Z" fill="currentColor" fillOpacity="0.12" />
</svg>
);
}
@@ -425,35 +402,10 @@ export function IconSidebarQuota({ size = 20, ...props }: IconProps) {
export function IconSidebarUsage({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<path d="M5 5v14a2 2 0 0 0 2 2h12" />
<polyline points="7.4 15.5 10.2 12.3 12.7 13.8 16.1 9.1 18.4 10.8" />
<rect
x="9.55"
y="11.65"
width="1.3"
height="1.3"
rx="0.2"
fill="currentColor"
stroke="none"
/>
<rect
x="12.05"
y="13.15"
width="1.3"
height="1.3"
rx="0.2"
fill="currentColor"
stroke="none"
/>
<rect
x="15.45"
y="8.45"
width="1.3"
height="1.3"
rx="0.2"
fill="currentColor"
stroke="none"
/>
<path d="M3.5 20h17" />
<rect x="5" y="13" width="3.5" height="7" rx="0.5" />
<rect x="10.25" y="7" width="3.5" height="13" rx="0.5" fill="currentColor" fillOpacity="0.12" />
<rect x="15.5" y="10" width="3.5" height="10" rx="0.5" />
</svg>
);
}
@@ -461,30 +413,12 @@ export function IconSidebarUsage({ size = 20, ...props }: IconProps) {
export function IconSidebarLogs({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<rect x="4" y="5" width="16" height="14" rx="1.5" />
<path d="M4 9h16" />
<rect
x="6.1"
y="6.35"
width="1.15"
height="1.15"
rx="0.15"
fill="currentColor"
stroke="none"
/>
<rect
x="8.55"
y="6.35"
width="1.15"
height="1.15"
rx="0.15"
fill="currentColor"
fillOpacity="0.45"
stroke="none"
/>
<path d="m7.1 12.3 2.5 2-2.5 2" />
<path d="M11.9 12.2h3.4" />
<path d="M11.9 16.4h4.8" />
<rect x="3" y="4" width="18" height="16" rx="2" />
<path d="M3 8.5h18" />
<circle cx="5.5" cy="6.2" r="0.8" fill="currentColor" stroke="none" />
<circle cx="7.8" cy="6.2" r="0.8" fill="currentColor" fillOpacity="0.4" stroke="none" />
<path d="M7 12l3 2.5-3 2.5" />
<path d="M13 17h4" />
</svg>
);
}
@@ -492,23 +426,16 @@ export function IconSidebarLogs({ size = 20, ...props }: IconProps) {
export function IconSidebarSystem({ size = 20, ...props }: IconProps) {
return (
<svg {...sidebarSvgProps} width={size} height={size} {...props}>
<rect x="5" y="5" width="14" height="3.3" rx="0.8" />
<rect x="5" y="10.35" width="14" height="3.3" rx="0.8" />
<rect x="5" y="15.7" width="14" height="3.3" rx="0.8" />
<rect x="6.8" y="6.05" width="1.1" height="1.1" rx="0.15" fill="currentColor" stroke="none" />
<rect x="6.8" y="11.4" width="1.1" height="1.1" rx="0.15" fill="currentColor" stroke="none" />
<rect
x="6.8"
y="16.75"
width="1.1"
height="1.1"
rx="0.15"
fill="currentColor"
stroke="none"
/>
<path d="M10.4 6.6h5.2" />
<path d="M10.4 11.95h5.2" />
<path d="M10.4 17.3h5.2" />
<rect x="6" y="6" width="12" height="12" rx="2" />
<rect x="9" y="9" width="6" height="6" rx="1" fill="currentColor" fillOpacity="0.12" />
<path d="M6 10H3" />
<path d="M6 14H3" />
<path d="M21 10h-3" />
<path d="M21 14h-3" />
<path d="M10 6V3" />
<path d="M14 6V3" />
<path d="M10 21v-3" />
<path d="M14 21v-3" />
</svg>
);
}
@@ -22,6 +22,7 @@ import {
getTypeColor,
getTypeLabel,
isRuntimeOnlyAuthFile,
parsePriorityValue,
resolveAuthFileStats,
type QuotaProviderType,
type ResolvedTheme,
@@ -110,6 +111,9 @@ export function AuthFileCard(props: AuthFileCardProps) {
const hasStatusWarning =
Boolean(rawStatusMessage) && !HEALTHY_STATUS_MESSAGES.has(rawStatusMessage.toLowerCase());
const priorityValue = parsePriorityValue(file.priority ?? file['priority']);
const noteValue = typeof file.note === 'string' ? file.note.trim() : '';
return (
<div
className={`${styles.fileCard} ${providerCardClass} ${selected ? styles.fileCardSelected : ''} ${file.disabled ? styles.fileCardDisabled : ''}`}
@@ -147,8 +151,20 @@ export function AuthFileCard(props: AuthFileCardProps) {
<span>
{t('auth_files.file_modified')}: {formatModified(file)}
</span>
{priorityValue !== undefined && (
<span className={styles.priorityBadge}>
{t('auth_files.priority_display')}: <span className={styles.priorityValue}>{priorityValue}</span>
</span>
)}
</div>
{noteValue && (
<div className={styles.noteText} title={noteValue}>
<span className={styles.noteLabel}>{t('auth_files.note_display')}: </span>
{noteValue}
</div>
)}
{rawStatusMessage && hasStatusWarning && (
<div className={styles.healthStatusMessage} title={rawStatusMessage}>
{rawStatusMessage}
@@ -114,6 +114,14 @@ export function AuthFilesPrefixProxyEditorModal(props: AuthFilesPrefixProxyEdito
disabled={disableControls || editor.saving || !editor.json}
onChange={(e) => onChange('disableCooling', e.target.value)}
/>
<Input
label={t('auth_files.note_label')}
value={editor.note}
placeholder={t('auth_files.note_placeholder')}
hint={t('auth_files.note_hint')}
disabled={disableControls || editor.saving || !editor.json}
onChange={(e) => onChange('note', e.target.value)}
/>
{editor.isCodexFile && (
<div className="form-group">
<label>{t('ai_providers.codex_websockets_label')}</label>
@@ -18,7 +18,8 @@ export type PrefixProxyEditorField =
| 'priority'
| 'excludedModelsText'
| 'disableCooling'
| 'websocket';
| 'websocket'
| 'note';
export type PrefixProxyEditorFieldValue = string | boolean;
@@ -37,6 +38,8 @@ export type PrefixProxyEditorState = {
excludedModelsText: string;
disableCooling: string;
websocket: boolean;
note: string;
noteTouched: boolean;
};
export type UseAuthFilesPrefixProxyEditorOptions = {
@@ -93,6 +96,15 @@ const buildPrefixProxyUpdatedText = (editor: PrefixProxyEditorState | null): str
next.websocket = editor.websocket;
}
if (editor.noteTouched) {
const noteValue = editor.note.trim();
if (noteValue) {
next.note = editor.note;
} else if ('note' in next) {
delete next.note;
}
}
return JSON.stringify(next);
};
@@ -146,6 +158,8 @@ export function useAuthFilesPrefixProxyEditor(
excludedModelsText: '',
disableCooling: '',
websocket: false,
note: '',
noteTouched: false,
});
try {
@@ -195,6 +209,7 @@ export function useAuthFilesPrefixProxyEditor(
const excludedModels = normalizeExcludedModels(json.excluded_models);
const disableCoolingValue = parseDisableCoolingValue(json.disable_cooling);
const websocketValue = parseDisableCoolingValue(json.websocket);
const note = typeof json.note === 'string' ? json.note : '';
setPrefixProxyEditor((prev) => {
if (!prev || prev.fileName !== name) return prev;
@@ -211,6 +226,8 @@ export function useAuthFilesPrefixProxyEditor(
disableCooling:
disableCoolingValue === undefined ? '' : disableCoolingValue ? 'true' : 'false',
websocket: websocketValue ?? false,
note,
noteTouched: false,
error: null,
};
});
@@ -235,6 +252,7 @@ export function useAuthFilesPrefixProxyEditor(
if (field === 'priority') return { ...prev, priority: String(value) };
if (field === 'excludedModelsText') return { ...prev, excludedModelsText: String(value) };
if (field === 'disableCooling') return { ...prev, disableCooling: String(value) };
if (field === 'note') return { ...prev, note: String(value), noteTouched: true };
return { ...prev, websocket: Boolean(value) };
});
};
+9
View File
@@ -1,12 +1,21 @@
export const AUTH_FILES_SORT_MODES = ['default', 'az', 'priority'] as const;
export type AuthFilesSortMode = (typeof AUTH_FILES_SORT_MODES)[number];
export type AuthFilesUiState = {
filter?: string;
problemOnly?: boolean;
search?: string;
page?: number;
pageSize?: number;
sortMode?: AuthFilesSortMode;
};
const AUTH_FILES_UI_STATE_KEY = 'authFilesPage.uiState';
const AUTH_FILES_SORT_MODE_SET = new Set<AuthFilesSortMode>(AUTH_FILES_SORT_MODES);
export const isAuthFilesSortMode = (value: unknown): value is AuthFilesSortMode =>
typeof value === 'string' && AUTH_FILES_SORT_MODE_SET.has(value as AuthFilesSortMode);
export const readAuthFilesUiState = (): AuthFilesUiState | null => {
if (typeof window === 'undefined') return null;
+20 -2
View File
@@ -495,6 +495,11 @@
"search_placeholder": "Filter by name, type, or provider",
"problem_filter_label": "Problem Filter",
"problem_filter_only": "Only show problematic credentials",
"sort_label": "Sort",
"sort_default": "Default",
"sort_az": "A-Z Name",
"sort_priority": "Priority",
"priority_display": "Priority",
"page_size_label": "Per page",
"page_size_unit": "items",
"view_mode_paged": "Paged",
@@ -564,6 +569,10 @@
"disable_cooling_label": "Disable cooling (disable_cooling)",
"disable_cooling_placeholder": "e.g. true / false / 1 / 0",
"disable_cooling_hint": "Supports booleans, numeric 0/non-0, and strings like true/false/1/0; unparseable values are ignored.",
"note_label": "Note",
"note_placeholder": "Enter a note, e.g.: John's account",
"note_hint": "Optional. Used to describe the purpose or owner of this credential; leave empty to omit.",
"note_display": "Note",
"prefix_proxy_invalid_json": "This auth file is not a JSON object, so fields cannot be edited.",
"prefix_proxy_saved_success": "Updated auth file \"{{name}}\" successfully",
"quota_refresh_success": "Quota refreshed for \"{{name}}\"",
@@ -630,7 +639,8 @@
"plan_label": "Plan",
"plan_plus": "Plus",
"plan_team": "Team",
"plan_free": "Free"
"plan_free": "Free",
"plan_pro": "Pro"
},
"gemini_cli_quota": {
"title": "Gemini CLI Quota",
@@ -644,7 +654,15 @@
"empty_buckets": "No quota data available",
"refresh_button": "Refresh Quota",
"fetch_all": "Fetch All",
"remaining_amount": "Remaining {{count}}"
"remaining_amount": "Remaining {{count}}",
"tier_label": "Tier",
"tier_free": "Free",
"tier_legacy": "Legacy",
"tier_standard": "Standard",
"tier_pro": "Pro",
"tier_ultra": "Ultra",
"credit_label": "Google One AI Credits",
"credit_amount": "{{count}} credits"
},
"kimi_quota": {
"title": "Kimi Quota",
+20 -2
View File
@@ -495,6 +495,11 @@
"search_placeholder": "Фильтр по имени, типу или провайдеру",
"problem_filter_label": "Фильтр проблем",
"problem_filter_only": "Показывать только проблемные учётные данные",
"sort_label": "Сортировка",
"sort_default": "По умолчанию",
"sort_az": "A-Z Имя",
"sort_priority": "Приоритет",
"priority_display": "Приоритет",
"page_size_label": "На странице",
"page_size_unit": "элементов",
"view_mode_paged": "Постранично",
@@ -564,6 +569,10 @@
"disable_cooling_label": "Отключение охлаждения (disable_cooling)",
"disable_cooling_placeholder": "например: true / false / 1 / 0",
"disable_cooling_hint": "Поддерживает boolean, числа 0/не 0 и строки true/false/1/0; непарсируемые значения игнорируются.",
"note_label": "Заметка (note)",
"note_placeholder": "Введите заметку, например: аккаунт Ивана",
"note_hint": "Необязательно. Используется для описания назначения или владельца учётных данных; оставьте пустым, чтобы не записывать.",
"note_display": "Заметка",
"prefix_proxy_invalid_json": "Этот файл авторизации не является JSON-объектом, поэтому поля нельзя редактировать.",
"prefix_proxy_saved_success": "Файл авторизации \"{{name}}\" успешно обновлён",
"card_tools_title": "Инструменты",
@@ -633,7 +642,8 @@
"plan_label": "Тариф",
"plan_plus": "Plus",
"plan_team": "Team",
"plan_free": "Free"
"plan_free": "Free",
"plan_pro": "Pro"
},
"gemini_cli_quota": {
"title": "Квота Gemini CLI",
@@ -647,7 +657,15 @@
"empty_buckets": "Данные по квоте отсутствуют",
"refresh_button": "Обновить квоту",
"fetch_all": "Получить все",
"remaining_amount": "Осталось {{count}}"
"remaining_amount": "Осталось {{count}}",
"tier_label": "Уровень",
"tier_free": "Бесплатный",
"tier_legacy": "Устаревший",
"tier_standard": "Стандартный",
"tier_pro": "Pro",
"tier_ultra": "Ultra",
"credit_label": "Google One AI кредиты",
"credit_amount": "{{count}} кредитов"
},
"kimi_quota": {
"title": "Квота Kimi",
+20 -2
View File
@@ -495,6 +495,11 @@
"search_placeholder": "输入名称、类型或提供方关键字",
"problem_filter_label": "问题筛选",
"problem_filter_only": "仅显示有问题凭证",
"sort_label": "排序",
"sort_default": "默认",
"sort_az": "A-Z 名称",
"sort_priority": "优先级",
"priority_display": "优先级",
"page_size_label": "单页数量",
"page_size_unit": "个/页",
"view_mode_paged": "按页显示",
@@ -564,6 +569,10 @@
"disable_cooling_label": "禁用冷却(disable_cooling",
"disable_cooling_placeholder": "例如: true / false / 1 / 0",
"disable_cooling_hint": "支持布尔值、0/非0 数字或字符串 true/false/1/0;无法解析时忽略。",
"note_label": "备注(note",
"note_placeholder": "输入备注信息,例如:张三的账号",
"note_hint": "可选,用于标记凭证用途或归属;留空则不写入。",
"note_display": "备注",
"prefix_proxy_invalid_json": "该认证文件不是 JSON 对象,无法编辑字段。",
"prefix_proxy_saved_success": "已更新认证文件 \"{{name}}\"",
"quota_refresh_success": "已刷新 \"{{name}}\" 的额度",
@@ -630,7 +639,8 @@
"plan_label": "套餐",
"plan_plus": "Plus",
"plan_team": "Team",
"plan_free": "Free"
"plan_free": "Free",
"plan_pro": "Pro"
},
"gemini_cli_quota": {
"title": "Gemini CLI 额度",
@@ -644,7 +654,15 @@
"empty_buckets": "暂无额度数据",
"refresh_button": "刷新额度",
"fetch_all": "获取全部",
"remaining_amount": "剩余 {{count}}"
"remaining_amount": "剩余 {{count}}",
"tier_label": "层级",
"tier_free": "免费版",
"tier_legacy": "旧版",
"tier_standard": "标准版",
"tier_pro": "Pro",
"tier_ultra": "Ultra",
"credit_label": "Google One AI 积分",
"credit_amount": "{{count}} 积分"
},
"kimi_quota": {
"title": "Kimi 额度",
-1
View File
@@ -381,7 +381,6 @@ export function AiProvidersPage() {
loading={loading}
disableControls={disableControls}
isSwitching={isSwitching}
resolvedTheme={resolvedTheme}
onAdd={() => openEditor('/ai-providers/codex/new')}
onEdit={(index) => openEditor(`/ai-providers/codex/${index}`)}
onDelete={(index) => void deleteProviderEntry('codex', index)}
@@ -170,19 +170,19 @@
}
.modelItem {
display: flex;
align-items: center;
gap: $spacing-sm;
width: 100%;
align-items: flex-start;
padding: 10px 0;
border-bottom: 1px solid var(--border-color);
border-radius: $radius-sm;
transition: background-color $transition-fast;
&:last-child {
border-bottom: none;
}
input {
width: 16px;
height: 16px;
&:hover {
background-color: var(--bg-hover);
}
}
@@ -191,6 +191,7 @@
flex-direction: column;
gap: 2px;
min-width: 0;
flex: 1;
}
.modelId {
+17 -14
View File
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Card } from '@/components/ui/Card';
import { Button } from '@/components/ui/Button';
import { LoadingSpinner } from '@/components/ui/LoadingSpinner';
import { SelectionCheckbox } from '@/components/ui/SelectionCheckbox';
import { AutocompleteInput } from '@/components/ui/AutocompleteInput';
import { EmptyState } from '@/components/ui/EmptyState';
import { IconInfo } from '@/components/ui/icons';
@@ -400,20 +401,22 @@ export function AuthFilesOAuthExcludedEditPage() {
{modelsList.map((model) => {
const checked = selectedModels.has(model.id);
return (
<label key={model.id} className={styles.modelItem}>
<input
type="checkbox"
checked={checked}
disabled={disableControls || saving}
onChange={(event) => toggleModel(model.id, event.target.checked)}
/>
<span className={styles.modelText}>
<span className={styles.modelId}>{model.id}</span>
{model.display_name && model.display_name !== model.id && (
<span className={styles.modelDisplayName}>{model.display_name}</span>
)}
</span>
</label>
<SelectionCheckbox
key={model.id}
checked={checked}
disabled={disableControls || saving}
onChange={(value) => toggleModel(model.id, value)}
className={styles.modelItem}
labelClassName={styles.modelText}
label={
<>
<span className={styles.modelId}>{model.id}</span>
{model.display_name && model.display_name !== model.id && (
<span className={styles.modelDisplayName}>{model.display_name}</span>
)}
</>
}
/>
);
})}
</div>
+83 -3
View File
@@ -81,7 +81,7 @@
.filterTag {
display: inline-flex;
align-items: baseline;
align-items: center;
gap: 8px;
padding: 6px 14px;
border-radius: 20px;
@@ -104,13 +104,21 @@
.filterTagLabel {
display: inline-flex;
align-items: baseline;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.filterTagIcon {
width: 15px;
height: 15px;
flex: 0 0 auto;
object-fit: contain;
}
.filterTagCount {
display: inline-flex;
align-items: baseline;
align-items: center;
justify-content: flex-end;
min-width: 2ch;
font-size: 12px;
@@ -504,6 +512,45 @@
text-transform: capitalize;
}
.premiumPlanValue {
display: inline-flex;
align-items: center;
font-weight: 700;
font-size: 12px;
padding: 2px 8px;
border-radius: 999px;
background: linear-gradient(135deg, #fdf3d7, #f0d060);
border: 1px solid #e0b830;
box-shadow: 0 1px 4px rgba(200, 160, 0, 0.18);
color: #7a5c00;
text-transform: capitalize;
@media (dynamic-range: high) {
background: linear-gradient(135deg,
color(display-p3 0.99 0.95 0.82),
color(display-p3 0.97 0.82 0.28));
border-color: color(display-p3 0.90 0.73 0.12);
box-shadow: 0 1px 8px color(display-p3 1.0 0.84 0.0 / 0.25);
color: color(display-p3 0.50 0.38 0.0);
}
}
:global([data-theme='dark']) .premiumPlanValue {
background: linear-gradient(135deg, #3d3210, #5a4a18);
border-color: #8b7030;
box-shadow: 0 1px 8px rgba(180, 140, 0, 0.2);
color: #e8c84c;
@media (dynamic-range: high) {
background: linear-gradient(135deg,
color(display-p3 0.24 0.20 0.06),
color(display-p3 0.38 0.30 0.08));
border-color: color(display-p3 0.58 0.46 0.15);
box-shadow: 0 1px 12px color(display-p3 0.80 0.65 0.0 / 0.2);
color: color(display-p3 0.95 0.82 0.25);
}
}
// 单个认证文件卡片
.fileCard {
background-color: var(--bg-primary);
@@ -593,6 +640,39 @@
border-bottom: 1px solid var(--border-color);
}
.priorityBadge {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 12px;
color: var(--text-secondary);
.priorityValue {
font-weight: 600;
color: var(--text-primary);
font-variant-numeric: tabular-nums;
}
}
.noteText {
font-size: 12px;
color: var(--text-secondary);
line-height: 1.4;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-break: break-word;
.noteLabel {
color: var(--text-tertiary);
}
}
.sortSelect {
min-width: 140px;
}
.healthStatusMessage {
font-size: 12px;
color: var(--warning-text);
+106 -8
View File
@@ -18,6 +18,7 @@ import { usePageTransitionLayer } from '@/components/common/PageTransitionLayer'
import { Card } from '@/components/ui/Card';
import { Button } from '@/components/ui/Button';
import { Input } from '@/components/ui/Input';
import { Select } from '@/components/ui/Select';
import { EmptyState } from '@/components/ui/EmptyState';
import { ToggleSwitch } from '@/components/ui/ToggleSwitch';
import { copyToClipboard } from '@/utils/clipboard';
@@ -31,6 +32,7 @@ import {
hasAuthFileStatusMessage,
isRuntimeOnlyAuthFile,
normalizeProviderKey,
parsePriorityValue,
type QuotaProviderType,
type ResolvedTheme,
} from '@/features/authFiles/constants';
@@ -40,13 +42,27 @@ import { AuthFileModelsModal } from '@/features/authFiles/components/AuthFileMod
import { AuthFilesPrefixProxyEditorModal } from '@/features/authFiles/components/AuthFilesPrefixProxyEditorModal';
import { OAuthExcludedCard } from '@/features/authFiles/components/OAuthExcludedCard';
import { OAuthModelAliasCard } from '@/features/authFiles/components/OAuthModelAliasCard';
import iconAntigravity from '@/assets/icons/antigravity.svg';
import iconClaude from '@/assets/icons/claude.svg';
import iconCodex from '@/assets/icons/codex.svg';
import iconGemini from '@/assets/icons/gemini.svg';
import iconIflow from '@/assets/icons/iflow.svg';
import iconKimiDark from '@/assets/icons/kimi-dark.svg';
import iconKimiLight from '@/assets/icons/kimi-light.svg';
import iconQwen from '@/assets/icons/qwen.svg';
import iconVertex from '@/assets/icons/vertex.svg';
import { useAuthFilesData } from '@/features/authFiles/hooks/useAuthFilesData';
import { useAuthFilesModels } from '@/features/authFiles/hooks/useAuthFilesModels';
import { useAuthFilesOauth } from '@/features/authFiles/hooks/useAuthFilesOauth';
import { useAuthFilesPrefixProxyEditor } from '@/features/authFiles/hooks/useAuthFilesPrefixProxyEditor';
import { useAuthFilesStats } from '@/features/authFiles/hooks/useAuthFilesStats';
import { useAuthFilesStatusBarCache } from '@/features/authFiles/hooks/useAuthFilesStatusBarCache';
import { readAuthFilesUiState, writeAuthFilesUiState } from '@/features/authFiles/uiState';
import {
isAuthFilesSortMode,
readAuthFilesUiState,
writeAuthFilesUiState,
type AuthFilesSortMode,
} from '@/features/authFiles/uiState';
import { useAuthStore, useNotificationStore, useThemeStore } from '@/stores';
import type { AuthFileItem } from '@/types';
import styles from './AuthFilesPage.module.scss';
@@ -55,6 +71,28 @@ const easePower3Out = (progress: number) => 1 - (1 - progress) ** 4;
const easePower2In = (progress: number) => progress ** 3;
const BATCH_BAR_BASE_TRANSFORM = 'translateX(-50%)';
const BATCH_BAR_HIDDEN_TRANSFORM = 'translateX(-50%) translateY(56px)';
const AUTH_FILE_FILTER_ICONS: Record<string, string | { light: string; dark: string }> = {
antigravity: iconAntigravity,
aistudio: iconGemini,
claude: iconClaude,
codex: iconCodex,
gemini: iconGemini,
'gemini-cli': iconGemini,
iflow: iconIflow,
kimi: { light: iconKimiLight, dark: iconKimiDark },
qwen: iconQwen,
vertex: iconVertex,
};
const getFilterTagIcon = (type: string, resolvedTheme: ResolvedTheme): string | null => {
const iconEntry = AUTH_FILE_FILTER_ICONS[normalizeProviderKey(type)];
if (!iconEntry) return null;
return typeof iconEntry === 'string'
? iconEntry
: resolvedTheme === 'dark'
? iconEntry.dark
: iconEntry.light;
};
export function AuthFilesPage() {
const { t } = useTranslation();
@@ -74,6 +112,7 @@ export function AuthFilesPage() {
const [detailModalOpen, setDetailModalOpen] = useState(false);
const [selectedFile, setSelectedFile] = useState<AuthFileItem | null>(null);
const [viewMode, setViewMode] = useState<'diagram' | 'list'>('list');
const [sortMode, setSortMode] = useState<AuthFilesSortMode>('default');
const [batchActionBarVisible, setBatchActionBarVisible] = useState(false);
const floatingBatchActionsRef = useRef<HTMLDivElement>(null);
const batchActionAnimationRef = useRef<AnimationPlaybackControlsWithThen | null>(null);
@@ -177,11 +216,14 @@ export function AuthFilesPage() {
if (typeof persisted.pageSize === 'number' && Number.isFinite(persisted.pageSize)) {
setPageSize(clampCardPageSize(persisted.pageSize));
}
if (isAuthFilesSortMode(persisted.sortMode)) {
setSortMode(persisted.sortMode);
}
}, []);
useEffect(() => {
writeAuthFilesUiState({ filter, problemOnly, search, page, pageSize });
}, [filter, problemOnly, search, page, pageSize]);
writeAuthFilesUiState({ filter, problemOnly, search, page, pageSize, sortMode });
}, [filter, problemOnly, search, page, pageSize, sortMode]);
useEffect(() => {
setPageSizeInput(String(pageSize));
@@ -223,6 +265,16 @@ export function AuthFilesPage() {
setPage(1);
};
const handleSortModeChange = useCallback(
(value: string) => {
if (!isAuthFilesSortMode(value) || value === sortMode) return;
setSortMode(value);
setPage(1);
void loadFiles().catch(() => {});
},
[loadFiles, sortMode]
);
const handleHeaderRefresh = useCallback(async () => {
await Promise.all([loadFiles(), refreshKeyStats(), loadExcluded(), loadModelAlias()]);
}, [loadFiles, refreshKeyStats, loadExcluded, loadModelAlias]);
@@ -259,6 +311,15 @@ export function AuthFilesPage() {
[files, problemOnly]
);
const sortOptions = useMemo(
() => [
{ value: 'default', label: t('auth_files.sort_default') },
{ value: 'az', label: t('auth_files.sort_az') },
{ value: 'priority', label: t('auth_files.sort_priority') },
],
[t]
);
const typeCounts = useMemo(() => {
const counts: Record<string, number> = { all: filesMatchingProblemFilter.length };
filesMatchingProblemFilter.forEach((file) => {
@@ -281,10 +342,32 @@ export function AuthFilesPage() {
});
}, [filesMatchingProblemFilter, filter, search]);
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
const sorted = useMemo(() => {
const copy = [...filtered];
if (sortMode === 'default') {
copy.sort((a, b) => {
const providerA = normalizeProviderKey(String(a.provider ?? a.type ?? 'unknown'));
const providerB = normalizeProviderKey(String(b.provider ?? b.type ?? 'unknown'));
const providerCompare = providerA.localeCompare(providerB);
if (providerCompare !== 0) return providerCompare;
return a.name.localeCompare(b.name);
});
} else if (sortMode === 'az') {
copy.sort((a, b) => a.name.localeCompare(b.name));
} else if (sortMode === 'priority') {
copy.sort((a, b) => {
const pa = parsePriorityValue(a.priority ?? a['priority']) ?? 0;
const pb = parsePriorityValue(b.priority ?? b['priority']) ?? 0;
return pb - pa; // 高优先级排前面
});
}
return copy;
}, [filtered, sortMode]);
const totalPages = Math.max(1, Math.ceil(sorted.length / pageSize));
const currentPage = Math.min(page, totalPages);
const start = (currentPage - 1) * pageSize;
const pageItems = filtered.slice(start, start + pageSize);
const pageItems = sorted.slice(start, start + pageSize);
const selectablePageItems = useMemo(
() => pageItems.filter((file) => !isRuntimeOnlyAuthFile(file)),
[pageItems]
@@ -433,6 +516,7 @@ export function AuthFilesPage() {
<div className={styles.filterTags}>
{existingTypes.map((type) => {
const isActive = filter === type;
const iconSrc = getFilterTagIcon(type, resolvedTheme);
const color =
type === 'all'
? { bg: 'var(--bg-tertiary)', text: 'var(--text-primary)' }
@@ -452,7 +536,10 @@ export function AuthFilesPage() {
setPage(1);
}}
>
<span className={styles.filterTagLabel}>{getTypeLabel(t, type)}</span>
<span className={styles.filterTagLabel}>
{iconSrc && <img src={iconSrc} alt="" className={styles.filterTagIcon} />}
<span>{getTypeLabel(t, type)}</span>
</span>
<span className={styles.filterTagCount}>{typeCounts[type] ?? 0}</span>
</button>
);
@@ -559,6 +646,17 @@ export function AuthFilesPage() {
}}
/>
</div>
<div className={styles.filterItem}>
<label>{t('auth_files.sort_label')}</label>
<Select
className={styles.sortSelect}
value={sortMode}
options={sortOptions}
onChange={handleSortModeChange}
ariaLabel={t('auth_files.sort_label')}
fullWidth={false}
/>
</div>
<div className={`${styles.filterItem} ${styles.filterToggleItem}`}>
<label>{t('auth_files.problem_filter_label')}</label>
<div className={styles.filterToggle}>
@@ -615,7 +713,7 @@ export function AuthFilesPage() {
</div>
)}
{!loading && filtered.length > pageSize && (
{!loading && sorted.length > pageSize && (
<div className={styles.pagination}>
<Button
variant="secondary"
@@ -629,7 +727,7 @@ export function AuthFilesPage() {
{t('auth_files.pagination_info', {
current: currentPage,
total: totalPages,
count: filtered.length,
count: sorted.length,
})}
</div>
<Button
+2 -3
View File
@@ -8,8 +8,7 @@ import { oauthApi, type OAuthProvider, type IFlowCookieAuthResponse } from '@/se
import { vertexApi, type VertexImportResponse } from '@/services/api/vertex';
import { copyToClipboard } from '@/utils/clipboard';
import styles from './OAuthPage.module.scss';
import iconCodexLight from '@/assets/icons/codex_light.svg';
import iconCodexDark from '@/assets/icons/codex_drak.svg';
import iconCodex from '@/assets/icons/codex.svg';
import iconClaude from '@/assets/icons/claude.svg';
import iconAntigravity from '@/assets/icons/antigravity.svg';
import iconGemini from '@/assets/icons/gemini.svg';
@@ -73,7 +72,7 @@ function getErrorStatus(error: unknown): number | undefined {
}
const PROVIDERS: { id: OAuthProvider; titleKey: string; hintKey: string; urlLabelKey: string; icon: string | { light: string; dark: string } }[] = [
{ id: 'codex', titleKey: 'auth_login.codex_oauth_title', hintKey: 'auth_login.codex_oauth_hint', urlLabelKey: 'auth_login.codex_oauth_url_label', icon: { light: iconCodexLight, dark: iconCodexDark } },
{ id: 'codex', titleKey: 'auth_login.codex_oauth_title', hintKey: 'auth_login.codex_oauth_hint', urlLabelKey: 'auth_login.codex_oauth_url_label', icon: iconCodex },
{ id: 'anthropic', titleKey: 'auth_login.anthropic_oauth_title', hintKey: 'auth_login.anthropic_oauth_hint', urlLabelKey: 'auth_login.anthropic_oauth_url_label', icon: iconClaude },
{ id: 'antigravity', titleKey: 'auth_login.antigravity_oauth_title', hintKey: 'auth_login.antigravity_oauth_hint', urlLabelKey: 'auth_login.antigravity_oauth_url_label', icon: iconAntigravity },
{ id: 'gemini-cli', titleKey: 'auth_login.gemini_cli_oauth_title', hintKey: 'auth_login.gemini_cli_oauth_hint', urlLabelKey: 'auth_login.gemini_cli_oauth_url_label', icon: iconGemini },
+39
View File
@@ -318,6 +318,45 @@
text-transform: capitalize;
}
.premiumPlanValue {
display: inline-flex;
align-items: center;
font-weight: 700;
font-size: 12px;
padding: 2px 8px;
border-radius: 999px;
background: linear-gradient(135deg, #fdf3d7, #f0d060);
border: 1px solid #e0b830;
box-shadow: 0 1px 4px rgba(200, 160, 0, 0.18);
color: #7a5c00;
text-transform: capitalize;
@media (dynamic-range: high) {
background: linear-gradient(135deg,
color(display-p3 0.99 0.95 0.82),
color(display-p3 0.97 0.82 0.28));
border-color: color(display-p3 0.90 0.73 0.12);
box-shadow: 0 1px 8px color(display-p3 1.0 0.84 0.0 / 0.25);
color: color(display-p3 0.50 0.38 0.0);
}
}
:global([data-theme='dark']) .premiumPlanValue {
background: linear-gradient(135deg, #3d3210, #5a4a18);
border-color: #8b7030;
box-shadow: 0 1px 8px rgba(180, 140, 0, 0.2);
color: #e8c84c;
@media (dynamic-range: high) {
background: linear-gradient(135deg,
color(display-p3 0.24 0.20 0.06),
color(display-p3 0.38 0.30 0.08));
border-color: color(display-p3 0.58 0.46 0.15);
box-shadow: 0 1px 12px color(display-p3 0.80 0.65 0.0 / 0.2);
color: color(display-p3 0.95 0.82 0.25);
}
}
.fileCard {
background-color: var(--bg-primary);
border: 1px solid var(--border-color);
+20 -8
View File
@@ -78,7 +78,10 @@
color: inherit;
padding: $spacing-md $spacing-lg;
cursor: pointer;
transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
transition:
transform 0.18s ease,
border-color 0.2s ease,
box-shadow 0.2s ease;
&:hover {
transform: translateY(-1px);
@@ -97,6 +100,19 @@
color: var(--text-secondary);
}
.tileHeader {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: $spacing-sm;
}
.tileAction {
flex-shrink: 0;
white-space: nowrap;
margin: -4px -8px 0 0;
}
.tileValue {
font-size: 22px;
font-weight: 700;
@@ -111,12 +127,6 @@
line-height: 1.4;
}
.aboutActions {
display: flex;
justify-content: flex-end;
margin-top: $spacing-lg;
}
.section {
display: flex;
flex-direction: column;
@@ -212,7 +222,9 @@
border-radius: $radius-full;
border: 1px solid var(--border-color);
background-color: var(--bg-secondary);
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
font-family:
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
}
.modelName {
+241 -154
View File
@@ -5,8 +5,14 @@ import { Button } from '@/components/ui/Button';
import { Modal } from '@/components/ui/Modal';
import { ToggleSwitch } from '@/components/ui/ToggleSwitch';
import { IconGithub, IconBookOpen, IconExternalLink, IconCode } from '@/components/ui/icons';
import { useAuthStore, useConfigStore, useNotificationStore, useModelsStore, useThemeStore } from '@/stores';
import { configApi } from '@/services/api';
import {
useAuthStore,
useConfigStore,
useNotificationStore,
useModelsStore,
useThemeStore,
} from '@/stores';
import { configApi, versionApi } from '@/services/api';
import { apiKeysApi } from '@/services/api/apiKeys';
import { classifyModels } from '@/utils/models';
import { STORAGE_KEY_AUTH } from '@/utils/constants';
@@ -36,6 +42,32 @@ const MODEL_CATEGORY_ICONS: Record<string, string | { light: string; dark: strin
minimax: iconMinimax,
};
const parseVersionSegments = (version?: string | null) => {
if (!version) return null;
const cleaned = version.trim().replace(/^v/i, '');
if (!cleaned) return null;
const parts = cleaned
.split(/[^0-9]+/)
.filter(Boolean)
.map((segment) => Number.parseInt(segment, 10))
.filter(Number.isFinite);
return parts.length ? parts : null;
};
const compareVersions = (latest?: string | null, current?: string | null) => {
const latestParts = parseVersionSegments(latest);
const currentParts = parseVersionSegments(current);
if (!latestParts || !currentParts) return null;
const length = Math.max(latestParts.length, currentParts.length);
for (let i = 0; i < length; i++) {
const l = latestParts[i] || 0;
const c = currentParts[i] || 0;
if (l > c) return 1;
if (l < c) return -1;
}
return 0;
};
export function SystemPage() {
const { t, i18n } = useTranslation();
const { showNotification, showConfirmation } = useNotificationStore();
@@ -51,11 +83,15 @@ export function SystemPage() {
const modelsError = useModelsStore((state) => state.error);
const fetchModelsFromStore = useModelsStore((state) => state.fetchModels);
const [modelStatus, setModelStatus] = useState<{ type: 'success' | 'warning' | 'error' | 'muted'; message: string }>();
const [modelStatus, setModelStatus] = useState<{
type: 'success' | 'warning' | 'error' | 'muted';
message: string;
}>();
const [requestLogModalOpen, setRequestLogModalOpen] = useState(false);
const [requestLogDraft, setRequestLogDraft] = useState(false);
const [requestLogTouched, setRequestLogTouched] = useState(false);
const [requestLogSaving, setRequestLogSaving] = useState(false);
const [checkingVersion, setCheckingVersion] = useState(false);
const apiKeysCache = useRef<string[]>([]);
const versionTapCount = useRef(0);
@@ -136,7 +172,7 @@ export function SystemPage() {
if (auth.connectionStatus !== 'connected') {
setModelStatus({
type: 'warning',
message: t('notification.connection_required')
message: t('notification.connection_required'),
});
return;
}
@@ -158,11 +194,12 @@ export function SystemPage() {
const hasModels = list.length > 0;
setModelStatus({
type: hasModels ? 'success' : 'warning',
message: hasModels ? t('system_info.models_count', { count: list.length }) : t('system_info.models_empty')
message: hasModels
? t('system_info.models_count', { count: list.length })
: t('system_info.models_empty'),
});
} catch (err: unknown) {
const message =
err instanceof Error ? err.message : typeof err === 'string' ? err : '';
const message = err instanceof Error ? err.message : typeof err === 'string' ? err : '';
const suffix = message ? `: ${message}` : '';
const text = `${t('system_info.models_error')}${suffix}`;
setModelStatus({ type: 'error', message: text });
@@ -244,6 +281,39 @@ export function SystemPage() {
}
};
const handleVersionCheck = useCallback(async () => {
setCheckingVersion(true);
try {
const data = await versionApi.checkLatest();
const latestRaw = data?.['latest-version'] ?? data?.latest_version ?? data?.latest ?? '';
const latest = typeof latestRaw === 'string' ? latestRaw : String(latestRaw ?? '');
const comparison = compareVersions(latest, auth.serverVersion);
if (!latest) {
showNotification(t('system_info.version_check_error'), 'error');
return;
}
if (comparison === null) {
showNotification(t('system_info.version_current_missing'), 'warning');
return;
}
if (comparison > 0) {
showNotification(t('system_info.version_update_available', { version: latest }), 'warning');
} else {
showNotification(t('system_info.version_is_latest'), 'success');
}
} catch (error: unknown) {
const message =
error instanceof Error ? error.message : typeof error === 'string' ? error : '';
const suffix = message ? `: ${message}` : '';
showNotification(`${t('system_info.version_check_error')}${suffix}`, 'error');
} finally {
setCheckingVersion(false);
}
}, [auth.serverVersion, showNotification, t]);
useEffect(() => {
fetchConfig().catch(() => {
// ignore
@@ -273,160 +343,177 @@ export function SystemPage() {
<div className={styles.container}>
<h1 className={styles.pageTitle}>{t('system_info.title')}</h1>
<div className={styles.content}>
<Card className={styles.aboutCard}>
<div className={styles.aboutHeader}>
<img src={INLINE_LOGO_JPEG} alt="CPAMC" className={styles.aboutLogo} />
<div className={styles.aboutTitle}>{t('system_info.about_title')}</div>
</div>
<div className={styles.aboutInfoGrid}>
<button
type="button"
className={`${styles.infoTile} ${styles.tapTile}`}
onClick={handleInfoVersionTap}
>
<div className={styles.tileLabel}>{t('footer.version')}</div>
<div className={styles.tileValue}>{appVersion}</div>
</button>
<div className={styles.infoTile}>
<div className={styles.tileLabel}>{t('footer.api_version')}</div>
<div className={styles.tileValue}>{apiVersion}</div>
<Card className={styles.aboutCard}>
<div className={styles.aboutHeader}>
<img src={INLINE_LOGO_JPEG} alt="CPAMC" className={styles.aboutLogo} />
<div className={styles.aboutTitle}>{t('system_info.about_title')}</div>
</div>
<div className={styles.infoTile}>
<div className={styles.tileLabel}>{t('footer.build_date')}</div>
<div className={styles.tileValue}>{buildTime}</div>
<div className={styles.aboutInfoGrid}>
<button
type="button"
className={`${styles.infoTile} ${styles.tapTile}`}
onClick={handleInfoVersionTap}
>
<div className={styles.tileLabel}>{t('footer.version')}</div>
<div className={styles.tileValue}>{appVersion}</div>
</button>
<div className={styles.infoTile}>
<div className={styles.tileHeader}>
<div className={styles.tileLabel}>{t('footer.api_version')}</div>
<Button
type="button"
variant="ghost"
size="sm"
className={styles.tileAction}
onClick={() => void handleVersionCheck()}
loading={checkingVersion}
title={t('system_info.version_check_button')}
aria-label={t('system_info.version_check_button')}
>
{t('system_info.version_check_button')}
</Button>
</div>
<div className={styles.tileValue}>{apiVersion}</div>
</div>
<div className={styles.infoTile}>
<div className={styles.tileLabel}>{t('footer.build_date')}</div>
<div className={styles.tileValue}>{buildTime}</div>
</div>
<div className={styles.infoTile}>
<div className={styles.tileLabel}>{t('connection.status')}</div>
<div className={styles.tileValue}>{t(`common.${auth.connectionStatus}_status`)}</div>
<div className={styles.tileSub}>{auth.apiBase || '-'}</div>
</div>
</div>
</Card>
<div className={styles.infoTile}>
<div className={styles.tileLabel}>{t('connection.status')}</div>
<div className={styles.tileValue}>{t(`common.${auth.connectionStatus}_status`)}</div>
<div className={styles.tileSub}>{auth.apiBase || '-'}</div>
</div>
</div>
<div className={styles.aboutActions}>
<Button variant="secondary" size="sm" onClick={() => fetchConfig(undefined, true)}>
{t('common.refresh')}
</Button>
</div>
</Card>
<Card title={t('system_info.quick_links_title')}>
<p className={styles.sectionDescription}>{t('system_info.quick_links_desc')}</p>
<div className={styles.quickLinks}>
<a
href="https://github.com/router-for-me/CLIProxyAPI"
target="_blank"
rel="noopener noreferrer"
className={styles.linkCard}
>
<div className={`${styles.linkIcon} ${styles.github}`}>
<IconGithub size={22} />
</div>
<div className={styles.linkContent}>
<div className={styles.linkTitle}>
{t('system_info.link_main_repo')}
<IconExternalLink size={14} />
<Card title={t('system_info.quick_links_title')}>
<p className={styles.sectionDescription}>{t('system_info.quick_links_desc')}</p>
<div className={styles.quickLinks}>
<a
href="https://github.com/router-for-me/CLIProxyAPI"
target="_blank"
rel="noopener noreferrer"
className={styles.linkCard}
>
<div className={`${styles.linkIcon} ${styles.github}`}>
<IconGithub size={22} />
</div>
<div className={styles.linkDesc}>{t('system_info.link_main_repo_desc')}</div>
</div>
</a>
<a
href="https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
target="_blank"
rel="noopener noreferrer"
className={styles.linkCard}
>
<div className={`${styles.linkIcon} ${styles.github}`}>
<IconCode size={22} />
</div>
<div className={styles.linkContent}>
<div className={styles.linkTitle}>
{t('system_info.link_webui_repo')}
<IconExternalLink size={14} />
</div>
<div className={styles.linkDesc}>{t('system_info.link_webui_repo_desc')}</div>
</div>
</a>
<a
href="https://help.router-for.me/"
target="_blank"
rel="noopener noreferrer"
className={styles.linkCard}
>
<div className={`${styles.linkIcon} ${styles.docs}`}>
<IconBookOpen size={22} />
</div>
<div className={styles.linkContent}>
<div className={styles.linkTitle}>
{t('system_info.link_docs')}
<IconExternalLink size={14} />
</div>
<div className={styles.linkDesc}>{t('system_info.link_docs_desc')}</div>
</div>
</a>
</div>
</Card>
<Card
title={t('system_info.models_title')}
extra={
<Button variant="secondary" size="sm" onClick={() => fetchModels({ forceRefresh: true })} loading={modelsLoading}>
{t('common.refresh')}
</Button>
}
>
<p className={styles.sectionDescription}>{t('system_info.models_desc')}</p>
{modelStatus && <div className={`status-badge ${modelStatus.type}`}>{modelStatus.message}</div>}
{modelsError && <div className="error-box">{modelsError}</div>}
{modelsLoading ? (
<div className="hint">{t('common.loading')}</div>
) : models.length === 0 ? (
<div className="hint">{t('system_info.models_empty')}</div>
) : (
<div className="item-list">
{groupedModels.map((group) => {
const iconSrc = getIconForCategory(group.id);
return (
<div key={group.id} className="item-row">
<div className="item-meta">
<div className={styles.groupTitle}>
{iconSrc && <img src={iconSrc} alt="" className={styles.groupIcon} />}
<span className="item-title">{group.label}</span>
</div>
<div className="item-subtitle">{t('system_info.models_count', { count: group.items.length })}</div>
</div>
<div className={styles.modelTags}>
{group.items.map((model) => (
<span
key={`${model.name}-${model.alias ?? 'default'}`}
className={styles.modelTag}
title={model.description || ''}
>
<span className={styles.modelName}>{model.name}</span>
{model.alias && <span className={styles.modelAlias}>{model.alias}</span>}
</span>
))}
</div>
<div className={styles.linkContent}>
<div className={styles.linkTitle}>
{t('system_info.link_main_repo')}
<IconExternalLink size={14} />
</div>
);
})}
</div>
)}
</Card>
<div className={styles.linkDesc}>{t('system_info.link_main_repo_desc')}</div>
</div>
</a>
<Card title={t('system_info.clear_login_title')}>
<p className={styles.sectionDescription}>{t('system_info.clear_login_desc')}</p>
<div className={styles.clearLoginActions}>
<Button variant="danger" onClick={handleClearLoginStorage}>
{t('system_info.clear_login_button')}
</Button>
</div>
</Card>
<a
href="https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
target="_blank"
rel="noopener noreferrer"
className={styles.linkCard}
>
<div className={`${styles.linkIcon} ${styles.github}`}>
<IconCode size={22} />
</div>
<div className={styles.linkContent}>
<div className={styles.linkTitle}>
{t('system_info.link_webui_repo')}
<IconExternalLink size={14} />
</div>
<div className={styles.linkDesc}>{t('system_info.link_webui_repo_desc')}</div>
</div>
</a>
<a
href="https://help.router-for.me/"
target="_blank"
rel="noopener noreferrer"
className={styles.linkCard}
>
<div className={`${styles.linkIcon} ${styles.docs}`}>
<IconBookOpen size={22} />
</div>
<div className={styles.linkContent}>
<div className={styles.linkTitle}>
{t('system_info.link_docs')}
<IconExternalLink size={14} />
</div>
<div className={styles.linkDesc}>{t('system_info.link_docs_desc')}</div>
</div>
</a>
</div>
</Card>
<Card
title={t('system_info.models_title')}
extra={
<Button
variant="secondary"
size="sm"
onClick={() => fetchModels({ forceRefresh: true })}
loading={modelsLoading}
>
{t('common.refresh')}
</Button>
}
>
<p className={styles.sectionDescription}>{t('system_info.models_desc')}</p>
{modelStatus && (
<div className={`status-badge ${modelStatus.type}`}>{modelStatus.message}</div>
)}
{modelsError && <div className="error-box">{modelsError}</div>}
{modelsLoading ? (
<div className="hint">{t('common.loading')}</div>
) : models.length === 0 ? (
<div className="hint">{t('system_info.models_empty')}</div>
) : (
<div className="item-list">
{groupedModels.map((group) => {
const iconSrc = getIconForCategory(group.id);
return (
<div key={group.id} className="item-row">
<div className="item-meta">
<div className={styles.groupTitle}>
{iconSrc && <img src={iconSrc} alt="" className={styles.groupIcon} />}
<span className="item-title">{group.label}</span>
</div>
<div className="item-subtitle">
{t('system_info.models_count', { count: group.items.length })}
</div>
</div>
<div className={styles.modelTags}>
{group.items.map((model) => (
<span
key={`${model.name}-${model.alias ?? 'default'}`}
className={styles.modelTag}
title={model.description || ''}
>
<span className={styles.modelName}>{model.name}</span>
{model.alias && <span className={styles.modelAlias}>{model.alias}</span>}
</span>
))}
</div>
</div>
);
})}
</div>
)}
</Card>
<Card title={t('system_info.clear_login_title')}>
<p className={styles.sectionDescription}>{t('system_info.clear_login_desc')}</p>
<div className={styles.clearLoginActions}>
<Button variant="danger" onClick={handleClearLoginStorage}>
{t('system_info.clear_login_button')}
</Button>
</div>
</Card>
</div>
<Modal
+23
View File
@@ -442,6 +442,29 @@
}
}
.sidebar-backdrop {
display: none;
border: 0;
padding: 0;
margin: 0;
background: rgb(15 23 42 / 0.18);
opacity: 0;
pointer-events: none;
transition: opacity $transition-fast;
@media (max-width: $breakpoint-mobile) {
display: block;
position: fixed;
inset: var(--header-height) 0 0;
z-index: $z-dropdown - 1;
&.visible {
opacity: 1;
pointer-events: auto;
}
}
}
.sidebar {
width: 240px;
background: var(--bg-primary);
+25
View File
@@ -25,6 +25,28 @@ export interface GeminiCliQuotaPayload {
buckets?: GeminiCliQuotaBucket[];
}
export interface GeminiCliCredits {
creditType?: string;
credit_type?: string;
creditAmount?: string | number;
credit_amount?: string | number;
}
export interface GeminiCliUserTier {
id?: string;
name?: string;
description?: string;
availableCredits?: GeminiCliCredits[];
available_credits?: GeminiCliCredits[];
}
export interface GeminiCliCodeAssistPayload {
currentTier?: GeminiCliUserTier | null;
current_tier?: GeminiCliUserTier | null;
paidTier?: GeminiCliUserTier | null;
paid_tier?: GeminiCliUserTier | null;
}
export interface AntigravityQuotaInfo {
displayName?: string;
quotaInfo?: {
@@ -200,6 +222,9 @@ export interface GeminiCliQuotaBucketState {
export interface GeminiCliQuotaState {
status: 'idle' | 'loading' | 'success' | 'error';
buckets: GeminiCliQuotaBucketState[];
tierLabel?: string | null;
tierId?: string | null;
creditBalance?: number | null;
error?: string;
errorStatus?: number;
}
+3
View File
@@ -117,6 +117,9 @@ export const ANTIGRAVITY_QUOTA_GROUPS: AntigravityQuotaGroupDefinition[] = [
export const GEMINI_CLI_QUOTA_URL =
'https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota';
export const GEMINI_CLI_CODE_ASSIST_URL =
'https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist';
export const GEMINI_CLI_REQUEST_HEADERS = {
Authorization: 'Bearer $TOKEN$',
'Content-Type': 'application/json',
+18 -1
View File
@@ -2,7 +2,7 @@
* Normalization and parsing functions for quota data.
*/
import type { ClaudeUsagePayload, CodexUsagePayload, GeminiCliQuotaPayload, KimiUsagePayload } from '@/types';
import type { ClaudeUsagePayload, CodexUsagePayload, GeminiCliCodeAssistPayload, GeminiCliQuotaPayload, KimiUsagePayload } from '@/types';
import { normalizeAuthIndex } from '@/utils/usage';
const GEMINI_CLI_MODEL_SUFFIX = '_vertex';
@@ -191,6 +191,23 @@ export function parseGeminiCliQuotaPayload(payload: unknown): GeminiCliQuotaPayl
return null;
}
export function parseGeminiCliCodeAssistPayload(payload: unknown): GeminiCliCodeAssistPayload | null {
if (payload === undefined || payload === null) return null;
if (typeof payload === 'string') {
const trimmed = payload.trim();
if (!trimmed) return null;
try {
return JSON.parse(trimmed) as GeminiCliCodeAssistPayload;
} catch {
return null;
}
}
if (typeof payload === 'object') {
return payload as GeminiCliCodeAssistPayload;
}
return null;
}
export function parseKimiUsagePayload(payload: unknown): KimiUsagePayload | null {
if (payload === undefined || payload === null) return null;
if (typeof payload === 'string') {