Add blockImages setting to prevent images from being sent to LLM providers

- Setting controls filtering at convertToLlm layer (defense-in-depth)
- Images are always stored in session, filtered dynamically based on current setting
- Toggle mid-session works: LLM sees/doesn't see images already in session
- Fixed SettingsManager.save() to handle inMemory mode for all setters

Closes #492
This commit is contained in:
Mario Zechner 2026-01-06 11:59:09 +01:00
parent b582a6b70d
commit 1fc2a912d4
8 changed files with 80 additions and 127 deletions

View file

@ -171,23 +171,23 @@ export class SettingsManager {
}
private save(): void {
if (!this.persist || !this.settingsPath) return;
if (this.persist && this.settingsPath) {
try {
const dir = dirname(this.settingsPath);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
try {
const dir = dirname(this.settingsPath);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
// Save only global settings (project settings are read-only)
writeFileSync(this.settingsPath, JSON.stringify(this.globalSettings, null, 2), "utf-8");
} catch (error) {
console.error(`Warning: Could not save settings file: ${error}`);
}
// Save only global settings (project settings are read-only)
writeFileSync(this.settingsPath, JSON.stringify(this.globalSettings, null, 2), "utf-8");
// Re-merge project settings into active settings
const projectSettings = this.loadProjectSettings();
this.settings = deepMergeSettings(this.globalSettings, projectSettings);
} catch (error) {
console.error(`Warning: Could not save settings file: ${error}`);
}
// Always re-merge to update active settings (needed for both file and inMemory modes)
const projectSettings = this.loadProjectSettings();
this.settings = deepMergeSettings(this.globalSettings, projectSettings);
}
getLastChangelogVersion(): string | undefined {
@ -408,11 +408,6 @@ export class SettingsManager {
this.globalSettings.images = {};
}
this.globalSettings.images.blockImages = blocked;
// Also update active settings for inMemory mode
if (!this.settings.images) {
this.settings.images = {};
}
this.settings.images.blockImages = blocked;
this.save();
}