fix(tabs): close the leftover initial about:blank when a real tab opens
A fresh session's daemon creates an about:blank scratch tab on connect; a subsequent `tab new <url>` then opened the work tab beside it, so every session's tab group showed a stray 'about:blank' next to the real page (e.g. about:blank + ChatGPT). tab_new now closes any OWNED, still-blank tab once a real (non-blank) tab exists, and re-pins the new tab. Verified live: `tab new <url>` on a fresh session leaves only the work tab. 870 tests pass.
This commit is contained in:
Generated
+1
-1
@@ -290,7 +290,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrome-use"
|
name = "chrome-use"
|
||||||
version = "1.5.26"
|
version = "1.5.27"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "chrome-use"
|
name = "chrome-use"
|
||||||
version = "1.5.26"
|
version = "1.5.27"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Fast browser automation CLI for AI agents"
|
description = "Fast browser automation CLI for AI agents"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|||||||
@@ -2070,6 +2070,44 @@ impl BrowserManager {
|
|||||||
self.active_page_index = index;
|
self.active_page_index = index;
|
||||||
self.pin_active_target();
|
self.pin_active_target();
|
||||||
|
|
||||||
|
// Close the daemon's leftover initial `about:blank` scratch tab once this
|
||||||
|
// real tab exists, so the session's tab group isn't left showing a stray
|
||||||
|
// blank page beside the work tab (every group otherwise carried one). Only
|
||||||
|
// when opening a real url, and only OWNED, still-blank tabs.
|
||||||
|
if target_url != "about:blank" {
|
||||||
|
if let Some(new_tid) = self.pages.get(index).map(|p| p.target_id.clone()) {
|
||||||
|
let blanks: Vec<String> = self
|
||||||
|
.pages
|
||||||
|
.iter()
|
||||||
|
.filter(|p| {
|
||||||
|
p.target_id != new_tid
|
||||||
|
&& self.created_targets.contains(&p.target_id)
|
||||||
|
&& (p.url == "about:blank" || p.url.is_empty())
|
||||||
|
})
|
||||||
|
.map(|p| p.target_id.clone())
|
||||||
|
.collect();
|
||||||
|
for tid in blanks {
|
||||||
|
let _ = self
|
||||||
|
.client
|
||||||
|
.send_command_typed::<_, Value>(
|
||||||
|
"Target.closeTarget",
|
||||||
|
&CloseTargetParams {
|
||||||
|
target_id: tid.clone(),
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
self.created_targets.remove(&tid);
|
||||||
|
self.remove_page_by_target_id(&tid);
|
||||||
|
}
|
||||||
|
// Removing earlier pages shifts indices — re-pin the new tab.
|
||||||
|
if let Some(i) = self.pages.iter().position(|p| p.target_id == new_tid) {
|
||||||
|
self.active_page_index = i;
|
||||||
|
self.pin_active_target();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"tabId": format_tab_id(tab_id),
|
"tabId": format_tab_id(tab_id),
|
||||||
"label": label,
|
"label": label,
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chrome-use",
|
"name": "chrome-use",
|
||||||
"version": "1.5.26",
|
"version": "1.5.27",
|
||||||
"description": "chrome-use — drive your real, logged-in Chrome from any AI agent, stealth by default",
|
"description": "chrome-use — drive your real, logged-in Chrome from any AI agent, stealth by default",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"packageManager": "pnpm@11.1.3",
|
"packageManager": "pnpm@11.1.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user