GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — desktop(browser): screenshot refuses with "needs a visible tab" when the review pane is not displaying the tab (fromSurface) · Issue #50781 · anomalyco/opencode

desktop(browser): screenshot refuses with "needs a visible tab" when the review pane is not displaying the tab (fromSurface) #50781

New issue
Copy link
New issue
Copy link
Closed
Closed
desktop(browser): screenshot refuses with "needs a visible tab" when the review pane is not displaying the tab (fromSurface)#50781
Copy link
Assignees
Brendonovich

Description

@4Liberty
4Liberty
opened on Sep 23, 2026
Issue body actions

Description

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 hidden Chrome_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:

try {
  return await page(browser, "Page.captureScreenshot", {
    format: "jpeg", quality: 80, fromSurface: true, captureBeyondViewport: fullPage,
  })
} catch {
  return await page(browser, "Page.captureScreenshot", {
    format: "jpeg", quality: 80, fromSurface: false, captureBeyondViewport: false,
  })
}

captureBeyondViewport wants the surface in some Chrome builds, hence dropping it on the fallback path.

Two smaller asks:

  1. 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".
  2. 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

  1. browser.tabs.open a URL, then browser.tabs.focus the tab.
  2. Switch the app to another session so the review pane is not displaying that tab.
  3. 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)

Activity

  1. github-actions
    assigned
    Brendonovich
    on Sep 23, 2026
  2. mostafa-binesh commented on Oct 17, 2026

    @mostafa-binesh
    mostafa-binesh
    on Oct 17, 2026
    More actions

    really need this feature

  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    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.

    Related:

    • feat(browser): rebuild agent browser tools around offscreen tabs, locators, and real waits #53861 (open PR): rebuilds the agent browser tabs to render offscreen. It records the same failures with the review pane hidden: screenshots failing and click/hover throwing a bare UnknownVizError.
    • browser: screenshot returns stale frame after client-side navigation #52407 / fix(gui-extensions): wait for painted frame before screenshot capture #52704: screenshots returning a stale frame after client-side navigation. Related, but a different problem.
  4. D-Code commented on Nov 5, 2026

    @D-Code
    D-Code
    on Nov 5, 2026
    More actions

    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:

    await waitFor(() => view.getVisible() && win.isVisible() && !win.isMinimized(), signal, 3_000).catch(
      () => { throw new Error("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:

    arrangement Review pane showing the tab window state browser.screenshot
    OpenCode in front yes normal worked
    foreign window floating mid-screen, app partly covered yes visible, unfocused worked
    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:

    1. 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.
    2. 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.
    3. 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.

  5. neriousy commented on Nov 23, 2026

    @neriousy
    neriousy
    on Nov 23, 2026
    Member
    More actions

    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.

  6. neriousy
    closed this as completedon Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Brendonovich
    Brendonovich

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.