Skip to content

Conversation

@Kvadratni
Copy link
Collaborator

Summary

Adds the ability to create Builder Bot tasks directly from code review comments with a single click. This integrates the plugin system with the comment workflow, making it easy to convert review feedback into actionable tasks.

Changes

Frontend

  • TopBar: Added ⚡ "Create Task" button next to copy/delete comment buttons
    • Exports all comments as markdown
    • Opens Builder Bot modal with comments pre-filled
    • Only visible when comments exist
  • Plugin System: Enhanced to pass custom props to plugin modals
    • Plugins can now receive initialPrompt and other context

Backend

  • Command Registration: Fixed critical bug where plugin commands weren't actually being registered
    • Implemented thread-local storage (TLS) to properly pass registrar through C ABI
    • Commands now register with full plugin-name:command-name format
    • Plugins can now be invoked from frontend without "command not found" errors

Test Plan

  1. Open a diff with some comments (or add test comments)
  2. Verify the ⚡ button appears in the top bar next to copy/delete buttons
  3. Click the ⚡ button
  4. Builder Bot modal should open with comments pre-filled in the prompt textarea
  5. Create a task to verify the full flow works

Screenshots

[Add screenshot of the create task button in action]

Related

  • Part of plugin system feature work
  • Enables seamless integration between code review and task creation workflows

🤖 Generated with Claude Code

Kvadratni and others added 6 commits January 13, 2026 11:31
Adds foundational plugin system that allows loading third-party
functionality at runtime without modifying core code.

Core components:
- C ABI with VTable pattern for stable cross-version compatibility
- Plugin discovery from ~/.config/staged/plugins/
- TOML-based manifest parsing (plugin.toml)
- Dynamic library loading using libloading
- API version checking and validation
- Plugin initialization with context (app handle, data dir, config)

Technical details:
- Plugins expose staged_plugin_entry() function returning PluginVTable
- VTable contains function pointers for init, shutdown, and registration
- Plugin manager discovers, loads, and initializes plugins at app startup
- Managed state integration with Tauri

Files added:
- src-tauri/src/plugin/mod.rs: PluginManager implementation
- src-tauri/src/plugin/api.rs: C ABI definitions

Files modified:
- src-tauri/Cargo.toml: Added libloading, toml, glob dependencies
- src-tauri/src/lib.rs: Integrated plugin module and initialization

Next phase: Command registration system

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds runtime command dispatch system allowing plugins to register
commands callable from the frontend via a universal dispatcher.

Core components:
- PluginCommandRegistry: Thread-safe command registry with HashMap
- CommandRegistrarImpl: C ABI bridge for plugin command registration
- Universal plugin_invoke dispatcher: Single Tauri command routing to all plugins
- Panic catching with AssertUnwindSafe for plugin stability
- JSON payload serialization/deserialization

Command flow:
1. Plugin registers commands during initialization
2. Frontend calls invoke('plugin_invoke', {pluginName, commandName, payload})
3. Dispatcher routes to correct plugin command handler
4. JSON response returned to frontend

New Tauri commands:
- plugin_invoke: Execute plugin command
- list_plugin_commands: Get all registered commands
- list_plugins: Get plugin manifests for frontend

Technical details:
- 64KB max response buffer per command
- Commands identified as "plugin:command" format
- Per-plugin isolation in command registry
- Command handlers receive JSON in/out via C strings

Files added:
- src-tauri/src/plugin/commands.rs: Command registry and dispatcher

Files modified:
- src-tauri/src/plugin/mod.rs: Added command registration integration
- src-tauri/src/lib.rs: Added plugin commands to Tauri handler

Next phase: Frontend integration

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds complete frontend plugin system with dynamic asset loading
and modal UI support.

Frontend components:
- PluginAPI: Interface for plugins to interact with Stage
- PluginSystem class: Manages plugin lifecycle and asset loading
- Modal system: Plugins can register and show modal overlays
- Asset loading: Dynamic script/CSS injection from plugin directories

Backend additions:
- get_plugin_asset command: Serves plugin JS/CSS files via file:// URLs
- Path traversal protection: Validates assets stay in plugin directory
- list_plugins command: Returns manifests with frontend metadata

Frontend integration:
- App.svelte: Initializes plugin system on mount
- Modal backdrop: Renders plugin modals with backdrop
- Plugin API includes: invoke, registerModal, showModal, closeModal

Plugin workflow:
1. Backend discovers plugins at startup
2. Frontend calls list_plugins to get manifests
3. For each plugin with frontend assets:
   - Load CSS (if present)
   - Load JS and call initialization function
   - Plugin receives PluginAPI and registers modals
4. Plugins can show modals via API

