Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
This PR significantly enhances the Copilot feature with message editing, improved checkpoint management, model selection updates, and Exa search integration.
Key Changes
- Message Editing: Users can now edit previously sent messages, which triggers conversation truncation and re-sends the edited message
- Checkpoint Management: Checkpoints are automatically deleted after reverting to prevent reuse, with improved UI for revert confirmation
- Model Selection: Added Claude Haiku 4.5 model with proper validation to ensure selected models are in the enabled list
- Exa Search Integration: Added Exa AI as the primary search provider with automatic fallback to Serper
- Context Usage API: New endpoint to fetch context usage statistics from sim-agent
- Chat Management: New API routes for deleting chats and updating chat titles
- UI Improvements: Enhanced mention menu with portal rendering, better positioning logic, and message dimming during edits
Technical Improvements
- Improved tool call instance management to ensure client tools are properly registered
- Added
clearOnSubmitprop toUserInputfor better control in edit mode - Enhanced scroll and positioning logic for mention menu to prevent off-screen rendering
- Better error handling in checkpoint deletion (non-blocking failure)
Issues Found
- Critical: Regex escaping pattern in user-input.tsx has incorrect syntax for bracket escaping
Confidence Score: 4/5
- This PR is mostly safe to merge with one syntax fix required
- Score of 4 reflects comprehensive feature additions with good error handling and logical implementation. The single critical syntax error in the regex pattern needs to be fixed before deployment, as it could cause runtime issues when escaping special characters in mention labels. The rest of the implementation is well-structured with proper state management, API error handling, and UI/UX improvements.
- apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx requires the regex syntax fix before merge
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/copilot/tools/server/other/search-online.ts | 4/5 | Added Exa search as primary search provider with fallback to Serper |
| apps/sim/app/api/copilot/context-usage/route.ts | 4/5 | New API route to fetch context usage statistics from sim-agent, userId now extracted from session |
| apps/sim/stores/copilot/store.ts | 4/5 | Major refactoring: added message editing, checkpoint management, context usage fetching, and improved chat deletion |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx | 4/5 | Added message editing UI, revert mode with checkpoint discard confirmation, and message dimming during edits |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx | 3/5 | Major refactoring of input component: added claude-4.5-haiku, improved mention menu positioning with portal, added clearOnSubmit prop, fixed overlay sync issues |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/copilot.tsx | 4/5 | Added model selection validation, edit/revert mode tracking, message dimming during edits, and context usage fetching on mount |
Sequence Diagram
sequenceDiagram
participant User
participant CopilotUI as Copilot UI
participant UserInput as User Input
participant Store as Copilot Store
participant ChatAPI as Chat API
participant CheckpointAPI as Checkpoint API
participant ContextAPI as Context Usage API
participant SimAgent as Sim Agent
participant SearchTool as Search Tool
participant Exa as Exa API
participant Serper as Serper API
%% Message Edit Flow
User->>CopilotUI: Click message to edit
CopilotUI->>CopilotUI: Enter edit mode, dim later messages
User->>UserInput: Modify message content
User->>UserInput: Submit edited message
alt Has checkpoints
UserInput->>CopilotUI: Show discard confirmation
User->>CopilotUI: Confirm discard
end
UserInput->>Store: Truncate messages after edit point
Store->>ChatAPI: Update messages in DB
Store->>Store: Send edited message
Store->>ContextAPI: Fetch context usage
ContextAPI->>SimAgent: Request context usage
SimAgent-->>ContextAPI: Return usage data
ContextAPI-->>Store: Update context usage
%% Checkpoint Revert Flow
User->>CopilotUI: Click revert on message
CopilotUI->>CopilotUI: Show confirmation, dim later messages
User->>CopilotUI: Confirm revert
CopilotUI->>CheckpointAPI: Revert to checkpoint
CheckpointAPI->>CheckpointAPI: Apply checkpoint state
CheckpointAPI->>CheckpointAPI: Delete checkpoint from DB
CheckpointAPI-->>CopilotUI: Success
CopilotUI->>Store: Remove checkpoint, truncate messages
Store->>ChatAPI: Update messages in DB
CopilotUI->>CopilotUI: Enter edit mode for message
%% Search Flow with Exa
User->>Store: Send message with search intent
Store->>SimAgent: Stream chat request
SimAgent->>SearchTool: Execute search_online
alt Exa API available
SearchTool->>Exa: Search query
alt Exa returns results
Exa-->>SearchTool: Results
SearchTool-->>SimAgent: Transformed results
else Exa fails/no results
SearchTool->>Serper: Fallback search
Serper-->>SearchTool: Results
SearchTool-->>SimAgent: Results
end
else Only Serper available
SearchTool->>Serper: Search query
Serper-->>SearchTool: Results
SearchTool-->>SimAgent: Results
end
SimAgent-->>Store: Stream response
Store-->>CopilotUI: Update UI
Store->>ContextAPI: Fetch context usage
ContextAPI->>SimAgent: Request context usage
SimAgent-->>ContextAPI: Return usage data
ContextAPI-->>Store: Update context usage
27 files reviewed, 1 comment
| @@ -2065,7 +2298,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>( | |||
| // Build regex for all labels | |||
| const labels = contexts.map((c) => c.label).filter(Boolean) | |||
| const pattern = new RegExp( | |||
| `@(${labels.map((l) => l.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')).join('|')})`, | |||
| `@(${labels.map((l) => l.replace(/[.*+?^${}()|[\\]\\]/g, '\\$&')).join('|')})`, | |||
Contributor
There was a problem hiding this comment.
syntax: regex pattern for escaping special characters is incorrect - closing bracket ] should be escaped as \\] not \\ alone
Suggested change
| `@(${labels.map((l) => l.replace(/[.*+?^${}()|[\\]\\]/g, '\\$&')).join('|')})`, | |
| `@(${labels.map((l) => l.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})`, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx
Line: 2301:2301
Comment:
**syntax:** regex pattern for escaping special characters is incorrect - closing bracket `]` should be escaped as `\\]` not `\\` alone
```suggestion
`@(${labels.map((l) => l.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})`,
```
How can I resolve this? If you propose a fix, please make it concise.
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
edit sent messages, revert logic, model selection, add haiku 4.5, add exa search, fix env var
Fixes #(issue)
Type of Change
Testing
Manual
Checklist