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 — browser: add an API operation to close tabs · Issue #59787 · anomalyco/opencode

browser: add an API operation to close tabs #59787

New issue
Copy link
New issue
Copy link
Closed
#63002
Closed
browser: add an API operation to close tabs#59787
#63002
Copy link
Labels
triaging

Description

@mynameistito
mynameistito
opened on Oct 28, 2026
Issue body actions

Summary

The browser API can open tabs, but it does not appear to expose a way to close one. Please add a tab-closing operation to the browser API so an agent can clean up tabs it opened when it is done with them.

Why this is useful

Agents can create tabs for research, documentation, or testing and inspect the open tabs with browser.tabs.list(). Without a corresponding close operation, those tabs remain open in the GUI after the task finishes. This makes it harder for users to keep their browser tidy and for agents to manage temporary tabs across multi-step workflows.

Proposed behavior

  • Add an operation such as browser.tabs.close({ tabID }), following the existing tab-ID convention used by browser operations.
  • Close only the explicitly identified tab; do not implicitly close the focused tab or the whole browser window.
  • Define predictable behavior for an unknown or already-closed tab (ideally an actionable error or an idempotent success).
  • Handle closing the focused tab and the last remaining tab consistently with the GUI's existing behavior.
  • Return enough information for the caller to know the close succeeded and, if applicable, which tab is now focused.

Use case

An agent opens a few pages to compare information, extracts what it needs, then closes those temporary tabs while leaving the user's other tabs untouched.

Acceptance criteria

  • The browser API exposes a close-tab operation that accepts an explicit tab ID.
  • The operation closes the requested tab in the GUI and reports success or a clear failure.
  • Closing one tab does not close unrelated tabs or the browser window.
  • Behavior for the focused tab, last tab, and invalid/stale tab IDs is documented and covered by tests.

Automatically submitted on behalf of the user by an AI agent.

Activity

  1. mynameistito commented on Oct 28, 2026

    @mynameistito
    mynameistito
    on Oct 28, 2026
    ContributorAuthor
    More actions

    I checked the current dev branch after filing this. The requested operation is already implemented: packages/plugin-browser/src/rpc.ts defines tabs.close with an explicit tabID, documents that it closes only that tab and aborts its work, and returns the updated browser State. packages/plugin-browser/src/tools.ts registers every operation in Browser.Operations as a browser tool, so this operation is exposed as browser.tabs.close without a separate registration change.

    I’m closing this issue as already implemented in the current code. If the API you’re using does not show browser.tabs.close, it may be running an older or incompatible OpenCode/browser-plugin build; the missing operation would then be a version/distribution discrepancy rather than an unimplemented feature on dev.

  2. mynameistito
    closed this as completedon Oct 28, 2026
  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    Thanks for the suggestion! The browser API should already have this: browser.tabs.close({ tabID }) has been part of the browser operations since v2.0.0. It closes only the tab you name and returns the session's remaining tabs and the focused tab, the same result browser.tabs.list() gives.

    If your agent couldn't find it or call it, that may be a bug, so could you tell us, briefly and in your own words:

    • Your OpenCode version (opencode --version) and whether you're using the desktop app
    • What happened when the agent tried to close a tab, or how it decided that no close operation existed (the exact error, if there was one)

    You can reply here or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.

    Related issues, most relevant first:

    • browser: sessions with no current attachment get a 'will not help' error, and browser.tabs.list throws it too #55795: browser.tabs.list (and other browser calls) can fail with an attachment error in some sessions, which could make the tab operations look unavailable
    • refactor(browser): serve the in-app browser's tools from the desktop over client MCP #59477: an open PR that would move the browser tools to client MCP and rename the Code Mode path to tools.browser.tabs_close
    • feat(browser): rebuild agent browser tools around offscreen tabs, locators, and real waits #53861: a rebuild of the agent browser tools around offscreen tabs
  4. opencodejr
    added
    triaging
    on Oct 28, 2026
  5. mynameistito commented on Oct 28, 2026

    @mynameistito
    mynameistito
    on Oct 28, 2026
    ContributorAuthor
    More actions

    Thanks for clarifying. I’m on OpenCode Desktop 2.2.0.

    I wasn’t trying to call browser.tabs.close from an agent turn. I’m building a GUI plugin that opens Reels automatically on session.execution.started and needs to close that exact tab from the GUI lifecycle handler when the run succeeds, fails, or is interrupted. In the installed @opencode/plugin 2.2.0 types, @opencode/plugin/gui/browser exposes attached, canOpen, open, and openFile; open returns void, and the contract has no tab ID or close method. So I can confirm the agent browser operation exists, but I can’t reach it from this GUI plugin API or retain the tab ID through Browser.open.

    Is there a supported way for a GUI plugin to call the desktop browser tab operations (or receive the opened tab ID and close it later)? If those operations are intentionally agent-only, that API boundary is what blocked this use case.

  6. mynameistito commented on Oct 28, 2026

    @mynameistito
    mynameistito
    on Oct 28, 2026
    ContributorAuthor
    More actions

    One more clarification from the GUI plugin side: this is not a failure of an agent calling browser.tabs.close; the GUI lifecycle callback needs to open the page on run start and close it even after interruption. The public GUI Browser.open(session, url) contract returns no tab ID and has no matching close operation, so the plugin cannot use the agent Code Mode operation to clean up its tab. Please consider exposing an equivalent tab-scoped browser API to GUI plugins, or documenting a supported bridge for lifecycle cleanup.

  7. opencodejr
    closed this as not plannedon Oct 31, 2026
  8. opencodejr commented on Oct 31, 2026

    @opencodejr
    opencodejrBot
    on Oct 31, 2026
    Contributor
    More actions

    Closing this for now, since we haven't heard back. As mentioned above, the browser API already has browser.tabs.close({ tabID }) (since v2.0.0). It closes only the tab you name and returns the remaining tabs and the focused tab. We waited to hear whether your agent couldn't see or call it, which could be a bug.

    If it's missing or fails for you, please comment with your OpenCode version (opencode --version) and what happened (the exact error, if there was one), and we can reopen this. Thanks!

  9. opencodejr
    reopened this on Nov 3, 2026
  10. Hona
    closed this as completedin #63002on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triaging

    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.