Skip to content

Commit 3c64dc7

Browse files
feat(web): settings switch for changing account at a usage limit
Agents can read and change it through the environment preferences tool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ac00531 commit 3c64dc7

5 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎apps/server/src/mcp/toolkits/environment/handlers.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function preferences(settings: ServerSettings) {
1313
defaultThreadEnvMode,
1414
newWorktreesStartFromOrigin,
1515
enableProviderUpdateChecks,
16+
switchAccountAtUsageLimit,
1617
backgroundActivity,
1718
sourceControlWritingStyle,
1819
} = settings;
@@ -21,6 +22,7 @@ export function preferences(settings: ServerSettings) {
2122
defaultThreadEnvMode,
2223
newWorktreesStartFromOrigin,
2324
enableProviderUpdateChecks,
25+
switchAccountAtUsageLimit,
2426
backgroundActivity: { profile: backgroundActivity.profile },
2527
sourceControlWritingStyle: {
2628
...sourceControlWritingStyle,

‎apps/server/src/mcp/toolkits/environment/tools.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const PreferenceFields = {
1818
defaultThreadEnvMode: ServerSettings.fields.defaultThreadEnvMode,
1919
newWorktreesStartFromOrigin: ServerSettings.fields.newWorktreesStartFromOrigin,
2020
enableProviderUpdateChecks: ServerSettings.fields.enableProviderUpdateChecks,
21+
switchAccountAtUsageLimit: ServerSettings.fields.switchAccountAtUsageLimit,
2122
backgroundActivity: Schema.Struct({ profile: BackgroundActivityProfileSelection }),
2223
sourceControlWritingStyle: Schema.Struct({
2324
mode: Schema.String,
@@ -59,6 +60,7 @@ const EnvironmentPreferencesTool = Tool.make("t3_environment_preferences_update"
5960
defaultThreadEnvMode: ServerSettingsPatch.fields.defaultThreadEnvMode,
6061
newWorktreesStartFromOrigin: ServerSettingsPatch.fields.newWorktreesStartFromOrigin,
6162
enableProviderUpdateChecks: ServerSettingsPatch.fields.enableProviderUpdateChecks,
63+
switchAccountAtUsageLimit: ServerSettingsPatch.fields.switchAccountAtUsageLimit,
6264
backgroundActivity: Schema.optionalKey(Schema.Struct({ profile: BackgroundActivityProfile })),
6365
sourceControlWritingStyle: ServerSettingsPatch.fields.sourceControlWritingStyle,
6466
}),

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ export function useSettingsRestore(onRestored?: () => void) {
647647
DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks
648648
? ["Provider update checks"]
649649
: []),
650+
...(settings.switchAccountAtUsageLimit !== DEFAULT_UNIFIED_SETTINGS.switchAccountAtUsageLimit
651+
? ["Switch account at usage limit"]
652+
: []),
650653
...(settings.continueThreadsAfterServerUpdate !==
651654
DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate
652655
? ["Continue threads after restarts"]
@@ -723,6 +726,7 @@ export function useSettingsRestore(onRestored?: () => void) {
723726
settings.responseStreamingMode,
724727
settings.persistComposerContextStrip,
725728
settings.enableProviderUpdateChecks,
729+
settings.switchAccountAtUsageLimit,
726730
settings.continueThreadsAfterServerUpdate,
727731
settings.sidebarAutoSettleAfterDays,
728732
settings.sidebarAutoSettleOnMerge,
@@ -843,6 +847,7 @@ export function useSettingsRestore(onRestored?: () => void) {
843847
snoozeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads,
844848
responseStreamingMode: DEFAULT_UNIFIED_SETTINGS.responseStreamingMode,
845849
enableProviderUpdateChecks: DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks,
850+
switchAccountAtUsageLimit: DEFAULT_UNIFIED_SETTINGS.switchAccountAtUsageLimit,
846851
continueThreadsAfterServerUpdate: DEFAULT_UNIFIED_SETTINGS.continueThreadsAfterServerUpdate,
847852
backgroundActivity: DEFAULT_UNIFIED_SETTINGS.backgroundActivity,
848853
backgroundActivityProfile: DEFAULT_UNIFIED_SETTINGS.backgroundActivityProfile,
@@ -3025,6 +3030,36 @@ export function GeneralSettingsPanel() {
30253030
}
30263031
/>
30273032

3033+
<SettingsRow
3034+
serverScoped
3035+
settingKeys={["switchAccountAtUsageLimit"]}
3036+
{...searchableSetting("switch-account-at-usage-limit")}
3037+
description="When an account has used up a usage window, start new turns on another signed-in account of the same provider instead of failing or spending credits."
3038+
resetAction={
3039+
settings.switchAccountAtUsageLimit !==
3040+
DEFAULT_UNIFIED_SETTINGS.switchAccountAtUsageLimit ? (
3041+
<SettingResetButton
3042+
label="switch account at usage limit"
3043+
onClick={() =>
3044+
updateSettings({
3045+
switchAccountAtUsageLimit: DEFAULT_UNIFIED_SETTINGS.switchAccountAtUsageLimit,
3046+
})
3047+
}
3048+
/>
3049+
) : null
3050+
}
3051+
control={
3052+
<ScopedSwitch
3053+
settingKeys={["switchAccountAtUsageLimit"]}
3054+
checked={settings.switchAccountAtUsageLimit}
3055+
onCheckedChange={(checked) =>
3056+
updateSettings({ switchAccountAtUsageLimit: Boolean(checked) })
3057+
}
3058+
aria-label="Switch account at usage limit"
3059+
/>
3060+
}
3061+
/>
3062+
30283063
<SettingsRow
30293064
{...searchableSetting("continue-threads-after-server-update")}
30303065
serverScoped

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ export const SETTINGS_SEARCH_ITEMS = [
488488
searchTerms: ["installed cli versions newer available codex claude cursor grok opencode"],
489489
scope: "environment-defaults",
490490
},
491+
{
492+
id: "switch-account-at-usage-limit",
493+
title: "Switch account at usage limit",
494+
to: "/settings/general",
495+
searchTerms: ["quota limit credits second account subscription automatic fallback weekly"],
496+
},
491497
{
492498
id: "continue-threads-after-server-update",
493499
title: "Continue threads after restarts",

‎docs/user/providers-codex.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ Codex can keep working past a used-up limit by spending ChatGPT credits, so the
114114
turn never stops. Once the selected account's session or weekly limit is used up,
115115
the composer shows **Switch to** another signed-in account for your next message.
116116

117+
To make that switch without a click, turn on **Settings → General → Switch account at usage
118+
limit**. A new turn then starts on another signed-in account of the same provider that offers the
119+
model, whenever the thread's account has used up a usage window. It applies to messages you send,
120+
to scheduled tasks, and to turns agents start. A turn that is already running stays on its account.
121+
When no other account has allowance left, the turn runs where it was.
122+
117123
## Send feedback to OpenAI
118124

119125
In an existing Codex thread, send `/feedback` with an optional description, for

0 commit comments

Comments
 (0)