mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-22 10:57:27 +02:00
修复多会话任务栏抖动、会话跳回与停止失效 (#264)
* fix(web): stabilize active task ordering * fix(chat): preserve navigation during conversation startup * fix(tasks): guarantee hard cancellation * fix(chat): bind navigation and hard stop targets * fix(chat): prevent replay from reclaiming navigation
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetActiveTasksUsesStableCreationOrder(t *testing.T) {
|
||||
m := NewAgentTaskManager()
|
||||
started := time.Date(2026, 8, 19, 10, 0, 0, 0, time.UTC)
|
||||
m.mu.Lock()
|
||||
m.tasks = map[string]*AgentTask{
|
||||
"conversation-z": {ConversationID: "conversation-z", StartedAt: started, Status: "running"},
|
||||
"conversation-late": {ConversationID: "conversation-late", StartedAt: started.Add(time.Minute), Status: "running"},
|
||||
"conversation-a": {ConversationID: "conversation-a", StartedAt: started, Status: "running"},
|
||||
}
|
||||
m.mu.Unlock()
|
||||
|
||||
want := []string{"conversation-a", "conversation-z", "conversation-late"}
|
||||
for attempt := 0; attempt < 20; attempt++ {
|
||||
gotTasks := m.GetActiveTasks()
|
||||
if len(gotTasks) != len(want) {
|
||||
t.Fatalf("GetActiveTasks() length = %d, want %d", len(gotTasks), len(want))
|
||||
}
|
||||
for i, task := range gotTasks {
|
||||
if task.ConversationID != want[i] {
|
||||
t.Fatalf("attempt %d order[%d] = %q, want %q", attempt, i, task.ConversationID, want[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user