Skip to content

Conversation

@z80dev
Copy link

@z80dev z80dev commented Dec 29, 2025

Summary

Adds a plugin API that allows plugins to register custom panels in the sidebar.

Closes #5971

Changes

  • Add SidebarPanel and SidebarPanelItem types to @opencode-ai/plugin
  • Add sidebar hook for plugins to register panels
  • Add GET /plugin/sidebar server endpoint
  • Add Plugin.getSidebarPanels() to aggregate panels from all plugins
  • Render plugin panels in sidebar with collapse/expand support
  • Poll every 5 seconds for dynamic updates

Usage

import { definePlugin } from "@opencode-ai/plugin"

export default definePlugin({
  name: "my-plugin",
  hooks: {
    sidebar: [
      {
        id: "status",
        title: "My Plugin Status",
        items: [
          { label: "Version", value: "1.0.0" },
          { label: "Status", value: "Active", status: "success" }
        ]
      }
    ]
  }
})

Both sidebar and items can be functions for dynamic content.

Allow plugins to register custom sidebar panels via the 'sidebar' hook.
Panels can be static arrays or getter functions for dynamic content.
Each panel item supports label, value, and status (success/warning/error/info).
Plugin sidebar panels were not appearing because the TUI process called
Plugin.getSidebarPanels() directly, but loadedHooks is only populated in
the worker process. Now fetches via /plugin/sidebar API endpoint.
- Make getSidebarPanels async and await pluginsLoaded to fix race condition
- Add error logging for failed sidebar panel hooks
- Remove unnecessary session dependency in sidebar resource fetch
- Add try/catch for API call error handling
- Clean up debug code from test plugin
- Add error logging for failed sidebar panel fetches in UI
- Add session-based refresh trigger for plugin panels
- Refactor plugin state to use Instance pattern (remove module-level vars)
- Add per-plugin error handling so one failure doesn't break others
- Add type annotation for expanded store to support dynamic plugin keys
- Change resource signal to sessionID for proper reactivity
- Add collapse/expand UI for plugin panels (consistent with MCP/LSP/Todo)
- Handle 'info' status in addition to success/warning/error
- Resolve panel.items that can be functions before sending over API
- Remove unused refetchPluginPanels destructuring
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.

Plugin API for custom sidebar panels

1 participant