Add basic validation for quick action create dialog

This commit is contained in:
Kovid Goyal 2025-09-07 13:41:42 +05:30
parent 3116b484de
commit ab1da2ffdc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -637,6 +637,18 @@ class ActionEditDialog(QDialog):
title = self.name_edit.text().strip()
return Action(f'custom-{title}', title, self.prompt_edit.toPlainText().strip())
def accept(self) -> None:
ac = self.get_action()
if not ac.human_name:
return error_dialog(self, _('No name specified'), _('You must specify a name for the Quick action'), show=True)
if not ac.prompt_template:
return error_dialog(self, _('No prompt specified'), _('You must specify a prompt for the Quick action'), show=True)
try:
ac.prompt_text()
except Exception as e:
return error_dialog(self, _('Invalid prompt'), _('The prompt you specified is not valid. Error: {}').format(e), show=True)
super().accept()
class LLMSettingsWidget(QWidget):