fix(ui): Fix SSE in chat

This commit is contained in:
Richard Palethorpe
2025-04-01 08:43:12 +01:00
parent 1f8c601795
commit ab3e6ae3c8
3 changed files with 29 additions and 21 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"path/filepath"
"strings"
"time"
@@ -215,7 +216,7 @@ func (a *App) ImportAgent(pool *state.AgentPool) func(c *fiber.Ctx) error {
os.MkdirAll("./uploads", os.ModePerm)
// Safely save the file to prevent path traversal
destination := fmt.Sprintf("./uploads/%s", file.Filename)
destination := filepath.Join("./uploads", file.Filename)
if err := c.SaveFile(file, destination); err != nil {
// Handle error
return err
@@ -385,7 +386,7 @@ func (a *App) ChatAPI(pool *state.AgentPool) func(c *fiber.Ctx) error {
xlog.Error("Error marshaling error message", "error", err)
} else {
manager.Send(
sse.NewMessage(string(errorData)).WithEvent("error"))
sse.NewMessage(string(errorData)).WithEvent("json_error"))
}
} else {
// Send agent response