plugin

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plugin defines the plugin system interface and registry for registering, managing, and coordinating sidecar plugins with shared context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStale

func IsStale(ctx *Context, msg EpochMessage) bool

IsStale returns true if the message's epoch doesn't match the current context epoch. Use this in Update() handlers to discard messages from previous projects:

if plugin.IsStale(p.ctx, msg) { return p, nil }

Types

type AttentionOrigin added in v1.11.0

type AttentionOrigin struct {
	TmuxSession string
	ProjectKey  string
	WorkDir     string
	// HostID names the registered remote host the visible workspace lives on,
	// empty for one on this machine. Two machines legitimately share a session
	// name and a checkout path, so without it a local selection would answer
	// "is the user looking at that remote workspace" with yes.
	HostID string
}

AttentionOrigin is the app-level identity shared by project and global workspace projections. It deliberately contains no notification or transport types.

type AttentionOriginProvider added in v1.11.0

type AttentionOriginProvider interface {
	AttentionOrigin() (AttentionOrigin, bool)
}

AttentionOriginProvider projects the workspace/session actually visible in a presentation-only surface. The app owns focus and publishes this identity for host-wide background policy.

type BindingRegistrar

type BindingRegistrar interface {
	RegisterPluginBinding(key, command, context string)
}

BindingRegistrar allows plugins to register key bindings dynamically. This is implemented by keymap.Registry.

type Category

type Category string

Category represents a logical grouping of commands for the command palette.

const (
	CategoryNavigation Category = "Navigation"
	CategoryActions    Category = "Actions"
	CategoryView       Category = "View"
	CategorySearch     Category = "Search"
	CategoryEdit       Category = "Edit"
	CategoryGit        Category = "Git"
	CategorySystem     Category = "System"
)

type Command

type Command struct {
	ID          string         // Unique identifier (e.g., "stage-file")
	Name        string         // Short name for footer (e.g., "Stage")
	Description string         // Full description for palette
	Category    Category       // Logical grouping for palette display
	Handler     func() tea.Cmd // Action to execute (optional)
	Context     string         // Activation context
	Priority    int            // Footer display priority: 1=highest, 0=default (treated as 99)
}

Command represents a keybinding command exposed by a plugin.

type ContentLinkProvider added in v1.2.0

type ContentLinkProvider interface {
	ContentLinkSurfaces() []contentlink.Surface
}

ContentLinkProvider is an optional capability for plugins that expose exact read-only rendered text rectangles for app-owned content-link decoration. Hosts read it after View so its geometry describes the frame just rendered.

type Context

type Context struct {
	WorkDir     string // Actual working directory (worktree path for linked worktrees)
	ProjectRoot string // Main repo root for shared state (same as WorkDir for non-worktrees)
	ConfigDir   string
	Config      *config.Config
	Adapters    map[string]adapter.Adapter
	EventBus    *event.Dispatcher
	Logger      *slog.Logger
	Keymap      BindingRegistrar // For plugins to register dynamic bindings
	Epoch       uint64           // Incremented on project switch to invalidate stale async messages
}

Context provides shared resources to plugins during initialization.

type CursorProvider added in v0.88.0

type CursorProvider interface {
	Cursor() *tea.Cursor
}

CursorProvider is an optional capability for plugins that own the terminal cursor. Coordinates are local to the plugin content area; the app applies its header offset and suppresses the cursor while blurred or covered by a modal.

type Diagnostic

type Diagnostic struct {
	ID     string
	Status string
	Detail string
}

Diagnostic represents a health/status check result.

type DiagnosticProvider

type DiagnosticProvider interface {
	Diagnostics() []Diagnostic
}

DiagnosticProvider is implemented by plugins that expose diagnostics.

type EpochMessage

type EpochMessage interface {
	GetEpoch() uint64
}

EpochMessage is implemented by async messages that need staleness detection. Messages from async operations should embed an Epoch field and implement this interface.

type FocusCycler added in v1.2.0

type FocusCycler interface {
	// AtFocusCycleEnd reports that focus is on the last window of the surface's
	// ring in the direction the cycle is about to move, so the next Tab would
	// wrap. That is where a shell-owned stop belongs.
	AtFocusCycleEnd(reverse bool) bool

	// FocusCycleStart puts focus back on the window the cycle resumes at — the
	// first going forward, the last going back — when the shell hands the
	// keyboard back to the surface.
	FocusCycleStart(reverse bool) tea.Cmd
}

