UI Components & Code Editors
Relevant source files
The following files were used as context for generating this wiki page:
- packages/web/src/components/editors/JavaScriptCodeEditor.tsx
- packages/web/src/components/systems/sections/ContextSection.tsx
- packages/web/src/components/agent/welcome/AgentWelcomeExamples.tsx
- packages/web/src/components/agent/tool-components/SearchDocumentationComponent.tsx
- packages/web/src/lib/agent/agent-context.ts
- packages/web/src/lib/agent/agent-prompts.ts
The UI Components and Code Editors module provides the interactive interface for managing systems, tools, and documentation within the superglue platform. It includes specialized editors for JavaScript transformations, complex section managers for system knowledge bases, and interactive agent components for guided tool building.
These components work together to allow users to configure integrations, write deterministic workflow logic, and interact with the AI agent to automate tool creation. The module relies on shared libraries for code formatting, resizable layouts, and real-time state management between the web interface and the underlying agent services.
JavaScript Code Editor
The JavaScriptCodeEditor component provides a Monaco-based editing environment specifically tailored for writing superglue tool transformations and logic. It enforces specific patterns, such as requiring arrow functions for transform steps.
Core Functionality
- Arrow Function Validation: When
isTransformEditoris active, the component validates that the code follows the(sourceData) => { ... }pattern. - Auto-Formatting: The editor uses
formatJavaScriptCodeto clean up code upon mounting ifautoFormatOnMountis enabled. - Resizable Interface: It utilizes a
useResizablehook to allow users to adjust the height of the editor between defined minimum and maximum bounds. - Monaco Integration: The component configures the Monaco editor with specific defaults for the superglue environment, such as disabling the minimap, enabling word wrap, and setting a specific font size.
Sources: packages/web/src/components/editors/JavaScriptCodeEditor.tsx:17-104
Code Editor Configuration
| Option | Type | Description |
|---|---|---|
isTransformEditor | boolean | Enables specific tooltips and validation for (sourceData) transformations. |
autoFormatOnMount | boolean | Automatically triggers code formatting when the component loads. |
resizable | boolean | Allows manual height adjustment via a drag handle. |
readOnly | boolean | Disables user input while maintaining syntax highlighting. |
Sources: packages/web/src/components/editors/JavaScriptCodeEditor.tsx:18-35
System Context and Knowledge Base
The ContextSection manages the system's "Knowledge Base," which consists of documentation files, OpenAPI specs, and specific usage instructions used by the agent to understand external APIs.
Component Logic
- Usage Instructions: A text area allowing users to provide instructions regarding rate limits, pagination, or authentication quirks.
- File Management: Users can upload local files or provide URLs for scraping. OpenAPI specifications are automatically detected and prioritized.
- Knowledge Base Visualization: Documents are rendered as
DocCardcomponents showing their source (Web, File, or OpenAPI) and current processing status.
Sources: packages/web/src/components/systems/sections/ContextSection.tsx:191-417
Knowledge Base Data Flow
The following diagram illustrates how documentation moves from external sources into the superglue system context.
The diagram shows the transition of documentation from user input to indexed context used by the AI agent. Sources: packages/web/src/components/systems/sections/ContextSection.tsx:210-240, packages/web/src/lib/agent/agent-prompts.ts:167-175
Agent UI Components
The agent interface utilizes specialized components to handle complex interactions, such as displaying tool building examples and rendering search results from documentation.
Search Documentation Component
The SearchDocumentationComponent displays the results of the search_documentation tool call. It handles various states:
- Pending/Running: Displays a loading spinner while the search is active.
- Completed (No Results): Shows an alert if the system has no documentation or if the specific keyword search returned nothing.
- Success: Renders the found documentation content within the chat flow.
Sources: packages/web/src/components/agent/tool-components/SearchDocumentationComponent.tsx:14-79
Tool Example Grid
The AgentWelcomeExamples component provides a set of pre-configured suggestions to help users start building tools for popular platforms like GitHub, HubSpot, and Notion.
This sequence shows how example buttons trigger the initial agent state. Sources: packages/web/src/components/agent/welcome/AgentWelcomeExamples.tsx:103-120
Playground and State Management
The UI components synchronize with the "Playground" state, which represents the current unsaved draft of a tool or system.
Initialization Markers
The system uses specific markers to track the initial state of a conversation in the playground, ensuring the agent has the correct context for editing.
TOOL_PLAYGROUND_INIT_MARKER: Marks the start of a tool editing session.SYSTEM_PLAYGROUND_INIT_MARKER: Marks the start of a system configuration session.
Sources: packages/web/src/lib/agent/agent-context.ts:98-103
Payload Merging Logic
When a user tests a tool in the playground, the system merges manual payloads with configurations to generate a snapshot for the agent. This allows the agent to see exactly what data was used during a test run.
Sources: packages/web/src/lib/agent/agent-context.ts:105-139
Conclusion
The UI components and editors in superglue provide a specialized environment for building deterministic workflows. By combining interactive code editors with a robust knowledge base management system, the platform ensures that both the user and the AI agent have the necessary context to create, test, and deploy integrations effectively.