diff --git a/server/command.go b/server/command.go index 5cb0dd3..46f9df2 100644 --- a/server/command.go +++ b/server/command.go @@ -30,7 +30,17 @@ Also works with /ai . /ai new clears memory. ` // ExecuteCommand handles slash commands (/ai, /resetmatterless). -func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) { +func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (resp *model.CommandResponse, err *model.AppError) { + defer func() { + if r := recover(); r != nil { + p.API.LogError("ExecuteCommand panic", "recover", fmt.Sprintf("%v", r)) + resp = &model.CommandResponse{ + ResponseType: model.CommandResponseTypeEphemeral, + Text: "Command failed due to an internal error. Check server logs for details.", + } + } + }() + // /ai — dispatch subcommands. trigger := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(args.Command), "/ai")) parts := parseArgs(trigger)