feat(FN-1375): add null-as-delete pattern for settings with Reset button

- Send null instead of undefined when clearing token cap to explicitly delete setting
- Handle null values as delete operations in updateSettings (for clearing keys)
- Add Reset button in Settings modal to clear token cap with one click
- Update placeholder and help text for token cap input
- Fix TypeScript cast error for config.settings
This commit is contained in:
gsxdsm
2026-04-09 12:43:38 -07:00
parent d0cb2e7faf
commit 3ef12726d1
3 changed files with 36 additions and 11 deletions

View File

@@ -595,6 +595,17 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
return this.withConfigLock(async () => {
const config = await this.readConfig();
// Handle null values as "delete this key from settings"
// This allows the frontend to explicitly clear a setting by sending null
// (since JSON.stringify drops undefined keys, we use null as a sentinel)
for (const key of Object.keys(projectPatch)) {
if ((projectPatch as Record<string, unknown>)[key] === null) {
delete (config.settings as unknown as Record<string, unknown>)[key];
delete (projectPatch as Record<string, unknown>)[key];
}
}
const globalSettings = await this.globalSettingsStore.getSettings();
const previousMerged: Settings = { ...DEFAULT_SETTINGS, ...globalSettings, ...config.settings } as Settings;
const updatedProjectSettings = { ...config.settings, ...projectPatch };