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(computer): keep the front tab title from launch_app

jeffrey16a14613f49c
diff --git a/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go b/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go
index 0102fe34..c4ed7799 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go
@@ -247,9 +247,9 @@ func (c *cuaSession) launchAgentSafari(ctx context.Context, b agentBrowser, urls
return nil, err
}
}
- tabs := c.agentChromeTabs(ctx, pid, window.WindowID)
+ tabs, title, _ := c.agentChromeTabsAndTitle(ctx, pid, window.WindowID)
c.op.mu.Lock()
- c.op.chromeTabs, c.op.chromePID, c.op.chromeWindow = tabs, pid, window.WindowID
+ c.op.chromeTabs, c.op.chromeTitle, c.op.chromePID, c.op.chromeWindow = tabs, title, pid, window.WindowID
c.op.mu.Unlock()
note := "This is the Computer's own window in the user's Safari. Safari has no separate profile, so this window has the user's Safari sign-ins; work only in this window, never in the user's other Safari windows. It works while other windows cover it, but only on the desktop (Space) the user is on. Keys without an element go to this window in the background. Type into a page field with type_text and the field's element_token. Move between pages as a person does: through the page's search box, menus and links, back with cmd+[; never type an address into the address bar. Close a tab with its tab's close action, not cmd+w."
if started {
@@ -413,8 +413,11 @@ func (c *cuaSession) launchEverydayChrome(ctx context.Context, b agentBrowser, u
return nil, err
}
m.setSharedWindow(b.Bundle, pid, window.WindowID)
+ // The front tab's title, so the first input reports only a change it
+ // made; the window search above keeps no title.
+ _, title, _ := c.agentChromeTabsAndTitle(ctx, pid, window.WindowID)
c.op.mu.Lock()
- c.op.chromeTabs, c.op.chromePID, c.op.chromeWindow = tabs, pid, window.WindowID
+ c.op.chromeTabs, c.op.chromeTitle, c.op.chromePID, c.op.chromeWindow = tabs, title, pid, window.WindowID
c.op.mu.Unlock()
note := "This is the Computer's own window in the user's everyday Chrome, with the user's sign-ins; work only in this window, never in the user's other Chrome windows. It works while other windows cover it, but only on the desktop (Space) the user is on. The user's Chrome takes no keys from the Computer, because a key could reach the window the user is typing in: fill a field with set_value, press the page's own buttons, such as its search button, and go back through the page's links. Close a tab with the Close button of its tab; closing the window's last tab closes the window. If a site asks to sign in, ask the user to sign in once in this window."
if restored {
diff --git a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go
index 36c8f9b9..fec93667 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go
@@ -195,9 +195,9 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urls
m.mu.Lock()
m.agentChromePID, m.agentChromeChecked = pid, time.Now()
m.mu.Unlock()
- tabs = c.agentChromeTabs(ctx, pid, window.WindowID)
+ tabs, title, _ := c.agentChromeTabsAndTitle(ctx, pid, window.WindowID)
c.op.mu.Lock()
- c.op.chromeTabs, c.op.chromePID, c.op.chromeWindow = tabs, pid, window.WindowID
+ c.op.chromeTabs, c.op.chromeTitle, c.op.chromePID, c.op.chromeWindow = tabs, title, pid, window.WindowID
c.op.mu.Unlock()
opened := "No URL was opened, so no tab is this task's."
if len(urls) > 0 {
diff --git a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go
index 8c7f8928..027736a8 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go
@@ -1998,8 +1998,13 @@ func TestLocalToolCuaMacEverydayChromeOpensTheComputersWindowAndTakesNoKeys(t *t
if _, err := c.call(t.Context(), "hotkey", json.RawMessage(`{"keys":["cmd","w"],"element_token":"s7:1"}`)); !strings.Contains(fmt.Sprint(err), "COMPUTER_TARGET_REQUIRED") {
t.Fatalf("hotkey with no pid: err=%v, want refused", err)
}
- if _, err := c.call(t.Context(), "set_value", json.RawMessage(`{"pid":42,"window_id":12,"value":"kettle","element_token":"s1:1"}`)); err != nil {
- t.Fatalf("set_value: %v", err)
+ // launch_app keeps the front tab's title, so the first input, which
+ // changes no tab, reports no change.
+ if c.op.chromeTitle != "Tab 0" {
+ t.Fatalf("front title after launch_app=%q, want Tab 0", c.op.chromeTitle)
+ }
+ if result, err := c.call(t.Context(), "set_value", json.RawMessage(`{"pid":42,"window_id":12,"value":"kettle","element_token":"s1:1"}`)); err != nil || strings.Contains(string(result), "tab in front") {
+ t.Fatalf("set_value result=%s err=%v, want no tab note", result, err)
}
// Any script, whatever it targets, is guarded against keys to the
// user's Chrome.
diff --git a/apps/computer/local-daemon/internal/linger/localtools/manager.go b/apps/computer/local-daemon/internal/linger/localtools/manager.go
index e031fe87..26393aee 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/manager.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/manager.go
@@ -232,8 +232,8 @@ type operation struct {
// chromeTabs is the tab count of the Computer's own browser after this
// task's last input there, and chromePID and chromeWindow the browser
// and window this task opened with launch_app; see checkAgentChromeTabs.
- // chromeTitle is the front tab's title read with chromeTabs, empty until
- // the task's first input there. Guarded by mu.
+ // chromeTitle is the front tab's title read with chromeTabs, from
+ // launch_app on. Guarded by mu.
chromeTabs int
chromeTitle string
chromePID int