Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(usage): compact Codex reset card automation (#6510)

Chris Zhang82cf0119e03d
diff --git a/apps/desktop/scripts/fixtures/codex-reset/codex-reset-fixture.tsx b/apps/desktop/scripts/fixtures/codex-reset/codex-reset-fixture.tsx
new file mode 100644
index 0000000000..5ee66c6ac8
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/codex-reset/codex-reset-fixture.tsx
@@ -0,0 +1,33 @@
+import { useState } from 'react';
+import { mountPage } from '../../ui-page/harness';
+import { CodexResetCredits } from '../../../src/renderer/components/status/CodexResetCredits';
+import { DEFAULT_CODEX_RESET_AUTO_USE } from '../../../src/main/usage/codexResetAutoUse';
+import type { MobileCodexRateLimitsResult } from '@cindy/maker-shared/device-link-contract';
+
+const now = Date.now();
+let snapshot: MobileCodexRateLimitsResult = {
+ providerId: 'openai', account: { email: 'ch***@example.com', accountId: '…123456', planType: 'plus' },
+ rateLimits: { secondary: { usedPercent: 77, windowMinutes: 10080, resetsAt: now / 1000 + 4 * 86400 } },
+ rateLimitsByLimitId: null,
+ rateLimitResetCredits: { availableCount: 2, credits: [1, 2].map(n => ({
+ status: 'available', resetType: 'codexRateLimits', grantedAt: 1, expiresAt: now / 1000 + n * 86400,
+ title: null, description: null, resetOffer: { idempotencyKey: `fixture-${n}`, expiresAt: now / 1000 + n * 86400, validUntil: now + 600_000 },
+ })) },
+ resetOffer: { idempotencyKey: 'fixture-1', expiresAt: now / 1000 + 86400, validUntil: now + 600_000 },
+ autoUse: { accountKey: 'fixture-account', settings: { ...DEFAULT_CODEX_RESET_AUTO_USE }, customized: false, lastUsedAt: null },
+};
+function Fixture({ embedded }: { embedded: boolean }) {
+ const [value, setValue] = useState(snapshot);
+ return <main className="mx-auto w-full max-w-[580px] p-4"><div className="rounded-xl border border-[var(--border-default)] bg-[var(--bg-primary)] p-4">
+ <CodexResetCredits variant={embedded ? 'embedded' : 'dialog'} snapshot={value} busy={false} canReset onReset={() => {}}
+ onChanged={() => setValue({ ...snapshot })} />
+ </div></main>;
+}
+void mountPage({
+ host: { maker: { usage: { setCodexResetAutoUse: async (patch: object | null) => {
+ snapshot = { ...snapshot, autoUse: { ...snapshot.autoUse!, customized: patch !== null,
+ settings: patch === null ? { ...DEFAULT_CODEX_RESET_AUTO_USE } : { ...snapshot.autoUse!.settings, ...patch } } };
+ return snapshot;
+ } } } },
+ render: ctx => <Fixture embedded={ctx.case === 'embedded'} />,
+});
diff --git a/apps/desktop/scripts/fixtures/codex-reset/ui-page.mjs b/apps/desktop/scripts/fixtures/codex-reset/ui-page.mjs
new file mode 100644
index 0000000000..6bd0d8aa99
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/codex-reset/ui-page.mjs
@@ -0,0 +1,26 @@
+import assert from 'node:assert/strict';
+export default {
+ name: 'codex-reset', entry: './codex-reset-fixture.tsx', viewport: { width: 700, height: 650 },
+ real: 'CodexResetCredits, CodexResetAutoUseControl, production controls, five locales and themes',
+ notCovered: 'Fixture settings RPC; actual redemption, account authentication, persistence and native mobile runtime are not exercised here',
+ cases: { default: { about: 'Manual cards with compact automatic rules' }, embedded: { about: 'Collapsed provider card entry' } },
+ async check(page, ui) {
+ await page.getByRole('button', { name: await ui.t('codexResets.autoUse.rules') }).click();
+ await page.getByRole('combobox', { name: await ui.t('codexResets.autoUse.resetDistance') }).waitFor();
+ await ui.capture('rules');
+ await page.getByRole('combobox', { name: await ui.t('codexResets.autoUse.resetDistance') }).click();
+ await page.getByRole('option', { name: await ui.t('codexResets.autoUse.custom'), exact: true }).click();
+ const input = page.getByRole('spinbutton');
+ await input.fill('7');
+ await page.getByRole('button', { name: await ui.t('codexResets.autoUse.apply'), exact: true }).click();
+ assert.equal(await input.inputValue(), '7');
+ await ui.capture('custom-days');
+ await page.keyboard.press('Escape');
+ const toggle = page.getByRole('switch');
+ await toggle.click();
+ await page.waitForFunction(() => document.querySelector('[role=switch]')?.getAttribute('aria-checked') === 'true');
+ await ui.capture('enabled');
+ await toggle.click();
+ await page.waitForFunction(() => document.querySelector('[role=switch]')?.getAttribute('aria-checked') === 'false');
+ },
+};
diff --git a/apps/desktop/src/main/device-link/__tests__/sharedTaskDispatch.test.ts b/apps/desktop/src/main/device-link/__tests__/sharedTaskDispatch.test.ts
index fd9fef220c..8342c3c1ec 100644
--- a/apps/desktop/src/main/device-link/__tests__/sharedTaskDispatch.test.ts
+++ b/apps/desktop/src/main/device-link/__tests__/sharedTaskDispatch.test.ts
@@ -35,7 +35,7 @@ describe('sharedTask dispatch scope', () => {
expect(() => assertSharedTaskInvoke(capture(), payload)).toThrow();
});
it('never inherits the full-device allowlist or wildcard subscriptions', () => {
- for (const channel of ['maker:create-session', 'maker:set-permission-mode', 'device-link:voice:credential-sync', 'local-db:sessions:list', 'maker:remote-resources:list']) {
+ for (const channel of ['maker:usage:codex-reset-auto-use', 'maker:create-session', 'maker:set-permission-mode', 'device-link:voice:credential-sync', 'local-db:sessions:list', 'maker:remote-resources:list']) {
expect(() => assertSharedTaskInvoke(capture(), { channel, args: ['task'] })).toThrow('PERMISSION_DENIED');
}
for (const topics of [['*'], ['sessions'], ['session:other'], ['session:task', 'session:other']]) {
diff --git a/apps/desktop/src/main/goal-host/__tests__/controller.test.ts b/apps/desktop/src/main/goal-host/__tests__/controller.test.ts
index 91813c9aa5..49eaae2eea 100644
--- a/apps/desktop/src/main/goal-host/__tests__/controller.test.ts
+++ b/apps/desktop/src/main/goal-host/__tests__/controller.test.ts
@@ -4426,6 +4426,27 @@ describe('GoalController', () => {
});
// ── usageLimited(账号用量受限)──
+ it('a confirmed reset resumes an existing quota wait once before the natural reset time', async () => {
+ h.setAccountLimit({ limited: true, resetAtMs: 3_601_000 });
+ await startGoal(h);
+ h.session.emitErrorTurn({ sdkError: 'rate_limit', message: 'rate limit reached' });
+ await tick();
+ h.setAccountLimit({ limited: false, resetAtMs: null });
+ await h.controller.resumeRestoredQuota(async () => true);
+ await tick();
+ expect(h.session.sends).toHaveLength(2);
+ await h.controller.resumeRestoredQuota(async () => true);
+ expect(h.session.sends).toHaveLength(2);
+ });
+
+ it('a quota refresh does not shorten an overload wait', async () => {
+ await startGoal(h);
+ h.session.emitErrorTurn({ errorStatus: 529, message: 'overloaded_error' });
+ await tick();
+ await h.controller.resumeRestoredQuota(async () => true);
+ expect(h.session.sends).toHaveLength(1);
+ });
+
it('reactive: a usage-limit turn error → usageLimited with resetAt, no continuation', async () => {
h.setAccountLimit({ limited: true, resetAtMs: 3_601_000 }); // 远未来 → 不在测试窗口自动续
await startGoal(h);
diff --git a/apps/desktop/src/main/goal-host/controller.ts b/apps/desktop/src/main/goal-host/controller.ts
index d4b853673f..fa14408018 100644
--- a/apps/desktop/src/main/goal-host/controller.ts
+++ b/apps/desktop/src/main/goal-host/controller.ts
@@ -2242,6 +2242,17 @@ export class GoalController {
this.deferredManualResumeTimers.set(sessionId, timer);
}
+ /** A confirmed quota refresh can satisfy an existing wait; overload backoff stays unchanged. */
+ async resumeRestoredQuota(matches: (sessionId: string) => Promise<boolean>): Promise<void> {
+ for (const [sessionId, timer] of this.usageResumeTimers) {
+ const state = await this.deps.storage.get(sessionId).catch(() => null);
+ if (state?.status !== 'usageLimited' || state.lastReason === OVERLOAD_LAST_REASON) continue;
+ if (!await matches(sessionId) || this.usageResumeTimers.get(sessionId) !== timer) continue;
+ clearTimeout(timer);
+ await this.autoResumeFromUsageLimit(sessionId);
+ }
+ }
+
/**
* usageLimited 到点自动续跑:resetAtMs 已知则排 timer(已过点 → delay 0 下一 tick 触发);
* null = 不知道何时恢复,不排 timer,留待用户手动 resume。幂等(清旧 timer)。
diff --git a/apps/desktop/src/main/goal-host/index.ts b/apps/desktop/src/main/goal-host/index.ts
index 05401b8e5c..21137144f1 100644
--- a/apps/desktop/src/main/goal-host/index.ts
+++ b/apps/desktop/src/main/goal-host/index.ts
@@ -12,6 +12,7 @@ import type { Maker } from '@cindy/maker-core';
import { createLogger } from '../logger.js';
import {
+ hasRestoredCodexQuota,
acquirePendingAgentSwitchForDirectSend,
isSessionInTurn,
ensureGoalInputReady,
@@ -29,6 +30,7 @@ import {
subscriptionFamilyOf,
} from '../usage/accountUsageLimit.js';
import { readClaudeAccountUsageSnapshot } from '../usage/claudeAccountUsage.js';
+import { onCodexAutoResetRestored } from '../maker-ipc/usage.js';
import { GoalController } from './controller';
import { readTurnUsageResetAt } from './usageLimit.js';
import { restoreSessionForGoal } from './sessionRestore.js';
@@ -45,6 +47,9 @@ export interface StartGoalControllerDeps {
}
let _controller: GoalController | null = null;
+onCodexAutoResetRestored(async providerId => {
+ await _controller?.resumeRestoredQuota(id => hasRestoredCodexQuota(id, providerId));
+});
/** Incremented on every resetGoalController call. attemptStartScheduler uses
* this to bail out if a teardown raced its await. */
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/authStatusUsageHandlers.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/authStatusUsageHandlers.test.ts
index af84b5b483..0410391267 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/authStatusUsageHandlers.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/authStatusUsageHandlers.test.ts
@@ -1463,6 +1463,16 @@ describe('maker usage IPC handlers', () => {
expect(readModelPricing).not.toHaveBeenCalled();
});
+ it('routes account-bound automatic settings and rejects unknown fields', async () => {
+ const harness = new IpcHarness();
+ const setCodexResetAutoUse = vi.fn().mockResolvedValue({ saved: true });
+ registerMakerUsageHandlers(harness, makeUsageDeps({ setCodexResetAutoUse }));
+ await expect(harness.invoke(MAKER_INVOKE.USAGE_CODEX_RESET_AUTO_USE, { minimumDays: 7 }, 'account-key', 'openai')).resolves.toEqual({ saved: true });
+ expect(setCodexResetAutoUse).toHaveBeenCalledWith({ minimumDays: 7 }, 'account-key', 'openai');
+ await expect(harness.invoke(MAKER_INVOKE.USAGE_CODEX_RESET_AUTO_USE, { creditId: 'unexpected' }, 'account-key')).rejects.toMatchObject({ code: 'INVALID_PARAMS' });
+ expect(setCodexResetAutoUse).toHaveBeenCalledOnce();
+ });
+
it('reads Codex reset credits and consumes only a UUID offer key', async () => {
const harness = new IpcHarness();
const snapshot = {
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/usageLimitAutoResume.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/usageLimitAutoResume.test.ts
index 704a000db4..d513431bf3 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/usageLimitAutoResume.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/usageLimitAutoResume.test.ts
@@ -73,6 +73,18 @@ describe('isAccountUsageLimitError', () => {
});
describe('UsageLimitAutoResume', () => {
+ it('resumes only matching armed waits after a reset and respects user cancellation', async () => {
+ const h = harness();
+ h.guard.onTurnError('matching', LIMIT); h.guard.onTurnError('other', LIMIT);
+ await h.flush();
+ await h.guard.resumeRestored(async id => id === 'matching');
+ expect(h.deps.continueSession).toHaveBeenCalledOnce();
+ expect(vi.mocked(h.deps.continueSession).mock.calls[0][0]).toBe('matching');
+ h.current.clear();
+ await h.guard.resumeRestored(async () => true);
+ expect(h.deps.continueSession).toHaveBeenCalledOnce();
+ });
+
it('arms a wait after the reset plus buffer and continues the session when it fires', async () => {
const h = harness();
h.guard.onTurnError('s1', LIMIT);
diff --git a/apps/desktop/src/main/maker-ipc/channels.ts b/apps/desktop/src/main/maker-ipc/channels.ts
index 4ff47ce596..c7d82db306 100644
--- a/apps/desktop/src/main/maker-ipc/channels.ts
+++ b/apps/desktop/src/main/maker-ipc/channels.ts
@@ -343,6 +343,7 @@ export const MAKER_INVOKE = {
USAGE_ACCOUNT: 'maker:usage:account',
// Codex app-server 官方控制面:完整额度/reset 次数读取 + desktop 预签发幂等 offer 消耗。
USAGE_CODEX_RATE_LIMITS: 'maker:usage:codex-rate-limits',
+ USAGE_CODEX_RESET_AUTO_USE: 'maker:usage:codex-reset-auto-use',
USAGE_CODEX_RATE_LIMIT_RESET: 'maker:usage:codex-rate-limit-reset',
// Claude 订阅账号余量 (oauth/usage 端点 + unified headers 双源, cached-first) — 状态栏 chip 用
USAGE_CLAUDE_SUBSCRIPTION: 'maker:usage:claude-subscription',
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 6b28bd5b41..498614b915 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -797,7 +797,7 @@ import {
issuePiPackageMutationGrant,
piPackageMutationNeedsGrant,
} from '../maker-host/pi-package-mutation-grant.js';
-import { readXaiSubscriptionUsageSnapshotForDeviceLink, readClaudeSubscriptionUsageSnapshotForDeviceLink } from './usage.js';
+import { onCodexAutoResetRestored, readXaiSubscriptionUsageSnapshotForDeviceLink, readClaudeSubscriptionUsageSnapshotForDeviceLink } from './usage.js';
import { requireEnum, requireObject, throwIpcError } from '../utils/ipcValidate.js';
import { applyPersistedCindyMakeMarker } from './cindyMakeSessionStart.js';
import { assertCindyMakeEnabled, assertCindyMakeSessionAvailable } from '../cindy-make/featureGate.js';
@@ -1600,6 +1600,20 @@ const usageLimitAutoResume = new UsageLimitAutoResume({
log: (message, fields) => log.info(message, fields),
});
+/** Used by ordinary and goal waits; never substitutes this computer's quota for an SSH/remote agent. */
+export async function hasRestoredCodexQuota(sessionId: string, expectedProvider: string): Promise<boolean> {
+ const row = await getSessionRowSnapshot(sessionId);
+ if (!row || sessionUsesOtherMachineAccount(row)) return false;
+ const kind = row.agentKind ? dbToMakerAgentKind(row.agentKind) : null;
+ if (!kind) return false;
+ const route = resolveSessionRuntimeRoute(sessionId, kind, row);
+ const providerId = route.providerId ?? (kind === 'codex' ? 'openai' : null);
+ if (providerId !== expectedProvider) return false;
+ const limit = await readAccountUsageLimit(kind, route.providerId, route.modelId);
+ return limit != null && !limit.limited;
+}
+onCodexAutoResetRestored(providerId => usageLimitAutoResume.resumeRestored(id => hasRestoredCodexQuota(id, providerId)));
+
// Schedule 不另建重试状态机:真正的恢复仍由 AgentInputCoordinator +
// AutoResumeBookkeeping 独占。这里仅把「这一轮 scheduler run 已被普通自动续跑接管」
// 和「最终仍失败」桥给 runner,让同一个 run 继续等待或正确失败。
diff --git a/apps/desktop/src/main/maker-ipc/usage.ts b/apps/desktop/src/main/maker-ipc/usage.ts
index 3cbe1d72d3..a6acf11e4b 100644
--- a/apps/desktop/src/main/maker-ipc/usage.ts
+++ b/apps/desktop/src/main/maker-ipc/usage.ts
@@ -38,7 +38,7 @@ import {
CodexWebUsageUnauthorizedError,
fetchCodexWebUsageSnapshot,
} from '../usage/codexWebUsage.js';
-import { app } from 'electron';
+import { app, powerMonitor } from 'electron';
import { requireAppCapability } from '../appCapabilities.js';
import { emptyUsageHistoryPayload, readUsageHistory } from '../usage/usageHistory.js';
import { readUsageDeviceRows } from '../usage/usageDeviceRows.js';
@@ -76,6 +76,10 @@ import { peekClaudeCliLoginStatus } from '../maker-host/claude-native-cli-status
import { readClaudeCliPlanUsage } from '../maker-host/claude-native-cli.js';
import { getGrokAccessToken, hasGrokOAuthLogin } from '../maker-host/grok-oauth-login.js';
import { outboundFetch } from '../maker-host/outbound-fetch.js';
+import { CodexResetAutoUse, parseCodexResetAutoUse } from '../usage/codexResetAutoUse.js';
+import { codexResetAutoUseStore, codexResetAccountKey } from '../usage/codexResetAutoUseStore.js';
+import { observeUsageChanges } from '../usageBroadcaster.js';
+import type { CodexResetAutoUseSettings } from '@cindy/maker-shared/device-link-contract';
import { createCodexRateLimitResetService } from '../usage/codexRateLimitReset.js';
import { createElectronIpcHandlerRegistry } from './electronIpcRegistry.js';
@@ -213,13 +217,13 @@ function normalizeCodexUsageProvider(providerId?: string): string | undefined {
}
let codexReadersOwner = '';
const codexUsageReaders = new Map<string, ReturnType<typeof createCodexAccountUsageSnapshotReader>>();
-function readCodexAccountUsageSnapshotWithWebRefresh(requestedProviderId?: string) {
+function readCodexAccountUsageSnapshotWithWebRefresh(requestedProviderId?: string, options?: { fresh?: boolean }) {
const providerId = normalizeCodexUsageProvider(requestedProviderId);
const scope = activeOwnerScopeKey();
if (scope !== codexReadersOwner) { codexUsageReaders.clear(); codexReadersOwner = scope; }
const key = providerId ?? 'openai';
const existing = codexUsageReaders.get(key);
- if (existing) return existing();
+ if (existing) return existing(options);
const reader = createCodexAccountUsageSnapshotReader({
readAccessToken: () => scope === activeOwnerScopeKey() ? desktopCodexAuthAdapter.getAccessToken(providerId) : Promise.reject(new Error('Account scope changed')),
readAccountId: () => desktopCodexAuthAdapter.getAccountId(providerId),
@@ -235,7 +239,7 @@ const reader = createCodexAccountUsageSnapshotReader({
});
codexUsageReaders.set(key, reader);
- return reader();
+ return reader(options);
}
/**
@@ -261,6 +265,12 @@ export async function readCodexRateLimitsForHost(providerId?: string): Promise<M
return codexRateLimitsReader ? codexRateLimitsReader(providerId) : null;
}
+const resetRestoredListeners = new Set<(providerId: string) => Promise<void>>();
+export function onCodexAutoResetRestored(listener: (providerId: string) => Promise<void>): () => void {
+ resetRestoredListeners.add(listener);
+ return () => resetRestoredListeners.delete(listener);
+}
+
export function registerMakerUsageIpc(maker: Maker): void {
log.info('registering maker:usage:* IPC handlers');
@@ -297,31 +307,82 @@ export function registerMakerUsageIpc(maker: Maker): void {
return service;
}
+ async function accountKeyFor(providerId?: string): Promise<string> {
+ const scope = activeOwnerScopeKey();
+ const id = normalizeCodexUsageProvider(providerId);
+ const state = await desktopCodexAuthAdapter.getState({ providerId: id });
+ const accountId = state.authSource === 'oauth' ? await desktopCodexAuthAdapter.getAccountId(id) : null;
+ if (scope !== activeOwnerScopeKey() || isAppSessionBoundaryPending()) throw new Error('Account scope changed');
+ return codexResetAccountKey(state.authSource === 'oauth' ? state.identity ?? null : null, accountId);
+ }
+
// Bind recovery confirmation to the exact owner, marker and OAuth credential observed before
// this account-level RPC. A stale response still returns its usage payload but cannot consume a
// newer recovery state.
const readCodexRateLimits: CodexRateLimitsReader = async (providerId) => {
const scope = activeOwnerScopeKey();
+ const accountKey = await accountKeyFor(providerId);
const service = getResetService(providerId);
const result = providerId && providerId !== 'openai'
? await service.read()
: await desktopCodexAuthAdapter.verifyRecoveryWithAccountRpc(() => service.read());
if (scope !== activeOwnerScopeKey()) throw new Error('PRECONDITION_FAILED: Account scope changed');
- return { ...result, providerId: providerId ?? 'openai' };
+ if (accountKey !== await accountKeyFor(providerId)) throw new Error('ChatGPT account changed');
+ return { ...result, providerId: providerId ?? 'openai', autoUse: codexResetAutoUseStore.read(providerId ?? 'openai', accountKey) };
};
codexRateLimitsReader = readCodexRateLimits;
+ const automatic = new CodexResetAutoUse({
+ scope: activeOwnerScopeKey, now: Date.now, read: readCodexRateLimits,
+ authorized: (providerId, snapshot) => {
+ if (isAppSessionBoundaryPending() || !snapshot.autoUse?.accountKey) return false;
+ const current = codexResetAutoUseStore.read(providerId, snapshot.autoUse.accountKey);
+ return current.settings.enabled && JSON.stringify(current.settings) === JSON.stringify(snapshot.autoUse.settings);
+ },
+ consume: (providerId, key, authorized) => getResetService(providerId).consume(key, authorized),
+ record: (providerId, snapshot, at) => codexResetAutoUseStore.record(providerId, snapshot.autoUse!.accountKey, at),
+ refreshWeb: async (providerId) => { await readCodexAccountUsageSnapshotWithWebRefresh(providerId, { fresh: true }); },
+ restored: async (providerId) => {
+ for (const listener of resetRestoredListeners) await listener(providerId);
+ },
+ warn: () => log.warn('Codex automatic reset check could not complete'),
+ });
+ const checkEnabled = () => {
+ if (isAppSessionBoundaryPending()) return;
+ for (const providerId of codexResetAutoUseStore.providers()) void automatic.check(providerId);
+ };
+ // Checks run on the execution computer even with no renderer or remote phone connected.
+ const timer = setInterval(checkEnabled, 60_000);
+ timer.unref();
+ const unobserve = observeUsageChanges(kind => { if (kind === 'codex') checkEnabled(); });
+ powerMonitor.on('resume', checkEnabled);
+ app.once('will-quit', () => { clearInterval(timer); unobserve(); powerMonitor.removeListener('resume', checkEnabled); });
+ checkEnabled();
+
setSubscriptionAccountUsageBroadcaster(broadcastSubscriptionAccountUsage, clearXaiRateLimitSnapshot);
registerMakerUsageHandlers(createElectronIpcHandlerRegistry(), {
readAgentTodayUsage,
readCodexAccountUsageSnapshot: readCodexAccountUsageSnapshotWithWebRefresh,
readCodexRateLimits,
+ setCodexResetAutoUse: async (patch, expectedAccountKey, providerId = 'openai') => {
+ const scope = activeOwnerScopeKey();
+ const key = await accountKeyFor(providerId);
+ if (!key || key !== expectedAccountKey) throw new Error('PRECONDITION_FAILED: ChatGPT account changed');
+ if (patch !== null) parseCodexResetAutoUse({ ...codexResetAutoUseStore.read(providerId, key).settings, ...patch });
+ await codexResetAutoUseStore.write(providerId, key, patch as Partial<CodexResetAutoUseSettings> | null);
+ if (scope !== activeOwnerScopeKey() || key !== await accountKeyFor(providerId)) throw new Error('PRECONDITION_FAILED: Account changed');
+ checkEnabled();
+ return readCodexRateLimits(providerId);
+ },
consumeCodexRateLimitReset: async (key, providerId) => {
const scope = activeOwnerScopeKey();
+ const accountKey = await accountKeyFor(providerId);
const result = await getResetService(providerId).consume(key);
if (scope !== activeOwnerScopeKey()) throw new Error('PRECONDITION_FAILED: Account scope changed');
+ if (accountKey !== await accountKeyFor(providerId)) throw new Error('PRECONDITION_FAILED: ChatGPT account changed');
return { ...result, providerId: providerId ?? 'openai',
- rateLimits: result.rateLimits ? { ...result.rateLimits, providerId: providerId ?? 'openai' } : null };
+ rateLimits: result.rateLimits ? { ...result.rateLimits, providerId: providerId ?? 'openai',
+ autoUse: codexResetAutoUseStore.read(providerId ?? 'openai', accountKey) } : null };
},
readClaudeSubscriptionUsageSnapshot: readClaudeSubscriptionUsageSnapshotForDeviceLink,
readXaiSubscriptionUsageSnapshot: readXaiSubscriptionUsageSnapshotForDeviceLink,
diff --git a/apps/desktop/src/main/maker-ipc/usageHandlers.ts b/apps/desktop/src/main/maker-ipc/usageHandlers.ts
index 81e9d7df2c..921a54c32f 100644
--- a/apps/desktop/src/main/maker-ipc/usageHandlers.ts
+++ b/apps/desktop/src/main/maker-ipc/usageHandlers.ts
@@ -75,6 +75,7 @@ export interface MakerUsageHandlerDeps {
readClaudeAccountQuotaClear?(): { quotaState: 'unlimited' | 'invalidated' } | null;
readAgentTodayUsage(agentKind: AgentKind): Promise<AgentTodayUsage>;
readCodexAccountUsageSnapshot(providerId?: string): Promise<RateLimitSnapshot | null>;
+ setCodexResetAutoUse?(patch: Record<string, unknown> | null, accountKey: string, providerId?: string): Promise<MobileCodexRateLimitsResult>;
readCodexRateLimits(providerId?: string): Promise<MobileCodexRateLimitsResult>;
consumeCodexRateLimitReset(idempotencyKey: string, providerId?: string): Promise<MobileCodexRateLimitResetResult>;
readClaudeSubscriptionUsageSnapshot(providerId?: string): Promise<ClaudeSubscriptionUsageSnapshot | null>;
@@ -149,6 +150,16 @@ export function registerMakerUsageHandlers(
},
);
+ registry.handle(MAKER_INVOKE.USAGE_CODEX_RESET_AUTO_USE, async (_event, patch: unknown, accountKey: unknown, providerId?: unknown) => {
+ if (patch !== null && (!patch || typeof patch !== 'object' || Array.isArray(patch)
+ || Object.keys(patch).some(key => !['enabled', 'lowQuota', 'minimumDays', 'expiring', 'expiryMinutes'].includes(key)))) {
+ throwIpcError('INVALID_PARAMS', 'Invalid reset settings');
+ }
+ if (!deps.setCodexResetAutoUse) throwIpcError('UNSUPPORTED_CAPABILITY', 'Automatic reset settings unavailable');
+ return deps.setCodexResetAutoUse(patch as Record<string, unknown> | null,
+ requireString(accountKey, 'accountKey'), providerId === undefined ? undefined : requireString(providerId, 'providerId'));
+ });
+
// Claude 订阅账号余量 (5h/周/分模型窗口) — cached-first, 内部按需后台刷新。
registry.handle(MAKER_INVOKE.USAGE_CLAUDE_SUBSCRIPTION, async (event, providerId) => {
if (providerId !== undefined) deps.assertTrustedSender?.(event);
diff --git a/apps/desktop/src/main/maker-ipc/usageLimitAutoResume.ts b/apps/desktop/src/main/maker-ipc/usageLimitAutoResume.ts
index 833f55853d..f1325af659 100644
--- a/apps/desktop/src/main/maker-ipc/usageLimitAutoResume.ts
+++ b/apps/desktop/src/main/maker-ipc/usageLimitAutoResume.ts
@@ -158,6 +158,15 @@ export class UsageLimitAutoResume {
this.deps.log('usage-limit auto-resume fired', { sessionId, outcome, attempt });
}
+ /** A verified quota refresh may satisfy existing waits before their natural reset time. */
+ async resumeRestored(matches: (sessionId: string) => Promise<boolean>): Promise<void> {
+ for (const [sessionId, pending] of this.timers) {
+ if (!await matches(sessionId) || this.timers.get(sessionId) !== pending) continue;
+ this.deps.clearTimer(pending.handle);
+ await this.fire(sessionId, pending.token);
+ }
+ }
+
/** 任务有了实质产出:重新计算连续自动继续次数。 */
noteProgress(sessionId: string): void {
this.consecutive.delete(sessionId);
diff --git a/apps/desktop/src/main/usage/__tests__/accountUsageLimit.test.ts b/apps/desktop/src/main/usage/__tests__/accountUsageLimit.test.ts
index 493b7a3943..7e372c4d15 100644
--- a/apps/desktop/src/main/usage/__tests__/accountUsageLimit.test.ts
+++ b/apps/desktop/src/main/usage/__tests__/accountUsageLimit.test.ts
@@ -30,6 +30,11 @@ import {
subscriptionFamilyOf,
xaiAccountUsageLimit,
} from '../accountUsageLimit';
+import { CodexResetAutoUse, DEFAULT_CODEX_RESET_AUTO_USE } from '../codexResetAutoUse';
+import { createCodexAccountUsageSnapshotReader } from '../codexAccountUsageRefresh';
+import { UsageLimitAutoResume } from '../../maker-ipc/usageLimitAutoResume';
+import type { MobileCodexRateLimitsResult } from '@cindy/maker-shared/device-link-contract';
+import type { CodexAccountUsagePayload } from '../../usageBroadcaster';
// 远程 Agent 的任务撞上限额时,本机订阅快照属于另一个账号(2026-10-09:与 SSH 同一边界)。
describe('sessionUsesOtherMachineAccount', () => {
@@ -73,6 +78,55 @@ beforeEach(() => {
});
describe('codexAccountUsageLimit', () => {
+ it.each(['pi', 'claude-code'])('automatic reset refreshes the 100%% web slot before resuming %s', async agentKind => {
+ // Integration: old WHAM quota must not strand an existing wait after app-server redemption.
+ const now = Date.now();
+ const secondary = { usedPercent: 100, windowMinutes: 10080, resetsAt: now / 1000 + 4 * 86400 };
+ let payload: CodexAccountUsagePayload = { accountId: 'account-id', secondary,
+ webSnapshot: { accountId: 'account-id', secondary } };
+ mocks.codex.mockImplementation(async () => payload);
+ let redeemed = false;
+ const webReader = createCodexAccountUsageSnapshotReader({
+ readAccessToken: async () => 'token', readAccountId: async () => 'account-id',
+ fetchWebUsageSnapshot: async () => ({ accountId: 'account-id', source: 'openai-web', secondary: { ...secondary, usedPercent: redeemed ? 0 : 100 } }),
+ recordSnapshot: async webSnapshot => { payload = { ...payload, webSnapshot }; },
+ clearSnapshot: async () => {}, readCachedSnapshot: async () => payload, now: () => now, onRefreshError: vi.fn(),
+ });
+ await webReader({ fresh: true }); // Prime the throttle with the old 100% web quota.
+ const continueSession = vi.fn(async () => 'resumed' as const);
+ let arm!: () => void;
+ const armed = new Promise<void>(resolve => { arm = resolve; });
+ const waiter = new UsageLimitAutoResume({
+ now: () => now, random: () => 0, isEligible: async () => true,
+ resolveResetAt: async () => secondary.resetsAt * 1000,
+ arm: () => true, isCurrent: () => true, cancel() {}, log() {}, continueSession,
+ setTimer: () => { arm(); return 1; }, clearTimer() {},
+ });
+ waiter.onTurnError('waiting-task', { sdkError: 'rate_limit', message: 'usage limit reached' }, 1);
+ await armed;
+ const read = async (): Promise<MobileCodexRateLimitsResult> => ({
+ account: { email: null, accountId: 'account-id', planType: 'plus' },
+ rateLimits: { secondary: { ...secondary, usedPercent: redeemed ? 0 : 100 } }, rateLimitsByLimitId: null,
+ rateLimitResetCredits: { availableCount: redeemed ? 0 : 1, credits: [] },
+ resetOffer: { idempotencyKey: 'key', validUntil: now + 60_000, expiresAt: secondary.resetsAt },
+ autoUse: { accountKey: 'account', settings: { ...DEFAULT_CODEX_RESET_AUTO_USE, enabled: true }, customized: true, lastUsedAt: null },
+ });
+ const engine = new CodexResetAutoUse({
+ scope: () => 'owner', now: () => now, read, authorized: () => true, record: async () => {}, warn: vi.fn(),
+ consume: async () => {
+ redeemed = true;
+ expect((await readAccountUsageLimit(agentKind, 'openai'))?.limited).toBe(true);
+ return { outcome: 'reset', rateLimits: null };
+ },
+ refreshWeb: async () => { await webReader({ fresh: true }); },
+ restored: async () => waiter.resumeRestored(async () => (await readAccountUsageLimit(agentKind, 'openai'))?.limited === false),
+ });
+ await engine.check('openai');
+ expect(continueSession).toHaveBeenCalledOnce();
+ expect((await readAccountUsageLimit(agentKind, 'openai'))?.limited).toBe(false);
+ waiter.dispose();
+ });
+
const buckets = {
codex: { limitId: 'codex', primary: { usedPercent: 40, resetsAt: RESET_5H } },
spark: {
diff --git a/apps/desktop/src/main/usage/__tests__/codexAccountUsageRefresh.test.ts b/apps/desktop/src/main/usage/__tests__/codexAccountUsageRefresh.test.ts
index 4eb324c1c7..6ea95ed7a5 100644
--- a/apps/desktop/src/main/usage/__tests__/codexAccountUsageRefresh.test.ts
+++ b/apps/desktop/src/main/usage/__tests__/codexAccountUsageRefresh.test.ts
@@ -17,6 +17,25 @@ function makeSnapshot(source: string, accountId: string | null = 'account-id'):
}
describe('createCodexAccountUsageSnapshotReader', () => {
+ it('fresh reads wait out a pre-reset request and bypass the UI throttle', async () => {
+ // Reset recovery needs a post-reset response, not the 100% request already in flight.
+ let cached = { ...makeSnapshot('openai-web'), secondary: { usedPercent: 100 } };
+ const oldRequest = deferred<RateLimitSnapshot | null>();
+ const fresh = { ...cached, secondary: { usedPercent: 0 } };
+ const fetchWebUsageSnapshot = vi.fn().mockReturnValueOnce(oldRequest.promise).mockResolvedValue(fresh);
+ const reader = createCodexAccountUsageSnapshotReader({
+ readAccessToken: async () => 'token', readAccountId: async () => 'account-id',
+ fetchWebUsageSnapshot, recordSnapshot: async value => { cached = value as typeof cached; },
+ clearSnapshot: async () => {}, readCachedSnapshot: async () => cached,
+ now: () => 10_000, onRefreshError: vi.fn(),
+ });
+ await reader();
+ const recovery = reader({ fresh: true });
+ oldRequest.resolve(cached);
+ await expect(recovery).resolves.toBe(fresh);
+ expect(fetchWebUsageSnapshot).toHaveBeenCalledTimes(2);
+ });
+
it('returns cached snapshot before the web refresh settles', async () => {
const cached = makeSnapshot('cached');
const web = makeSnapshot('openai-web');
@@ -160,24 +179,26 @@ describe('createCodexAccountUsageSnapshotReader', () => {
await vi.waitFor(() => expect(recordSnapshot).toHaveBeenCalledWith(makeSnapshot('openai-web')));
});
- it('clears cached usage before returning it when the account id changed', async () => {
- const fetchWebUsageSnapshot = vi.fn().mockResolvedValue(makeSnapshot('openai-web', 'new-account'));
- const clearSnapshot = vi.fn().mockResolvedValue(undefined);
+ it.each([false, true])('clears cached usage when the account id changed (fresh=%s)', async fresh => {
+ let cached: RateLimitSnapshot | null = makeSnapshot('cached', 'old-account');
+ const web = makeSnapshot('openai-web', 'new-account');
+ const fetchWebUsageSnapshot = vi.fn().mockResolvedValue(web);
+ const clearSnapshot = vi.fn(async () => { cached = null; });
const reader = createCodexAccountUsageSnapshotReader(
{
readAccessToken: vi.fn().mockResolvedValue('token'),
readAccountId: vi.fn().mockResolvedValue('new-account'),
fetchWebUsageSnapshot,
- recordSnapshot: vi.fn().mockResolvedValue(undefined),
+ recordSnapshot: vi.fn(async (value: RateLimitSnapshot) => { cached = value; }),
clearSnapshot,
- readCachedSnapshot: vi.fn().mockResolvedValue(makeSnapshot('cached', 'old-account')),
+ readCachedSnapshot: async () => cached,
now: () => 10_000,
onRefreshError: vi.fn(),
},
{ throttleMs: 10_000 },
);
- await expect(reader()).resolves.toBeNull();
+ await expect(reader({ fresh })).resolves.toBe(fresh ? web : null);
expect(clearSnapshot).toHaveBeenCalledTimes(1);
await vi.waitFor(() => expect(fetchWebUsageSnapshot).toHaveBeenCalledTimes(1));
});
diff --git a/apps/desktop/src/main/usage/__tests__/codexRateLimitReset.test.ts b/apps/desktop/src/main/usage/__tests__/codexRateLimitReset.test.ts
index c4eb92676f..e61358c63a 100644
--- a/apps/desktop/src/main/usage/__tests__/codexRateLimitReset.test.ts
+++ b/apps/desktop/src/main/usage/__tests__/codexRateLimitReset.test.ts
@@ -63,6 +63,15 @@ function harness(over: Partial<Parameters<typeof createCodexRateLimitResetServic
}
describe('Codex rate-limit reset control plane', () => {
+ it('rechecks automatic authorization immediately before consuming, while manual use remains available', async () => {
+ const { service, deps } = harness({ readRateLimits: vi.fn().mockResolvedValue(response({ rateLimits: { primary: { usedPercent: 20 } } })) });
+ const offer = (await service.read()).resetOffer!;
+ await expect(service.consume(offer.idempotencyKey, () => false)).rejects.toMatchObject({ reason: 'OFFER_EXPIRED' });
+ expect(deps.consumeResetCredit).not.toHaveBeenCalled();
+ await service.consume(offer.idempotencyKey);
+ expect(deps.consumeResetCredit).toHaveBeenCalledOnce();
+ });
+
it('selects the earliest eligible credit without exposing its id to mobile', async () => {
const { deps, service } = harness();
const snapshot = await service.read();
diff --git a/apps/desktop/src/main/usage/__tests__/codexResetAutoUse.test.ts b/apps/desktop/src/main/usage/__tests__/codexResetAutoUse.test.ts
new file mode 100644
index 0000000000..d1ab940cdd
--- /dev/null
+++ b/apps/desktop/src/main/usage/__tests__/codexResetAutoUse.test.ts
@@ -0,0 +1,93 @@
+import { describe, expect, it, vi } from 'vitest';
+import type { MobileCodexRateLimitsResult } from '@cindy/maker-shared/device-link-contract';
+import { CodexResetAutoUse, DEFAULT_CODEX_RESET_AUTO_USE, type CodexResetAutoUseDeps } from '../codexResetAutoUse';
+
+// Tier unit: observable redemption/resume boundaries. Fake time and RPC, never real credits.
+const NOW = 1_800_000_000_000;
+const DAY = 86_400_000;
+function snapshot(): MobileCodexRateLimitsResult {
+ return { account: { email: null, accountId: null, planType: 'plus' },
+ rateLimits: { secondary: { usedPercent: 99.5, windowMinutes: 10080, resetsAt: (NOW + 4 * DAY) / 1000 } },
+ rateLimitsByLimitId: null,
+ rateLimitResetCredits: { availableCount: 1, credits: [] },
+ resetOffer: { idempotencyKey: 'credit-key', expiresAt: (NOW + 2 * DAY) / 1000, validUntil: NOW + 600_000 },
+ autoUse: { accountKey: 'account', settings: { ...DEFAULT_CODEX_RESET_AUTO_USE, enabled: true }, customized: true, lastUsedAt: null } };
+}
+function harness(value = snapshot()) {
+ let now = NOW;
+ let scope = 'owner';
+ const deps: CodexResetAutoUseDeps = {
+ scope: () => scope, now: () => now,
+ read: vi.fn(async () => value), authorized: vi.fn(() => true),
+ consume: vi.fn(async () => ({ outcome: 'reset' as const, rateLimits: null })),
+ record: vi.fn(async () => {}), refreshWeb: vi.fn(async () => {}), restored: vi.fn(async () => {}), warn: vi.fn(),
+ };
+ const engine = new CodexResetAutoUse(deps);
+ return { value, deps, engine, advance: () => { now += 60_000; }, switchOwner: () => { scope = 'another'; } };
+}
+describe('automatic Codex reset', () => {
+ it.each([
+ ['three days', 3, 99.5, true], ['custom seven days', 7, 99.5, false],
+ ['unlimited', 0, 100, true], ['exactly one percent', 0, 99, false],
+ ])('checks the weekly threshold: %s', async (_name, days, used, expected) => {
+ const h = harness(); h.value.autoUse!.settings.minimumDays = days;
+ h.value.rateLimits.secondary!.usedPercent = used;
+ await h.engine.check('openai');
+ expect(h.deps.consume).toHaveBeenCalledTimes(expected ? 1 : 0);
+ });
+ it.each([30, 60])('uses the selected expiry lead of %i minutes independently', async minutes => {
+ const h = harness(); h.value.autoUse!.settings.expiryMinutes = minutes;
+ h.value.autoUse!.settings.lowQuota = false;
+ h.value.rateLimits.secondary!.usedPercent = 20;
+ h.value.resetOffer!.expiresAt = (NOW + 48 * 60_000) / 1000;
+ await h.engine.check('openai');
+ expect(h.deps.consume).toHaveBeenCalledTimes(minutes === 60 ? 1 : 0);
+ });
+ // Regression: the top-level snapshot may be the last model-specific bucket received.
+ it.each([[100, 20, false], [20, 100, true]])('uses generic quota when model quota is %i and generic is %i', async (model, generic, expected) => {
+ const h = harness();
+ h.value.rateLimits.secondary!.usedPercent = model;
+ h.value.rateLimitsByLimitId = {
+ spark: { ...h.value.rateLimits, limitId: 'spark', limitName: 'GPT-5.3-Codex-Spark' },
+ codex: { secondary: { ...h.value.rateLimits.secondary!, usedPercent: generic } },
+ };
+ await h.engine.check('openai');
+ expect(h.deps.consume).toHaveBeenCalledTimes(expected ? 1 : 0);
+ });
+ it('skips full quotas, unknown windows and a separate model bucket', async () => {
+ for (const used of [0, NaN]) {
+ const h = harness(); h.value.rateLimits.secondary!.usedPercent = used;
+ h.value.resetOffer!.expiresAt = (NOW + 60_000) / 1000;
+ await h.engine.check('openai'); expect(h.deps.consume).not.toHaveBeenCalled();
+ }
+ const h = harness(); h.value.rateLimits.secondary!.usedPercent = 0;
+ h.value.rateLimitsByLimitId = { other: { secondary: { usedPercent: 100, windowMinutes: 10080, resetsAt: (NOW + 4 * DAY) / 1000 } } };
+ await h.engine.check('openai'); expect(h.deps.consume).not.toHaveBeenCalled();
+ });
+ it('coalesces concurrent checks and resumes after a confirmed refresh', async () => {
+ const h = harness(); await Promise.all([h.engine.check('openai'), h.engine.check('openai')]);
+ expect(h.deps.consume).toHaveBeenCalledExactlyOnceWith('openai', 'credit-key', expect.any(Function));
+ expect(h.deps.record).toHaveBeenCalledOnce(); expect(h.deps.restored).toHaveBeenCalledOnce();
+ await h.engine.check('openai'); expect(h.deps.consume).toHaveBeenCalledOnce();
+ });
+ it('does not redeem after settings are disabled or the owner changes during a read', async () => {
+ const h = harness(); vi.mocked(h.deps.authorized).mockReturnValue(false);
+ await h.engine.check('openai'); expect(h.deps.consume).not.toHaveBeenCalled();
+ const switched = harness(); vi.mocked(switched.deps.read).mockImplementation(async () => { switched.switchOwner(); return switched.value; });
+ await switched.engine.check('openai'); expect(switched.deps.consume).not.toHaveBeenCalled();
+ });
+ it('retries only its own ambiguous attempt with the same key, never a manual attempt', async () => {
+ const h = harness(); vi.mocked(h.deps.consume).mockRejectedValueOnce(new Error('connection lost'));
+ await h.engine.check('openai'); h.value.resetOffer!.retryOnly = true; h.advance();
+ await h.engine.check('openai');
+ expect(h.deps.consume).toHaveBeenCalledTimes(2);
+ expect(vi.mocked(h.deps.consume).mock.calls.map(call => call[1])).toEqual(['credit-key', 'credit-key']);
+ const manual = harness(); manual.value.resetOffer!.retryOnly = true;
+ await manual.engine.check('openai'); expect(manual.deps.consume).not.toHaveBeenCalled();
+ });
+ it('does not turn a failed receipt write into another redemption', async () => {
+ const h = harness(); vi.mocked(h.deps.record).mockRejectedValue(new Error('disk full'));
+ await h.engine.check('openai');
+ expect(h.deps.consume).toHaveBeenCalledOnce(); expect(h.deps.restored).toHaveBeenCalledOnce();
+ });
+});
diff --git a/apps/desktop/src/main/usage/__tests__/codexResetAutoUseStore.test.ts b/apps/desktop/src/main/usage/__tests__/codexResetAutoUseStore.test.ts
new file mode 100644
index 0000000000..753560191c
--- /dev/null
+++ b/apps/desktop/src/main/usage/__tests__/codexResetAutoUseStore.test.ts
@@ -0,0 +1,87 @@
+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+vi.mock('../../appSessionState.js', () => ({ activeOwnerScopeKey: () => 'owner', ownerScopedUserDataPath: () => '/unused' }));
+vi.mock('../../maker-host/logger-adapter.js', () => ({ desktopMakerLogger: { child: () => ({ info() {}, warn() {} }) } }));
+import { CodexResetAutoUse } from '../codexResetAutoUse';
+import { createCodexRateLimitResetService } from '../codexRateLimitReset';
+import { UsageLimitAutoResume } from '../../maker-ipc/usageLimitAutoResume';
+import { createCodexResetAutoUseStore, codexResetAccountKey } from '../codexResetAutoUseStore';
+
+const dirs: string[] = [];
+afterEach(() => { for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); });
+describe('reset preferences persistence', () => {
+ it('runs persisted preferences through the reset service and resumes a waiting task exactly once', async () => {
+ const dir = mkdtempSync(path.join(tmpdir(), 'cindy-reset-integration-')); dirs.push(dir);
+ const now = 1_800_000_000_000;
+ const store = createCodexResetAutoUseStore(() => path.join(dir, 'settings.json'), () => 'owner');
+ const account = codexResetAccountKey('[email protected]', 'workspace');
+ await store.write('openai', account, { enabled: true });
+ let redeemed = false;
+ const consumeRpc = vi.fn(async () => { redeemed = true; return { outcome: 'reset' as const }; });
+ const service = createCodexRateLimitResetService({
+ now: () => now, createIdempotencyKey: () => '00000000-0000-4000-8000-000000000001',
+ readAccountIdentity: async () => ({ email: '[email protected]', accountId: 'workspace' }),
+ readRateLimits: async () => ({
+ rateLimits: { secondary: { usedPercent: redeemed ? 0 : 100, windowDurationMins: 10080, resetsAt: now / 1000 + 4 * 86400 } },
+ rateLimitsByLimitId: null,
+ rateLimitResetCredits: { availableCount: redeemed ? 0 : 1, credits: redeemed ? [] : [{ id: 'one-credit', status: 'available', resetType: 'codexRateLimits', grantedAt: 1, expiresAt: now / 1000 + 86400, title: null, description: null }] },
+ }),
+ consumeResetCredit: consumeRpc, recordRateLimitSnapshot: async () => {},
+ });
+ const continueSession = vi.fn(async () => 'resumed' as const);
+ let arm!: () => void;
+ const armed = new Promise<void>(resolve => { arm = resolve; });
+ const waiter = new UsageLimitAutoResume({
+ now: () => now, random: () => 0, isEligible: async () => true, resolveResetAt: async () => now + 4 * 86_400_000,
+ arm: () => true, isCurrent: () => true, cancel() {}, log() {}, continueSession,
+ setTimer: () => { arm(); return 1; }, clearTimer() {},
+ });
+ waiter.onTurnError('waiting-task', { sdkError: 'rate_limit', message: 'usage limit reached' }, 1);
+ await armed;
+ const engine = new CodexResetAutoUse({
+ now: () => now, scope: () => 'owner',
+ read: async () => ({ ...await service.read(), autoUse: store.read('openai', account) }),
+ authorized: () => store.read('openai', account).settings.enabled,
+ consume: (_provider, key, authorized) => service.consume(key, authorized),
+ record: (_provider, _snapshot, at) => store.record('openai', account, at),
+ refreshWeb: async () => {},
+ restored: async () => { await waiter.resumeRestored(async () => redeemed); }, warn: vi.fn(),
+ });
+ await Promise.all([engine.check('openai'), engine.check('openai')]);
+ expect(consumeRpc).toHaveBeenCalledExactlyOnceWith({ creditId: 'one-credit', idempotencyKey: '00000000-0000-4000-8000-000000000001' });
+ expect(continueSession).toHaveBeenCalledOnce();
+ expect(store.read('openai', account).lastUsedAt).toBe(now);
+ expect((await service.read()).rateLimitResetCredits?.availableCount).toBe(0);
+ waiter.dispose();
+ });
+
+ it('reopens explicit overrides, binds them to one account and restores defaults', async () => {
+ const dir = mkdtempSync(path.join(tmpdir(), 'cindy-reset-settings-')); dirs.push(dir);
+ const filename = path.join(dir, 'settings.json');
+ const open = () => createCodexResetAutoUseStore(() => filename, () => 'owner');
+ const key = codexResetAccountKey('[email protected]', 'workspace');
+ const store = open();
+ await store.write('openai', key, { enabled: true, minimumDays: 7 });
+ expect(JSON.parse(readFileSync(filename, 'utf8')).openai.overrides).toEqual({ enabled: true, minimumDays: 7 });
+ expect(open().read('openai', key).settings).toMatchObject({ enabled: true, minimumDays: 7 });
+ expect(open().read('openai', codexResetAccountKey('[email protected]', 'other')).settings.enabled).toBe(false);
+ await store.record('openai', key, 123);
+ expect(open().read('openai', key).lastUsedAt).toBe(123);
+ await store.write('openai', key, null);
+ expect(open().read('openai', key)).toMatchObject({ customized: false, settings: { enabled: false, minimumDays: 3 } });
+ expect(readFileSync(filename, 'utf8')).not.toContain('example@');
+ });
+ it('preserves sibling updates and rejects invalid settings instead of granting auto-use', async () => {
+ const dir = mkdtempSync(path.join(tmpdir(), 'cindy-reset-settings-')); dirs.push(dir);
+ const store = createCodexResetAutoUseStore(() => path.join(dir, 'settings.json'), () => 'owner');
+ const key = codexResetAccountKey('[email protected]', 'workspace');
+ await Promise.all([store.write('openai', key, { enabled: true }), store.write('other', key, { minimumDays: 7 })]);
+ expect(store.read('openai', key).settings.enabled).toBe(true);
+ expect(store.read('other', key).settings.minimumDays).toBe(7);
+ await expect(store.write('openai', key, { minimumDays: -1 })).rejects.toThrow();
+ await expect(store.write('openai', key, { lowQuota: false, expiring: false })).rejects.toThrow();
+ expect(store.read('openai', key).settings.lowQuota).toBe(true);
+ });
+});
diff --git a/apps/desktop/src/main/usage/codexAccountUsageRefresh.ts b/apps/desktop/src/main/usage/codexAccountUsageRefresh.ts
index d649e34e63..ad0aa2d3a2 100644
--- a/apps/desktop/src/main/usage/codexAccountUsageRefresh.ts
+++ b/apps/desktop/src/main/usage/codexAccountUsageRefresh.ts
@@ -40,7 +40,7 @@ function refreshKey(accessToken: string, accountId: string | null): string {
export function createCodexAccountUsageSnapshotReader(
deps: CodexWebUsageRefreshDeps,
options: CodexWebUsageRefreshOptions = {},
-): () => Promise<RateLimitSnapshot | null> {
+): (options?: { fresh?: boolean }) => Promise<RateLimitSnapshot | null> {
const throttleMs = options.throttleMs ?? DEFAULT_THROTTLE_MS;
const refreshInFlightByKey = new Map<string, RefreshInFlight>();
const lastRefreshAtByKey = new Map<string, number>();
@@ -69,14 +69,14 @@ export function createCodexAccountUsageSnapshotReader(
}
}
- function triggerRefresh(accessToken: string, accountId: string | null): Promise<void> {
+ function triggerRefresh(accessToken: string, accountId: string | null, force = false): Promise<void> {
const key = refreshKey(accessToken, accountId);
const existing = refreshInFlightByKey.get(key);
if (existing) return existing.promise;
const now = deps.now();
const lastRefreshAt = lastRefreshAtByKey.get(key) ?? 0;
- if (lastRefreshAt > 0 && now - lastRefreshAt < throttleMs) {
+ if (!force && lastRefreshAt > 0 && now - lastRefreshAt < throttleMs) {
return Promise.resolve();
}
@@ -115,7 +115,7 @@ export function createCodexAccountUsageSnapshotReader(
return refreshInFlight.promise;
}
- return async () => {
+ return async (readOptions) => {
let accessToken: string | null;
try {
accessToken = await deps.readAccessToken();
@@ -137,15 +137,21 @@ export function createCodexAccountUsageSnapshotReader(
const cachedSnapshot = await deps.readCachedSnapshot();
const cachedAccountId = cachedSnapshot?.accountId ?? null;
- if (cachedSnapshot && cachedAccountId !== accountId) {
+ if (cachedSnapshot && (cachedAccountId !== accountId
+ || (accountId === null && lastUnknownAccountSnapshotAccessToken !== accessToken))) {
await clearCachedSnapshot();
- void triggerRefresh(accessToken, accountId);
- return null;
+ if (!readOptions?.fresh) {
+ void triggerRefresh(accessToken, accountId);
+ return null;
+ }
}
- if (cachedSnapshot && accountId === null && lastUnknownAccountSnapshotAccessToken !== accessToken) {
- await clearCachedSnapshot();
- void triggerRefresh(accessToken, accountId);
- return null;
+ if (readOptions?.fresh) {
+ // A request already in flight may have observed quota before the reset. Let it settle,
+ // then fetch again without the UI read throttle; credential checks still guard publication.
+ await refreshInFlightByKey.get(refreshKey(accessToken, accountId))?.promise;
+ if (!await isRefreshStillCurrent(accessToken, accountId)) return null;
+ await triggerRefresh(accessToken, accountId, true);
+ return await isRefreshStillCurrent(accessToken, accountId) ? deps.readCachedSnapshot() : null;
}
void triggerRefresh(accessToken, accountId);
return cachedSnapshot;
diff --git a/apps/desktop/src/main/usage/codexRateLimitReset.ts b/apps/desktop/src/main/usage/codexRateLimitReset.ts
index cdc83bad7d..a545035a13 100644
--- a/apps/desktop/src/main/usage/codexRateLimitReset.ts
+++ b/apps/desktop/src/main/usage/codexRateLimitReset.ts
@@ -40,7 +40,7 @@ export interface CodexRateLimitResetServiceDeps {
/** Read/consume façade exposed to IPC; one instance owns the bounded offer registry. */
export interface CodexRateLimitResetService {
read(): Promise<MobileCodexRateLimitsResult>;
- consume(idempotencyKey: string): Promise<MobileCodexRateLimitResetResult>;
+ consume(idempotencyKey: string, stillAuthorized?: () => boolean): Promise<MobileCodexRateLimitResetResult>;
}
export type CodexRateLimitResetRejection = 'OFFER_EXPIRED' | 'ACCOUNT_CHANGED' | 'RESET_IN_PROGRESS';
@@ -344,7 +344,7 @@ export function createCodexRateLimitResetService(
};
};
- const consume = async (idempotencyKey: string): Promise<MobileCodexRateLimitResetResult> => {
+ const consume = async (idempotencyKey: string, stillAuthorized?: () => boolean): Promise<MobileCodexRateLimitResetResult> => {
pruneOffers();
const offer = offers.get(idempotencyKey);
if (!offer) {
@@ -383,6 +383,9 @@ export function createCodexRateLimitResetService(
}
// From this point a transport failure is ambiguous: the backend may have consumed the
// credit. Every later read/retry must keep this exact key + credit selection.
+ if (stillAuthorized && !stillAuthorized()) {
+ throw new CodexRateLimitResetRejectedError('OFFER_EXPIRED', 'Automatic reset settings changed');
+ }
offer.attempted = true;
const response = await deps.consumeResetCredit({
idempotencyKey,
diff --git a/apps/desktop/src/main/usage/codexResetAutoUse.ts b/apps/desktop/src/main/usage/codexResetAutoUse.ts
new file mode 100644
index 0000000000..1273977084
--- /dev/null
+++ b/apps/desktop/src/main/usage/codexResetAutoUse.ts
@@ -0,0 +1,101 @@
+import type {
+ CodexResetAutoUseSettings, MobileCodexRateLimitsResult, MobileCodexRateLimitResetResult,
+} from '@cindy/maker-shared/device-link-contract';
+import { matchCodexBucketForModel } from '@cindy/maker-shared/codex-usage-buckets';
+
+export const DEFAULT_CODEX_RESET_AUTO_USE: Readonly<CodexResetAutoUseSettings> = {
+ enabled: false, lowQuota: true, minimumDays: 3, expiring: true, expiryMinutes: 60,
+};
+
+export function parseCodexResetAutoUse(raw: unknown): CodexResetAutoUseSettings {
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new Error('Invalid reset settings');
+ const v = raw as Record<string, unknown>;
+ if (typeof v.enabled !== 'boolean' || typeof v.lowQuota !== 'boolean' || typeof v.expiring !== 'boolean'
+ || typeof v.minimumDays !== 'number' || !Number.isInteger(v.minimumDays) || v.minimumDays < 0 || v.minimumDays > 365
+ || typeof v.expiryMinutes !== 'number' || ![30, 60, 360, 1440].includes(v.expiryMinutes)
+ || (v.enabled && !v.lowQuota && !v.expiring)) throw new Error('Invalid reset settings');
+ return { enabled: v.enabled, lowQuota: v.lowQuota, minimumDays: v.minimumDays,
+ expiring: v.expiring, expiryMinutes: v.expiryMinutes };
+}
+
+/** Only the ordinary Codex weekly bucket triggers low quota; a different model's bucket cannot spend a card. */
+export function shouldAutoUseCodexReset(snapshot: MobileCodexRateLimitsResult, now: number): boolean {
+ const settings = snapshot.autoUse?.settings;
+ if (!settings?.enabled || !snapshot.resetOffer || snapshot.resetOffer.retryOnly
+ || snapshot.resetOffer.validUntil <= now || !snapshot.rateLimitResetCredits?.availableCount) return false;
+ const windows = [snapshot.rateLimits, ...Object.values(snapshot.rateLimitsByLimitId ?? {})]
+ .flatMap(bucket => [bucket.primary, bucket.secondary])
+ .filter(w => w && Number.isFinite(w.usedPercent) && Number.isFinite(w.resetsAt)
+ && w.resetsAt! * 1000 > now);
+ if (!windows.some(w => w!.usedPercent > 0)) return false;
+ const expiry = snapshot.resetOffer.expiresAt;
+ if (settings.expiring && typeof expiry === 'number' && expiry * 1000 > now
+ && expiry * 1000 - now <= settings.expiryMinutes * 60_000) return true;
+ const buckets = snapshot.rateLimitsByLimitId;
+ const generic = buckets && Object.keys(buckets).length
+ ? matchCodexBucketForModel(buckets, null, now) : snapshot.rateLimits;
+ return settings.lowQuota && !!generic && !generic.rateLimitReachedType?.includes('credits_depleted') && [generic.primary, generic.secondary].some(w =>
+ w && Number.isFinite(w.usedPercent) && w.usedPercent > 99
+ && (w.windowMinutes ?? 0) >= 7 * 24 * 60 && typeof w.resetsAt === 'number'
+ && w.resetsAt * 1000 > now && w.resetsAt * 1000 - now >= settings.minimumDays * 86_400_000);
+}
+
+export interface CodexResetAutoUseDeps {
+ scope(): string;
+ read(providerId: string): Promise<MobileCodexRateLimitsResult>;
+ /** A synchronous final check immediately before the upstream request. */
+ authorized(providerId: string, snapshot: MobileCodexRateLimitsResult): boolean;
+ consume(providerId: string, key: string, authorized: () => boolean): Promise<MobileCodexRateLimitResetResult>;
+ record(providerId: string, snapshot: MobileCodexRateLimitsResult, at: number): Promise<void>;
+ /** Wait for the web quota used by Pi/Claude Code before checking existing waits. */
+ refreshWeb(providerId: string): Promise<void>;
+ restored(providerId: string, snapshot: MobileCodexRateLimitsResult): Promise<void>;
+ now(): number;
+ warn(): void;
+}
+
+/** One in-flight check per owner/account. Consumption itself shares the manual reset service's lock and key. */
+export class CodexResetAutoUse {
+ private readonly pending = new Map<string, Promise<void>>();
+ private readonly attempts = new Map<string, string>();
+ private readonly cooldown = new Map<string, number>();
+ constructor(private readonly deps: CodexResetAutoUseDeps) {}
+
+ check(providerId: string): Promise<void> {
+ const scope = this.deps.scope();
+ const key = `${scope}:${providerId}`;
+ const existing = this.pending.get(key);
+ if (existing) return existing;
+ // Reading also broadcasts usage. Deferring the read installs the in-flight guard before that callback.
+ const run = Promise.resolve().then(async () => {
+ if ((this.cooldown.get(key) ?? 0) > this.deps.now()) return;
+ this.cooldown.set(key, this.deps.now() + 30_000);
+ const snapshot = await this.deps.read(providerId);
+ const authorized = () => scope === this.deps.scope() && this.deps.authorized(providerId, snapshot);
+ if (!authorized()) return;
+ const retryOwnAttempt = snapshot.resetOffer?.retryOnly
+ && this.attempts.get(key) === snapshot.resetOffer.idempotencyKey;
+ if (retryOwnAttempt || shouldAutoUseCodexReset(snapshot, this.deps.now())) {
+ this.attempts.set(key, snapshot.resetOffer!.idempotencyKey);
+ const result = await this.deps.consume(providerId, snapshot.resetOffer!.idempotencyKey, authorized);
+ this.attempts.delete(key);
+ if (scope !== this.deps.scope()) return;
+ if (result.outcome === 'reset' || result.outcome === 'alreadyRedeemed') {
+ // Persistence failure cannot turn a completed redemption into a second attempt.
+ try { await this.deps.record(providerId, snapshot, this.deps.now()); } catch { this.deps.warn(); }
+ const refreshed = await this.deps.read(providerId);
+ if (authorized() && refreshed.autoUse?.accountKey === snapshot.autoUse?.accountKey) {
+ await this.deps.refreshWeb(providerId);
+ if (authorized()) await this.deps.restored(providerId, refreshed);
+ }
+ }
+ } else {
+ // Another device/manual action may have restored quota. Resume only existing eligible waits.
+ await this.deps.refreshWeb(providerId);
+ if (authorized()) await this.deps.restored(providerId, snapshot);
+ }
+ }).catch(() => this.deps.warn()).finally(() => this.pending.delete(key));
+ this.pending.set(key, run);
+ return run;
+ }
+}
diff --git a/apps/desktop/src/main/usage/codexResetAutoUseStore.ts b/apps/desktop/src/main/usage/codexResetAutoUseStore.ts
new file mode 100644
index 0000000000..3ccd39e3af
--- /dev/null
+++ b/apps/desktop/src/main/usage/codexResetAutoUseStore.ts
@@ -0,0 +1,72 @@
+import { createHash } from 'node:crypto';
+import path from 'node:path';
+import type { CodexResetAutoUseSettings, CodexResetAutoUseState } from '@cindy/maker-shared/device-link-contract';
+import { activeOwnerScopeKey, ownerScopedUserDataPath } from '../appSessionState.js';
+import { createOverrideSettingsFile } from '../maker-host/override-settings-file.js';
+import { desktopMakerLogger } from '../maker-host/logger-adapter.js';
+import { DEFAULT_CODEX_RESET_AUTO_USE, parseCodexResetAutoUse } from './codexResetAutoUse.js';
+
+type AccountEntry = { accountKey: string; overrides: Partial<CodexResetAutoUseSettings>; lastUsedAt: number | null };
+type SettingsFile = Record<string, AccountEntry>;
+const log = desktopMakerLogger.child('codex-reset-auto-use');
+
+export function codexResetAccountKey(email: string | null, accountId: string | null): string {
+ return email && accountId ? createHash('sha256').update(JSON.stringify([email, accountId])).digest('hex') : '';
+}
+function normalize(raw: unknown): SettingsFile {
+ const result: SettingsFile = {};
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return result;
+ for (const [provider, entry] of Object.entries(raw).slice(0, 128)) {
+ if (!entry || typeof entry !== 'object' || !/^[a-f0-9]{64}$/.test(entry.accountKey ?? '')) continue;
+ try {
+ parseCodexResetAutoUse({ ...DEFAULT_CODEX_RESET_AUTO_USE, ...entry.overrides });
+ const overrides: Partial<CodexResetAutoUseSettings> = {};
+ for (const key of Object.keys(DEFAULT_CODEX_RESET_AUTO_USE) as (keyof CodexResetAutoUseSettings)[]) {
+ if (Object.hasOwn(entry.overrides ?? {}, key)) Object.assign(overrides, { [key]: entry.overrides[key] });
+ }
+ result[provider] = { accountKey: entry.accountKey, overrides,
+ lastUsedAt: typeof entry.lastUsedAt === 'number' && Number.isFinite(entry.lastUsedAt) ? entry.lastUsedAt : null };
+ } catch { /* Invalid settings never authorize a redemption. */ }
+ }
+ return result;
+}
+
+/** Owner-scoped local overrides; no credentials or full account identifiers are persisted. */
+export function createCodexResetAutoUseStore(filePath: () => string, scopeKey = activeOwnerScopeKey) {
+ const file = createOverrideSettingsFile<SettingsFile>({
+ filePath, defaults: {}, normalize, log, label: 'codex-reset-auto-use', scopeKey,
+ maxBytes: 128 * 1024, preserveUnreadableFile: true, logLoadedValue: false, logReadErrorDetails: false,
+ });
+ const entries = () => { file.invalidateIfChanged(); return file.read(); };
+ const read = (provider: string, accountKey: string): CodexResetAutoUseState => {
+ const record = entries()[provider];
+ const entry = record?.accountKey === accountKey ? record : undefined;
+ return { accountKey, settings: { ...DEFAULT_CODEX_RESET_AUTO_USE, ...entry?.overrides },
+ customized: Boolean(entry && Object.keys(entry.overrides).length), lastUsedAt: entry?.lastUsedAt ?? null };
+ };
+ return {
+ read,
+ providers: () => Object.entries(entries()).filter(([, e]) => e.overrides.enabled === true).map(([id]) => id),
+ async write(provider: string, accountKey: string, settings: Partial<CodexResetAutoUseSettings> | null) {
+ if (!/^[a-f0-9]{64}$/.test(accountKey)) throw new Error('ChatGPT account unavailable');
+ if (settings !== null) parseCodexResetAutoUse({ ...read(provider, accountKey).settings, ...settings });
+ await file.updateAtomic(current => {
+ const previous = current.value[provider];
+ const overrides = settings === null ? {} : { ...(previous?.accountKey === accountKey ? previous.overrides : {}), ...settings };
+ parseCodexResetAutoUse({ ...DEFAULT_CODEX_RESET_AUTO_USE, ...overrides });
+ return { [provider]: { accountKey, overrides,
+ lastUsedAt: previous?.accountKey === accountKey ? previous.lastUsedAt : null } };
+ });
+ return read(provider, accountKey);
+ },
+ async record(provider: string, accountKey: string, at: number) {
+ await file.updateAtomic(current => {
+ const entry = current.value[provider];
+ return entry?.accountKey === accountKey ? { [provider]: { ...entry, lastUsedAt: at } } : {};
+ });
+ },
+ };
+}
+
+export const codexResetAutoUseStore = createCodexResetAutoUseStore(() =>
+ path.join(ownerScopedUserDataPath(), 'codex-reset-auto-use.json'));
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index 1a125295f3..179f40eaf5 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -7948,6 +7948,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
getCodexRateLimits: (providerId?: string): Promise<MobileCodexRateLimitsResult> =>
ipcRenderer.invoke('maker:usage:codex-rate-limits', providerId),
/** Consume one desktop-issued reset offer; Main validates its account and expiry. */
+ setCodexResetAutoUse: (patch: Partial<import('@cindy/maker-shared/device-link-contract').CodexResetAutoUseSettings> | null, accountKey: string, providerId?: string): Promise<MobileCodexRateLimitsResult> =>
+ ipcRenderer.invoke('maker:usage:codex-reset-auto-use', patch, accountKey, providerId),
consumeCodexRateLimitReset: (idempotencyKey: string, providerId?: string): Promise<MobileCodexRateLimitResetResult> =>
ipcRenderer.invoke('maker:usage:codex-rate-limit-reset', idempotencyKey, providerId),
/** Claude 订阅账号余量 (5h/周/分模型窗口, cached-first, main 侧按需后台刷新)。 */
diff --git a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx
index 9d826d7a3f..cb50d11e34 100644
--- a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx
@@ -901,7 +901,7 @@ function DetailHeader({
}
>
{resetEnabled ? (
- <CodexResetCredits key={provider?.id} variant="embedded" snapshot={resetSnapshot} busy={manualReset.busy} canReset={manualReset.canReset} canRetry={manualReset.canRetry} onReset={(credit) => void manualReset.reset(credit)} />
+ <CodexResetCredits providerId={provider?.id} onChanged={refreshResets} key={provider?.id} variant="embedded" snapshot={resetSnapshot} busy={manualReset.busy} canReset={manualReset.canReset} canRetry={manualReset.canRetry} onReset={(credit) => void manualReset.reset(credit)} />
) : null}
</QuotaHoverCard>
</div>
diff --git a/apps/desktop/src/renderer/components/status/CodexResetAutoUseControl.tsx b/apps/desktop/src/renderer/components/status/CodexResetAutoUseControl.tsx
new file mode 100644
index 0000000000..88e1209e44
--- /dev/null
+++ b/apps/desktop/src/renderer/components/status/CodexResetAutoUseControl.tsx
@@ -0,0 +1,91 @@
+import { useEffect, useId, useRef, useState } from 'react';
+import { ChevronDown } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+import type { CodexResetAutoUseSettings, CodexResetAutoUseState } from '@cindy/maker-shared/device-link-contract';
+import { Button } from '@/components/ui/button';
+import { Switch } from '@/components/ui/switch';
+import { Select } from '@/components/ui/select';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+
+/** The closed state occupies one small row; rules stay in a popover. */
+export function CodexResetAutoUseControl({ state, providerId, onChanged }: {
+ state: CodexResetAutoUseState; providerId: string; onChanged: () => void;
+}) {
+ const { t } = useTranslation();
+ const labelId = useId();
+ const [current, setCurrent] = useState(state);
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState(false);
+ const [custom, setCustom] = useState(![0, 1, 2, 3].includes(state.settings.minimumDays));
+ const [days, setDays] = useState(String(state.settings.minimumDays));
+ const saving = useRef(false);
+ const account = useRef(`${providerId}:${state.accountKey}`);
+ account.current = `${providerId}:${state.accountKey}`;
+ useEffect(() => { setCurrent(state); setDays(String(state.settings.minimumDays)); }, [state]);
+ const s = current.settings;
+ const label = (key: string, values?: Record<string, unknown>) => t(`codexResets.autoUse.${key}`, values);
+ const save = async (patch: Partial<CodexResetAutoUseSettings> | null) => {
+ if (saving.current) return;
+ saving.current = true;
+ const key = state.accountKey;
+ setBusy(true); setError(false);
+ try {
+ const next = await window.electronAPI.maker.usage.setCodexResetAutoUse(patch, key, providerId);
+ if (account.current === `${providerId}:${key}` && next.autoUse?.accountKey === key) {
+ setCurrent(next.autoUse); setDays(String(next.autoUse.settings.minimumDays));
+ onChanged();
+ }
+ } catch { if (account.current === `${providerId}:${key}`) setError(true); }
+ finally { saving.current = false; setBusy(false); }
+ };
+ const condition = (field: 'lowQuota' | 'expiring', checked: boolean) => {
+ // Clearing the final condition also turns automatic use off, without silently enabling another rule.
+ void save({ [field]: checked, ...(!checked && !s[field === 'lowQuota' ? 'expiring' : 'lowQuota'] ? { enabled: false } : {}) });
+ };
+ return (
+ <Popover>
+ <div className="flex shrink-0 items-center gap-2">
+ <label id={labelId} className="text-12 text-[var(--text-secondary)]">{label('label')}</label>
+ <Switch aria-labelledby={labelId} checked={s.enabled} disabled={busy || !state.accountKey}
+ onCheckedChange={enabled => void save({ enabled, ...(enabled && !s.lowQuota && !s.expiring ? { lowQuota: true } : {}) })} />
+ <PopoverTrigger asChild>
+ <Button variant="secondary" tone="quiet" size="md" compact aria-label={label('rules')}><ChevronDown className="h-3.5 w-3.5" /></Button>
+ </PopoverTrigger>
+ </div>
+ <PopoverContent align="end" className="w-80 max-w-[calc(100vw-32px)] space-y-4 text-13">
+ <div className="text-14 font-medium text-[var(--text-primary)]">{label('rules')}</div>
+ <div className="space-y-2">
+ <label className="flex items-start gap-2 text-[var(--text-primary)]">
+ <input type="checkbox" className="mt-0.5 accent-[var(--text-primary)]" checked={s.lowQuota} disabled={busy} onChange={e => condition('lowQuota', e.target.checked)} />
+ {label('lowQuota')}
+ </label>
+ <div className="ml-5 space-y-2">
+ <div className="text-12 text-[var(--text-secondary)]">{label('resetDistance')}</div>
+ <Select label={label('resetDistance')} value={custom || ![0, 1, 2, 3].includes(s.minimumDays) ? 'custom' : String(s.minimumDays)}
+ disabled={busy || !s.lowQuota} className="min-h-8 text-13"
+ options={[3, 2, 1, 0].map(n => ({ value: String(n), label: n ? label('days', { count: n }) : label('unlimited') })).concat({ value: 'custom', label: label('custom') })}
+ onValueChange={value => { setCustom(value === 'custom'); if (value !== 'custom') void save({ minimumDays: Number(value) }); }} />
+ {(custom || ![0, 1, 2, 3].includes(s.minimumDays)) && <form className="flex items-center gap-2" onSubmit={e => { e.preventDefault(); if (/^\d+$/.test(days) && Number(days) <= 365) void save({ minimumDays: Number(days) }); }}>
+ <input aria-label={label('customDays')} type="number" min="0" max="365" step="1" required value={days} disabled={busy || !s.lowQuota}
+ onChange={e => setDays(e.target.value)} className="h-8 w-20 rounded-lg border border-[var(--border-default)] bg-[var(--bg-secondary)] px-2 text-13 text-[var(--text-primary)]" />
+ <span className="text-12 text-[var(--text-secondary)]">{label('dayUnit')}</span>
+ <Button type="submit" size="sm" compact variant="secondary" disabled={busy || !s.lowQuota}>{label('apply')}</Button>
+ </form>}
+ </div>
+ </div>
+ <div className="space-y-2">
+ <label className="flex items-start gap-2 text-[var(--text-primary)]">
+ <input type="checkbox" className="mt-0.5 accent-[var(--text-primary)]" checked={s.expiring} disabled={busy} onChange={e => condition('expiring', e.target.checked)} />
+ {label('expiring')}
+ </label>
+ <div className="ml-5"><Select label={label('leadTime')} value={String(s.expiryMinutes)} disabled={busy || !s.expiring} className="min-h-8 text-13"
+ options={[30, 60, 360, 1440].map(n => ({ value: String(n), label: label(n === 30 ? 'minutes' : 'hours', { count: n === 30 ? 30 : n / 60 }) }))}
+ onValueChange={value => void save({ expiryMinutes: Number(value) })} /></div>
+ </div>
+ <div className="border-t border-[var(--border-default)] pt-3 text-12 leading-relaxed text-[var(--text-secondary)]">{label('hint')}</div>
+ {current.customized && <Button size="sm" compact variant="secondary" tone="quiet" disabled={busy} onClick={() => { setCustom(false); void save(null); }}>{label('restore')}</Button>}
+ </PopoverContent>
+ {error && <span role="alert" className="text-12 text-[var(--text-secondary)]">{label('failed')}</span>}
+ </Popover>
+ );
+}
diff --git a/apps/desktop/src/renderer/components/status/CodexResetCredits.tsx b/apps/desktop/src/renderer/components/status/CodexResetCredits.tsx
index 15172e7988..304591ca12 100644
--- a/apps/desktop/src/renderer/components/status/CodexResetCredits.tsx
+++ b/apps/desktop/src/renderer/components/status/CodexResetCredits.tsx
@@ -4,11 +4,14 @@ import { useTranslation } from 'react-i18next';
import type { MobileCodexRateLimitResetCredit, MobileCodexRateLimitsResult } from '@cindy/maker-shared/device-link-contract';
import { Button } from '@/components/ui/button';
import { Collapse } from '@/components/ui/collapse';
+import { CodexResetAutoUseControl } from './CodexResetAutoUseControl';
import { formatQuotaResetAt } from './usageCardModel';
/** Shared reset list for provider settings and the usage dialog. */
-export function CodexResetCredits({ snapshot, busy, canReset, canRetry = false, onReset, variant }: {
+export function CodexResetCredits({ snapshot, busy, canReset, canRetry = false, onReset, variant, providerId = 'openai', onChanged }: {
variant: 'embedded' | 'dialog';
+ providerId?: string;
+ onChanged?: () => void;
snapshot: MobileCodexRateLimitsResult | null;
busy: boolean;
canReset: boolean;
@@ -22,7 +25,7 @@ export function CodexResetCredits({ snapshot, busy, canReset, canRetry = false,
const panelId = useId();
const credits = snapshot?.rateLimitResetCredits;
const retryOnly = snapshot?.resetOffer?.retryOnly === true;
- if (!credits && !retryOnly) return null;
+ if (!credits && !retryOnly && !snapshot?.autoUse) return null;
const now = Date.now();
const available = (credits?.credits ?? [])
.filter(credit => credit.status === 'available' && credit.resetType === 'codexRateLimits'
@@ -62,7 +65,7 @@ export function CodexResetCredits({ snapshot, busy, canReset, canRetry = false,
</div>
) : null}
{!canReset && !retryOnly && availableCount > 0 ? (
- <p className="mt-2 text-12 text-[var(--text-secondary)]">{t('codexResets.availableAtLimit')}</p>
+ <p className="mt-2 text-12 text-[var(--text-secondary)]">{t('codexResets.detailsUnavailable')}</p>
) : null}
{available.length > 0 && availableCount > 0 ? (
<ul className="mt-2 divide-y divide-[var(--border-default)]">
@@ -101,15 +104,18 @@ export function CodexResetCredits({ snapshot, busy, canReset, canRetry = false,
<section className={embedded ? 'mx-4 mt-2 border-t border-[var(--border-default)] pt-3' : undefined} aria-label={t('codexResets.title')}>
{embedded ? (
<>
+ <div className="flex flex-wrap items-center justify-between gap-2">
<button type="button" id={triggerId} aria-expanded={expanded} aria-controls={panelId}
onClick={() => setExpanded(value => !value)}
- className="flex min-h-7 w-full items-center justify-between gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus-ring)]">
+ className="flex min-h-8 items-center justify-between gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus-ring)]">
<span className="flex items-center gap-1.5 text-14 font-medium text-[var(--text-primary)]">
<ChevronRight className={`h-3.5 w-3.5 shrink-0 ${expanded ? 'rotate-90' : ''}`} aria-hidden="true" />
{t('codexResets.title')}
</span>
{count}
</button>
+ {snapshot?.autoUse && onChanged && <CodexResetAutoUseControl key={`${providerId}:${snapshot.autoUse.accountKey}`} state={snapshot.autoUse} providerId={providerId} onChanged={onChanged} />}
+ </div>
<Collapse open={expanded} id={panelId} role="region" aria-labelledby={triggerId}>
{content}
</Collapse>
@@ -120,6 +126,7 @@ export function CodexResetCredits({ snapshot, busy, canReset, canRetry = false,
<h3 className="text-18 font-medium text-[var(--confirm-title)]">{t('codexResets.title')}</h3>
{count}
</div>
+ {snapshot?.autoUse && onChanged && <div className="mt-3 flex justify-end"><CodexResetAutoUseControl key={`${providerId}:${snapshot.autoUse.accountKey}`} state={snapshot.autoUse} providerId={providerId} onChanged={onChanged} /></div>}
{content}
</>
)}
diff --git a/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx b/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx
index 3b8ed9b001..95dd83ddb2 100644
--- a/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx
+++ b/apps/desktop/src/renderer/components/status/TodaySpendChip.tsx
@@ -1744,7 +1744,7 @@ export function TodaySpendChip({
>
<Dialog.Title className="sr-only">{t('codexResets.title')}</Dialog.Title>
<div className="max-h-[60vh] overflow-y-auto">
- <CodexResetCredits variant="dialog" snapshot={codexRateLimits} busy={manualReset.busy}
+ <CodexResetCredits providerId={providerId ?? 'openai'} onChanged={refreshCodexRateLimits} variant="dialog" snapshot={codexRateLimits} busy={manualReset.busy}
canReset={manualReset.canReset} canRetry={manualReset.canRetry} onReset={(credit) => {
setResetListOpen(false);
const context = quotaPopoverContextRef.current.identity;
diff --git a/apps/desktop/src/renderer/components/status/__tests__/CodexResetCredits.test.tsx b/apps/desktop/src/renderer/components/status/__tests__/CodexResetCredits.test.tsx
index 66adc94cdc..fb1b5ae7de 100644
--- a/apps/desktop/src/renderer/components/status/__tests__/CodexResetCredits.test.tsx
+++ b/apps/desktop/src/renderer/components/status/__tests__/CodexResetCredits.test.tsx
@@ -23,6 +23,23 @@ beforeEach(() => {
afterEach(cleanup);
describe('available reset list', () => {
+ it('persists the automatic toggle only after success and shows save errors', async () => {
+ const state = { accountKey: 'account', settings: { enabled: false, lowQuota: true, minimumDays: 3, expiring: true, expiryMinutes: 60 }, customized: false, lastUsedAt: null };
+ mocks.snapshot!.autoUse = state;
+ const save = vi.fn().mockRejectedValueOnce(new Error('offline')).mockResolvedValue({ ...mocks.snapshot, autoUse: { ...state, settings: { ...state.settings, enabled: true } } });
+ Object.assign(window, { electronAPI: { maker: { usage: { setCodexResetAutoUse: save } } } });
+ const refresh = vi.fn();
+ render(<CodexResetCredits variant="dialog" snapshot={mocks.snapshot} busy={false} canReset onReset={mocks.reset} onChanged={refresh} providerId="openai-b" />);
+ fireEvent.click(screen.getByRole('switch'));
+ await screen.findByRole('alert');
+ expect(screen.getByRole('switch').getAttribute('aria-checked')).toBe('false');
+ expect(refresh).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('switch'));
+ await waitFor(() => expect(screen.getByRole('switch').getAttribute('aria-checked')).toBe('true'));
+ expect(save).toHaveBeenLastCalledWith({ enabled: true }, 'account', 'openai-b');
+ expect(refresh).toHaveBeenCalledOnce();
+ });
+
it('sorts rows by expiry and passes the clicked row to its own action', () => {
render(<CodexResetCredits variant="dialog" snapshot={mocks.snapshot} busy={mocks.busy} canReset={mocks.canReset} onReset={mocks.reset} />);
expect(screen.getAllByRole('listitem').map(row => row.textContent)).toEqual([
diff --git a/apps/desktop/src/renderer/hooks/__tests__/useCodexRateLimitReset.test.ts b/apps/desktop/src/renderer/hooks/__tests__/useCodexRateLimitReset.test.ts
index a7444dd132..5cc0b7c04a 100644
--- a/apps/desktop/src/renderer/hooks/__tests__/useCodexRateLimitReset.test.ts
+++ b/apps/desktop/src/renderer/hooks/__tests__/useCodexRateLimitReset.test.ts
@@ -57,7 +57,7 @@ describe('manual Codex resets', () => {
const { value, selected } = withRows();
const hook = renderHook(() => useCodexRateLimitReset(value, refresh));
await act(async () => hook.result.current.reset(selected));
- expect(mocks.confirm).toHaveBeenCalledWith(expect.objectContaining({ description: 'codexResets.confirmSelectedBody' }));
+ expect(mocks.confirm).toHaveBeenCalledWith(expect.objectContaining({ description: expect.stringContaining('codexResets.confirmSelectedBody\n\n') }));
expect(consume).toHaveBeenCalledExactlyOnceWith(selected.resetOffer.idempotencyKey, 'openai');
});
@@ -81,7 +81,7 @@ describe('manual Codex resets', () => {
expect(consume).not.toHaveBeenCalled();
});
- it('does not consume if the quota recovers while confirmation is open', async () => {
+ it('honors manual confirmation even when quota has recovered', async () => {
let accept!: (value: boolean) => void;
mocks.confirm.mockImplementation(() => new Promise<boolean>(resolve => { accept = resolve; }));
const value = snapshot();
@@ -90,7 +90,7 @@ describe('manual Codex resets', () => {
act(() => { request = hook.result.current.reset(); });
hook.rerender({ current: { ...value, rateLimits: { primary: { usedPercent: 0 } } } });
await act(async () => { accept(true); await request; });
- expect(consume).not.toHaveBeenCalled();
+ expect(consume).toHaveBeenCalledOnce();
});
it('does not consume when the confirmation is cancelled', async () => {
@@ -139,7 +139,7 @@ describe('manual Codex resets', () => {
expect(hook.result.current.canReset).toBe(false);
expect(hook.result.current.canRetry).toBe(true);
await act(async () => hook.result.current.reset());
- expect(mocks.confirm).toHaveBeenCalledWith(expect.objectContaining({ description: 'codexResets.confirmRetryBody' }));
+ expect(mocks.confirm).toHaveBeenCalledWith(expect.objectContaining({ description: expect.stringContaining('codexResets.confirmRetryBody\n\n') }));
expect(consume).toHaveBeenCalledExactlyOnceWith(value.resetOffer!.idempotencyKey, 'openai');
});
@@ -214,13 +214,13 @@ describe('manual Codex resets', () => {
expect(mocks.info).toHaveBeenCalledWith(`codexResets.${outcome}`);
});
- it('does not offer resets before the limit or when credits are depleted', async () => {
+ it('allows manual reset independently of the quota threshold', async () => {
const value = snapshot();
value.rateLimits = { primary: { usedPercent: 99 }, rateLimitReachedType: 'credits_depleted' };
const hook = renderHook(() => useCodexRateLimitReset(value, refresh));
- expect(hook.result.current.canReset).toBe(false);
+ expect(hook.result.current.canReset).toBe(true);
await act(async () => hook.result.current.reset());
- expect(mocks.confirm).not.toHaveBeenCalled();
- expect(consume).not.toHaveBeenCalled();
+ expect(mocks.confirm).toHaveBeenCalledOnce();
+ expect(consume).toHaveBeenCalledOnce();
});
});
diff --git a/apps/desktop/src/renderer/hooks/useCodexRateLimitReset.ts b/apps/desktop/src/renderer/hooks/useCodexRateLimitReset.ts
index 061ffc9d3c..b4d4b55936 100644
--- a/apps/desktop/src/renderer/hooks/useCodexRateLimitReset.ts
+++ b/apps/desktop/src/renderer/hooks/useCodexRateLimitReset.ts
@@ -5,7 +5,7 @@ import { summarizeCodexRateLimitReset } from '@cindy/maker-shared/session-contro
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';
import { toast } from '@/lib/toast';
-import { formatQuotaResetAt } from '@/components/status/usageCardModel';
+import { formatQuotaResetAt, quotaWindowLabel } from '@/components/status/usageCardModel';
import { extractIpcError } from '@/utils/ipcError';
/** Manual reset only. Main owns credit selection, account binding and retry idempotency. */
@@ -46,14 +46,21 @@ export function useCodexRateLimitReset(
try {
const account = [snapshot.account.email, snapshot.account.accountId]
.filter(Boolean).join(' · ') || t('codexResets.currentAccount');
+ const quota = [snapshot.rateLimits.primary, snapshot.rateLimits.secondary]
+ .filter(window => window && Number.isFinite(window.usedPercent)
+ && (window.resetsAt == null || window.resetsAt * 1000 > Date.now()))
+ .map(window => `${quotaWindowLabel(window!.windowMinutes, t)} · ${t('quotaCard.remainingPercent', {
+ percent: Number(Math.max(0, Math.min(100, 100 - window!.usedPercent)).toFixed(1)),
+ })}`).join('\n');
+ const description = retry ? t('codexResets.confirmRetryBody', { account }) : credit ? t('codexResets.confirmSelectedBody', {
+ account, title: credit.title || t('codexResets.fullReset'),
+ expiry: formatQuotaResetAt(credit.expiresAt, Date.now(), i18n?.resolvedLanguage ?? i18n?.language)
+ || t('codexResets.expiryUnknown'),
+ }) : t('codexResets.confirmBody', { account });
const accepted = await confirm({
presentation: 'standard',
title: t(retry ? 'codexResets.confirmRetryTitle' : 'codexResets.confirmTitle'),
- description: retry ? t('codexResets.confirmRetryBody', { account }) : credit ? t('codexResets.confirmSelectedBody', {
- account, title: credit.title || t('codexResets.fullReset'),
- expiry: formatQuotaResetAt(credit.expiresAt, Date.now(), i18n?.resolvedLanguage ?? i18n?.language)
- || t('codexResets.expiryUnknown'),
- }) : t('codexResets.confirmBody', { account }),
+ description: quota ? `${description}\n\n${quota}` : description,
confirmText: t(retry ? 'codexResets.retryReset' : 'codexResets.consumeOnce'),
});
const currentSnapshot = current.current.snapshot;
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 3a7f0e3841..f8ed7ee54f 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -16810,7 +16810,26 @@
"nothingToReset": "No usage limit needs a reset",
"offerExpired": "The account or reset offer changed. Refresh usage before resetting.",
"resetFailed": "Could not confirm the reset result. Refresh usage to check whether limits were restored.",
- "limitAction": "Use Reset · {{count}} Available"
+ "limitAction": "Use Reset · {{count}} Available",
+ "autoUse": {
+ "label": "Auto use",
+ "rules": "Auto-use rules",
+ "lowQuota": "Use when weekly quota falls below 1%",
+ "resetDistance": "Time until quota resets",
+ "days": "At least {{count}} days",
+ "unlimited": "Any time",
+ "custom": "Custom…",
+ "customDays": "Custom days",
+ "dayUnit": "days or more",
+ "apply": "Apply",
+ "expiring": "Use before a card expires",
+ "leadTime": "Use how early",
+ "minutes": "{{count}} minutes before expiry",
+ "hours": "{{count}} hours before expiry",
+ "hint": "Either rule uses the earliest-expiring card. Skip when all quotas are full. Runs on this computer while Cindy is running.",
+ "failed": "Could not save. Try again.",
+ "restore": "Restore defaults"
+ }
},
"mcpApps": {
"sharedTaskReadOnly": "Only the session owner can interact with this card.",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 79025e0dc7..2bbcef9451 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -16751,7 +16751,26 @@
"nothingToReset": "リセットが必要な利用上限はありません",
"offerExpired": "アカウントまたはリセットの状態が変わりました。使用量を更新してからリセットを使用してください。",
"resetFailed": "リセットの結果を確認できませんでした。使用量を更新して、利用枠が回復したか確認してください。",
- "limitAction": "リセットを使用 · 残り {{count}} 回"
+ "limitAction": "リセットを使用 · 残り {{count}} 回",
+ "autoUse": {
+ "label": "自動使用",
+ "rules": "自動使用ルール",
+ "lowQuota": "週間配分の残りが 1% 未満で使用",
+ "resetDistance": "配分リセットまでの残り時間",
+ "days": "{{count}} 日以上",
+ "unlimited": "制限なし",
+ "custom": "カスタム…",
+ "customDays": "日数を指定",
+ "dayUnit": "日以上",
+ "apply": "適用",
+ "expiring": "カードの有効期限前に使用",
+ "leadTime": "使用するタイミング",
+ "minutes": "有効期限の {{count}} 分前",
+ "hours": "有効期限の {{count}} 時間前",
+ "hint": "いずれかの条件で、期限が近いカードから使用します。全配分が満量の場合は使用しません。このパソコンで Cindy の起動中に実行します。",
+ "failed": "保存できませんでした。再試行してください。",
+ "restore": "既定に戻す"
+ }
},
"mcpApps": {
"sharedTaskReadOnly": "このカードを操作できるのはセッションのオーナーだけです。",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 8d7523c51c..07c396f021 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -16751,7 +16751,26 @@
"nothingToReset": "초기화가 필요한 사용 한도가 없습니다",
"offerExpired": "계정 또는 초기화 상태가 변경되었습니다. 사용량을 새로고침한 후 초기화를 사용하세요.",
"resetFailed": "초기화 결과를 확인할 수 없습니다. 사용량을 새로고침하여 한도가 복구되었는지 확인하세요.",
- "limitAction": "초기화 사용 · {{count}}회 남음"
+ "limitAction": "초기화 사용 · {{count}}회 남음",
+ "autoUse": {
+ "label": "자동 사용",
+ "rules": "자동 사용 규칙",
+ "lowQuota": "주간 잔여량이 1% 미만일 때 사용",
+ "resetDistance": "할당량 초기화까지 남은 시간",
+ "days": "{{count}}일 이상",
+ "unlimited": "제한 없음",
+ "custom": "직접 입력…",
+ "customDays": "일수 입력",
+ "dayUnit": "일 이상",
+ "apply": "적용",
+ "expiring": "카드 만료 전에 사용",
+ "leadTime": "사용 시점",
+ "minutes": "만료 {{count}}분 전",
+ "hours": "만료 {{count}}시간 전",
+ "hint": "어느 조건이든 충족하면 만료가 가장 가까운 카드를 사용합니다. 모든 할당량이 가득 차면 건너뜁니다. 이 컴퓨터에서 Cindy가 실행 중이어야 합니다.",
+ "failed": "저장하지 못했습니다. 다시 시도하세요.",
+ "restore": "기본값 복원"
+ }
},
"mcpApps": {
"sharedTaskReadOnly": "이 카드는 세션 소유자만 조작할 수 있습니다.",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 51a8d7f5b8..58d65f4de5 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -16751,7 +16751,26 @@
"nothingToReset": "当前没有需要重置的用量上限",
"offerExpired": "账号或重置状态已变化,请刷新用量后再使用重置",
"resetFailed": "无法确认重置结果,请刷新用量查看额度是否已恢复",
- "limitAction": "使用重置 · 剩余 {{count}} 次"
+ "limitAction": "使用重置 · 剩余 {{count}} 次",
+ "autoUse": {
+ "label": "自动使用",
+ "rules": "自动使用规则",
+ "lowQuota": "每周剩余低于 1% 时自动用",
+ "resetDistance": "距离配额重置还剩",
+ "days": "{{count}} 天以上",
+ "unlimited": "不限",
+ "custom": "自定义…",
+ "customDays": "自定义天数",
+ "dayUnit": "天以上",
+ "apply": "应用",
+ "expiring": "临近卡到期时自动用",
+ "leadTime": "提前多久使用",
+ "minutes": "到期前 {{count}} 分钟",
+ "hours": "到期前 {{count}} 小时",
+ "hint": "任一条件满足时,优先用最早到期的卡。配额全满时跳过。由这台电脑执行,需保持 Cindy 运行。",
+ "failed": "保存失败,请重试。",
+ "restore": "恢复默认"
+ }
},
"mcpApps": {
"sharedTaskReadOnly": "此卡片仅任务主人可操作。",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 0958d5717c..068c38a554 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -16751,7 +16751,26 @@
"nothingToReset": "目前沒有需要重置的用量上限",
"offerExpired": "帳號或重置狀態已變更,請重新整理用量後再使用重置",
"resetFailed": "無法確認重置結果,請重新整理用量查看額度是否已恢復",
- "limitAction": "使用重置 · 剩餘 {{count}} 次"
+ "limitAction": "使用重置 · 剩餘 {{count}} 次",
+ "autoUse": {
+ "label": "自動使用",
+ "rules": "自動使用規則",
+ "lowQuota": "每週剩餘低於 1% 時自動用",
+ "resetDistance": "距離配額重設還剩",
+ "days": "{{count}} 天以上",
+ "unlimited": "不限",
+ "custom": "自訂…",
+ "customDays": "自訂天數",
+ "dayUnit": "天以上",
+ "apply": "套用",
+ "expiring": "臨近卡到期時自動用",
+ "leadTime": "提前多久使用",
+ "minutes": "到期前 {{count}} 分鐘",
+ "hours": "到期前 {{count}} 小時",
+ "hint": "任一條件滿足時,優先用最早到期的卡。配額全滿時略過。由這台電腦執行,需保持 Cindy 執行。",
+ "failed": "儲存失敗,請重試。",
+ "restore": "恢復預設"
+ }
},
"mcpApps": {
"sharedTaskReadOnly": "此卡片僅任務擁有者可操作。",
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 328854c896..12360ea642 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -7012,6 +7012,7 @@ interface ElectronAPI {
getCodexRateLimits: (
providerId?: string,
) => Promise<import('@cindy/maker-shared/device-link-contract').MobileCodexRateLimitsResult>;
+ setCodexResetAutoUse: (patch: Partial<import('@cindy/maker-shared/device-link-contract').CodexResetAutoUseSettings> | null, accountKey: string, providerId?: string) => Promise<import('@cindy/maker-shared/device-link-contract').MobileCodexRateLimitsResult>;
consumeCodexRateLimitReset: (
idempotencyKey: string,
providerId?: string,
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index a49c8b18c3..91e1dc9d48 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -9651,6 +9651,14 @@ function SessionScreenContent() {
onLoadExtraDirPath={(path) => void loadExtraDirBrowsePath(path)}
onRefreshAccountUsage={() => void refreshAccountUsage()}
onResetCodexRateLimits={() => void resetCodexRateLimits()}
+ onSaveCodexResetAutoUse={async patch => {
+ const key = codexRateLimits?.autoUse?.accountKey;
+ if (!key || !maker || !localCodexRateLimitControl) throw new Error('Account unavailable');
+ const result = await maker.setCodexResetAutoUse(patch, key, accountProviderId);
+ if (accountControlScopeRef.current !== accountControlScope) return;
+ setCodexRateLimits(result);
+ setAccountUsage(result.rateLimits);
+ }}
onOpenWorkspace={() => {
if (!currentSession.workingDir) return;
setSettingsOpen(false);
diff --git a/apps/mobile/src/__tests__/mobileMakerTransport.test.ts b/apps/mobile/src/__tests__/mobileMakerTransport.test.ts
index 290a66c4b2..f0544c72f1 100644
--- a/apps/mobile/src/__tests__/mobileMakerTransport.test.ts
+++ b/apps/mobile/src/__tests__/mobileMakerTransport.test.ts
@@ -39,6 +39,15 @@ function harness() {
}
describe("mobile maker transport", () => {
+ it('writes reset preferences to the execution device and rejects a different account response', async () => {
+ const invoke = vi.fn(async () => ({ providerId: 'openai-b', autoUse: { accountKey: 'bound-account' } }));
+ const maker = createMobileMakerTransport({ deviceId: 'execution-device', invoke: invoke as RemoteInvoke });
+ await maker.setCodexResetAutoUse({ minimumDays: 7 }, 'bound-account', 'openai-b');
+ expect(invoke).toHaveBeenCalledWith('execution-device', 'maker:usage:codex-reset-auto-use', [{ minimumDays: 7 }, 'bound-account', 'openai-b']);
+ invoke.mockResolvedValueOnce({ providerId: 'openai-b', autoUse: { accountKey: 'changed-account' } });
+ await expect(maker.setCodexResetAutoUse({ enabled: true }, 'bound-account', 'openai-b')).rejects.toThrow('Account scope changed');
+ });
+
// Unit: a visible text snapshot is already cached by the reader. Its refresh
// must await the Host, while retaining the existing confirmed-version cache.
it('revalidates text without returning stale bytes or invalidating a confirmed version', async () => {
@@ -442,6 +451,7 @@ describe("mobile maker transport", () => {
"local-db:messages:estimatedSessionValue",
"maker:usage:codex-rate-limits",
"maker:usage:codex-rate-limit-reset",
+ "maker:usage:codex-reset-auto-use",
"maker:usage:claude-subscription",
"maker:usage:xai-subscription",
"maker:claude-session-route:get",
diff --git a/apps/mobile/src/device-link/mobileMakerTransport.ts b/apps/mobile/src/device-link/mobileMakerTransport.ts
index 1a80caca83..37c985f3fc 100644
--- a/apps/mobile/src/device-link/mobileMakerTransport.ts
+++ b/apps/mobile/src/device-link/mobileMakerTransport.ts
@@ -60,6 +60,7 @@ import type {
MobileGoalStatusPayload,
MobileCodexRateLimitResetResult,
MobileCodexRateLimitsResult,
+ CodexResetAutoUseSettings,
MobileSessionAgentSwitchIntent,
MobileSessionAgentSwitchResult,
MobileVoiceDictionaryLearningRequest,
@@ -627,6 +628,7 @@ export interface MobileMakerTransport {
): Promise<{ totalValueMoney?: unknown; totalValueUsd?: number }>;
/** Codex app-server authoritative windows plus banked reset credits and a bound reset offer. */
getCodexRateLimits(providerId?: string): Promise<MobileCodexRateLimitsResult>;
+ setCodexResetAutoUse(patch: Partial<CodexResetAutoUseSettings> | null, accountKey: string, providerId?: string): Promise<MobileCodexRateLimitsResult>;
/**
* 被控端订阅账号余量快照(只读,cached-first;Claude 5h/周/分模型窗口、SuperGrok 周用量)。
* 默认账号不传 providerId;独立账号的回包必须回显同一 providerId,否则按旧被控端处理。
@@ -1358,6 +1360,12 @@ export function createMobileMakerTransport({
throw new Error("PRECONDITION_FAILED: Account scope unsupported");
return result;
},
+ setCodexResetAutoUse: async (patch, accountKey, providerId) => {
+ const result = await call<MobileCodexRateLimitsResult>('maker:usage:codex-reset-auto-use', [patch, accountKey, providerId ?? 'openai']);
+ if (result.providerId !== (providerId ?? 'openai') || result.autoUse?.accountKey !== accountKey)
+ throw new Error('PRECONDITION_FAILED: Account scope changed');
+ return result;
+ },
getSubscriptionUsage: async (kind, providerId) => {
// 默认账号不带参数,兼容只认默认账号的老被控端。
const scoped =
diff --git a/apps/mobile/src/i18n/locales/en/session.json b/apps/mobile/src/i18n/locales/en/session.json
index 0ee9e17553..99eabbc6fe 100644
--- a/apps/mobile/src/i18n/locales/en/session.json
+++ b/apps/mobile/src/i18n/locales/en/session.json
@@ -685,5 +685,24 @@
"ORCA_CREATE_UNCONFIRMED": "Creating the Worker timed out and couldn't be confirmed. Check the Worker list first, and retry only if no new Worker appears.",
"ORCA_ACTION_UNCONFIRMED": "The request timed out, so the result isn't confirmed yet. The list has been refreshed; go by what it shows now."
}
+ },
+ "resetAutoUse": {
+ "label": "Auto use",
+ "rules": "Auto-use rules",
+ "lowQuota": "Use when weekly quota falls below 1%",
+ "resetDistance": "Time until quota resets",
+ "days": "At least {{count}} days",
+ "unlimited": "Any time",
+ "custom": "Custom…",
+ "customDays": "Custom days",
+ "dayUnit": "days or more",
+ "apply": "Apply",
+ "expiring": "Use before a card expires",
+ "leadTime": "Use how early",
+ "minutes": "{{count}} minutes before expiry",
+ "hours": "{{count}} hours before expiry",
+ "hint": "Either rule uses the earliest-expiring card. Skip when all quotas are full. Runs on this computer while Cindy is running.",
+ "failed": "Could not save. Try again.",
+ "restore": "Restore defaults"
}
}
diff --git a/apps/mobile/src/i18n/locales/ja/session.json b/apps/mobile/src/i18n/locales/ja/session.json
index 323def182b..fa210e1747 100644
--- a/apps/mobile/src/i18n/locales/ja/session.json
+++ b/apps/mobile/src/i18n/locales/ja/session.json
@@ -685,5 +685,24 @@
"ORCA_CREATE_UNCONFIRMED": "Worker の作成がタイムアウトし、成功したか確認できませんでした。まず Worker 一覧を確認し、新しい Worker がない場合のみ再試行してください。",
"ORCA_ACTION_UNCONFIRMED": "操作がタイムアウトしたため、結果をまだ確認できません。一覧を更新しました。現在の表示を基準にしてください。"
}
+ },
+ "resetAutoUse": {
+ "label": "自動使用",
+ "rules": "自動使用ルール",
+ "lowQuota": "週間配分の残りが 1% 未満で使用",
+ "resetDistance": "配分リセットまでの残り時間",
+ "days": "{{count}} 日以上",
+ "unlimited": "制限なし",
+ "custom": "カスタム…",
+ "customDays": "日数を指定",
+ "dayUnit": "日以上",
+ "apply": "適用",
+ "expiring": "カードの有効期限前に使用",
+ "leadTime": "使用するタイミング",
+ "minutes": "有効期限の {{count}} 分前",
+ "hours": "有効期限の {{count}} 時間前",
+ "hint": "いずれかの条件で、期限が近いカードから使用します。全配分が満量の場合は使用しません。このパソコンで Cindy の起動中に実行します。",
+ "failed": "保存できませんでした。再試行してください。",
+ "restore": "既定に戻す"
}
}
diff --git a/apps/mobile/src/i18n/locales/ko/session.json b/apps/mobile/src/i18n/locales/ko/session.json
index 9145d14c8f..7e93db762b 100644
--- a/apps/mobile/src/i18n/locales/ko/session.json
+++ b/apps/mobile/src/i18n/locales/ko/session.json
@@ -681,5 +681,24 @@
"ORCA_CREATE_UNCONFIRMED": "Worker 만들기가 시간 초과되어 성공 여부를 확인하지 못했습니다. 먼저 Worker 목록을 확인하고, 새 Worker가 없을 때만 다시 시도하세요.",
"ORCA_ACTION_UNCONFIRMED": "작업 시간이 초과되어 결과를 아직 확인하지 못했습니다. 목록을 새로 고쳤으니 현재 표시된 상태를 기준으로 하세요."
}
+ },
+ "resetAutoUse": {
+ "label": "자동 사용",
+ "rules": "자동 사용 규칙",
+ "lowQuota": "주간 잔여량이 1% 미만일 때 사용",
+ "resetDistance": "할당량 초기화까지 남은 시간",
+ "days": "{{count}}일 이상",
+ "unlimited": "제한 없음",
+ "custom": "직접 입력…",
+ "customDays": "일수 입력",
+ "dayUnit": "일 이상",
+ "apply": "적용",
+ "expiring": "카드 만료 전에 사용",
+ "leadTime": "사용 시점",
+ "minutes": "만료 {{count}}분 전",
+ "hours": "만료 {{count}}시간 전",
+ "hint": "어느 조건이든 충족하면 만료가 가장 가까운 카드를 사용합니다. 모든 할당량이 가득 차면 건너뜁니다. 이 컴퓨터에서 Cindy가 실행 중이어야 합니다.",
+ "failed": "저장하지 못했습니다. 다시 시도하세요.",
+ "restore": "기본값 복원"
}
}
diff --git a/apps/mobile/src/i18n/locales/zh-CN/session.json b/apps/mobile/src/i18n/locales/zh-CN/session.json
index 15a9f63c1f..bf67dd4065 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/session.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/session.json
@@ -681,5 +681,24 @@
"ORCA_CREATE_UNCONFIRMED": "创建 Worker 超时,暂时无法确认是否成功。请先查看 Worker 列表,确认没有新建的 Worker 后再重试。",
"ORCA_ACTION_UNCONFIRMED": "操作超时,暂时无法确认结果。已刷新列表,请以当前显示的状态为准。"
}
+ },
+ "resetAutoUse": {
+ "label": "自动使用",
+ "rules": "自动使用规则",
+ "lowQuota": "每周剩余低于 1% 时自动用",
+ "resetDistance": "距离配额重置还剩",
+ "days": "{{count}} 天以上",
+ "unlimited": "不限",
+ "custom": "自定义…",
+ "customDays": "自定义天数",
+ "dayUnit": "天以上",
+ "apply": "应用",
+ "expiring": "临近卡到期时自动用",
+ "leadTime": "提前多久使用",
+ "minutes": "到期前 {{count}} 分钟",
+ "hours": "到期前 {{count}} 小时",
+ "hint": "任一条件满足时,优先用最早到期的卡。配额全满时跳过。由这台电脑执行,需保持 Cindy 运行。",
+ "failed": "保存失败,请重试。",
+ "restore": "恢复默认"
}
}
diff --git a/apps/mobile/src/i18n/locales/zh-TW/session.json b/apps/mobile/src/i18n/locales/zh-TW/session.json
index 10ba714de1..398f89b073 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/session.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/session.json
@@ -685,5 +685,24 @@
"ORCA_CREATE_UNCONFIRMED": "建立 Worker 逾時,暫時無法確認是否成功。請先查看 Worker 列表,確認沒有新建的 Worker 後再重試。",
"ORCA_ACTION_UNCONFIRMED": "操作逾時,暫時無法確認結果。已重新整理列表,請以目前顯示的狀態為準。"
}
+ },
+ "resetAutoUse": {
+ "label": "自動使用",
+ "rules": "自動使用規則",
+ "lowQuota": "每週剩餘低於 1% 時自動用",
+ "resetDistance": "距離配額重設還剩",
+ "days": "{{count}} 天以上",
+ "unlimited": "不限",
+ "custom": "自訂…",
+ "customDays": "自訂天數",
+ "dayUnit": "天以上",
+ "apply": "套用",
+ "expiring": "臨近卡到期時自動用",
+ "leadTime": "提前多久使用",
+ "minutes": "到期前 {{count}} 分鐘",
+ "hours": "到期前 {{count}} 小時",
+ "hint": "任一條件滿足時,優先用最早到期的卡。配額全滿時略過。由這台電腦執行,需保持 Cindy 執行。",
+ "failed": "儲存失敗,請重試。",
+ "restore": "恢復預設"
}
}
diff --git a/apps/mobile/src/session/CodexResetAutoUseControl.tsx b/apps/mobile/src/session/CodexResetAutoUseControl.tsx
new file mode 100644
index 0000000000..412f05e06e
--- /dev/null
+++ b/apps/mobile/src/session/CodexResetAutoUseControl.tsx
@@ -0,0 +1,85 @@
+import { useEffect, useRef, useState } from 'react';
+import { Pressable, StyleSheet, Switch, View } from 'react-native';
+import { ChevronDown, ChevronUp } from 'lucide-react-native';
+import { useTranslation } from 'react-i18next';
+import type { CodexResetAutoUseSettings, CodexResetAutoUseState } from '@cindy/maker-shared/device-link-contract';
+import { Text, TextInput } from '@/components/AppText';
+import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';
+import { typeScale, lineHeight, fontWeight, radius, spacing, iconSize } from '@/theme/tokens';
+
+export function CodexResetAutoUseControl({ state, onSave }: {
+ state: CodexResetAutoUseState;
+ onSave: (patch: Partial<CodexResetAutoUseSettings> | null) => Promise<void>;
+}) {
+ const { t } = useTranslation();
+ const { colors } = useTheme();
+ const styles = useThemedStyles(makeStyles);
+ const [expanded, setExpanded] = useState(false);
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState(false);
+ const [custom, setCustom] = useState(false);
+ const [days, setDays] = useState(String(state.settings.minimumDays));
+ const saving = useRef(false);
+ useEffect(() => { setDays(String(state.settings.minimumDays)); setError(false); }, [state]);
+ const s = state.settings;
+ const label = (key: string, values?: Record<string, unknown>) => t(`session.resetAutoUse.${key}`, values);
+ const save = async (patch: Partial<CodexResetAutoUseSettings> | null) => {
+ if (saving.current) return;
+ saving.current = true; setBusy(true); setError(false);
+ try { await onSave(patch); } catch { setError(true); }
+ finally { saving.current = false; setBusy(false); }
+ };
+ const condition = (field: 'lowQuota' | 'expiring') => void save({ [field]: !s[field],
+ ...(s[field] && !s[field === 'lowQuota' ? 'expiring' : 'lowQuota'] ? { enabled: false } : {}) });
+ const option = (text: string, selected: boolean, action: () => void, disabled = false) => (
+ <Pressable key={text} accessibilityRole="button" accessibilityState={{ selected, disabled: busy || disabled }} disabled={busy || disabled}
+ onPress={action} style={[styles.option, selected && styles.selected]}>
+ <Text style={styles.optionText}>{text}</Text>
+ </Pressable>
+ );
+ return <View>
+ <View style={styles.header}>
+ <Pressable accessibilityRole="button" accessibilityLabel={label('rules')} accessibilityState={{ expanded }} onPress={() => setExpanded(!expanded)} style={styles.trigger}>
+ <Text style={styles.title}>{label('label')}</Text>
+ {expanded ? <ChevronUp size={iconSize.sm} color={colors.textSecondary} /> : <ChevronDown size={iconSize.sm} color={colors.textSecondary} />}
+ </Pressable>
+ <Switch accessibilityLabel={label('label')} value={s.enabled} disabled={busy || !state.accountKey}
+ trackColor={{ false: colors.surfaceChip, true: colors.cta }} thumbColor={s.enabled ? colors.ctaText : colors.textSecondary}
+ onValueChange={enabled => void save({ enabled, ...(enabled && !s.lowQuota && !s.expiring ? { lowQuota: true } : {}) })} />
+ </View>
+ {expanded && <View style={styles.rules}>
+ <Pressable accessibilityRole="checkbox" accessibilityState={{ checked: s.lowQuota, disabled: busy }} disabled={busy} onPress={() => condition('lowQuota')} style={styles.condition}>
+ <Text style={styles.title}>{s.lowQuota ? '☑' : '☐'} {label('lowQuota')}</Text>
+ </Pressable>
+ {s.lowQuota && <View>
+ <Text style={styles.hint}>{label('resetDistance')}</Text>
+ <View style={styles.options}>{[3, 2, 1, 0].map(n => option(n ? label('days', { count: n }) : label('unlimited'), !custom && n === s.minimumDays, () => { setCustom(false); void save({ minimumDays: n }); }))}
+ {option(label('custom'), custom || ![0, 1, 2, 3].includes(s.minimumDays), () => setCustom(true))}</View>
+ {(custom || ![0, 1, 2, 3].includes(s.minimumDays)) && <View style={styles.options}>
+ <TextInput accessibilityLabel={label('customDays')} value={days} onChangeText={setDays} keyboardType="number-pad" editable={!busy} style={styles.input} />
+ {option(label('apply'), false, () => { if (/^\d+$/.test(days) && Number(days) <= 365) void save({ minimumDays: Number(days) }); }, !/^\d+$/.test(days) || Number(days) > 365)}
+ </View>}
+ </View>}
+ <Pressable accessibilityRole="checkbox" accessibilityState={{ checked: s.expiring, disabled: busy }} disabled={busy} onPress={() => condition('expiring')} style={styles.condition}>
+ <Text style={styles.title}>{s.expiring ? '☑' : '☐'} {label('expiring')}</Text>
+ </Pressable>
+ {s.expiring && <View style={styles.options}>{[30, 60, 360, 1440].map(n => option(label(n === 30 ? 'minutes' : 'hours', { count: n === 30 ? 30 : n / 60 }), s.expiryMinutes === n, () => void save({ expiryMinutes: n })))}</View>}
+ <Text style={styles.hint}>{label('hint')}</Text>
+ {state.customized && option(label('restore'), false, () => { setCustom(false); void save(null); })}
+ </View>}
+ {error && <Text accessibilityRole="alert" style={styles.hint}>{label('failed')}</Text>}
+ </View>;
+}
+const makeStyles = (colors: ThemeColors) => StyleSheet.create({
+ header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: spacing.sm },
+ trigger: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, minHeight: 48, flexShrink: 1 },
+ title: { fontSize: typeScale.bodySmall, lineHeight: lineHeight.bodySmall, fontWeight: fontWeight.medium, color: colors.textPrimary },
+ rules: { borderWidth: 1, borderColor: colors.border, borderRadius: radius.container, padding: spacing.md, gap: spacing.sm },
+ condition: { minHeight: 48, justifyContent: 'center' },
+ options: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.xs, marginVertical: spacing.xs },
+ option: { minHeight: 48, justifyContent: 'center', paddingHorizontal: spacing.md, borderRadius: radius.pill, borderWidth: 1, borderColor: colors.border },
+ selected: { backgroundColor: colors.surfaceChip, borderColor: colors.borderStrong },
+ optionText: { fontSize: typeScale.bodySmall, lineHeight: lineHeight.bodySmall, fontWeight: fontWeight.medium, color: colors.textPrimary },
+ hint: { fontSize: typeScale.footnote, lineHeight: lineHeight.caption, fontWeight: fontWeight.regular, color: colors.textSecondary },
+ input: { minHeight: 48, minWidth: 72, paddingHorizontal: spacing.md, borderWidth: 1, borderColor: colors.border, borderRadius: radius.control, fontSize: typeScale.body, fontWeight: fontWeight.regular, color: colors.textPrimary },
+});
diff --git a/apps/mobile/src/session/SessionMenuSheet.tsx b/apps/mobile/src/session/SessionMenuSheet.tsx
index 393e4ed11c..1c3e7296cc 100644
--- a/apps/mobile/src/session/SessionMenuSheet.tsx
+++ b/apps/mobile/src/session/SessionMenuSheet.tsx
@@ -1,3 +1,4 @@
+import { CodexResetAutoUseControl } from './CodexResetAutoUseControl';
import { TaskTagLabels, TaskTagsPanel } from './TaskTags';
import { TaskTagsSheet, useTaskTagsSheet } from './TaskTagsSheet';
import type { OpenAiAccountProvider } from './sessionControls';
@@ -50,7 +51,7 @@ import { mobilePresentationLocalizer } from '@/i18n/presentationLocalizer';
import { Text, TextInput } from '@/components/AppText';
import { MainWindowActionButton, MainWindowActionGroup } from '@/components/MobilePrimitives';
import type { MobileMakerTransport, RemoteDirectoryEntry } from '@/device-link/mobileMakerTransport';
-import type { MobileCodexRateLimitsResult } from '@cindy/maker-shared/device-link-contract';
+import type { CodexResetAutoUseSettings, MobileCodexRateLimitsResult } from '@cindy/maker-shared/device-link-contract';
import { projectDraftSessionTitle } from '@cindy/maker-shared/session-title';
import { isSharedTaskPeer } from '@cindy/device-link';
import { computeContextSheetSnapHeights, type ContextSheetSnap } from '@/session/contextSheetModel';
@@ -145,6 +146,7 @@ export interface SessionMenuSheetProps {
codexRateLimits: MobileCodexRateLimitsResult | null;
codexResetBusy: boolean;
onResetCodexRateLimits(): void;
+ onSaveCodexResetAutoUse?: (patch: Partial<CodexResetAutoUseSettings> | null) => Promise<void>;
onRefreshAccountUsage(): void;
extraDirBrowser?: SessionExtraDirBrowserState | null;
onLoadExtraDirPath(path: string): void;
@@ -190,6 +192,7 @@ export function SessionMenuSheet({
codexRateLimits,
codexResetBusy,
onResetCodexRateLimits,
+ onSaveCodexResetAutoUse,
onRefreshAccountUsage,
extraDirBrowser,
onLoadExtraDirPath,
@@ -829,11 +832,12 @@ export function SessionMenuSheet({
{resetSummary?.rows.map((row, index) => (
<InfoRow key={`reset:${row.label}:${index}`} label={row.label} value={row.value} />
))}
+ {codexRateLimits?.autoUse && onSaveCodexResetAutoUse && <CodexResetAutoUseControl key={codexRateLimits.autoUse.accountKey} state={codexRateLimits.autoUse} onSave={onSaveCodexResetAutoUse} />}
{resetSummary?.canReset ? (
<>
- <Text style={styles.infoCaption}>
+ {resetSummary.shouldPrompt && <Text style={styles.infoCaption}>
{t('session.menu.quotaExhaustedResettable')}
- </Text>
+ </Text>}
<View style={styles.infoActionRow}>
<MenuPillButton
busy={codexResetBusy}
diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.md
index 991a8bfd29..fedaea1263 100644
--- a/docs/design-rules/design-inventory.md
+++ b/docs/design-rules/design-inventory.md
@@ -53,7 +53,7 @@
| `mobile.account-deletion` | mobile | 账号注销 | app/account-deletion.tsx | AdaptiveWindow, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, HomeStackHeader, IncomingShareBridge, McpAppViews, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeMcpAppSurface, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, OutsideTap, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, ResidentHomeList, SheetModal, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, account-deletion, gestureHandler, nativeToolbarMenuItems, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/account-deletion.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/HomeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 214 | 59 |
| `mobile.auth` | mobile | 登录与添加账号 | app/(auth)/login.tsx / app/add-account.tsx | AccountSwitcherSheet, AdaptiveWindow, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, CompanionNativeContent.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, IncomingShareBridge, LoginCaptchaWebView, LoginNativeButton, LoginNativeButton.ios, LoginSkinControls, McpAppViews, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, MobileUserAvatar, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeMcpAppSurface, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, OutsideTap, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, ResidentHomeList, SheetModal, SheetSurface, StartupSplashOverlay, SystemNavigationBack, ThemeProvider, _layout, add-account, gestureHandler, login, peerFileTransport, useLocale | apps/mobile/app/(auth)/login.tsx, apps/mobile/app/_layout.tsx, apps/mobile/app/add-account.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/LoginCaptchaWebView.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/LoginNativeButton.ios.tsx, apps/mobile/src/components/LoginNativeButton.tsx, apps/mobile/src/components/LoginSkinControls.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileUserAvatar.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 221 | 84 |
| `mobile.chat.new` | mobile | 新建任务 | app/sessions/new.tsx | AdaptiveWindow, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, BlurBackdrop, CenteredScreen, CompanionNativeContent.ios, ComposerActivityPill, ComposerAttachmentTray, ComposerDockKeyboardFollow, ComposerFrame, ComposerFrame.ios, ComposerKeyboardAvoidingView, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ContextSheetCollabView, ContextSheetGoalView, ContextSheetGoalView.ios, ContextSheetMediaViews, ContextSheetPlugins, DeviceLinkContext, ErrorNotice, FileTypeIcon, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, HomeStackHeader, ImageLightbox, IncomingShareBridge, McpAppViews, MobileAgentMark, MobileAgentSwitcher, MobileChoicePickerList, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileModelPickerList, MobileModelPickerList.ios, MobileOutboxBridge, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileVendorIcon, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeErrorNotice.ios, NativeMcpAppSurface, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, NativeVideoPlayer, NewTaskSelectionRow, NewTaskSelectionSheet, NewTaskSelectionSheet.android, NewTaskSelectionSheet.ios, OrcaWorkerDirectoryPicker, OutsideTap, PaperPlaneIcon, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, RemoteSourceMark, ResidentHomeList, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, ThemeProvider, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VoiceRecordingPill, _layout, composerPullThrough, gestureHandler, mediaPlayerWebView, nativeToolbarMenuItems, new, peerFileTransport, useComposerPendingImagePreview, useLocale, voicePillWidthMotion | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/new.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/ErrorNotice.tsx, apps/mobile/src/components/FileTypeIcon.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/NativeErrorNotice.ios.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/HomeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/ComposerActivityPill.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerDockKeyboardFollow.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerNativeRow.ios.tsx, apps/mobile/src/session/ComposerNativeRow.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetCollabView.tsx, apps/mobile/src/session/ContextSheetGoalView.ios.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/ContextSheetPlugins.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileChoicePickerList.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/MobilePermissionPickerList.ios.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.ios.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerNativeHeader.ios.tsx, apps/mobile/src/session/ModelPickerNativeHeader.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativePermissionSheet.ios.tsx, apps/mobile/src/session/NativePermissionSheet.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/NativeVideoPlayer.tsx, apps/mobile/src/session/NewTaskSelectionRow.tsx, apps/mobile/src/session/NewTaskSelectionSheet.android.tsx, apps/mobile/src/session/NewTaskSelectionSheet.ios.tsx, apps/mobile/src/session/NewTaskSelectionSheet.tsx, apps/mobile/src/session/OrcaWorkerDirectoryPicker.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/RemoteSourceMark.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/composerPullThrough.tsx, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/useComposerPendingImagePreview.tsx, apps/mobile/src/session/voicePillWidthMotion.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 251 | 120 |
-| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AccountSwitcherSheet, AdaptiveWindow, AgentErrorDetails, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, ChatIdentityHeader, ChatPathChipSpan, ChatReplyIcon, CindyMakeSessionGate, CloudHomeSwitchSheet, CloudHomeUnreachableNotice, CompanionCardButton, CompanionChoice, CompanionCreateNativeView, CompanionCreateNativeView.ios, CompanionEntering, CompanionHeader, CompanionImportSheet, CompanionLearningFooter, CompanionMemoryPage, CompanionMemoryPage.ios, CompanionMessageActions, CompanionMessageCard, CompanionModelChain, CompanionNativeContent.ios, CompanionPortraitPicker, CompanionPresenceRing, CompanionProfileArtifacts, CompanionProfileNativeView, CompanionProfileNativeView.ios, CompanionProfileSheet, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, CompanionTaskResultCard, CompanionTodoRow, CompanionTodos, CompanionWorkingStatus, ComposerActivityPill, ComposerAttachmentTray, ComposerDockKeyboardFollow, ComposerExpandButton, ComposerExpandButton.ios, ComposerFrame, ComposerFrame.ios, ComposerKeyboardAvoidingView, ComposerMorphSource, ComposerMorphSource.ios, ComposerNativeInput, ComposerNativeInput.ios, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerRichInput, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ContextSheetCollabView, ContextSheetGoalView, ContextSheetGoalView.ios, ContextSheetMediaViews, ContextSheetPlugins, ConversationSearchFilterSheet, ConversationShareSvg, ConversationShareWebView, DeviceLinkContext, ErrorNotice, FailedScheduleNotice, FileTypeIcon, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSessionInfoMeta, HomeStackHeader, HomeSurface, HomeUnreadContext, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InputHandoffCard, InputHandoffDeviceCode, InputHandoffPictureStep, InputHandoffQrCode, InputHandoffRecordRow, InputHandoffSheet, InputHandoffSheet.ios, InputHandoffStepFields, InteractionPanel, MailLinkSpan, MarkdownBlockContent, McpAppCard, McpAppViews, MessageActionSheet, MessageLoadingImage, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileMailHtmlPreview, MobileModelPickerList, MobileModelPickerList.ios, MobileOutboxBridge, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileUserAvatar, MobileVendorIcon, ModalContentArea, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, MountOnFirstOpen, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeErrorNotice.ios, NativeMcpAppSurface, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, NativeVideoPlayer, NewTaskSelectionRow, NewTaskSelectionSheet, NewTaskSelectionSheet.android, NewTaskSelectionSheet.ios, OrcaWorkerDirectoryPicker, OutsideTap, PaperPlaneIcon, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PluginCardActions, PluginCardRecipients, PluginInvocationHeader, PluginMenuUnreadDot, PluginSetupNativeActions, PluginSetupNativeForm, PromptRecommendation, PushNotificationsBridge, QuestionReferenceText, QuietSyncIndicator, QuoteCapsule, ReadableHistoryRecovery, RecentMessageHistories, RemoteAccessGuide, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, RemoteSourceMark, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, RewindPreviewPanel, RichAnswer, RunningTokenRatePopover, SentInlineAtomBody, SessionActionSheet, SessionActionSheetFrame, SessionActionSheetFrame.android, SessionDetailsNative, SessionDetailsNative.ios, SessionEntryRecovery, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionListDrawer, SessionMenuSheet, SessionOptionsExpoSheet, SessionResourceCards, SessionRightSpinner, SessionSearchNative, SessionSearchNative.ios, SessionTailBanner, SessionTransientNotice, SessionUsageSummary, ShareImageNativeButton, ShareImageNativeButton.ios, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SharedTaskEndedState, SharedTaskScreen, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, SwipeableProjectHeader, SwipeableSessionRow, SwipeableSessionRow.ios, SystemNavigationBack, TaskTags, TaskTagsSheet, ThemeProvider, ThinkingDots, TodoDateInput, TodoDateInput.android, TodoDateInput.ios, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VideoSitePreview, VoiceRecordingPill, WorkingStatusText, [sessionId], _layout, composerPullThrough, gestureHandler, listDisclosureTransition, mathWebView, mediaPlayerWebView, mermaidWebView, nativeToolbarMenuItems, peerFileTransport, useComposerPendingImagePreview, useLocale, useSharedTaskConfirmation, voicePillWidthMotion | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/[sessionId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ChatReplyIcon.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/ErrorNotice.tsx, apps/mobile/src/components/FileTypeIcon.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileUserAvatar.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/NativeErrorNotice.ios.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteAccessGuide.tsx, apps/mobile/src/components/RemoteCompanionAvatar.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/inputHandoff/InputHandoffCard.tsx, apps/mobile/src/inputHandoff/InputHandoffDeviceCode.tsx, apps/mobile/src/inputHandoff/InputHandoffPictureStep.tsx, apps/mobile/src/inputHandoff/InputHandoffQrCode.tsx, apps/mobile/src/inputHandoff/InputHandoffRecordRow.tsx, apps/mobile/src/inputHandoff/InputHandoffSheet.ios.tsx, apps/mobile/src/inputHandoff/InputHandoffSheet.tsx, apps/mobile/src/inputHandoff/InputHandoffStepFields.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/HomeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/plugins/MobileMailHtmlPreview.tsx, apps/mobile/src/plugins/PluginCardActions.tsx, apps/mobile/src/plugins/PluginCardRecipients.tsx, apps/mobile/src/plugins/PluginMenuUnreadDot.tsx, apps/mobile/src/plugins/PluginSetupNativeActions.tsx, apps/mobile/src/plugins/PluginSetupNativeForm.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AgentErrorDetails.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/ChatIdentityHeader.tsx, apps/mobile/src/session/ChatPathChipSpan.tsx, apps/mobile/src/session/CindyMakeSessionGate.tsx, apps/mobile/src/session/CloudHomeSwitchSheet.tsx, apps/mobile/src/session/CloudHomeUnreachableNotice.tsx, apps/mobile/src/session/CompanionCardButton.tsx, apps/mobile/src/session/CompanionChoice.tsx, apps/mobile/src/session/CompanionCreateNativeView.ios.tsx, apps/mobile/src/session/CompanionCreateNativeView.tsx, apps/mobile/src/session/CompanionEntering.tsx, apps/mobile/src/session/CompanionHeader.tsx, apps/mobile/src/session/CompanionImportSheet.tsx, apps/mobile/src/session/CompanionLearningFooter.tsx, apps/mobile/src/session/CompanionMemoryPage.ios.tsx, apps/mobile/src/session/CompanionMemoryPage.tsx, apps/mobile/src/session/CompanionMessageActions.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/CompanionModelChain.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionPortraitPicker.tsx, apps/mobile/src/session/CompanionPresenceRing.tsx, apps/mobile/src/session/CompanionProfileArtifacts.tsx, apps/mobile/src/session/CompanionProfileNativeView.ios.tsx, apps/mobile/src/session/CompanionProfileNativeView.tsx, apps/mobile/src/session/CompanionProfileSheet.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.tsx, apps/mobile/src/session/CompanionTaskResultCard.tsx, apps/mobile/src/session/CompanionTodoRow.tsx, apps/mobile/src/session/CompanionTodos.tsx, apps/mobile/src/session/CompanionWorkingStatus.tsx, apps/mobile/src/session/ComposerActivityPill.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerDockKeyboardFollow.tsx, apps/mobile/src/session/ComposerExpandButton.ios.tsx, apps/mobile/src/session/ComposerExpandButton.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerMorphSource.ios.tsx, apps/mobile/src/session/ComposerMorphSource.tsx, apps/mobile/src/session/ComposerNativeInput.ios.tsx, apps/mobile/src/session/ComposerNativeInput.tsx, apps/mobile/src/session/ComposerNativeRow.ios.tsx, apps/mobile/src/session/ComposerNativeRow.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerRichInput.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetCollabView.tsx, apps/mobile/src/session/ContextSheetGoalView.ios.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/ContextSheetPlugins.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/ConversationShareSvg.tsx, apps/mobile/src/session/ConversationShareWebView.tsx, apps/mobile/src/session/FailedScheduleNotice.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSessionInfoMeta.tsx, apps/mobile/src/session/HomeSurface.tsx, apps/mobile/src/session/HomeUnreadContext.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/InlineQueueSection.tsx, apps/mobile/src/session/InlineQuoteChip.tsx, apps/mobile/src/session/InlineReferenceChip.tsx, apps/mobile/src/session/InteractionPanel.tsx, apps/mobile/src/session/MailLinkSpan.tsx, apps/mobile/src/session/MarkdownBlockContent.tsx, apps/mobile/src/session/McpAppCard.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MessageActionSheet.tsx, apps/mobile/src/session/MessageLoadingImage.tsx, apps/mobile/src/session/MessageRenderer.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileBoundaryNotice.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/MobilePermissionPickerList.ios.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.ios.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerNativeHeader.ios.tsx, apps/mobile/src/session/ModelPickerNativeHeader.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/MountOnFirstOpen.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativePermissionSheet.ios.tsx, apps/mobile/src/session/NativePermissionSheet.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/NativeVideoPlayer.tsx, apps/mobile/src/session/NewTaskSelectionRow.tsx, apps/mobile/src/session/NewTaskSelectionSheet.android.tsx, apps/mobile/src/session/NewTaskSelectionSheet.ios.tsx, apps/mobile/src/session/NewTaskSelectionSheet.tsx, apps/mobile/src/session/OrcaWorkerDirectoryPicker.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/PluginInvocationHeader.tsx, apps/mobile/src/session/PromptRecommendation.tsx, apps/mobile/src/session/QuestionReferenceText.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/ReadableHistoryRecovery.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/RemoteSourceMark.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/RichAnswer.tsx, apps/mobile/src/session/RunningTokenRatePopover.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionActionSheetFrame.android.tsx, apps/mobile/src/session/SessionActionSheetFrame.tsx, apps/mobile/src/session/SessionDetailsNative.ios.tsx, apps/mobile/src/session/SessionDetailsNative.tsx, apps/mobile/src/session/SessionEntryRecovery.tsx, apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx, apps/mobile/src/session/SessionHeaderNativeControls.tsx, apps/mobile/src/session/SessionListDrawer.tsx, apps/mobile/src/session/SessionMenuSheet.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SessionResourceCards.tsx, apps/mobile/src/session/SessionRightSpinner.tsx, apps/mobile/src/session/SessionSearchNative.ios.tsx, apps/mobile/src/session/SessionSearchNative.tsx, apps/mobile/src/session/SessionTailBanner.tsx, apps/mobile/src/session/SessionTransientNotice.tsx, apps/mobile/src/session/SessionUsageSummary.tsx, apps/mobile/src/session/ShareImageNativeButton.ios.tsx, apps/mobile/src/session/ShareImageNativeButton.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/ShareSelectAllButton.tsx, apps/mobile/src/session/ShareSelectionBar.tsx, apps/mobile/src/session/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/SwipeableProjectHeader.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/session/TaskTags.tsx, apps/mobile/src/session/TaskTagsSheet.tsx, apps/mobile/src/session/ThinkingDots.tsx, apps/mobile/src/session/TodoDateInput.android.tsx, apps/mobile/src/session/TodoDateInput.ios.tsx, apps/mobile/src/session/TodoDateInput.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.tsx, apps/mobile/src/session/VideoSitePreview.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/WorkingStatusText.tsx, apps/mobile/src/session/composerPullThrough.tsx, apps/mobile/src/session/composerRichInputHtml.ts, apps/mobile/src/session/conversationShareWebViewHtml.ts, apps/mobile/src/session/listDisclosureTransition.tsx, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/selectableMarkdownHtml.ts, apps/mobile/src/session/useComposerPendingImagePreview.tsx, apps/mobile/src/session/useSharedTaskConfirmation.tsx, apps/mobile/src/session/voicePillWidthMotion.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 7 | 252 | 334 |
+| `mobile.chat.session` | mobile | 任务内容与输入 | app/sessions/[sessionId].tsx | AccountSwitcherSheet, AdaptiveWindow, AgentErrorDetails, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AnnotationBurnInWebView, AppText, AuthContext, AuthorizationMessageCard, AutomationTimerIcon, BlurBackdrop, CenteredScreen, ChatFileChipMenuSheet, ChatIdentityHeader, ChatPathChipSpan, ChatReplyIcon, CindyMakeSessionGate, CloudHomeSwitchSheet, CloudHomeUnreachableNotice, CodexResetAutoUseControl, CompanionCardButton, CompanionChoice, CompanionCreateNativeView, CompanionCreateNativeView.ios, CompanionEntering, CompanionHeader, CompanionImportSheet, CompanionLearningFooter, CompanionMemoryPage, CompanionMemoryPage.ios, CompanionMessageActions, CompanionMessageCard, CompanionModelChain, CompanionNativeContent.ios, CompanionPortraitPicker, CompanionPresenceRing, CompanionProfileArtifacts, CompanionProfileNativeView, CompanionProfileNativeView.ios, CompanionProfileSheet, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, CompanionTaskResultCard, CompanionTodoRow, CompanionTodos, CompanionWorkingStatus, ComposerActivityPill, ComposerAttachmentTray, ComposerDockKeyboardFollow, ComposerExpandButton, ComposerExpandButton.ios, ComposerFrame, ComposerFrame.ios, ComposerKeyboardAvoidingView, ComposerMorphSource, ComposerMorphSource.ios, ComposerNativeInput, ComposerNativeInput.ios, ComposerNativeRow, ComposerNativeRow.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerRichInput, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, ContextSheetCollabView, ContextSheetGoalView, ContextSheetGoalView.ios, ContextSheetMediaViews, ContextSheetPlugins, ConversationSearchFilterSheet, ConversationShareSvg, ConversationShareWebView, DeviceLinkContext, ErrorNotice, FailedScheduleNotice, FileTypeIcon, FoldTouchpad, HomeChromeDrawer, HomeChromeFrost, HomeEntryProvider, HomeGlassMenuPanel, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeListVisuals, HomeModeSwitch, HomeNativeStackHeader, HomeNewTaskButton, HomeProjectMachineLabel, HomeSearchBar, HomeSessionInfoMeta, HomeStackHeader, HomeSurface, HomeUnreadContext, ImageLightbox, IncomingShareBridge, InlineQueueSection, InlineQuoteChip, InlineReferenceChip, InputHandoffCard, InputHandoffDeviceCode, InputHandoffPictureStep, InputHandoffQrCode, InputHandoffRecordRow, InputHandoffSheet, InputHandoffSheet.ios, InputHandoffStepFields, InteractionPanel, MailLinkSpan, MarkdownBlockContent, McpAppCard, McpAppViews, MessageActionSheet, MessageLoadingImage, MessageRenderer, MobileAgentMark, MobileAgentSwitcher, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileMailHtmlPreview, MobileModelPickerList, MobileModelPickerList.ios, MobileOutboxBridge, MobilePermissionPickerList, MobilePermissionPickerList.ios, MobilePrimitives, MobileProviderMark, MobileUserAvatar, MobileVendorIcon, ModalContentArea, ModelOptionsSheetView, ModelOptionsSheetView.ios, ModelPickerNativeHeader, ModelPickerNativeHeader.ios, ModelPickerSheet, MountOnFirstOpen, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeErrorNotice.ios, NativeMcpAppSurface, NativePermissionSheet, NativePermissionSheet.ios, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, NativeVideoPlayer, NewTaskSelectionRow, NewTaskSelectionSheet, NewTaskSelectionSheet.android, NewTaskSelectionSheet.ios, OrcaWorkerDirectoryPicker, OutsideTap, PaperPlaneIcon, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PlanModeChip, PluginCardActions, PluginCardRecipients, PluginInvocationHeader, PluginMenuUnreadDot, PluginSetupNativeActions, PluginSetupNativeForm, PromptRecommendation, PushNotificationsBridge, QuestionReferenceText, QuietSyncIndicator, QuoteCapsule, ReadableHistoryRecovery, RecentMessageHistories, RemoteAccessGuide, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, RemoteSourceMark, RemoteTaskSuggestions, RenameSessionModal, ResidentHomeList, RewindPreviewPanel, RichAnswer, RunningTokenRatePopover, SentInlineAtomBody, SessionActionSheet, SessionActionSheetFrame, SessionActionSheetFrame.android, SessionDetailsNative, SessionDetailsNative.ios, SessionEntryRecovery, SessionHeaderNativeControls, SessionHeaderNativeControls.ios, SessionListDrawer, SessionMenuSheet, SessionOptionsExpoSheet, SessionResourceCards, SessionRightSpinner, SessionSearchNative, SessionSearchNative.ios, SessionTailBanner, SessionTransientNotice, SessionUsageSummary, ShareImageNativeButton, ShareImageNativeButton.ios, ShareMessageCheckbox, ShareSelectAllButton, ShareSelectionBar, SharedTaskEndedState, SharedTaskScreen, SheetModal, SheetSurface, SimpleStackHeader, SlowSendNotice, StartupSplashOverlay, SwipeableProjectHeader, SwipeableSessionRow, SwipeableSessionRow.ios, SystemNavigationBack, TaskTags, TaskTagsSheet, ThemeProvider, ThinkingDots, TodoDateInput, TodoDateInput.android, TodoDateInput.ios, UnifiedModelPickerSheet, UnifiedModelPickerView, UnifiedModelPickerView.ios, VideoSitePreview, VoiceRecordingPill, WorkingStatusText, [sessionId], _layout, composerPullThrough, gestureHandler, listDisclosureTransition, mathWebView, mediaPlayerWebView, mermaidWebView, nativeToolbarMenuItems, peerFileTransport, useComposerPendingImagePreview, useLocale, useSharedTaskConfirmation, voicePillWidthMotion | apps/mobile/app/_layout.tsx, apps/mobile/app/sessions/[sessionId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ChatReplyIcon.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/ErrorNotice.tsx, apps/mobile/src/components/FileTypeIcon.tsx, apps/mobile/src/components/MobileAgentMark.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/MobileUserAvatar.tsx, apps/mobile/src/components/MobileVendorIcon.tsx, apps/mobile/src/components/NativeErrorNotice.ios.tsx, apps/mobile/src/components/PaperPlaneIcon.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteAccessGuide.tsx, apps/mobile/src/components/RemoteCompanionAvatar.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/inputHandoff/InputHandoffCard.tsx, apps/mobile/src/inputHandoff/InputHandoffDeviceCode.tsx, apps/mobile/src/inputHandoff/InputHandoffPictureStep.tsx, apps/mobile/src/inputHandoff/InputHandoffQrCode.tsx, apps/mobile/src/inputHandoff/InputHandoffRecordRow.tsx, apps/mobile/src/inputHandoff/InputHandoffSheet.ios.tsx, apps/mobile/src/inputHandoff/InputHandoffSheet.tsx, apps/mobile/src/inputHandoff/InputHandoffStepFields.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/ModalContentArea.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/HomeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/chrome/SystemNavigationBack.tsx, apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/plugins/MobileMailHtmlPreview.tsx, apps/mobile/src/plugins/PluginCardActions.tsx, apps/mobile/src/plugins/PluginCardRecipients.tsx, apps/mobile/src/plugins/PluginMenuUnreadDot.tsx, apps/mobile/src/plugins/PluginSetupNativeActions.tsx, apps/mobile/src/plugins/PluginSetupNativeForm.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AccountSwitcherSheet.tsx, apps/mobile/src/session/AgentErrorDetails.tsx, apps/mobile/src/session/AnnotationBurnInWebView.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/AutomationTimerIcon.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/ChatFileChipMenuSheet.tsx, apps/mobile/src/session/ChatIdentityHeader.tsx, apps/mobile/src/session/ChatPathChipSpan.tsx, apps/mobile/src/session/CindyMakeSessionGate.tsx, apps/mobile/src/session/CloudHomeSwitchSheet.tsx, apps/mobile/src/session/CloudHomeUnreachableNotice.tsx, apps/mobile/src/session/CodexResetAutoUseControl.tsx, apps/mobile/src/session/CompanionCardButton.tsx, apps/mobile/src/session/CompanionChoice.tsx, apps/mobile/src/session/CompanionCreateNativeView.ios.tsx, apps/mobile/src/session/CompanionCreateNativeView.tsx, apps/mobile/src/session/CompanionEntering.tsx, apps/mobile/src/session/CompanionHeader.tsx, apps/mobile/src/session/CompanionImportSheet.tsx, apps/mobile/src/session/CompanionLearningFooter.tsx, apps/mobile/src/session/CompanionMemoryPage.ios.tsx, apps/mobile/src/session/CompanionMemoryPage.tsx, apps/mobile/src/session/CompanionMessageActions.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/CompanionModelChain.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionPortraitPicker.tsx, apps/mobile/src/session/CompanionPresenceRing.tsx, apps/mobile/src/session/CompanionProfileArtifacts.tsx, apps/mobile/src/session/CompanionProfileNativeView.ios.tsx, apps/mobile/src/session/CompanionProfileNativeView.tsx, apps/mobile/src/session/CompanionProfileSheet.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.tsx, apps/mobile/src/session/CompanionTaskResultCard.tsx, apps/mobile/src/session/CompanionTodoRow.tsx, apps/mobile/src/session/CompanionTodos.tsx, apps/mobile/src/session/CompanionWorkingStatus.tsx, apps/mobile/src/session/ComposerActivityPill.tsx, apps/mobile/src/session/ComposerAttachmentTray.tsx, apps/mobile/src/session/ComposerDockKeyboardFollow.tsx, apps/mobile/src/session/ComposerExpandButton.ios.tsx, apps/mobile/src/session/ComposerExpandButton.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerKeyboardAvoidingView.tsx, apps/mobile/src/session/ComposerMorphSource.ios.tsx, apps/mobile/src/session/ComposerMorphSource.tsx, apps/mobile/src/session/ComposerNativeInput.ios.tsx, apps/mobile/src/session/ComposerNativeInput.tsx, apps/mobile/src/session/ComposerNativeRow.ios.tsx, apps/mobile/src/session/ComposerNativeRow.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerRichInput.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/ContextSheetCollabView.tsx, apps/mobile/src/session/ContextSheetGoalView.ios.tsx, apps/mobile/src/session/ContextSheetGoalView.tsx, apps/mobile/src/session/ContextSheetMediaViews.tsx, apps/mobile/src/session/ContextSheetPlugins.tsx, apps/mobile/src/session/ConversationSearchFilterSheet.tsx, apps/mobile/src/session/ConversationShareSvg.tsx, apps/mobile/src/session/ConversationShareWebView.tsx, apps/mobile/src/session/FailedScheduleNotice.tsx, apps/mobile/src/session/HomeChromeDrawer.tsx, apps/mobile/src/session/HomeChromeFrost.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeGlassMenuPanel.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/HomeListVisuals.tsx, apps/mobile/src/session/HomeModeSwitch.tsx, apps/mobile/src/session/HomeNewTaskButton.tsx, apps/mobile/src/session/HomeProjectMachineLabel.tsx, apps/mobile/src/session/HomeSearchBar.tsx, apps/mobile/src/session/HomeSessionInfoMeta.tsx, apps/mobile/src/session/HomeSurface.tsx, apps/mobile/src/session/HomeUnreadContext.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/InlineQueueSection.tsx, apps/mobile/src/session/InlineQuoteChip.tsx, apps/mobile/src/session/InlineReferenceChip.tsx, apps/mobile/src/session/InteractionPanel.tsx, apps/mobile/src/session/MailLinkSpan.tsx, apps/mobile/src/session/MarkdownBlockContent.tsx, apps/mobile/src/session/McpAppCard.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MessageActionSheet.tsx, apps/mobile/src/session/MessageLoadingImage.tsx, apps/mobile/src/session/MessageRenderer.tsx, apps/mobile/src/session/MobileAgentSwitcher.tsx, apps/mobile/src/session/MobileBoundaryNotice.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileModelPickerList.ios.tsx, apps/mobile/src/session/MobileModelPickerList.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/MobilePermissionPickerList.ios.tsx, apps/mobile/src/session/MobilePermissionPickerList.tsx, apps/mobile/src/session/MobileProviderMark.tsx, apps/mobile/src/session/ModelOptionsSheetView.ios.tsx, apps/mobile/src/session/ModelOptionsSheetView.tsx, apps/mobile/src/session/ModelPickerNativeHeader.ios.tsx, apps/mobile/src/session/ModelPickerNativeHeader.tsx, apps/mobile/src/session/ModelPickerSheet.tsx, apps/mobile/src/session/MountOnFirstOpen.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativePermissionSheet.ios.tsx, apps/mobile/src/session/NativePermissionSheet.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/NativeVideoPlayer.tsx, apps/mobile/src/session/NewTaskSelectionRow.tsx, apps/mobile/src/session/NewTaskSelectionSheet.android.tsx, apps/mobile/src/session/NewTaskSelectionSheet.ios.tsx, apps/mobile/src/session/NewTaskSelectionSheet.tsx, apps/mobile/src/session/OrcaWorkerDirectoryPicker.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PlanModeChip.tsx, apps/mobile/src/session/PluginInvocationHeader.tsx, apps/mobile/src/session/PromptRecommendation.tsx, apps/mobile/src/session/QuestionReferenceText.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/ReadableHistoryRecovery.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/RemoteSourceMark.tsx, apps/mobile/src/session/RemoteTaskSuggestions.tsx, apps/mobile/src/session/RenameSessionModal.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/RewindPreviewPanel.tsx, apps/mobile/src/session/RichAnswer.tsx, apps/mobile/src/session/RunningTokenRatePopover.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/SessionActionSheet.tsx, apps/mobile/src/session/SessionActionSheetFrame.android.tsx, apps/mobile/src/session/SessionActionSheetFrame.tsx, apps/mobile/src/session/SessionDetailsNative.ios.tsx, apps/mobile/src/session/SessionDetailsNative.tsx, apps/mobile/src/session/SessionEntryRecovery.tsx, apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx, apps/mobile/src/session/SessionHeaderNativeControls.tsx, apps/mobile/src/session/SessionListDrawer.tsx, apps/mobile/src/session/SessionMenuSheet.tsx, apps/mobile/src/session/SessionOptionsExpoSheet.tsx, apps/mobile/src/session/SessionResourceCards.tsx, apps/mobile/src/session/SessionRightSpinner.tsx, apps/mobile/src/session/SessionSearchNative.ios.tsx, apps/mobile/src/session/SessionSearchNative.tsx, apps/mobile/src/session/SessionTailBanner.tsx, apps/mobile/src/session/SessionTransientNotice.tsx, apps/mobile/src/session/SessionUsageSummary.tsx, apps/mobile/src/session/ShareImageNativeButton.ios.tsx, apps/mobile/src/session/ShareImageNativeButton.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/ShareSelectAllButton.tsx, apps/mobile/src/session/ShareSelectionBar.tsx, apps/mobile/src/session/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/SlowSendNotice.tsx, apps/mobile/src/session/SwipeableProjectHeader.tsx, apps/mobile/src/session/SwipeableSessionRow.ios.tsx, apps/mobile/src/session/SwipeableSessionRow.tsx, apps/mobile/src/session/TaskTags.tsx, apps/mobile/src/session/TaskTagsSheet.tsx, apps/mobile/src/session/ThinkingDots.tsx, apps/mobile/src/session/TodoDateInput.android.tsx, apps/mobile/src/session/TodoDateInput.ios.tsx, apps/mobile/src/session/TodoDateInput.tsx, apps/mobile/src/session/UnifiedModelPickerSheet.tsx, apps/mobile/src/session/UnifiedModelPickerView.ios.tsx, apps/mobile/src/session/UnifiedModelPickerView.tsx, apps/mobile/src/session/VideoSitePreview.tsx, apps/mobile/src/session/VoiceRecordingPill.tsx, apps/mobile/src/session/WorkingStatusText.tsx, apps/mobile/src/session/composerPullThrough.tsx, apps/mobile/src/session/composerRichInputHtml.ts, apps/mobile/src/session/conversationShareWebViewHtml.ts, apps/mobile/src/session/listDisclosureTransition.tsx, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/selectableMarkdownHtml.ts, apps/mobile/src/session/useComposerPendingImagePreview.tsx, apps/mobile/src/session/useSharedTaskConfirmation.tsx, apps/mobile/src/session/voicePillWidthMotion.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 7 | 252 | 337 |
| `mobile.chat.sharing` | mobile | 共享任务邀请与成员;供应商分享链接提示 | app/shared-session.tsx / app/provider-share.tsx | AdaptiveWindow, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, IncomingShareBridge, McpAppViews, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeMcpAppSurface, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, OutsideTap, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, ResidentHomeList, SharedTaskAdmissionDialog, SharedTaskEndedState, SharedTaskScreen, SheetModal, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, _layout, gestureHandler, peerFileTransport, provider-share, shared-session, useLocale, useSharedTaskConfirmation | apps/mobile/app/_layout.tsx, apps/mobile/app/provider-share.tsx, apps/mobile/app/shared-session.tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SharedTaskAdmissionDialog.tsx, apps/mobile/src/session/SharedTaskEndedState.tsx, apps/mobile/src/session/SharedTaskScreen.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/useSharedTaskConfirmation.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 214 | 68 |
| `mobile.companions.cloud` | mobile | 云端伙伴:主力电脑离线时的对话与换电脑 | app/companions/cloud/[actorId].tsx | AdaptiveWindow, AgentErrorDetails, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AppText, AuthContext, AuthorizationMessageCard, BlurBackdrop, BotGroupAvatars, BotGroupMessageText, CenteredScreen, ChatIdentityHeader, ChatPathChipSpan, ChatReplyIcon, CloudCompanionScreen, CompanionCardButton, CompanionEntering, CompanionLearningFooter, CompanionMessageActions, CompanionMessageCard, CompanionNativeContent.ios, CompanionPresenceRing, CompanionSettingsRow, CompanionSettingsRow.ios, CompanionSheet, CompanionSheet.ios, CompanionTaskResultCard, ComposerFrame, ComposerFrame.ios, ComposerNativeSection, ComposerNativeSection.ios, ComposerSheet, ComposerSheet.ios, ConnectionBanner, ConnectionNoticeOverlay, ContextSheet, ContextSheet.ios, DeviceLinkContext, ErrorNotice, FileTypeIcon, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, HomeStackHeader, ImageLightbox, IncomingShareBridge, InlineQuoteChip, InlineReferenceChip, InputHandoffCard, InputHandoffDeviceCode, InputHandoffPictureStep, InputHandoffQrCode, InputHandoffRecordRow, InputHandoffSheet, InputHandoffSheet.ios, InputHandoffStepFields, InteractionPanel, MailLinkSpan, MarkdownBlockContent, McpAppCard, McpAppViews, MessageActionSheet, MessageLoadingImage, MessageRenderer, MobileBoundaryNotice, MobileComposerInputRow, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileMailHtmlPreview, MobileOutboxBridge, MobilePrimitives, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeErrorNotice.ios, NativeMcpAppSurface, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, NativeVideoPlayer, OutsideTap, PendingSendBubble, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PluginCardActions, PluginCardRecipients, PluginInvocationHeader, PluginSetupNativeActions, PluginSetupNativeForm, PushNotificationsBridge, QuestionReferenceText, QuietSyncIndicator, QuoteCapsule, RecentMessageHistories, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, ResidentHomeList, RichAnswer, SentInlineAtomBody, ShareMessageCheckbox, SheetModal, SheetSurface, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, VideoSitePreview, [actorId], _layout, gestureHandler, mathWebView, mediaPlayerWebView, mermaidWebView, nativeToolbarMenuItems, peerFileTransport, useLocale, voicePillWidthMotion | apps/mobile/app/_layout.tsx, apps/mobile/app/companions/cloud/[actorId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ChatReplyIcon.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/ErrorNotice.tsx, apps/mobile/src/components/FileTypeIcon.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/NativeErrorNotice.ios.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteCompanionAvatar.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/inputHandoff/InputHandoffCard.tsx, apps/mobile/src/inputHandoff/InputHandoffDeviceCode.tsx, apps/mobile/src/inputHandoff/InputHandoffPictureStep.tsx, apps/mobile/src/inputHandoff/InputHandoffQrCode.tsx, apps/mobile/src/inputHandoff/InputHandoffRecordRow.tsx, apps/mobile/src/inputHandoff/InputHandoffSheet.ios.tsx, apps/mobile/src/inputHandoff/InputHandoffSheet.tsx, apps/mobile/src/inputHandoff/InputHandoffStepFields.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/HomeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/plugins/MobileMailHtmlPreview.tsx, apps/mobile/src/plugins/PluginCardActions.tsx, apps/mobile/src/plugins/PluginCardRecipients.tsx, apps/mobile/src/plugins/PluginSetupNativeActions.tsx, apps/mobile/src/plugins/PluginSetupNativeForm.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/AgentErrorDetails.tsx, apps/mobile/src/session/AuthorizationMessageCard.tsx, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/BotGroupAvatars.tsx, apps/mobile/src/session/BotGroupMessageText.tsx, apps/mobile/src/session/ChatIdentityHeader.tsx, apps/mobile/src/session/ChatPathChipSpan.tsx, apps/mobile/src/session/CloudCompanionScreen.tsx, apps/mobile/src/session/CompanionCardButton.tsx, apps/mobile/src/session/CompanionEntering.tsx, apps/mobile/src/session/CompanionLearningFooter.tsx, apps/mobile/src/session/CompanionMessageActions.tsx, apps/mobile/src/session/CompanionMessageCard.tsx, apps/mobile/src/session/CompanionNativeContent.ios.tsx, apps/mobile/src/session/CompanionPresenceRing.tsx, apps/mobile/src/session/CompanionSettingsRow.ios.tsx, apps/mobile/src/session/CompanionSettingsRow.tsx, apps/mobile/src/session/CompanionSheet.ios.tsx, apps/mobile/src/session/CompanionSheet.tsx, apps/mobile/src/session/CompanionTaskResultCard.tsx, apps/mobile/src/session/ComposerFrame.ios.tsx, apps/mobile/src/session/ComposerFrame.tsx, apps/mobile/src/session/ComposerNativeSection.ios.tsx, apps/mobile/src/session/ComposerNativeSection.tsx, apps/mobile/src/session/ComposerSheet.ios.tsx, apps/mobile/src/session/ComposerSheet.tsx, apps/mobile/src/session/ContextSheet.ios.tsx, apps/mobile/src/session/ContextSheet.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/ImageLightbox.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/InlineQuoteChip.tsx, apps/mobile/src/session/InlineReferenceChip.tsx, apps/mobile/src/session/InteractionPanel.tsx, apps/mobile/src/session/MailLinkSpan.tsx, apps/mobile/src/session/MarkdownBlockContent.tsx, apps/mobile/src/session/McpAppCard.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MessageActionSheet.tsx, apps/mobile/src/session/MessageLoadingImage.tsx, apps/mobile/src/session/MessageRenderer.tsx, apps/mobile/src/session/MobileBoundaryNotice.tsx, apps/mobile/src/session/MobileComposerInputRow.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/NativeVideoPlayer.tsx, apps/mobile/src/session/PendingSendBubble.tsx, apps/mobile/src/session/PluginInvocationHeader.tsx, apps/mobile/src/session/QuestionReferenceText.tsx, apps/mobile/src/session/QuoteCapsule.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/RichAnswer.tsx, apps/mobile/src/session/SentInlineAtomBody.tsx, apps/mobile/src/session/ShareMessageCheckbox.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/session/SheetSurface.tsx, apps/mobile/src/session/VideoSitePreview.tsx, apps/mobile/src/session/mathWebView.tsx, apps/mobile/src/session/mathWebViewHtml.ts, apps/mobile/src/session/mediaPlayerWebView.tsx, apps/mobile/src/session/mediaPlayerWebViewHtml.ts, apps/mobile/src/session/mermaidWebView.tsx, apps/mobile/src/session/mermaidWebViewHtml.ts, apps/mobile/src/session/voicePillWidthMotion.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 251 | 196 |
| `mobile.companions.direct` | mobile | 伙伴私聊回看 | app/companions/direct/[threadId].tsx | AdaptiveWindow, AnchoredPullDownMenu, AnchoredPullDownMenu.android, AndroidUpdateSheet, AppText, AuthContext, BlurBackdrop, CenteredScreen, ConnectionBanner, ConnectionNoticeOverlay, DeviceLinkContext, FoldTouchpad, HomeEntryProvider, HomeHeaderGlassButton, HomeHeaderGlassButton.ios, HomeNativeStackHeader, HomeStackHeader, IncomingShareBridge, McpAppViews, MobileLoginHandoffContext, MobileLoginHandoffStage, MobileOutboxBridge, MobilePrimitives, NativeBottomSheet, NativeBottomSheet.android, NativeChromeBackButton.ios, NativeChromeButton.ios, NativeMcpAppSurface, NativePullDownMenu, NativeRemoteDesktopView, NativeResidentHistory, NativeSwitch, OutsideTap, PermissionGuide, PermissionGuideView, PermissionGuideView.ios, PushNotificationsBridge, QuietSyncIndicator, RecentMessageHistories, RemoteCompanionAvatar, RemoteDesktopActionButton, RemoteDesktopActionButton.ios, RemoteDesktopBackButton, RemoteDesktopBackButton.ios, RemoteDesktopChrome, RemoteDesktopChrome.ios, RemoteDesktopClipboardButton, RemoteDesktopControls, RemoteDesktopDisplaySettings, RemoteDesktopHost, RemoteDesktopIcons, RemoteDesktopMouseControls, RemoteDesktopMouseControls.ios, RemoteDesktopNetworkStatus, RemoteDesktopPanelButton, RemoteDesktopPanelButton.ios, RemoteDesktopScreen, RemoteDesktopSecuritySettings, RemoteDesktopWindows, RemoteHistoryPrefetchBridge, ResidentHomeList, SheetModal, SimpleStackHeader, StartupSplashOverlay, ThemeProvider, [threadId], _layout, gestureHandler, nativeToolbarMenuItems, peerFileTransport, useLocale | apps/mobile/app/_layout.tsx, apps/mobile/app/companions/direct/[threadId].tsx, apps/mobile/src/auth/AuthContext.tsx, apps/mobile/src/auth/MobileLoginHandoffContext.tsx, apps/mobile/src/components/AppText.tsx, apps/mobile/src/components/CenteredScreen.tsx, apps/mobile/src/components/ConnectionBanner.tsx, apps/mobile/src/components/ConnectionNoticeOverlay.tsx, apps/mobile/src/components/MobileLoginHandoffStage.tsx, apps/mobile/src/components/MobilePrimitives.tsx, apps/mobile/src/components/QuietSyncIndicator.tsx, apps/mobile/src/components/RemoteCompanionAvatar.tsx, apps/mobile/src/components/StartupSplashOverlay.tsx, apps/mobile/src/device-link/DeviceLinkContext.tsx, apps/mobile/src/device-link/peerFileTransport.tsx, apps/mobile/src/i18n/useLocale.tsx, apps/mobile/src/notifications/PushNotificationsBridge.tsx, apps/mobile/src/platform/AdaptiveWindow.tsx, apps/mobile/src/platform/OutsideTap.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx, apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx, apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx, apps/mobile/src/platform/chrome/HomeStackHeader.tsx, apps/mobile/src/platform/chrome/NativeChromeBackButton.ios.tsx, apps/mobile/src/platform/chrome/NativeChromeButton.ios.tsx, apps/mobile/src/platform/chrome/NativePullDownMenu.tsx, apps/mobile/src/platform/chrome/NativeSwitch.tsx, apps/mobile/src/platform/chrome/SimpleStackHeader.tsx, apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx, apps/mobile/src/platform/gestureHandler.tsx, apps/mobile/src/remote-desktop/FoldTouchpad.tsx, apps/mobile/src/remote-desktop/NativeRemoteDesktopView.tsx, apps/mobile/src/remote-desktop/PermissionGuide.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.ios.tsx, apps/mobile/src/remote-desktop/PermissionGuideView.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopActionButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopBackButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopChrome.tsx, apps/mobile/src/remote-desktop/RemoteDesktopClipboardButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopDisplaySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopHost.tsx, apps/mobile/src/remote-desktop/RemoteDesktopIcons.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopMouseControls.tsx, apps/mobile/src/remote-desktop/RemoteDesktopNetworkStatus.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.ios.tsx, apps/mobile/src/remote-desktop/RemoteDesktopPanelButton.tsx, apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx, apps/mobile/src/remote-desktop/RemoteDesktopSecuritySettings.tsx, apps/mobile/src/remote-desktop/RemoteDesktopWindows.tsx, apps/mobile/src/remote-desktop/viewerHtml.ts, apps/mobile/src/session/BlurBackdrop.tsx, apps/mobile/src/session/HomeEntryProvider.tsx, apps/mobile/src/session/HomeHeaderGlassButton.ios.tsx, apps/mobile/src/session/HomeHeaderGlassButton.tsx, apps/mobile/src/session/IncomingShareBridge.tsx, apps/mobile/src/session/McpAppViews.tsx, apps/mobile/src/session/MobileOutboxBridge.tsx, apps/mobile/src/session/NativeBottomSheet.android.tsx, apps/mobile/src/session/NativeBottomSheet.tsx, apps/mobile/src/session/NativeMcpAppSurface.tsx, apps/mobile/src/session/NativeResidentHistory.tsx, apps/mobile/src/session/RecentMessageHistories.tsx, apps/mobile/src/session/RemoteHistoryPrefetchBridge.tsx, apps/mobile/src/session/ResidentHomeList.tsx, apps/mobile/src/session/SheetModal.tsx, apps/mobile/src/theme/ThemeProvider.tsx, apps/mobile/src/theme/navigationTheme.ts, apps/mobile/src/theme/tokens.ts, apps/mobile/src/update/AndroidUpdateSheet.tsx | 0 | 214 | 57 |
diff --git a/docs/product-rules/usage-limit-auto-continue.md b/docs/product-rules/usage-limit-auto-continue.md
index a3058ee097..deafc8383b 100644
--- a/docs/product-rules/usage-limit-auto-continue.md
+++ b/docs/product-rules/usage-limit-auto-continue.md
@@ -53,3 +53,29 @@
重试不受影响。
- 自动继续在真正发给模型前被丢弃(任务关闭、准备失败等)时,恢复原错误与手动重试入口,不再自动等待。
- 等待由被控电脑持有;手机与另一台电脑只显示等待并可取消。
+
+## Codex 重置卡的自动使用
+
+手动使用由用户决定:有效重置卡不因剩余额度大于零而禁用。界面确认具体卡和账号,
+服务端仍可返回无需重置、无卡等结果,不能把“按钮可点”说成服务端保证接受。
+
+自动入口是重置卡旁的开关与小下拉,默认关闭。编辑规则不自动打开开关;取消最后一个
+条件同时关闭自动使用。两项条件独立,以“或”组合,合并触发只用最早到期的一张:
+
+- 普通 Codex 周窗口剩余低于 1%;可限定距自然配额重置至少 3 / 2 / 1 天,或不限、
+ 自填整数天数(0–365)。默认 3 天。其它模型专属窗口耗尽不触发这项条件。
+- 卡即将过期;可提前 30 分钟 / 1 小时 / 6 小时 / 24 小时使用,默认 1 小时。
+
+所有已知有效窗口均未使用时自动跳过;未知或失效用量不授权兑换。这些自动条件不限制
+手动使用。配额重置时刻与卡到期时刻分别来自额度窗口和卡,不能混用。
+
+设置属于执行电脑、当前 Cindy 数据所有者、供应商连接和确切 ChatGPT 账号。仅保存
+用户改动的覆盖值,恢复默认清除覆盖;换 ChatGPT 账号不继承自动授权。手机通过已有
+同账号远控权限修改执行电脑上的设置;旧主机无 `autoUse` 字段时隐藏入口。共享任务
+访客、供应商分享访客不能通过新通道授权扣卡。
+
+电脑上的 Cindy 运行时,在用量变化、唤醒及每分钟检查规则;手机不用保持连接。
+睡眠、离线或退出 Cindy 时不承诺能赶在到期前执行。自动与手动共用兑换锁和幂等键,
+自动检查在发出上游请求前复核授权;结果不明只重试自身同一个请求,不接管用户的
+未决手动请求。成功后重新读取权威配额,再通过已有普通任务和目标模式的等待机制
+提前恢复符合条件的任务;保留用户停止、取消、共享任务和执行电脑边界,不缩短过载等待。
diff --git a/packages/device-link/src/__tests__/allowlist.test.ts b/packages/device-link/src/__tests__/allowlist.test.ts
index 1fbe5182f3..f440a39137 100644
--- a/packages/device-link/src/__tests__/allowlist.test.ts
+++ b/packages/device-link/src/__tests__/allowlist.test.ts
@@ -193,6 +193,7 @@ describe('REMOTE_INVOKE_ALLOWLIST', () => {
it('放行 Codex 官方额度读取与 desktop 绑定的人工 reset offer', () => {
expect(REMOTE_INVOKE_ALLOWLIST.has('maker:usage:codex-rate-limits')).toBe(true);
expect(REMOTE_INVOKE_ALLOWLIST.has('maker:usage:codex-rate-limit-reset')).toBe(true);
+ expect(REMOTE_INVOKE_ALLOWLIST.has('maker:usage:codex-reset-auto-use')).toBe(true);
});
it('放行 Claude 订阅余量快照只读(远程订阅会话 chip 镜像被控端窗口剩余)', () => {
diff --git a/packages/device-link/src/allowlist.ts b/packages/device-link/src/allowlist.ts
index ac3d887ffc..f8ee1b23f0 100644
--- a/packages/device-link/src/allowlist.ts
+++ b/packages/device-link/src/allowlist.ts
@@ -521,6 +521,7 @@ const EXTENDED_INVOKE_CHANNELS: readonly string[] = [
// 人工 reset。mutation 不接收 creditId,不能泛化成任意账号/凭证控制入口。
'maker:usage:codex-rate-limits',
'maker:usage:codex-rate-limit-reset',
+ 'maker:usage:codex-reset-auto-use',
// Claude 订阅账号余量快照(只读,cached-first):控制端远程会话状态栏 chip 显示
// 被控端订阅的 5h/周/分模型窗口剩余(数据真相在被控端 —— turn 在被控端消耗其
// 订阅额度)。快照只含利用率百分比、reset 时间与账号归属指纹(单向 scrypt 哈希,
diff --git a/packages/maker-shared/src/__tests__/sessionControls.test.ts b/packages/maker-shared/src/__tests__/sessionControls.test.ts
index c701063809..50e83fadaa 100644
--- a/packages/maker-shared/src/__tests__/sessionControls.test.ts
+++ b/packages/maker-shared/src/__tests__/sessionControls.test.ts
@@ -88,11 +88,11 @@ describe('summarizeCodexRateLimitReset', () => {
});
});
- it('does not offer reset before exhaustion and leaves offer expiry to desktop', () => {
+ it('allows manual reset before exhaustion and leaves offer expiry to desktop', () => {
expect(summarizeCodexRateLimitReset({
...base,
rateLimits: { primary: { usedPercent: 99.9 } },
- }, NOW_MS)).toMatchObject({ shouldPrompt: false, canReset: false });
+ }, NOW_MS)).toMatchObject({ shouldPrompt: false, canReset: true });
expect(summarizeCodexRateLimitReset({
...base,
resetOffer: { ...base.resetOffer, validUntil: NOW_MS },
@@ -111,7 +111,7 @@ describe('summarizeCodexRateLimitReset', () => {
primary: { usedPercent: 100 },
rateLimitReachedType: 'workspace_owner_credits_depleted',
},
- }, NOW_MS)).toMatchObject({ shouldPrompt: false, canReset: false });
+ }, NOW_MS)).toMatchObject({ shouldPrompt: false, canReset: true });
});
it('omits the reset count when credit availability was not returned', () => {
diff --git a/packages/maker-shared/src/deviceLinkContract.ts b/packages/maker-shared/src/deviceLinkContract.ts
index 875910ffbf..e676446e64 100644
--- a/packages/maker-shared/src/deviceLinkContract.ts
+++ b/packages/maker-shared/src/deviceLinkContract.ts
@@ -228,6 +228,8 @@ export interface MobileCodexRateLimitResetOffer {
/** Full read-only Codex quota view plus an optional manually redeemable reset offer. */
export interface MobileCodexRateLimitsResult {
+ /** Absent on older hosts. Settings belong to this computer and exact ChatGPT account. */
+ autoUse?: CodexResetAutoUseState;
/** Echoed account scope; custom-account clients reject unscoped legacy responses. */
providerId?: string;
account: MobileCodexRateLimitAccount;
@@ -240,6 +242,23 @@ export interface MobileCodexRateLimitsResult {
resetOffer: MobileCodexRateLimitResetOffer | null;
}
+export interface CodexResetAutoUseSettings {
+ enabled: boolean;
+ lowQuota: boolean;
+ /** Inclusive days until the weekly quota resets; zero means no time condition. */
+ minimumDays: number;
+ expiring: boolean;
+ expiryMinutes: number;
+}
+
+export interface CodexResetAutoUseState {
+ /** Opaque account binding, never an auth credential. Required when saving. */
+ accountKey: string;
+ settings: CodexResetAutoUseSettings;
+ customized: boolean;
+ lastUsedAt: number | null;
+}
+
/** Stable terminal result for one desktop-issued reset offer. */
export interface MobileCodexRateLimitResetResult {
providerId?: string;
@@ -325,6 +344,7 @@ export const MOBILE_REMOTE_INVOKE_CHANNELS = [
// reset 使用 desktop 预签发、账号绑定的幂等 offer,手机不能自行指定 creditId。
'maker:usage:codex-rate-limits',
'maker:usage:codex-rate-limit-reset',
+ 'maker:usage:codex-reset-auto-use',
// 订阅账号余量快照(只读;Claude / SuperGrok)与 cc 默认路由会话的生效计费路由。
// 老被控端 CHANNEL_NOT_ALLOWED → 任务菜单保留「暂未获取账号配额」。
'maker:usage:claude-subscription',
diff --git a/packages/maker-shared/src/sessionControls.ts b/packages/maker-shared/src/sessionControls.ts
index d03cd87c07..2967b7b062 100644
--- a/packages/maker-shared/src/sessionControls.ts
+++ b/packages/maker-shared/src/sessionControls.ts
@@ -273,8 +273,7 @@ export function summarizeCodexRateLimitReset(
earliestExpiryAt,
availableCount,
shouldPrompt,
- canReset: shouldPrompt
- && availableCount > 0
+ canReset: availableCount > 0
// Offer TTL belongs to the issuing Desktop clock. Mobile only checks presence;
// consume returns a typed precondition error when Desktop has actually expired it.
&& Boolean(value.resetOffer),