AI Context Webview UI Skill
Purpose
Help the ai-context-writer subagent create and maintain docs/AI_CONTEXT/AI_CONTEXT_WEBVIEW_UI.md as the component-level reference for the webview-ui/ React + Rete graph editor:
- •How the webview is bootstrapped
- •How messages are handled
- •How graphs are rendered and updated
- •How node components map to AST node types
- •How styling and theming work
Sources to Read
Before updating the webview UI context, read:
- •
@webview-ui/src/index.tsx - •
@webview-ui/src/App.tsx - •
@webview-ui/src/editor.tsx - •
@webview-ui/src/types.ts - •
@webview-ui/src/conversion.ts(if used) - •
@webview-ui/src/nodes/components andnodes/index.ts - •
@webview-ui/src/index.cssand@webview-ui/src/components/NodeStyles.css - •Relevant tests under
@tests/(if any target webview behavior)
Optionally cross-check with:
- •
@src/types.tsfor shared message and graph types.
Required Sections in AI_CONTEXT_WEBVIEW_UI.md
Include at least:
- •
Metadata
- •Version
- •Last Updated (ISO date)
- •Tags including
webview-ui,react,rete - •Cross-References to repository and extension-host AI_CONTEXT docs
- •
Module Overview
- •Roles of:
- •
index.tsx - •
App.tsx - •
editor.tsx - •
types.ts - •
nodes/andcomponents/
- •
- •Roles of:
- •
Bootstrap & Lifecycle
- •How
index.tsxsets up the React root and connects to VS Code’sacquireVsCodeApi. - •How
App.tsxinitializesReteASTEditorand listens for messages viawindow.addEventListener("message", ...).
- •How
- •
Message Handling
- •Types of messages expected from the extension:
- •
updateGraph - •
error - •
loading
- •
- •Messages the webview sends back:
- •
navigateToSource - •
retry
- •
- •How each message affects local React state and the editor.
- •Types of messages expected from the extension:
- •
Graph Rendering (editor.tsx)
- •How
ReteASTEditor:- •Initializes the Rete editor, area, connection, and React plugins.
- •Transforms
ReteGraphinto Rete nodes and connections. - •Applies node positions and zoom-to-fit behavior.
- •How node click handlers are wired to send
navigateToSourcemessages.
- •How
- •
Node Components (nodes/)
- •How
ASTNode.tsxserves as the base visual component. - •How specialized nodes (
BinOpNode,CallNode,ClassDefNode,FunctionDefNode,NameNode, etc.) extend the base. - •How
nodes/index.tsmapsast_typestrings to concrete components.
- •How
- •
Styling & Theming
- •Use of VS Code theme variables for colors.
- •Role of
index.cssandNodeStyles.css. - •Any important class names (e.g.
.ast-node-wrapper) that other agents might rely on.
- •
Testing & Diagnostics (if available)
- •Describe how UI behavior is tested (if tests exist).
- •Mention how to debug message flow or graph rendering from within the webview.
Style & Constraints
- •Focus on behavior and integration rather than React basics.
- •Use concise descriptions and reference actual prop names and type names from
types.ts. - •Provide small code snippets for message payload shapes and example message handlers.
- •Keep the file within the content length limit; split into sub-documents if the webview grows significantly.
Update Strategy
When the webview UI changes:
- •Update message type lists and their behavior.
- •Add or update node component mappings.
- •Refresh styling/theming notes if CSS structure changes.
- •Adjust descriptions of initialization and lifecycle to match the current
App.tsxandeditor.tsx. - •Bump version and last-updated metadata.