Skip to content

Add attach_tab() and new_tab(background=True) for focus-preserving automation#504

Open
icekinder wants to merge 1 commit into
browser-use:mainfrom
icekinder:feat/attach-tab-background-new-tab
Open

Add attach_tab() and new_tab(background=True) for focus-preserving automation#504
icekinder wants to merge 1 commit into
browser-use:mainfrom
icekinder:feat/attach-tab-background-new-tab

Conversation

@icekinder

@icekinder icekinder commented Jul 10, 2026

Copy link
Copy Markdown

Motivation

When the harness drives a user's live browser (the daemon attached to their real Chrome), new_tab() and switch_tab() activate the target — which visibly yanks the user out of whatever tab they're working in every time automation runs. For background/batch workflows (CSV imports, polling a web app's UI, scraping a logged-in dashboard) the automation has no reason to be visible at all.

Changes

  • attach_tab(target) — attach a session to a tab without activating it. switch_tab() keeps its exact behavior and is now literally activate + attach_tab().
  • new_tab(url, background=False) — with background=True, the tab is created via Target.createTarget's background flag and only attached, never activated. Default behavior unchanged.
  • The reuse-a-blank-current-tab shortcut in new_tab() is skipped when background=True: the current tab may be the user's visible one, and background is an explicit request not to touch what they see.
  • Documented both in interaction-skills/tabs.md (code block + a "rules that held up" line).

Notes

Running this against a live daily-driver Chrome for a few weeks now — background CSV-import/enrichment runs no longer steal focus while the user keeps browsing.

🤖 Generated with Claude Code


Summary by cubic

Adds attach_tab() and new_tab(background=True) so automation can attach to tabs without activating them, preventing focus theft in a user’s live browser. Default behavior remains unchanged.

  • New Features
    • attach_tab(target): attach session without activating; switch_tab = activate + attach.
    • new_tab(url, background=True): create target with CDP background flag and attach only.
    • Skip “reuse current blank tab” when background=True to avoid touching the visible tab.
    • Docs: updated interaction-skills/tabs.md with examples and guidance.

Written for commit 5702b58. Summary will update on new commits.

Review in cubic

…tomation

When the harness drives a user's live browser, new_tab()/switch_tab()
activate the target and yank the user out of whatever tab they are
working in. This adds:

- attach_tab(target): attach a session without activating the tab
  (switch_tab() keeps its behavior and is now activate + attach_tab)
- new_tab(url, background=True): create via Target.createTarget's
  background flag and attach without activating

The reuse-a-blank-current-tab shortcut in new_tab() is skipped when
background=True, since the current tab may be the user's visible one.
Documented both in interaction-skills/tabs.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@browser-harness-review

Copy link
Copy Markdown

✅ Skill review passed

Reviewed 1 file(s) — no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant