You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
desktop(browser): screenshot refuses with "needs a visible tab" when the review pane is not displaying the tab (fromSurface) #50781
The desktop browser tool cannot screenshot a tab while the review pane is not displaying it (for example while the user works in another session). It fails with:
Screenshot needs a visible tab. Call browser.tabs.focus and keep its desktop window visible.
That guidance points at window focus, which is not the precondition. Measured on Windows 11 / desktop 2.0.14: I brought the app window to the foreground (GetForegroundWindow() returned the app's own window), focused the tab, and opened a file with the preview action — the refusal persists. snapshot / evaluate / navigate keep working on the same tab; only capture fails, and browser.click fails with UnknownVizError.
Cause: the tab's view is not composited. Enumerating the app's top-level windows shows the visible shell alongside a hiddenChrome_WidgetWin_0 (1920×1010, IsWindowVisible() == false) while the pane is not showing that tab. Page.captureScreenshot with fromSurface: true captures from the surface, which does not exist in that state.
Suggested fix in packages/opencode/src/tool/browser.ts (the browser-tool work in #48755) — keep the surface capture but fall back to a renderer capture instead of failing:
captureBeyondViewport wants the surface in some Chrome builds, hence dropping it on the fallback path.
Two smaller asks:
The error text sends callers after window focus; if the requirement is "the pane must be displaying the tab", say so, or distinguish "tab exists but its view is not visible" from "no such tab".
click / type already dispatch Input.dispatchMouseEvent / Input.insertText, which do not need a composited surface, so the UnknownVizError on click looks like a host-side visibility gate rather than something the tool file can fix.
Impact: an agent cannot capture or click while the user is working elsewhere in the app — the common case for background runs — and the only workaround is a separate headless browser, which loses the user's own session, cookies and extensions.
OpenCode version
2.0.14 (desktop)
Steps to reproduce
browser.tabs.open a URL, then browser.tabs.focus the tab.
Switch the app to another session so the review pane is not displaying that tab.
browser.screenshot → refuses with the message above. browser.click → UnknownVizError.
Operating System
Windows 11
Terminal
Desktop app (measured from an agent session inside it, not a terminal)
Thanks for the detailed report and the measurements. This only happens in the desktop app, when the review pane is showing a different session, and our automated sandbox (headless Linux, terminal app only) can't open or hide desktop browser tabs, so a maintainer with the desktop app will need to reproduce it.
From the code: on current dev, the screenshot check is in packages/gui-plugins/src/browser/chromium.ts, not packages/opencode/src/tool/browser.ts. Before capturing, it waits for the tab's view and its window to be visible, and otherwise fails with the error you quoted. So refusing hidden tabs looks deliberate, but you're right that the message points at window focus and never says the review pane has to be showing the tab.
Confirming on Windows 11, desktop 2.2.5 (core 5.6.2), with a private Next.js app in the Review pane.
The shipped bundle contains the same guard I read on dev:
awaitwaitFor(()=>view.getVisible()&&win.isVisible()&&!win.isMinimized(),signal,3_000).catch(()=>{thrownewError("Screenshot needs a visible tab. Call browser.tabs.focus and keep its desktop window visible.")},)
Both halves of that predicate reproduce independently, measured in one session:
a file opened with the preview action, stealing the pane slot
no
visible, unfocused
refused
same, after browser.tabs.focus
yes
visible, unfocused
worked
foreign window maximized to the app's own bounds (-8,-8,1928,1040)
yes
IsWindowVisible() == true, IsIconic() == false
refused
Three points that narrow it:
The preview action is a concrete trigger for the first condition.browser.preview takes the Review pane slot, which is enough to make view.getVisible() false; browser.tabs.focus restores capture immediately. The practical consequence is that an agent that shows a file to the user can no longer screenshot anything until it re-focuses a browser tab, and nothing in the tool descriptions says so.
Capture is also refused when another window is maximized to the app's exact bounds, even though Win32 reports that window IsWindowVisible() == true and IsIconic() == false, and even though the page is alive in the refused state: document.visibilityState was visible, document.hasFocus() was false, and 26 requestAnimationFrame callbacks ran in 400 ms. Renderer throttling is therefore not the cause. Which of the three predicates actually goes false there is an inference I cannot make from outside; I am reporting the state, not the internals.
The error text sends callers after window focus, which is the wrong lead for rows 3 and 4. Splitting "tab exists but its view is not composited" from "window not visible" — or just naming the Review pane requirement — would save callers the guesswork it took here: about a dozen experiments across window focus, window rectangles and EnumWindows before browser.tabs.focus fixed it.
For what it is worth, PR #53861 appears to remove this precondition outright ("no tool needs the tab to be focused or visible"), so this may already be resolved on that branch.
Disclosure, so nobody has to guess: these measurements were taken by an AI agent (OpenCode, in my desktop session) at my direction while I drove a local app in the Review pane. I read this before posting and I can rerun any row of the table.
This was fixed in #63002, which lets browser screenshots capture hidden and off-screen tabs instead of failing with "needs a visible tab". If you still see this on the latest version, comment here and we'll reopen.
Activity
mostafa-binesh commentedon Oct 17, 2026
really need this feature
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report and the measurements. This only happens in the desktop app, when the review pane is showing a different session, and our automated sandbox (headless Linux, terminal app only) can't open or hide desktop browser tabs, so a maintainer with the desktop app will need to reproduce it.
From the code: on current
dev, the screenshot check is inpackages/gui-plugins/src/browser/chromium.ts, notpackages/opencode/src/tool/browser.ts. Before capturing, it waits for the tab's view and its window to be visible, and otherwise fails with the error you quoted. So refusing hidden tabs looks deliberate, but you're right that the message points at window focus and never says the review pane has to be showing the tab.Related:
UnknownVizError.D-Code commentedon Nov 5, 2026
Confirming on Windows 11, desktop 2.2.5 (core 5.6.2), with a private Next.js app in the Review pane.
The shipped bundle contains the same guard I read on
dev:Both halves of that predicate reproduce independently, measured in one session:
browser.screenshotbrowser.tabs.focus-8,-8,1928,1040)IsWindowVisible() == true,IsIconic() == falseThree points that narrow it:
browser.previewtakes the Review pane slot, which is enough to makeview.getVisible()false;browser.tabs.focusrestores capture immediately. The practical consequence is that an agent that shows a file to the user can no longer screenshot anything until it re-focuses a browser tab, and nothing in the tool descriptions says so.IsWindowVisible() == trueandIsIconic() == false, and even though the page is alive in the refused state:document.visibilityStatewasvisible,document.hasFocus()wasfalse, and 26requestAnimationFramecallbacks ran in 400 ms. Renderer throttling is therefore not the cause. Which of the three predicates actually goes false there is an inference I cannot make from outside; I am reporting the state, not the internals.EnumWindowsbeforebrowser.tabs.focusfixed it.For what it is worth, PR #53861 appears to remove this precondition outright ("no tool needs the tab to be focused or visible"), so this may already be resolved on that branch.
Disclosure, so nobody has to guess: these measurements were taken by an AI agent (OpenCode, in my desktop session) at my direction while I drove a local app in the Review pane. I read this before posting and I can rerun any row of the table.
neriousy commentedon Nov 23, 2026
This was fixed in #63002, which lets browser screenshots capture hidden and off-screen tabs instead of failing with "needs a visible tab". If you still see this on the latest version, comment here and we'll reopen.