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(computer): free a restored action record once its file is removed
jeffreyda77c94fedf2
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.mdindex a269755f..73d8ecb1 100644--- a/apps/computer/local-daemon/README.md+++ b/apps/computer/local-daemon/README.md@@ -354,8 +354,9 @@ desktop input of that kind blocks browser calls, so does a record that anolder Daemon left without saying which kind it was. Such a call returns`COMPUTER_ACTION_UNKNOWN` and names the Agent and the record file that blocks it.A record that an earlier Daemon left has no task here to settle it; the error-says so, and removing that file once the action is known to be finished frees-the desktop. An unknown action on a whole everyday Chrome profile, left before+says so. Removing that file once the action is known to be finished frees its+desktop, Agent browser or seat at the next call, with no restart. A record of+this Daemon's own task still settles only through that task. An unknown action on a whole everyday Chrome profile, left beforethe extension kept many clients, also blocks every seat of that profile. After acancellation, the original connection must confirm that the Cua session wascleaned up; the exit of a shared service's proxy process does not count, and adiff --git a/apps/computer/local-daemon/internal/linger/localtools/journal.go b/apps/computer/local-daemon/internal/linger/localtools/journal.goindex 709e98e5..565b1456 100644--- a/apps/computer/local-daemon/internal/linger/localtools/journal.go+++ b/apps/computer/local-daemon/internal/linger/localtools/journal.go@@ -31,7 +31,8 @@ type actionJournal struct {path stringactive *actionIdentity// restored marks an active record read from disk: an earlier Daemon left- // it, so no task of this one holds its receipt.+ // it, so no task of this one holds its receipt. Only the user settles it,+ // by removing the file once they know the action finished.restored boolslot chan struct{}}@@ -80,7 +81,7 @@ func (j *actionJournal) begin(ctx context.Context, identity actionIdentity) (*ac<-j.slotreturn nil, context.Cause(ctx)}- if j.active != nil {+ if j.pendingLocked() {<-j.slotreturn nil, errors.New("COMPUTER_ACTION_UNKNOWN: an earlier action has no verified cleanup receipt; this desktop, Agent browser or everyday Chrome seat stays blocked until it settles")}@@ -150,11 +151,11 @@ func (r *actionReceipt) finish(confirmed bool) error {func (j *actionJournal) unknownAction() string {j.mu.Lock()defer j.mu.Unlock()- if j.active == nil {+ if !j.pendingLocked() {return ""}if j.restored {- return fmt.Sprintf("Agent %q left it in %s before the Daemon restarted; no task settles it; the user removes that file once they know the action finished", j.active.AgentID, j.path)+ return fmt.Sprintf("Agent %q left it in %s before the Daemon restarted; no task settles it; remove that file once the action is known to be finished", j.active.AgentID, j.path)}return fmt.Sprintf("Agent %q left it in %s; it settles when that task ends", j.active.AgentID, j.path)}@@ -162,7 +163,23 @@ func (j *actionJournal) unknownAction() string {func (j *actionJournal) blocked() bool {j.mu.Lock()defer j.mu.Unlock()- return j.active != nil+ return j.pendingLocked()+}++// pendingLocked reports an active record. A restored record whose file the+// user removed is dropped; any other failure to look keeps it. The caller+// holds j.mu.+func (j *actionJournal) pendingLocked() bool {+ if j.active == nil {+ return false+ }+ if j.restored {+ if _, err := os.Lstat(j.path); errors.Is(err, os.ErrNotExist) {+ j.active, j.restored = nil, false+ return false+ }+ }+ return true}// blocksFocus reports an unknown desktop input that a browser call bringing@@ -170,5 +187,5 @@ func (j *actionJournal) blocked() bool {func (j *actionJournal) blocksFocus() bool {j.mu.Lock()defer j.mu.Unlock()- return j.active != nil && !j.active.Background+ return j.pendingLocked() && !j.active.Background}diff --git a/apps/computer/local-daemon/internal/linger/localtools/lanes_test.go b/apps/computer/local-daemon/internal/linger/localtools/lanes_test.goindex dcd585cb..4ddccc52 100644--- a/apps/computer/local-daemon/internal/linger/localtools/lanes_test.go+++ b/apps/computer/local-daemon/internal/linger/localtools/lanes_test.go@@ -318,6 +318,21 @@ func TestLaneRecordsSurviveRestartPerLane(t *testing.T) {if _, _, err := restarted.holdFocusedInput(t.Context()); err == nil || !strings.Contains(err.Error(), "before the Daemon restarted") || !strings.Contains(err.Error(), browserJournalPrefix) {t.Fatalf("focused desktop input after a restart left browser records: %v", err)}+ // Removing the files once the actions are known to be finished frees the+ // lane, the seat and focused desktop input without another restart.+ for _, lane := range []string{browserLane("a"), chromeProfileJournal("Default")} {+ if err := os.Remove(laneJournal(t, restarted, lane).path); err != nil {+ t.Fatal(err)+ }+ }+ if laneBlocked(t, restarted, browserLane("a")) || laneBlocked(t, restarted, chromeProfileJournal("Default")) {+ t.Fatal("a removed record still blocked its lane")+ }+ _, release, err := restarted.holdFocusedInput(t.Context())+ if err != nil {+ t.Fatalf("focused desktop input stayed blocked after the records were removed: %v", err)+ }+ release()// A settled record leaves no file behind.journal, _ := restarted.namedJournal(browserLane("b"))receipt, err := journal.begin(t.Context(), actionIdentity{AgentID: "b", OperationID: "op", Session: "s"})