feat: include unconfigured secret paths in config settings snapshot

- Export SECRET_PATHS from registry for reuse
- Populate snapshot with `{ configured: true }` for non-empty secrets not already covered by registered fields
This commit is contained in:
2026-05-19 00:04:38 -07:00
parent 222edaf4a0
commit ed85cc4b5e
2 changed files with 16 additions and 2 deletions
+15 -1
View File
@@ -15,7 +15,7 @@ import type {
ConfigSettingsSnapshot, ConfigSettingsSnapshot,
} from '../../types/settings'; } from '../../types/settings';
import { resolveConfig } from '../resolve'; import { resolveConfig } from '../resolve';
import { getConfigValueAtPath } from './registry'; import { getConfigValueAtPath, SECRET_PATHS } from './registry';
const JSONC_FORMATTING_OPTIONS: FormattingOptions = { const JSONC_FORMATTING_OPTIONS: FormattingOptions = {
insertSpaces: true, insertSpaces: true,
@@ -337,6 +337,20 @@ export function buildConfigSettingsSnapshot(
values[field.configPath] = structuredClone(rawValue != null ? rawValue : resolvedValue); values[field.configPath] = structuredClone(rawValue != null ? rawValue : resolvedValue);
} }
for (const secretPath of SECRET_PATHS) {
if (Object.hasOwn(values, secretPath)) {
continue;
}
const rawValue = getConfigValueAtPath(options.rawConfig, secretPath);
const resolvedValue = getConfigValueAtPath(options.resolvedConfig, secretPath);
if (
(typeof rawValue === 'string' && rawValue.length > 0) ||
(typeof resolvedValue === 'string' && resolvedValue.length > 0)
) {
values[secretPath] = { configured: true };
}
}
return { return {
configPath: options.configPath, configPath: options.configPath,
fields: options.fields, fields: options.fields,
+1 -1
View File
@@ -93,7 +93,7 @@ const JSON_OBJECT_FIELDS = new Set([
'subtitleSidebar.css', 'subtitleSidebar.css',
]); ]);
const SECRET_PATHS = new Set(['ai.apiKey', 'jimaku.apiKey', 'anilist.accessToken']); export const SECRET_PATHS = new Set(['ai.apiKey', 'jimaku.apiKey', 'anilist.accessToken']);
const COLOR_SUFFIXES = new Set(['Color', 'color', 'backgroundColor', 'singleColor']); const COLOR_SUFFIXES = new Set(['Color', 'color', 'backgroundColor', 'singleColor']);
const SUBTITLE_CSS_MANAGED_CONFIG_PATHS = new Set([ const SUBTITLE_CSS_MANAGED_CONFIG_PATHS = new Set([