From ddcbfdaa0b5bc5c83a5b3a159863205203306a0a Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sat, 21 Mar 2026 22:53:07 +0300 Subject: [PATCH] feat: remove hardcoded command templates, enforce template system exclusively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove ALL hardcoded EN/RU fallback strings from handler.py — every command response now renders through CommandTemplateSlot templates - _render_cmd_template now returns error placeholder instead of None when template is missing, ensuring no silent failures - Fix register_commands_with_telegram tuple unpacking bug (was ignoring cmd_template_slots from _resolve_command_context) - Auto-assign system default template (matching locale) on command config creation when none specified - Add command_template_config_id to CommandConfigCreate model - Remove "no template" option from frontend dropdown — template is now required for command configs - Auto-select first matching template when creating new command config - Fix || vs ?? for command_template_config_id, default_count, and rate_limits in frontend edit function (0 was treated as falsy) --- .../src/routes/command-configs/+page.svelte | 16 +- .../api/command_configs.py | 43 +++- .../notify_bridge_server/commands/handler.py | 199 +++++------------- 3 files changed, 102 insertions(+), 156 deletions(-) diff --git a/frontend/src/routes/command-configs/+page.svelte b/frontend/src/routes/command-configs/+page.svelte index 5858963..d8663fa 100644 --- a/frontend/src/routes/command-configs/+page.svelte +++ b/frontend/src/routes/command-configs/+page.svelte @@ -62,7 +62,14 @@ finally { loaded = true; } } - function openNew() { form = defaultForm(); editing = null; showForm = true; } + function openNew() { + form = defaultForm(); + // Auto-select first matching template for the default provider_type + const match = cmdTemplateConfigs.find((c: any) => c.provider_type === form.provider_type); + if (match) form.command_template_config_id = match.id; + editing = null; + showForm = true; + } function editConfig(cfg: any) { form = { name: cfg.name, @@ -71,9 +78,9 @@ enabled_commands: [...(cfg.enabled_commands || [])], locale: cfg.locale || 'en', response_mode: cfg.response_mode || 'media', - default_count: cfg.default_count || 5, - rate_limits: { search: cfg.rate_limits?.search || 30, default: cfg.rate_limits?.default || 10 }, - command_template_config_id: cfg.command_template_config_id || null, + default_count: cfg.default_count ?? 5, + rate_limits: { search: cfg.rate_limits?.search ?? 30, default: cfg.rate_limits?.default ?? 10 }, + command_template_config_id: cfg.command_template_config_id ?? null, }; editing = cfg.id; showForm = true; @@ -167,7 +174,6 @@