feat: Add settings for auto apply changes

This commit is contained in:
Petr Mironychev
2025-10-20 18:10:21 +02:00
parent 0365018834
commit 254fac246d
6 changed files with 109 additions and 22 deletions

View File

@ -226,6 +226,13 @@ GeneralSettings::GeneralSettings()
Tr::tr("Allow tools to write and modify files on disk (WARNING: Use with caution!)"));
allowFileSystemWrite.setDefaultValue(false);
autoApplyFileEdits.setSettingsKey(Constants::CA_AUTO_APPLY_FILE_EDITS);
autoApplyFileEdits.setLabelText(Tr::tr("Automatically apply file edits"));
autoApplyFileEdits.setToolTip(
Tr::tr("When enabled, file edits suggested by AI will be applied automatically. "
"When disabled, you will need to manually approve each edit."));
autoApplyFileEdits.setDefaultValue(false);
readSettings();
Logger::instance().setLoggingEnabled(enableLogging());
@ -272,7 +279,7 @@ GeneralSettings::GeneralSettings()
auto caGroup = Group{
title(TrConstants::CHAT_ASSISTANT),
Column{caGrid,
Column{useTools, allowFileSystemRead, allowFileSystemWrite},
Column{useTools, allowFileSystemRead, allowFileSystemWrite, autoApplyFileEdits},
caTemplateDescription}};
auto rootLayout = Column{
@ -520,6 +527,7 @@ void GeneralSettings::resetPageToDefaults()
resetAspect(useTools);
resetAspect(allowFileSystemRead);
resetAspect(allowFileSystemWrite);
resetAspect(autoApplyFileEdits);
writeSettings();
}
}

View File

@ -103,6 +103,7 @@ public:
Utils::BoolAspect useTools{this};
Utils::BoolAspect allowFileSystemRead{this};
Utils::BoolAspect allowFileSystemWrite{this};
Utils::BoolAspect autoApplyFileEdits{this};
Utils::StringAspect caTemplateDescription{this};

View File

@ -77,6 +77,7 @@ const char MAX_FILE_THRESHOLD[] = "QodeAssist.maxFileThreshold";
const char CC_MULTILINE_COMPLETION[] = "QodeAssist.ccMultilineCompletion";
const char CC_MODEL_OUTPUT_HANDLER[] = "QodeAssist.ccModelOutputHandler";
const char CUSTOM_JSON_TEMPLATE[] = "QodeAssist.customJsonTemplate";
const char CA_AUTO_APPLY_FILE_EDITS[] = "QodeAssist.caAutoApplyFileEdits";
const char CA_TOKENS_THRESHOLD[] = "QodeAssist.caTokensThreshold";
const char CA_LINK_OPEN_FILES[] = "QodeAssist.caLinkOpenFiles";
const char CA_AUTOSAVE[] = "QodeAssist.caAutosave";