Open
Description
Feature: React Code Rendering in Chat Interface
Primary Objective:
Enable users to view and interact with generated React code both in raw form and as a rendered application.
Key Requirements:
- Display Location
- Render the generated React code within the existing
ArtifactRenderer
section - Maintain the current raw code display as the default view
- Implement a toggle switch between raw code and rendered application views
- Performance Optimization
- Lazy load the rendered application
- Only instantiate the React rendering when a user explicitly toggles to the rendered view
- Rationale: Prevents unnecessary rendering operations during code modifications
- Technical Implementation
- Utilize Code Sandbox API for the sandbox environment
- Preserve visibility of quick actions and custom quick actions in both views
- User Interaction Flow
- Maintain chat functionality while viewing rendered application
- Disable code highlighting when in rendered view
- During code streaming (
isStreaming
true):- Pause parsing/rendering of new code chunks
- Wait for complete code stream before updating render
Rationale: Prevents partial or invalid renders during code generation
- Error Handling
- Display toast notifications for errors (invalid code, type errors, etc.)
- Include specific error messages in notifications
- Maintain last valid rendered state during errors
Rationale: Ensures users can continue viewing working code while addressing issues
- Integration
- Integrate with Code Sandbox API for secure code execution
- Do not expose the Code Sandbox editor/IDE they offer, and instead use the existing code renderer component. (using their IDE appears to be expensive from their docs)
The ArtifactCodeV3
interface should be updated with a new field sandboxURL
so each revision can store the sandbox URL. This means when a user navigates between different revisions, it should update the rendered code.
Finally, in the final PR, it would be great if you could include a cost analysis so I have a rough idea as to how much it will cost.
Metadata
Metadata
Assignees
Type
Projects
Status
In Progress