Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Feb 10, 2026

Summary

Enterprise support for copilot models

Type of Change

  • [] New feature

Testing

Tested with @icecrasher321

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 Feb 10, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 11, 2026 0:26am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 11, 2026

Greptile Overview

Greptile Summary

This PR refactors copilot configuration to support enterprise deployments by moving model management from static frontend config to dynamic backend APIs.

Key Changes:

  • Deleted 337 lines of complex provider configuration logic (lib/copilot/config.ts)
  • Replaced hardcoded model lists with dynamic fetching from backend via new /api/copilot/models endpoint
  • Introduced composite model keys (provider/modelId format) to uniquely identify models across different providers
  • Moved chat title generation from frontend to backend API call
  • Removed COPILOT_PROVIDER and COPILOT_MODEL environment variables
  • Simplified provider configuration from complex object to simple string parameter

Architecture Impact:
The refactor centralizes control in the enterprise backend, allowing IT admins to configure available models server-side rather than requiring frontend code changes. This is a significant architectural shift toward enterprise configurability.

Minor Concerns:

  • Edge case handling for legacy model IDs without provider prefix could be improved
  • The composite model key pattern (provider/modelId) is used inconsistently - some code checks for slash presence while store initialization assumes the format

Confidence Score: 4/5

  • This PR is safe to merge with minor edge case considerations
  • The refactor successfully removes complex configuration logic and centralizes model management in the backend. The code changes are well-structured with proper type guards and error handling. However, there's a minor concern about legacy model ID migration and composite key format consistency that could cause issues if users have persisted old model selections.
  • Pay close attention to apps/sim/stores/panel/copilot/store.ts - verify the composite model key logic handles edge cases correctly, especially for users upgrading from previous versions

Important Files Changed

Filename Overview
apps/sim/app/api/copilot/chat/route.ts Moved chat title generation to backend API, removed local config dependency, now passes provider separately from model ID
apps/sim/app/api/copilot/models/route.ts New endpoint to fetch available models from copilot backend with proper type guards and error handling
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/components/model-selector/model-selector.tsx Refactored to use dynamic models from store, implemented composite provider/model key pattern with slash separator
apps/sim/lib/copilot/chat-payload.ts Removed complex provider config building logic, simplified to pass provider as string parameter
apps/sim/lib/copilot/config.ts File deleted - removed 337 lines of complex provider configuration logic in favor of enterprise backend control
apps/sim/stores/panel/copilot/store.ts Major refactor: replaced enabledModels with availableModels, added loadAvailableModels action, implemented composite model keys with parseModelKey, updated default model format

Sequence Diagram

sequenceDiagram
    participant UI as Copilot UI
    participant Store as Copilot Store
    participant ModelsAPI as /api/copilot/models
    participant ChatAPI as /api/copilot/chat
    participant Backend as SIM Agent Backend
    
    Note over UI,Store: Initialization Flow
    UI->>Store: loadAvailableModels()
    Store->>ModelsAPI: GET /api/copilot/models
    ModelsAPI->>Backend: GET /api/get-available-models
    Backend-->>ModelsAPI: {models: [{id, friendlyName, provider}]}
    ModelsAPI-->>Store: {success: true, models: [...]}
    Store->>Store: Transform to composite keys (provider/modelId)
    Store->>Store: Select default model (anthropic/claude-opus-4-6)
    Store-->>UI: Available models loaded
    
    Note over UI,Backend: Chat Message Flow
    UI->>Store: sendMessage(message)
    Store->>Store: parseModelKey(selectedModel)
    Store->>Store: Extract provider and modelId
    Store->>ChatAPI: POST {message, model: modelId, provider}
    ChatAPI->>Backend: POST /api/chat {model, provider, message}
    Backend-->>ChatAPI: Stream response
    ChatAPI-->>Store: SSE events
    Store-->>UI: Update messages
    
    Note over ChatAPI,Backend: Title Generation (First Message)
    ChatAPI->>Backend: POST /api/generate-chat-title {message, model, provider}
    Backend-->>ChatAPI: {title: "..."}
    ChatAPI->>ChatAPI: Update chat title in DB
Loading

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.

21 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@Sg312 Sg312 merged commit c5dd90e into staging Feb 11, 2026
11 checks passed
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