-
Notifications
You must be signed in to change notification settings - Fork 66
feat: Add SQL chat artifact #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit introduces a new chat artifact for handling SQL queries. Key features: - Displays SQL queries directly in the chat UI. - "Run Query" action: - Calls a new API endpoint (`/api/sql`) to execute the query (currently placeholder execution). - Provides your feedback via toast notifications (running, success, error). - Stores query results or errors in the artifact's metadata. - "View Results" action: - Allows you to see the results or errors from the last query run (currently via alert/console). - Disabled while a query is executing. - Server-side handler for creating/updating SQL documents. - Basic unit tests for the SQL artifact client, including: - Rendering of the query. - "Run Query" action behavior (API calls, metadata updates, toasts). - "View Results" action behavior based on metadata. The artifact is registered and available for use in the chat interface. Further work can include a more sophisticated results display and actual database integration for the query execution endpoint.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new SQL chat artifact that displays and executes SQL queries via a dedicated API endpoint while providing real-time feedback through toast notifications. Key changes include:
- Implementation of the SQL document handler (server.ts) to stream and return SQL queries.
- Development of the SQL artifact client (client.tsx) with “Run Query” and “View Results” actions, supported by unit tests.
- Registration of the SQL artifact in the artifact definitions and a new API route (route.ts) for executing SQL queries.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
apps/dbagent/src/components/chat/artifacts/sql/server.ts | Implements the SQL document handler for SQL artifacts. |
apps/dbagent/src/components/chat/artifacts/sql/client.tsx | Provides the UI and action logic for SQL queries and result handling. |
apps/dbagent/src/components/chat/artifacts/sql/client.test.tsx | Adds unit tests covering rendering and action behaviors for the SQL artifact client. |
apps/dbagent/src/components/chat/artifacts/artifact.tsx | Registers the SQL artifact along with the existing artifacts. |
apps/dbagent/src/app/api/sql/route.ts | Creates a new API endpoint for SQL query execution with simulated responses. |
Comments suppressed due to low confidence (1)
apps/dbagent/src/components/chat/artifacts/sql/client.tsx:27
- Consider replacing the hardcoded values (50 and 100) with named constants or adding inline comments to document their intent, which will improve readability and ease future adjustments.
draftArtifact.content.length > 50 && draftArtifact.content.length < 100
// Simulate an error for demonstration purposes if query contains "ERROR" | ||
if (query.toUpperCase().includes('ERROR')) { |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the error simulation relies on the query containing the string 'ERROR', consider using a dedicated flag or more explicit error simulation mechanism to avoid accidental triggers in realistic inputs.
// Simulate an error for demonstration purposes if query contains "ERROR" | |
if (query.toUpperCase().includes('ERROR')) { | |
// Simulate an error for demonstration purposes if simulateError is true | |
if (simulateError) { |
Copilot uses AI. Check for mistakes.
This commit introduces a new chat artifact for handling SQL queries.
Key features:
/api/sql
) to execute the query (currently placeholder execution).The artifact is registered and available for use in the chat interface. Further work can include a more sophisticated results display and actual database integration for the query execution endpoint.