fix(server): resolve latest available agent thread
This commit is contained in:
@@ -8,20 +8,24 @@ import (
|
||||
"img_infinite_canvas/internal/types"
|
||||
)
|
||||
|
||||
func latestLovartThreadID(project design.Project) string {
|
||||
if threadID := strings.TrimSpace(project.LastThreadID); threadID != "" {
|
||||
return threadID
|
||||
}
|
||||
for index := len(project.Messages) - 1; index >= 0; index-- {
|
||||
message := project.Messages[index]
|
||||
if isHiddenAgentMessage(message) {
|
||||
func latestLovartThreadID(currentThreadID string, threads []design.AgentThreadSummary) string {
|
||||
currentThreadID = strings.TrimSpace(currentThreadID)
|
||||
latestThreadID := ""
|
||||
var latestTimestamp int64
|
||||
for _, thread := range threads {
|
||||
threadID := strings.TrimSpace(thread.AgentThreadID)
|
||||
if threadID == "" {
|
||||
continue
|
||||
}
|
||||
if threadID := strings.TrimSpace(message.ThreadID); threadID != "" {
|
||||
if threadID == currentThreadID {
|
||||
return threadID
|
||||
}
|
||||
if latestThreadID == "" || thread.UpdateTimestamp >= latestTimestamp {
|
||||
latestThreadID = threadID
|
||||
latestTimestamp = thread.UpdateTimestamp
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return latestThreadID
|
||||
}
|
||||
|
||||
func toCandaChatHistoryItem(message design.Message, projectID string, threadID string) types.CandaChatHistoryItem {
|
||||
|
||||
Reference in New Issue
Block a user