-
Notifications
You must be signed in to change notification settings - Fork 78
Description
⚠️ Before implementing, read and follow the Implementation Rules in the epic issue #5364. These rules cover mandatory patterns for React component structure, BAI component usage, reactToWebComponent bridge, state management, i18n, error handling, styling, and code quality. The reference implementation isreact/src/components/SignupModal.tsx.Goal: Complete Lit file removal. Each migration must fully replace the Lit source file with React — not just the dialog parts. The migrated Lit
.tsfile and its type declarations must be deleted. This epic is a critical step toward removing all Lit/MWC/Vaadin dependencies from the codebase.
Description
The current plugin loading system is Lit-based: plugins are discovered from config.toml, dynamically imported as ES modules, instantiated as Lit web components, and appended to the Lit shadow DOM. Post-load management (rendering, routing) is already partially handled by React, but the loading and registration mechanism itself is still in Lit.
This issue migrates the plugin loading pipeline to React while maintaining backward compatibility with existing plugin modules.
Part of epic #5364
Depends on: Navigation consolidation (routing must support dynamic plugin routes)
Current Plugin Loading System
Location: src/components/backend-ai-webui.ts (lines ~500–580)
Flow:
config.tomlparsed →config.plugin.pagecontains plugin URLs- Each plugin URL dynamically imported:
import(pluginUrl) - Web component instance created:
document.createElement(pluginName) - Plugin appended to
#app-pagecontainer in Lit shadow DOM - Plugin metadata extracted (menuitem, icon, group) for navigation
backend-ai-plugin-loadedevent dispatched
Plugin interface (Lit web component):
- Extends
BackendAIPage(Lit-Element) - Exports properties:
menuitem,icon,group - Renders as standard Lit template
Plugin directories:
src/plugin___/,src/plugin_backup/,src/plugins_new/,src/plugins_sample/
Migration Plan
Option A: React Plugin Adapter (Recommended)
Create a React-based plugin loader that can load both legacy Lit plugins (via web component wrapper) and new React plugins.
-
Create
react/src/plugins/PluginLoader.tsx- Read plugin configuration from config context/Recoil state
- Dynamically import plugin modules
- For Lit plugins: render via web component wrapper
- For React plugins: render directly as React components
- Register dynamic routes in React Router
-
Create plugin metadata system
- Plugin manifest type:
{ name, menuitem, icon, group, component } - Store in Recoil atom:
pluginListState - Navigation menu reads from this atom
- Plugin manifest type:
-
Create
react/src/plugins/PluginPage.tsx- Wrapper component that renders a plugin by name
- Handles loading states and error boundaries
- Used as route element:
<Route path="/plugin/:name" element={<PluginPage />} />
Option B: Direct Migration
If no legacy Lit plugins need to be supported:
- Define React plugin interface
- Load plugins as React lazy components
- Register with React Router directly
Plugin Interface (New React)
interface BackendAIPlugin {
name: string;
menuitem: string;
icon: React.ReactNode;
group: string;
component: React.LazyExoticComponent<React.ComponentType>;
}Acceptance Criteria
- Plugin loading moved from
backend-ai-webui.tsto React - Plugins discoverable from
config.tomlconfiguration - Dynamic route registration works for plugin pages
- Plugin metadata (menuitem, icon, group) available to React navigation menu
- Legacy Lit plugins supported via web component wrapper (if needed)
- New React plugins can be loaded directly
-
backend-ai-plugin-loadedevent replaced with React state/callback - Error handling for failed plugin loads (error boundary)
- i18n support in plugins maintained