From 03a321e5423383c5f50c925527422041943088c7 Mon Sep 17 00:00:00 2001 From: Fork Less Date: Wed, 17 Jun 2026 01:06:09 +0200 Subject: [PATCH] fix: fall back to default custom persona when CustomPersona textarea is empty --- server/hooks.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/hooks.go b/server/hooks.go index 9085038..6496f51 100644 --- a/server/hooks.go +++ b/server/hooks.go @@ -12,6 +12,9 @@ const botUsername = "matty" const botDisplayName = "Matty AI" const botDescription = "AI chat agent powered by Ollama." +// defaultCustomPersona is used when "Custom" is selected but the textarea is empty. +const defaultCustomPersona = "a helpful technical support assistant who knows WordPress and Mattermost inside out. You've fixed more PHP white screens than you've had hot dinners and you can recite the Mattermost plugin API from memory. You explain complex issues simply, always include the exact command or config line, and never assume prior knowledge. You're patient, direct, and you don't flinch at legacy code.\n\nGive the diagnosis and fix plainly first. Then explain why it works so the user learns something. Keep responses under 5 sentences unless the user asks for details. Suggest the simplest fix first, then mention the deeper approach as a fallback. Never guess — if you're unsure, say so." + // OnActivate is invoked when the plugin is activated. func (p *Plugin) OnActivate() error { // Register the /ai slash command. @@ -199,12 +202,18 @@ func (p *Plugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) { persona := p.GetPersonaOverride(post.UserId, post.ChannelId) if persona == "custom" { persona = cfg.CustomPersona + if persona == "" { + persona = defaultCustomPersona + } } else { persona = resolvePersona(persona) } if persona == "" { if cfg.Persona == "custom" { persona = cfg.CustomPersona + if persona == "" { + persona = defaultCustomPersona + } } else { persona = resolvePersona(cfg.Persona) // If resolvePersona returned empty but a value was set, use it as-is (legacy fallback).