This commit is contained in:
Ian Gulliver
2026-10-16 09:51:32 -07:00
parent 59c2b2cb9c
commit 48ef2d6bb5
12 changed files with 343 additions and 192 deletions
+33 -1
View File
@@ -42,6 +42,10 @@ func leadActor(login string) string {
return login + " (lead)"
}
func humanActor(actor string) bool {
return actor != "byre" && actor != agentActor && !strings.HasSuffix(actor, leadActor(""))
}
func (m *Manager) LeadSessions(ctx context.Context, owner string) ([]api.AgentSession, error) {
return m.store.LeadSessions(ctx, owner)
}
@@ -199,7 +203,7 @@ func (m *Manager) leadStateText(ctx context.Context, owner string) (string, erro
pane = fmt.Sprintf("Your right pane shows project %s (%s) on its %s tab.", project.Name, project.Id, f.Tab)
}
m.mu.Lock()
focused := m.paneFocused[owner]
focused := m.paneFocus[owner].Focused
m.mu.Unlock()
if focused {
pane += " The human is working in it."
@@ -313,6 +317,10 @@ func (m *Manager) warnLeadContext(ctx context.Context, l *live) error {
func (m *Manager) Observe(ev api.Event) {
switch ev.Kind {
case "inbox.created", "inbox.updated", "task.created", "task.merge_started", "task.merged", "task.discarded", "turn.ended", "task.workflow_stage", "task.workflow_finished":
case "user.message":
if ev.TaskId == nil || !humanActor(ev.Actor) {
return
}
default:
return
}
@@ -370,6 +378,9 @@ func (m *Manager) signal(ctx context.Context, ev api.Event) error {
}
func (m *Manager) freedText(ctx context.Context, owner string, ev api.Event) (string, error) {
if ev.Kind == "user.message" {
return m.waitingText(ctx, owner, ev)
}
switch ev.Kind {
case "inbox.updated", "task.merge_started", "task.merged", "task.discarded":
default:
@@ -392,6 +403,24 @@ func (m *Manager) freedText(ctx context.Context, owner string, ev api.Event) (st
return fmt.Sprintf("Your right pane is free: %s %s.", m.taskLabel(ctx, *f.TaskId), finished), nil
}
func (m *Manager) waitingText(ctx context.Context, owner string, ev api.Event) (string, error) {
if ev.Actor != owner {
return "", nil
}
f, err := m.store.GetFocus(ctx, owner)
if err != nil {
return "", err
}
if f.TaskId == nil || *f.TaskId != deref(ev.TaskId) {
return "", nil
}
waiting, err := m.paneWaiting(ctx, owner, f)
if err != nil || !waiting {
return "", err
}
return fmt.Sprintf("Your right pane is free: the human is waiting on %s's agent.", m.taskLabel(ctx, *f.TaskId)), nil
}
func (m *Manager) taskLabel(ctx context.Context, taskID string) string {
task, err := m.store.GetTask(ctx, taskID)
if err != nil {
@@ -450,6 +479,9 @@ func (m *Manager) signalText(ctx context.Context, ev api.Event) (string, error)
case "task.workflow_finished":
return fmt.Sprintf("%s finished workflow %q:\n%s", m.taskLabel(ctx, deref(ev.TaskId)), ev.Payload["workflow"], clip(fmt.Sprint(ev.Payload["output"]), 1500)), nil
case "user.message":
return fmt.Sprintf("%s sent %s a message; its agent is working on it.", ev.Actor, m.taskLabel(ctx, deref(ev.TaskId))), nil
case "turn.ended":
if ev.Payload["summary"] != true {
return "", nil