Lock the right pane while focused, add project focus, quiet lead
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package agents_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -66,8 +67,61 @@ func TestLeadSignalsAndShow(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("get focus: %v", err)
|
||||
}
|
||||
if f.TaskId == nil || *f.TaskId != e.task.Id || f.Tab != api.TabInbox {
|
||||
if f.TaskId == nil || *f.TaskId != e.task.Id || f.ProjectId == nil || *f.ProjectId != e.project.Id || f.Tab != api.TabInbox {
|
||||
t.Fatalf("focus %+v", f)
|
||||
}
|
||||
e.waitFor("lead idle after show", leadIdle)
|
||||
|
||||
m.SetPaneFocus(login, true)
|
||||
_, err = m.MessageLead(e.ctx, e.user, "Call the show tool with task_id "+e.task.Id+", tabs [\"changes\"] and tab \"changes\". Then say done.", "", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("message lead: %v", err)
|
||||
}
|
||||
e.waitFor("show refused", func(ev api.Event) bool {
|
||||
return ev.Kind == "agent.tool_result" && ev.Owner != nil && strings.Contains(fmt.Sprint(ev.Payload), "working in the right pane")
|
||||
})
|
||||
e.waitFor("lead idle after refused show", leadIdle)
|
||||
f, err = e.store.GetFocus(e.ctx, login)
|
||||
if err != nil {
|
||||
t.Fatalf("get focus: %v", err)
|
||||
}
|
||||
if f.Tab != api.TabInbox {
|
||||
t.Fatalf("focus moved while the pane was focused: %+v", f)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFocusProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
e := newEnv(t)
|
||||
m := e.manager()
|
||||
|
||||
err := m.SetFocus(e.ctx, login, api.Focus{ProjectId: &e.project.Id, Tabs: []api.TaskTab{api.TabTodo}, Tab: api.TabTodo}, login)
|
||||
if err != nil {
|
||||
t.Fatalf("focus project: %v", err)
|
||||
}
|
||||
f, err := e.store.GetFocus(e.ctx, login)
|
||||
if err != nil {
|
||||
t.Fatalf("get focus: %v", err)
|
||||
}
|
||||
if f.TaskId != nil || f.ProjectId == nil || *f.ProjectId != e.project.Id || f.Tab != api.TabTodo {
|
||||
t.Fatalf("focus %+v", f)
|
||||
}
|
||||
|
||||
other := "nope"
|
||||
err = m.SetFocus(e.ctx, login, api.Focus{TaskId: &e.task.Id, ProjectId: &other, Tabs: []api.TaskTab{}, Tab: api.TabTranscript}, login)
|
||||
if err != nil {
|
||||
t.Fatalf("focus task: %v", err)
|
||||
}
|
||||
f, err = e.store.GetFocus(e.ctx, login)
|
||||
if err != nil {
|
||||
t.Fatalf("get focus: %v", err)
|
||||
}
|
||||
if f.TaskId == nil || *f.TaskId != e.task.Id || f.ProjectId == nil || *f.ProjectId != e.project.Id {
|
||||
t.Fatalf("focus %+v", f)
|
||||
}
|
||||
|
||||
err = m.SetFocus(e.ctx, login, api.Focus{ProjectId: &other, Tabs: []api.TaskTab{}, Tab: api.TabTodo}, login)
|
||||
if err == nil {
|
||||
t.Fatal("focus on an unknown project was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user