Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Training interface that will be enabled on Staging environment.

Type of Change

  • New feature

Testing

Tested with indexer repo @Sg312

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

vercel bot commented Sep 24, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Error Error Sep 24, 2025 9:16pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 24, 2025 9:16pm

@vercel vercel bot temporarily deployed to Preview – docs September 24, 2025 20:54 Inactive
Copy link
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 implements a comprehensive copilot training interface that allows users to capture workflow editing sessions and send them to an external indexer for training purposes. The implementation adds a modal-based UI for starting/stopping training sessions, viewing collected datasets, and exporting training data.

Key Changes:

  • Training API Route: New /api/copilot/training endpoint that forwards training data to an external agent indexer with proper validation and error handling
  • Training UI Components: Complete modal interface with tabbed views for starting sessions, monitoring progress, and managing datasets
  • State Management: Zustand store managing training sessions, workflow snapshots, and dataset collection with comprehensive edit sequence computation
  • Database Schema: Addition of showTrainingControls setting to control feature visibility
  • Environment Configuration: New environment variables for agent indexer integration

Technical Implementation:

The system captures workflow state snapshots before and after editing sessions, computes detailed edit sequences (add/edit/delete operations), converts states to YAML format, and forwards everything to an external training indexer. The UI provides full dataset management including bulk operations, individual sending, and export functionality.

Issues Found:

  • Use of z.any() in API validation schema reduces type safety
  • Large functions in training modal should be extracted for better maintainability
  • Minor type assertion issues in metadata processing

Confidence Score: 4/5

  • This PR is safe to merge with minor code quality improvements recommended
  • Score reflects solid implementation with comprehensive functionality, proper error handling, and good state management, but some code quality issues around type safety and function complexity should be addressed
  • Pay attention to the training API route and modal component for the mentioned type safety and refactoring improvements

Important Files Changed

File Analysis

Filename        Score        Overview
apps/sim/app/api/copilot/training/route.ts 3/5 New API route for training data submission with proper validation and error handling, but uses loose typing with z.any()
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/training-controls/training-modal.tsx 3/5 Complex training interface modal with comprehensive functionality but contains large functions that should be refactored
apps/sim/stores/copilot-training/store.ts 4/5 Well-structured Zustand store for training state management with clear separation of concerns

Sequence Diagram

sequenceDiagram
    participant User
    participant TrainingModal as Training Modal
    participant TrainingStore as Training Store
    participant WorkflowStore as Workflow Store
    participant TrainingAPI as Training API
    participant IndexerAPI as Agent Indexer API
    participant YAMLConverter as YAML Converter

    User->>TrainingModal: Click "Start Training Session"
    TrainingModal->>TrainingStore: startTraining(title, prompt)
    TrainingStore->>WorkflowStore: captureWorkflowSnapshot()
    WorkflowStore-->>TrainingStore: WorkflowState
    TrainingStore-->>TrainingModal: Session started
    
    Note over User, TrainingModal: User edits workflow...
    
    User->>TrainingModal: Click "Save Dataset"
    TrainingModal->>TrainingStore: stopTraining()
    TrainingStore->>WorkflowStore: captureWorkflowSnapshot()
    WorkflowStore-->>TrainingStore: EndWorkflowState
    TrainingStore->>TrainingStore: computeEditSequence(start, end)
    TrainingStore-->>TrainingModal: Dataset created
    
    User->>TrainingModal: Click "Send" on dataset
    TrainingModal->>YAMLConverter: Convert start/end states to YAML
    YAMLConverter-->>TrainingModal: YAML representations
    TrainingModal->>TrainingAPI: POST /api/copilot/training
    TrainingAPI->>TrainingAPI: Validate request body
    TrainingAPI->>IndexerAPI: POST /operations/add
    IndexerAPI-->>TrainingAPI: Success/Error response
    TrainingAPI-->>TrainingModal: Response
    TrainingModal-->>User: Success/Error notification
Loading

18 files reviewed, 3 comments

Edit Code Review Bot Settings | Greptile

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.

2 participants