FocusCycler is an optional capability for surfaces whose Tab cycle the shell may extend with a stop of its own. The notification centre is that stop: when it is open it joins the cycle between a surface's last window and its first, rather than running a second cycle beside it.

A surface that does not implement this keeps Tab exactly as it always had it; the shell then only offers Tab to the centre when nothing else has claimed the key in the focused context.

type FooterStatusProvider added in v0.95.0

type FooterStatusProvider interface {
	// FooterStatus returns text for the host footer and whether it is an error.
	// An empty string means "nothing to say".
	FooterStatus() (string, bool)
}

FooterStatusProvider is an optional capability for plugins with a condition that must stay visible even though the host owns the footer. A plugin that suppresses its own status line has no other always-on surface.

type GlobalKeyBlocker added in v0.96.0

type GlobalKeyBlocker interface {
	BlocksGlobalKeys() bool
}

GlobalKeyBlocker is an optional capability for plugins with overlays that own the keyboard. While it reports true, Sidecar forwards every key except its interrupt instead of running host-level shortcuts.

type KeyRouter added in v0.95.0

type KeyRouter interface {
	GlobalKeyBlocker

	// BlocksGlobalKeys reports that the plugin is showing an overlay that owns
	// the keyboard. Every key except the host's interrupt is forwarded.
	// ClaimsKey reports that the plugin has a live contextual binding for a
	// key. It is asked only for keys sidecar would otherwise handle globally,
	// and only when no overlay is blocking.
	ClaimsKey(key string) bool

	// QuitKeyExits reports whether `q` in the plugin's current context should
	// reach sidecar's quit flow. It replaces the host's isRootContext guess for
	// plugins that can answer for themselves.
	QuitKeyExits() bool
}

KeyRouter is an optional capability for plugins that own keys the host also binds globally. It makes sidecar's key precedence explicit instead of implicit in the order of a switch statement:

  1. an open sidecar application modal;
  2. the active plugin's text-input or blocking-overlay context (TextInputConsumer, or BlocksGlobalKeys here);
  3. an active plugin contextual binding (ClaimsKey here);
  4. sidecar global bindings;
  5. unbound input forwarded to the plugin.

Only plugins that implement it participate in levels 2 (overlay) and 3; every other plugin keeps the level-4-then-5 behaviour it has always had.

type MouseModeProvider added in v0.88.0

type MouseModeProvider interface {
	PreferredMouseMode() tea.MouseMode
}

MouseModeProvider is an optional capability for plugins that need a more specific mouse reporting mode in their current view. Sidecar defaults to all-motion for hover-driven UI and lets embedded terminal contexts request cell-motion so only clicks, drags, releases, and wheels are reported.

type OpenFileMsg

type OpenFileMsg struct {
	Editor string // Editor command (e.g., "vim", "code")
	Path   string // File path to open
	LineNo int    // Line number to open at (0 = start of file)
}

OpenFileMsg requests opening a file in an external editor. Sent by plugins, handled by app to exec the editor process.

type PaneFocusProvider added in v1.2.0

type PaneFocusProvider interface {
	PaneFocusStops() []PaneFocusStop
	PaneFocus() string
	SetPaneFocus(id string) tea.Cmd
	SetPaneFocusActive(active bool)
}

PaneFocusProvider is an optional capability for plugins whose own panes join an app-owned focus ring. Implementations project existing focus state rather than introducing a second focus model.

type PaneFocusStop added in v1.2.0

type PaneFocusStop struct {
	ID string
}

PaneFocusStop names one directly focusable window inside a plugin. IDs are stable while visual order is expressed by the provider's returned slice.

type PendingWorkspaceActionProvider added in v1.0.0

type PendingWorkspaceActionProvider interface {
	TakePendingWorkspaceAction() tea.Cmd
}

type PendingWorkspaceSelection added in v0.94.0

type PendingWorkspaceSelection struct {
	Kind WorkspaceSelectionKind
	Key  string
	Path string
	// Action asks the owning project surface to continue with one of its own
	// established workflows after the exact identity is selected.
	Action string
}

PendingWorkspaceSelection is delivered synchronously after registry.Reinit, before the returned async Start commands run.

