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 replied Run is working again when a follow-up joins it
jeffrey526754b64944
diff --git a/apps/teamhub/internal/agentruntimestate/steer.go b/apps/teamhub/internal/agentruntimestate/steer.goindex 2572f9b0..f2e8139c 100644--- a/apps/teamhub/internal/agentruntimestate/steer.go+++ b/apps/teamhub/internal/agentruntimestate/steer.go@@ -114,6 +114,18 @@ func (s *Service) AssignSteerRun(ctx context.Context, input AssignSteerRunInput)ordinal++}}+ // A follow-up newer than the Run's reply takes that reply back, but+ // the Run may add no event before it replies again. Announcing the+ // status now lets the Room show its Agent working on the follow-up.+ log, err := openRunStatusLog(ctx, queries, input.RunID)+ if err != nil {+ return false, err+ }+ if log != nil && !log.stopped() {+ if err := log.publish(ctx, queries); err != nil {+ return false, err+ }+ }if _, err := queries.BumpAgentExecutionContextStateRevision(ctx, input.ContextKey); err != nil {return false, err}diff --git a/apps/teamhub/tests/integration/room_run_replied_test.go b/apps/teamhub/tests/integration/room_run_replied_test.goindex 21d92312..e89f767b 100644--- a/apps/teamhub/tests/integration/room_run_replied_test.go+++ b/apps/teamhub/tests/integration/room_run_replied_test.go@@ -7,6 +7,7 @@ import ("slices""testing"+ "github.com/jackc/pgx/v5/pgxpool""github.com/simplexai-labs/linger/apps/teamhub/internal/agentruntimestate""github.com/simplexai-labs/linger/apps/teamhub/internal/realtime""github.com/simplexai-labs/linger/apps/teamhub/internal/store"@@ -134,6 +135,31 @@ func TestRunStopsWorkingOnceItReplied(t *testing.T) {working(false)// A follow-up newer than the reply is work the Agent has not answered.- acceptTrustedSteerGroup(t, env, runID, "run-replied-follow-up", "steer-run-replied")+ if !lastRunStatusAnnouncementReplied(t, env.pool, roomID, runID) {+ t.Fatal("the Room was not told the Run replied")+ }+ group := acceptTrustedSteerGroup(t, env, runID, "run-replied-follow-up", "steer-run-replied")working(true)+ // The Agent may answer it without another event, so taking the follow-up+ // tells the Room the Run is working again.+ if err := env.service.AssignSteerRun(ctx, agentruntimestate.AssignSteerRunInput{ContextKey: env.contextKey, Epoch: env.epoch, GroupID: group, RunID: runID}); err != nil {+ t.Fatalf("assign steer: %v", err)+ }+ if lastRunStatusAnnouncementReplied(t, env.pool, roomID, runID) {+ t.Fatal("the Room was not told the follow-up took back the reply")+ }+}++// lastRunStatusAnnouncementReplied returns whether the Run's latest+// agent_run.status_changed Room Event says it replied.+func lastRunStatusAnnouncementReplied(t *testing.T, pool *pgxpool.Pool, roomID, runID string) bool {+ t.Helper()+ var replied bool+ if err := pool.QueryRow(t.Context(), `+ SELECT (payload->'run'->>'replied')::boolean FROM room_events+ WHERE room_id=$1 AND event_type='agent_run.status_changed' AND resource_id=$2+ ORDER BY room_seq DESC LIMIT 1`, roomID, runID).Scan(&replied); err != nil {+ t.Fatal(err)+ }+ return replied}