"
var templateMessages []TemplateMessage
@@ -174,7 +175,7 @@ func GetUserMessageHandler(c *fiber.Ctx) error {
messageUUID, _ := edgedb.ParseUUID(id)
var selectedMessage Message
- err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(context.Background(), `
+ err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(edgeCtx, `
SELECT Message {
content
}
@@ -199,12 +200,24 @@ func GetMessageContentHandler(c *fiber.Ctx) error {
messageId := c.FormValue("id")
onlyContent := c.FormValue("onlyContent") // To init the text area of the edit message form
+ out := GenerateMessageContentHTML(c.Cookies("jade-edgedb-auth-token"), messageId, onlyContent, false)
+
+ return c.SendString(out)
+}
+
+func GenerateMessageContentHTML(authCookie string, messageId string, onlyContent string, withDiv bool) string {
+ fmt.Println("Generating message for:", authCookie)
+
messageUUID, _ := edgedb.ParseUUID(messageId)
var selectedMessage Message
- err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(context.Background(), `
+ err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": authCookie}).QuerySingle(edgeCtx, `
SELECT Message {
content,
+ area: {
+ id,
+ position,
+ },
llm : {
name,
modelInfo : {
@@ -221,10 +234,18 @@ func GetMessageContentHandler(c *fiber.Ctx) error {
}
if onlyContent == "true" {
- return c.SendString(markdownToHTML(selectedMessage.Content))
+ return markdownToHTML(selectedMessage.Content)
}
- out := "