Security:
- Asset paths validated against directory traversal
- Plugins loaded from trusted config directory
- Modal isolation with separate component instances

Files added:
- src/lib/services/plugins.ts: Frontend plugin system

Files modified:
- src-tauri/src/lib.rs: Added get_plugin_asset command
- src/App.svelte: Plugin initialization and modal rendering

Next phase: Menu registration and event hooks

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds complete plugin lifecycle event system and menu registration
capabilities, enabling plugins to respond to app events and extend menus.

Event system:
- PluginEvent enum: Startup, Shutdown, Commit, ReviewCompleted, etc.
- EventDispatcher: Thread-safe event subscription and emission
- EventSubscriberImpl: C ABI bridge for plugin event subscriptions
- Event callbacks with panic catching and error handling

Menu system:
- MenuRegistry: Stores plugin menu items
- PluginMenuItem: Menu metadata (id, parent, label, shortcut)
- MenuRegistrarImpl: C ABI bridge for menu registration

Plugin lifecycle:
1. Init → Register commands → Register menus → Subscribe to events
2. Runtime: Receive events, handle commands, show modals
3. Shutdown: Cleanup and event notification

Event integration points:
- Startup: After all plugins initialized
- Commit: After git commit created (commit command in lib.rs:139)
- ReviewCompleted: After review cleared (clear_review in lib.rs:312)
- Shutdown: Before plugins destroyed

Technical details:
- Events serialized to JSON for C ABI crossing
- Panic catching on all event handlers
- Multiple subscribers supported per event
- Menu items stored for later dynamic menu building

Files added:
- src-tauri/src/plugin/events.rs: Event system
- src-tauri/src/plugin/menus.rs: Menu registration

Files modified:
- src-tauri/src/plugin/mod.rs: Integrated events and menus
- src-tauri/src/lib.rs: Event emissions, menu/event registration

Next phase: Permission system (basic validation)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements plugin permission validation and enforcement to ensure
plugins only access resources they declare in their manifests.

Permission types:
- File system: fs_read and fs_write with glob patterns
- Network: URL patterns with wildcard matching
- Tauri commands: Whitelist of allowed commands
- External programs: List of allowed executables

PermissionChecker features:
- Manifest validation at plugin load time
- Runtime permission checks (can_read_file, can_write_file, etc.)
- Glob pattern matching for file paths
- Variable expansion: $REPO, $DATA, $HOME
- Path traversal prevention
- URL pattern matching for network access

Security features:
- Validates patterns don't contain ".." (path traversal)
- Network patterns must start with http:// or https://
- Permissions registered per plugin at load time
- Permission checks available for future enforcement

Integration:
- Permission checker integrated into PluginManager
- Validates manifest before loading plugin
- Registers permissions after validation

Note: Permission enforcement is validation-only in this phase.
Future phases can add runtime enforcement in command/file handlers.

Files added:
- src-tauri/src/plugin/permissions.rs: Permission checker

Files modified:
- src-tauri/src/plugin/mod.rs: Integrated permission checker

All 5 phases complete! Plugin system ready for testing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit adds the ability to create Builder Bot tasks directly from
code review comments with a single click.

Frontend changes:
- Add "Create Task" button (⚡ icon) to TopBar next to copy/delete buttons
  - Only visible when Builder Bot plugin is installed
  - Integrates with plugin system to pass comments as initial prompt
  - Exports comments as markdown and pre-fills plugin modal
- Add PluginModalWrapper for rendering plugin modals
- Add PluginSettings UI for managing plugins
- Integrate plugin system into App.svelte with keyboard shortcuts

Backend changes:
- Fix plugin command registration system using thread-local storage
- Commands now properly register with plugin-name:command-name format
- Plugins can now be invoked from frontend without "command not found" errors
- Add plugin system initialization and event handling

The create task button:
- Only appears when Builder Bot plugin is installed
- Only visible when comments exist
- Opens Builder Bot modal with comments pre-filled
- Formats comments as markdown for better context

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Kvadratni Kvadratni force-pushed the feature/plugin-system branch from 7b3c0d4 to 2188edc Compare January 14, 2026 01:12
Kvadratni and others added 2 commits January 13, 2026 17:18
Comprehensive guide covering:
- Plugin architecture and structure
- Quick start with simplest possible plugin example
- Plugin API reference
- Building and installing plugins
- Advanced examples and best practices
- Troubleshooting guide

Includes complete working code for:
- Frontend-only 'Hello Stage' plugin
- Full-stack plugin with Rust backend
- Modal components with props
- Backend command handlers

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When creating a task from comments, now passes:
- PR number (if viewing a PR)
- Repository path

This allows the plugin to automatically attach the PR as an artifact
to the created task using the bb CLI.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

2 participants