Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 在用量浮层首行显示当前账号
Dash2527e81515cd
diff --git a/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx b/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsxindex a6387e2250..48274bb110 100644--- a/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx+++ b/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx@@ -449,7 +449,16 @@ export function QuotaHoverCard({const embedded = variant === 'embedded';// 测试可只注入 t;运行时再优先跟随应用当前语言格式化日期。const locale = i18n?.resolvedLanguage ?? i18n?.language;- const { title, planLabel, windows, details = [], notices = [], emptyText, updatedAt } = account;+ const {+ title,+ identity,+ planLabel,+ windows,+ details = [],+ notices = [],+ emptyText,+ updatedAt,+ } = account;// Use observation time for pace so a stale snapshot cannot drift as the card renders.const paceNowMs = typeof updatedAt === 'number' && Number.isFinite(updatedAt) ? updatedAt : null;const staleMinutes =@@ -475,7 +484,9 @@ export function QuotaHoverCard({'flex select-none flex-col pb-2 text-13 leading-5 text-[var(--text-primary)]',variant === 'embedded'? 'w-full min-w-0'- : 'max-h-[min(calc(100vh-16px),var(--radix-popover-content-available-height,100vh))] w-[340px] max-w-[calc(100vw-16px)] overflow-hidden rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]',+ : 'max-h-[min(calc(100vh-16px),var(--radix-popover-content-available-height,100vh))] max-w-[calc(100vw-16px)] overflow-hidden rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]',+ !embedded &&+ (identity ? 'w-max min-w-[min(340px,calc(100vw-16px))]' : 'w-[340px]'),)}style={variant === 'popover' ? { boxShadow: 'var(--shadow-menu)' } : undefined}>@@ -492,11 +503,18 @@ export function QuotaHoverCard({{title && (!embedded || !hideIdentity) ? (<><div className="flex items-center gap-2 px-4 pb-2 pt-3 text-12 text-[var(--text-secondary)]">- <span className="min-w-0 break-words font-medium">{title}</span>+ <div className="flex min-w-0 flex-1 items-center gap-2">+ <span className="shrink-0 font-medium">{title}</span>+ {identity ? (+ <span className="min-w-0 truncate text-[var(--text-primary)]">+ {identity}+ </span>+ ) : null}+ </div>{planLabel ? (<spandata-testid="quota-plan-badge"- className="ml-auto max-w-[65%] break-words rounded-full border border-[var(--border-default)] px-[7px] py-px text-11 font-medium"+ className="ml-auto max-w-[65%] shrink-0 break-words rounded-full border border-[var(--border-default)] px-[7px] py-px text-11 font-medium">{planLabel}</span>diff --git a/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx b/apps/desktop/src/renderer/components/status/TodaySpendChip.tsxindex 3a24b718cb..217e7a7e2a 100644--- a/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx+++ b/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx@@ -1464,6 +1464,15 @@ export function TodaySpendChip({: usesXaiQuotaForm? buildXaiUsageCard(xaiSubscriptionUsage, xaiRateLimit, t, windowLabelNowMs): buildClaudeUsageCard(claudeSubscriptionUsage, t);+ // Identity and quota must come from the same provider on the same execution device.+ const identityProvider = quotaProviders.find(+ (provider) =>+ provider.id ===+ (providerId ?? (usesCodexQuotaForm ? 'openai' : usesXaiQuotaForm ? 'xai' : 'anthropic')),+ );+ account.identity = usesCodexQuotaForm+ ? identityProvider?.openAiAccount?.identity+ : identityProvider?.subscriptionAccount?.identity;}} else {const slots = computeMetricSlots(claudeQuota, creditTotals, sessionSegment, t);@@ -1679,7 +1688,7 @@ export function TodaySpendChip({quotaPopoverOpenSourceRef.current = null;scheduleQuotaPopoverClose();}}- className="w-[340px] max-w-[calc(100vw-16px)] border-0 bg-transparent p-0 shadow-none"+ className="w-auto max-w-[calc(100vw-16px)] border-0 bg-transparent p-0 shadow-none"><QuotaHoverCardaccount={account}diff --git a/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.deviceLink.test.tsx b/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.deviceLink.test.tsxindex 1f383180f6..4465373b69 100644--- a/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.deviceLink.test.tsx+++ b/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.deviceLink.test.tsx@@ -13,10 +13,15 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import type { ClaudeSubscriptionUsageSnapshot } from '../../../../shared/claudeSubscriptionUsage';import type { SessionUsageMoney } from '@/hooks/useSessionUsageMoney';+import type { ProviderView } from '@cindy/model-providers';++type TestProvider = Pick<ProviderView, 'id' | 'openAiAccount' | 'subscriptionAccount'> & {+ auth: { native: string };+};const mocks = vi.hoisted(() => ({- localProviders: [] as Array<{ id: string; auth: { native: string } }>,- deviceProviders: [] as Array<{ id: string; auth: { native: string } }>,+ localProviders: [] as TestProvider[],+ deviceProviders: [] as TestProvider[],remoteProviderIds: [] as Array<string | undefined>,localClaudeSnapshot: null as ClaudeSubscriptionUsageSnapshot | null,remoteClaudeSnapshot: null as ClaudeSubscriptionUsageSnapshot | null,@@ -300,6 +305,20 @@ describe('TodaySpendChip device-link remote sessions', () => {});it('远程 codex 会话按订阅形态渲染被控端账号窗口(组合 payload 选桶)', () => {+ mocks.localProviders = [+ {+ id: 'openai',+ auth: { native: 'codex' },+ openAiAccount: { source: 'oauth', identity: '[email protected]' },+ },+ ];+ mocks.deviceProviders = [+ {+ id: 'openai',+ auth: { native: 'codex' },+ openAiAccount: { source: 'oauth', identity: '[email protected]' },+ },+ ];mocks.remoteCodexPayload = {source: 'codex-app-server',limitId: 'codex',@@ -329,6 +348,10 @@ describe('TodaySpendChip device-link remote sessions', () => {expect(container.textContent).toContain('5h 剩余 88%');expect(container.textContent).toContain('7天 剩余 66%');expect(mocks.remoteCodexDeviceIds).toContain('device-abc');+ fireEvent.mouseEnter(screen.getByRole('button'));+ act(() => vi.advanceTimersByTime(300));+ expect(screen.getByText('[email protected]')).toBeTruthy();+ expect(screen.queryByText('[email protected]')).toBeNull();});it('窗口刚重置时倒计时以窗口长度封顶,不显示「8天」', () => {diff --git a/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.popover.test.tsx b/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.popover.test.tsxindex b1d3fb4040..5d11a82c19 100644--- a/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.popover.test.tsx+++ b/apps/desktop/src/renderer/components/status/__tests__/TodaySpendChip.popover.test.tsx@@ -962,6 +962,7 @@ describe('TodaySpendChip Claude subscription popover', () => {({id,auth: { method: 'oauth', native: 'codex' },+ openAiAccount: { source: 'oauth', identity: `${id}@example.com` },}) as ProviderView,);mocks.accountSnapshots = {@@ -981,6 +982,8 @@ describe('TodaySpendChip Claude subscription popover', () => {);act(() => screen.getByRole('button', { name: '打开 Codex 用量页面' }).focus());expect(within(screen.getByTestId('quota-hover-card')).getByText('Pro')).toBeTruthy();+ expect(screen.getByText('[email protected]')).toBeTruthy();+ expect(screen.queryByText('[email protected]')).toBeNull();view.rerender(<TodaySpendChip@@ -995,6 +998,11 @@ describe('TodaySpendChip Claude subscription popover', () => {);expect(screen.queryByTestId('quota-hover-card')).toBeNull();+ fireEvent.mouseEnter(screen.getByRole('button', { name: '打开 Codex 用量页面' }));+ act(() => vi.advanceTimersByTime(300));+ expect(screen.getByText('[email protected]')).toBeTruthy();+ expect(screen.queryByText('[email protected]')).toBeNull();+view.rerender(<TodaySpendChipvendorKey="codex"@@ -1026,6 +1034,31 @@ describe('TodaySpendChip Claude subscription popover', () => {}});+ it.each([+ ['codex', 'openai', 'gpt-6-astra', 'openAiAccount'],+ ['cc', 'anthropic', 'claude-opus-5', 'subscriptionAccount'],+ ['pi', 'xai', 'xai/grok-4.6', 'subscriptionAccount'],+ ] as const)('默认 %s 订阅显示对应账号身份', (vendorKey, id, modelId, accountField) => {+ mocks.codexAuthInjection = 'oauth-bearer';+ mocks.providers = [+ {+ id,+ name: id,+ source: 'builtin',+ connected: true,+ agents: [],+ auth: { method: 'oauth' },+ routing: {},+ models: {},+ [accountField]: { source: 'oauth', identity: `${id}@example.com` },+ },+ ];+ render(<TodaySpendChip vendorKey={vendorKey} modelId={modelId} />);+ fireEvent.mouseEnter(screen.getByRole('button'));+ act(() => vi.advanceTimersByTime(300));+ expect(screen.getByText(`${id}@example.com`)).toBeTruthy();+ });+it('ChatGPT 动态窗口和套餐渲染为与 Claude 相同的进度条', () => {mocks.codexAuthInjection = 'oauth-bearer';mocks.codexSnapshot = {diff --git a/apps/desktop/src/renderer/components/status/usageCardModel.ts b/apps/desktop/src/renderer/components/status/usageCardModel.tsindex a8530e328a..0cc1de72d9 100644--- a/apps/desktop/src/renderer/components/status/usageCardModel.ts+++ b/apps/desktop/src/renderer/components/status/usageCardModel.ts@@ -34,6 +34,7 @@ export interface UsageCardWindow {export interface UsageCardAccount {title?: string;+ identity?: string | null;planLabel?: string | null;windows: UsageCardWindow[];details?: string[];