feat: support factory-based extension widgets - #359
Open
kaiwishc wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pi-web now supports extension widgets registered as factories, alongside the existing
string[]widget API. A factory creates a component through the headless TUI facade, and each render is sent to the browser through the existing extension UI event path.For a concrete example,
@juicesharp/rpiv-todoadds a todo panel above Pi's input box. It registers that panel as a factory: the factory gives Pi a small component that can render the current task list at whatever width is available. When the agent updates a task, the extension asks the component to render again instead of replacing the widget with a new array of strings. pi-web now supports that same pattern, so the live todo panel can be rendered in the browser as the task list changes.The wrapper also cleans up widget components when they are replaced, cleared, reloaded, or destroyed. Stale render callbacks are ignored. If a factory or render fails, the widget is cleared and the error is reported as
extension_error.Testing
string[]compatibility, initial and subsequent renders, cleanup, error handling, reload and destroy behavior, and command-context reloads.node --test lib/rpc-manager-widgets.test.mjsnode_modules/.bin/tsc --noEmitnpm run lintScope
This PR changes the runtime support for factory-based widgets. It does not change where widgets appear in the browser; that layout change is covered separately.