Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(teamhub): tell the Room a Run replied again when its follow-up moves

jeffrey00f4881ee7c2
diff --git a/apps/teamhub/internal/agentruntimestate/steer.go b/apps/teamhub/internal/agentruntimestate/steer.go
index f2e8139c..5a18b479 100644
--- a/apps/teamhub/internal/agentruntimestate/steer.go
+++ b/apps/teamhub/internal/agentruntimestate/steer.go
@@ -47,6 +47,25 @@ func (s *Service) EnqueueSteer(ctx context.Context, input EnqueueSteerInput) (En
if err != nil {
return EnqueueSteerResult{}, err
}
+ // A Run the follow-up was assigned to announced it was working on it.
+ // Moving the follow-up to a new Run may leave that Run replied again,
+ // and it may add no event before it stops, so announce it now.
+ assigned := map[string]bool{}
+ for _, row := range rows {
+ if !row.LocalRunID.Valid || assigned[row.LocalRunID.String] {
+ continue
+ }
+ assigned[row.LocalRunID.String] = true
+ log, err := openRunStatusLog(ctx, queries, row.LocalRunID.String)
+ if err != nil {
+ return EnqueueSteerResult{}, err
+ }
+ if log != nil && !log.stopped() {
+ if err := log.publish(ctx, queries); err != nil {
+ return EnqueueSteerResult{}, err
+ }
+ }
+ }
if _, err := queries.BumpAgentExecutionContextStateRevision(ctx, input.ContextKey); err != nil {
return EnqueueSteerResult{}, err
}
diff --git a/apps/teamhub/tests/integration/room_run_replied_test.go b/apps/teamhub/tests/integration/room_run_replied_test.go
index e89f767b..68985c03 100644
--- a/apps/teamhub/tests/integration/room_run_replied_test.go
+++ b/apps/teamhub/tests/integration/room_run_replied_test.go
@@ -148,6 +148,15 @@ func TestRunStopsWorkingOnceItReplied(t *testing.T) {
if lastRunStatusAnnouncementReplied(t, env.pool, roomID, runID) {
t.Fatal("the Room was not told the follow-up took back the reply")
}
+ // The provider refused the steer, so the follow-up moves to a Run of its
+ // own and the first Run is back to its reply.
+ queued, err := env.service.EnqueueSteer(ctx, agentruntimestate.EnqueueSteerInput{ContextKey: env.contextKey, Epoch: env.epoch, GroupID: group})
+ if err != nil || queued.RunID == "" || queued.RunID == runID {
+ t.Fatalf("enqueue steer: result=%+v err=%v", queued, err)
+ }
+ if !lastRunStatusAnnouncementReplied(t, env.pool, roomID, runID) {
+ t.Fatal("the Room was not told the Run replied again once the follow-up moved")
+ }
}
// lastRunStatusAnnouncementReplied returns whether the Run's latest