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.
test(computer): hold fake stream EOF until Operation inputs settle
LeoXing2d1e6547434c
diff --git a/apps/computer/local-daemon/internal/daemon/daemon_test.go b/apps/computer/local-daemon/internal/daemon/daemon_test.goindex 5d169e27..3d2d463d 100644--- a/apps/computer/local-daemon/internal/daemon/daemon_test.go+++ b/apps/computer/local-daemon/internal/daemon/daemon_test.go@@ -1098,6 +1098,7 @@ func TestDaemonAppliesOperationInputAndRecordsAcknowledgement(t *testing.T) {t.Fatal(err)}stream.beforeCommand = gateInputUntilStarted(daemon)+ stream.idle = operationInputsSettled(daemon)daemon.daemonID = device.DaemonIDif err := daemon.runConnection(context.Background(), device); !errors.Is(err, io.EOF) {t.Fatalf("runConnection() error = %v, want EOF", err)@@ -1162,6 +1163,7 @@ func TestDaemonReplaysOperationInputOutcomeWithoutSteeringTwice(t *testing.T) {t.Fatal(err)}stream.beforeCommand = gateInputUntilStarted(daemon)+ stream.idle = operationInputsSettled(daemon)daemon.daemonID = device.DaemonIDif err := daemon.runConnection(context.Background(), device); !errors.Is(err, io.EOF) {t.Fatalf("runConnection() error = %v, want EOF", err)@@ -1275,6 +1277,7 @@ func TestDaemonAcceptsRetainedOperationInputAfterConnectionEpochChanges(t *testiinput.InputContextViewRef = viewRefsecond := &fakeStream{commands: []protocol.Command{{Type: "runner.welcome", ConnectionEpoch: 2}, input}}second.beforeCommand = gateInputUntilStarted(daemon)+ second.idle = operationInputsSettled(daemon)daemon.controlPlane = fakeControlPlane{stream: second}if err := daemon.runConnection(context.Background(), device); !errors.Is(err, io.EOF) {t.Fatalf("second connection error = %v, want EOF", err)@@ -1964,6 +1967,32 @@ func operationExecutionPending(d *Daemon) bool {return false}+// operationInputsSettled holds a fake stream's EOF until dispatch work is idle+// and every accepted Operation input has recorded its outcome: an input's+// Context View fetch ends with its connection, so an early EOF rejects it.+func operationInputsSettled(d *Daemon) func() bool {+ idle := dispatchIdle(d)+ return func() bool { return idle() && !operationInputPending(d) }+}++func operationInputPending(d *Daemon) bool {+ d.activeMu.Lock()+ actives := make([]*activeOperation, 0, len(d.activeOperations))+ for _, active := range d.activeOperations {+ actives = append(actives, active)+ }+ d.activeMu.Unlock()+ for _, active := range actives {+ active.inputMu.Lock()+ pending := len(active.pendingInputs)+ active.inputMu.Unlock()+ if pending > 0 {+ return true+ }+ }+ return false+}+// awaitOperationStarted waits for the Provider start of every admitted Operation.func awaitOperationStarted(t *testing.T, d *Daemon) {t.Helper()