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): report a tab change behind the front tab neutrally
jeffrey399084c4bc03
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.mdindex 97fd7471..06b1a47e 100644--- a/apps/computer/local-daemon/README.md+++ b/apps/computer/local-daemon/README.md@@ -375,10 +375,13 @@ the task; `rate_limited` also puts the site (its registrable domain) in a60-minute cooldown. The record lives in `computer-tools/agent-chrome-pace.json`.Once a task opens a site there, the browser tools refuse that site for therest of the task, and `launch_app` refuses to open it in another browser.-A change in the number of tabs between the task's inputs stops the task with-`COMPUTER_TAB_CHANGED`, because the next input could reach another page. The-Daemon reads the tab strip before an input only when the window's title in-`list_windows` differs from the front tab's title after the last input; after+A change of the front tab between the task's inputs that also changed the+number of tabs stops the task with `COMPUTER_TAB_CHANGED`, because the next+input could reach another page. The Daemon reads the tab strip before an input+only when the window's title in `list_windows` differs from the front tab's+title after the last input, so a tab opened or closed behind the front tab+does not stop the task: the input still reaches the task's page, and its+result reports the new count without saying the input changed it; afteran input it reads the strip only to its depth, unless a script returned readsthe Agent may act on, and not at all after a script that sent no input. Atab that the task's own input or script opens or closes is the task's: thediff --git a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.goindex 080736f8..07b6854e 100644--- a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go+++ b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go@@ -777,6 +777,11 @@ func (c *cuaSession) recordAgentChromeTabs(ctx context.Context, pid, window any,c.op.chromeTabs, c.op.chromeTitle = got, frontc.op.mu.Unlock()switch {+ case got != before && front == title:+ // The front tab is the one the input went to. A tab opened or+ // closed behind it may be someone else's, since the check before+ // the input reads the strip only when the front tab changed.+ return fmt.Sprintf("The window now has %d tab(s), %d before this input; the tab in front still shows %q.", got, before, front)case got > before && close != "":// The tab strip follows the page in the tree, past the default// walk, so the Agent's search for the button came back empty.diff --git a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.goindex fcff87db..82db818d 100644--- a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go+++ b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go@@ -1250,6 +1250,16 @@ func TestLocalToolCuaMacAgentChromeReadsTheTabStripOnlyAsFarAsItNeeds(t *testingif got := reads()[before:]; !slices.Equal(got, []string{"run_script", "6", "6"}) {t.Fatalf("calls for a script that clicked=%v, want two bounded reads after it", got)}+ // A tab closed behind the front tab does not stop the task, and the+ // result reports the count without saying the input closed it.+ c.op.chromeTabs = 2+ result, err := c.call(t.Context(), "click", json.RawMessage(`{"pid":42,"window_id":9,"element_token":"s1:1"}`))+ if err != nil {+ t.Fatal(err)+ }+ if note := `The window now has 1 tab(s), 2 before this input; the tab in front still shows \"Tab 0\".`; !strings.Contains(string(result), note) || strings.Contains(string(result), "This input closed") {+ t.Fatalf("result=%s, want the neutral note %s", result, note)+ }// A front tab that changed since the last input is read whole first.c.op.chromeTitle = "Elsewhere"if _, err := c.call(t.Context(), "click", json.RawMessage(`{"pid":42,"window_id":9,"element_token":"s1:1"}`)); err != nil {