Skip to content

improvement(copilot): version update#1689

Merged
Sg312 merged 32 commits intostagingfrom
improvement/copilot-2
Oct 18, 2025
Merged

improvement(copilot): version update#1689
Sg312 merged 32 commits intostagingfrom
improvement/copilot-2

Conversation

@Sg312
Copy link
Copy Markdown
Collaborator

@Sg312 Sg312 commented Oct 18, 2025

Summary

edit sent messages, revert logic, model selection, add haiku 4.5, add exa search, fix env var

Fixes #(issue)

Type of Change

  • Bug fix
  • New feature

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 18, 2025 7:58pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

@Sg312 Sg312 merged commit cc0ace7 into staging Oct 18, 2025
3 checks passed
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 clearOnSubmit prop to UserInput for 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
Loading

27 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@@ -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('|')})`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@waleedlatif1 waleedlatif1 deleted the improvement/copilot-2 branch October 30, 2025 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant