mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-10-15 01:12:06 +00:00
render AI agent replies as markdown and fix assistant identity, handoff, and stats bugs
Replies from the AI agent are now converted from markdown to HTML with goldmark before queueing, so bold, links, and lists render properly in the widget, agent app, and email. The prompt now allows simple markdown. Raw HTML in model output is escaped by goldmark, and both frontends sanitize on render anyway. Other fixes bundled in: - validate avatar type and size before creating or updating an assistant, and roll back the assistant if the avatar upload fails after create - return 404 from agent update and API key endpoints for AI assistant identity users, and hide assistants from mention and SLA user pickers - reserve the autonomous assistant's built-in tool names so custom tools cannot shadow them - apply resolve after the reply is posted so the CSAT survey follows the answer instead of preceding it - unassign the assistant on handoff even when the fallback team is the same team - count reopens by status category instead of status name, and exclude CSAT messages from the turn cap - split oversized wrapper divs into child blocks when chunking KB HTML instead of truncating them - return 404 when soft-deleting an already-deleted agent, and keep AI assistants (which have no email) visible in the compact users list
This commit is contained in:
@@ -193,6 +193,17 @@ func TestChunkHTMLContent_EdgeCases(t *testing.T) {
|
||||
config: newTestConfig(50, 20, 10),
|
||||
expectedChunks: 1, // Should truncate oversized content to fit max tokens
|
||||
},
|
||||
{
|
||||
name: "Oversized Wrapper Div Splits Into Children",
|
||||
html: "<div>" + strings.Repeat("<p>"+strings.Repeat("word ", 100)+"</p>", 10) + "</div>",
|
||||
config: newTestConfig(150, 20, 10),
|
||||
validate: func(t *testing.T, chunks []string) {
|
||||
assert.Greater(t, len(chunks), 1, "Wrapper div content should be split, not truncated to one chunk")
|
||||
full := strings.Join(chunks, " ")
|
||||
assert.Greater(t, len(full), 4000, "Most of the wrapped content should survive chunking")
|
||||
},
|
||||
expectedChunks: -1, // Validated via validate func
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@@ -203,7 +214,9 @@ func TestChunkHTMLContent_EdgeCases(t *testing.T) {
|
||||
assert.Contains(t, err.Error(), tc.expectedError)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, chunks, tc.expectedChunks)
|
||||
if tc.expectedChunks >= 0 {
|
||||
assert.Len(t, chunks, tc.expectedChunks)
|
||||
}
|
||||
if tc.validate != nil {
|
||||
tc.validate(t, chunks)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user