A demonstration plugin for OpenCode showcasing the experimental Sidebar Panel API.
Note: This plugin requires the Sidebar Panel API which is not yet merged into OpenCode. It currently only works with this fork (see PR #6389). As such, this code is primarily provided for illustration purposes to demonstrate how the API works and what's possible with sidebar plugins.
This plugin serves as a reference implementation for the OpenCode sidebar panel system. It demonstrates how plugins can register custom panels that appear in the OpenCode sidebar alongside built-in sections like MCPs, context usage, and todos.
The plugin registers two sidebar panels:
- Hello World - A simple static panel showing plugin status and version
- Plugin Metrics - A dynamic panel that updates on each render, displaying:
- A render counter (increments each time the sidebar polls)
- Current timestamp
- Sample warning/error indicators
- A random number (to visualize dynamic updates)
OpenCode's sidebar panel API allows plugins to define a sidebar hook that returns an array of panels. Each panel has:
id- Unique identifier for the paneltitle- Display name shown in the sidebaritems- Array of label/value pairs with optional status indicators
The API supports both static and dynamic content:
// Static - panels defined once at load time
sidebar: [
{ id: "my-panel", title: "My Panel", items: [...] }
]
// Dynamic - function called on each poll (every 5 seconds)
sidebar: () => [
{ id: "my-panel", title: "My Panel", items: [...] }
]This plugin uses a dynamic getter function to demonstrate real-time updates. The counter variable increments on each call, and the timestamp updates to show the polling mechanism in action.
Each item can include a status field that controls its visual appearance:
success- Green indicatorwarning- Yellow indicatorerror- Red indicatorinfo- Blue indicator
- Clone this repository:
git clone https://github.com/z80dev/opencode-sidebar-demo.git- Add the plugin to your
opencode.jsonusing the local file path:
{
"plugin": ["file:///path/to/opencode-sidebar-demo/src/index.ts"]
}Replace /path/to/ with the actual path where you cloned the repository.
This plugin exists to:
- Demonstrate the API - Show developers how to use the sidebar panel system
- Test the implementation - Validate that dynamic updates, status colors, and panel rendering work correctly
- Serve as a template - Provide a starting point for plugins that need sidebar integration
import type { PluginInput, Hooks, SidebarPanel, SidebarPanelItem } from "@opencode-ai/plugin"
interface SidebarPanelItem {
label: string
value?: string
status?: "success" | "warning" | "error" | "info"
}
interface SidebarPanel {
id: string
title: string
items: SidebarPanelItem[] | (() => SidebarPanelItem[])
}
// In your plugin's hooks:
sidebar?: SidebarPanel[] | (() => SidebarPanel[])The Sidebar Panel API is currently experimental and may change in future OpenCode releases.
MIT