type PendingWorkspaceSelector added in v0.94.0

type PendingWorkspaceSelector interface {
	SetPendingWorkspaceSelection(PendingWorkspaceSelection)
}

type Plugin

type Plugin interface {
	ID() string
	Name() string
	Icon() string
	Init(ctx *Context) error
	Start() tea.Cmd
	Stop()
	Update(msg tea.Msg) (Plugin, tea.Cmd)
	View(width, height int) string
	IsFocused() bool
	SetFocused(bool)
	Commands() []Command
	FocusContext() string
}

Plugin defines the interface for all sidecar plugins.

type PluginFocusedMsg

type PluginFocusedMsg struct{}

PluginFocusedMsg is sent to a plugin when it becomes the active plugin. Plugins can use this to refresh data or update their state on focus.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages plugin registration and lifecycle.

func NewRegistry

func NewRegistry(ctx *Context) *Registry

NewRegistry creates a new plugin registry with the given context.

func (*Registry) Context

func (r *Registry) Context() *Context

Context returns the shared plugin context, or nil when the registry was built without one. App-owned surfaces that are not registry plugins (the global Tasks host) read it to inherit config, logger, and adapters without taking part in the registry's per-project lifecycle.

func (*Registry) Get

func (r *Registry) Get(id string) Plugin

Get returns a plugin by ID, or nil if not found.

func (*Registry) Plugins

func (r *Registry) Plugins() []Plugin

Plugins returns all active plugins.

func (*Registry) Register

func (r *Registry) Register(p Plugin) error

Register adds a plugin to the registry. If Init fails, the plugin is marked unavailable (silent degradation).

func (*Registry) Reinit

func (r *Registry) Reinit(newWorkDir, newProjectRoot string) []tea.Cmd

Reinit stops all plugins, updates the context with a new WorkDir and ProjectRoot, and reinitializes all plugins. Returns the start commands for all plugins.

func (*Registry) Replace added in v1.0.3

func (r *Registry) Replace(i int, p Plugin)

Replace stores p at index i in the live registry. Plugins() returns a copy, so a caller that received a new value from Update must persist it here.

func (*Registry) Start

func (r *Registry) Start() []tea.Cmd

Start starts all registered plugins and returns their initial commands.

func (*Registry) Stop

func (r *Registry) Stop()

Stop stops all registered plugins in reverse order.

func (*Registry) Unavailable

func (r *Registry) Unavailable() map[string]string

Unavailable returns a map of plugin IDs to their failure reasons.

type ResizeDragReporter added in v1.2.0

type ResizeDragReporter interface {
	// ResizeDragActive reports that a pane rail is currently being dragged.
	ResizeDragActive() bool
}

ResizeDragReporter is implemented by a surface whose panes are resized by dragging a rail. While that drag is live the shell suppresses the floating tiers — toasts and status flashes — because every drag frame re-lays out the whole content region and a block composited on top of it both flickers and pays for a second full-screen composite on the frame that is already the expensive one (design 1g's "suppress while resizing", and the resize storm deferred from notifications Phase 1).

Nothing is lost by the suppression: the notification is already in the store, the centre and the header count, and it paints on the frame after the drop.

type TextInputConsumer

type TextInputConsumer interface {
	ConsumesTextInput() bool
}

TextInputConsumer is an optional capability for plugins that need alphanumeric key input to be forwarded as typed text instead of being intercepted by app-level shortcuts.

type WheelBoundaryConsumer added in v1.0.0

type WheelBoundaryConsumer interface {
	WheelAtBoundary(tea.MouseWheelMsg) bool
}

WheelBoundaryConsumer is an optional fast-path for plugins with scrollable surfaces. Bubble Tea asks it before Update and View; returning true drops an inertia event that cannot move the surface under the pointer. Implementations must return false when they are not certain (for example, a terminal application that owns mouse reporting).

The message coordinates are local to the plugin content box, after Sidecar's header has been removed. Implementations may reset gesture-only coalescing state when they report a boundary, but must not change visible content.

type WorkspaceSelectionKind added in v0.94.0

type WorkspaceSelectionKind string
const (
	WorkspaceSelectionWorktree WorkspaceSelectionKind = "worktree"
	WorkspaceSelectionShell    WorkspaceSelectionKind = "shell"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL