-
Couldn't load subscription status.
- Fork 2.4k
refactor: flatten image generation settings structure #7536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
017ef1b
1744d47
7161ce5
8f8d323
1abb1bf
ac5042b
bcc0c25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,10 @@ export const globalSettingsSchema = z.object({ | |
| customInstructions: z.string().optional(), | ||
| taskHistory: z.array(historyItemSchema).optional(), | ||
|
|
||
| // Image generation settings (experimental) - flattened for simplicity | ||
| openRouterImageApiKey: z.string().optional(), | ||
| imageGenerationSelectedModel: z.string().optional(), | ||
|
|
||
| condensingApiConfigId: z.string().optional(), | ||
| customCondensingPrompt: z.string().optional(), | ||
|
|
||
|
|
@@ -200,11 +204,24 @@ export const SECRET_STATE_KEYS = [ | |
| "featherlessApiKey", | ||
| "ioIntelligenceApiKey", | ||
| "vercelAiGatewayApiKey", | ||
| ] as const satisfies readonly (keyof ProviderSettings)[] | ||
| export type SecretState = Pick<ProviderSettings, (typeof SECRET_STATE_KEYS)[number]> | ||
| ] as const | ||
|
|
||
| // Global secrets that are part of GlobalSettings (not ProviderSettings) | ||
| export const GLOBAL_SECRET_KEYS = [ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add JSDoc comments here to explain the distinction between |
||
| "openRouterImageApiKey", // For image generation | ||
| ] as const | ||
|
|
||
| // Type for the actual secret storage keys | ||
| type ProviderSecretKey = (typeof SECRET_STATE_KEYS)[number] | ||
| type GlobalSecretKey = (typeof GLOBAL_SECRET_KEYS)[number] | ||
|
|
||
| // Type representing all secrets that can be stored | ||
| export type SecretState = Pick<ProviderSettings, Extract<ProviderSecretKey, keyof ProviderSettings>> & { | ||
| [K in GlobalSecretKey]?: string | ||
| } | ||
|
|
||
| export const isSecretStateKey = (key: string): key is Keys<SecretState> => | ||
| SECRET_STATE_KEYS.includes(key as Keys<SecretState>) | ||
| SECRET_STATE_KEYS.includes(key as ProviderSecretKey) || GLOBAL_SECRET_KEYS.includes(key as GlobalSecretKey) | ||
|
|
||
| /** | ||
| * GlobalState | ||
|
|
@@ -213,7 +230,7 @@ export const isSecretStateKey = (key: string): key is Keys<SecretState> => | |
| export type GlobalState = Omit<RooCodeSettings, Keys<SecretState>> | ||
|
|
||
| export const GLOBAL_STATE_KEYS = [...GLOBAL_SETTINGS_KEYS, ...PROVIDER_SETTINGS_KEYS].filter( | ||
| (key: Keys<RooCodeSettings>) => !SECRET_STATE_KEYS.includes(key as Keys<SecretState>), | ||
| (key: Keys<RooCodeSettings>) => !isSecretStateKey(key), | ||
| ) as Keys<GlobalState>[] | ||
|
|
||
| export const isGlobalStateKey = (key: string): key is Keys<GlobalState> => | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be openRouterImageGenerationSelectedModel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we leave this generic in case we want to add other models from other providers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm just not sure the right structure to support multiple providers. If we don't care about preserving the key when you switch between them, we might want
imageApiProvider,imageApiKey,imageApiModelId?