Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Fix several edge cases for JSON language copilot sees.

Type of Change

  • Bug fix

Testing

Tested manually and via training interface

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 Oct 4, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Oct 4, 2025 2:12am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 4, 2025 2:12am

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 comprehensive improvements to the copilot system, focusing on fixing JSON parsing edge cases and enhancing model management capabilities. The changes span multiple areas:

Database Schema Enhancement: Adds a new copilot_enabled_models JSONB column to the settings table, allowing users to configure which AI models are enabled for their copilot experience. This includes a complete database migration (0096) and SSL configuration improvements across all database connection points.

Copilot Model Management: Introduces a sophisticated model preference system where users can selectively enable/disable OpenAI and Anthropic models. The implementation includes a new API endpoint (/api/copilot/user-models) for managing these preferences, integration with the copilot store for state management, and a redesigned settings UI that combines API key management with model selection.

JSON Parsing Improvements: Addresses multiple edge cases in workflow processing that were causing issues for the copilot. Key fixes include:

  • Enhanced block output resolution that properly handles trigger mode vs normal mode
  • Improved workflow edit sequence computation with delta-based updates and duplicate operation prevention
  • Better JSON sanitization for responseFormat, conditions, and tools
  • Fixed parent-child relationship handling in workflow diffs
  • Robust input format validation to prevent null/undefined errors

UI/UX Enhancements: The copilot interface receives several improvements including responsive design with dynamic width handling, terminology changes from "MAX" to "Lite" mode for better user understanding, prefetching optimizations in settings navigation, and broader availability of copilot features across deployment environments (no longer restricted to hosted-only).

Infrastructure Improvements: Standardizes SSL configuration across all PostgreSQL connections with support for multiple SSL modes (disable, prefer, require, verify-ca, verify-full) and custom CA certificate handling, replacing previous boolean SSL toggles.

The changes integrate well with the existing codebase architecture, following established patterns for Zustand store management, API design, and database migrations. The copilot system now has more robust data processing capabilities and provides users with granular control over AI model preferences.

Important Files Changed

Changed Files
Filename Score Overview
packages/db/migrations/0096_tranquil_arachne.sql 5/5 Adds copilot_enabled_models JSONB column to settings table with proper defaults
packages/db/schema.ts 5/5 Defines the new copilotEnabledModels field in the settings table schema
apps/sim/stores/copilot/types.ts 5/5 Adds enabledModels state and setter for tracking user model preferences
apps/sim/lib/sim-agent/constants.ts 5/5 Version bump from 1.0.0 to 1.0.1 for copilot agent
apps/sim/stores/copilot/store.ts 5/5 Integrates GetOperationsExamplesClientTool and adds model preference management
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/settings-modal.tsx 4/5 Removes hosted-only restriction for copilot settings access
packages/db/scripts/migrate-deployment-versions.ts 4/5 Enhances SSL configuration with support for multiple modes and CA certificates
packages/db/scripts/deregister-sso-provider.ts 4/5 New administrative script for SSO provider cleanup operations
apps/sim/stores/workflows/workflow/store.ts 4/5 Improves block output handling for trigger mode blocks
apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts 4/5 Adds topological sorting and JSON normalization for workflow operations
apps/sim/.env.example 5/5 Updates database SSL configuration examples with new modes and CA options
apps/sim/hooks/use-collaborative-workflow.ts 4/5 Fixes block output generation for collaborative workflows
apps/sim/app/api/copilot/user-models/route.ts 3/5 New API endpoint for managing user model preferences with some validation concerns
apps/sim/socket-server/database/operations.ts 4/5 Implements comprehensive SSL configuration for socket server database connections
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/copilot.tsx 5/5 Passes panelWidth prop to UserInput for responsive behavior
apps/sim/lib/workflows/block-outputs.ts 4/5 Adds trigger mode support and input format sanitization
packages/db/scripts/register-sso-provider.ts 4/5 Updates SSL configuration for SSO provider registration script
apps/sim/lib/workflows/json-sanitizer.ts 3/5 Complex JSON sanitization improvements with some security and performance concerns
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/copilot/copilot.tsx 4/5 Major refactor to comprehensive copilot settings with model management
packages/db/migrations/meta/0096_snapshot.json 4/5 Complete database schema snapshot with new copilot tables and functionality
apps/sim/lib/workflows/diff/diff-engine.ts 5/5 Fixes parentId reference updates during block remapping
packages/db/index.ts 4/5 Comprehensive SSL configuration and database connection caching
apps/sim/lib/env.ts 5/5 Adds PostgreSQL SSL mode enum and CA certificate environment variables
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx 4/5 Adds model filtering, responsive design, and UI terminology improvements
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/subscription/subscription.tsx 5/5 Refactors billing notifications to use centralized store management
apps/sim/lib/workflows/training/compute-edit-sequence.ts 4/5 Optimizes workflow edit operations with delta updates and duplicate prevention
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx 4/5 Adds prefetching and removes copilot hosting restrictions
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/create-menu/create-menu.tsx 2/5 Refactors workflow import with potential dependency issues
apps/sim/socket-server/rooms/manager.ts 4/5 Updates SSL configuration for socket server database connections
packages/db/migrations/meta/_journal.json 5/5 Records new migration entry for database tracking

Confidence score: 4/5

  • This PR addresses important edge cases and introduces valuable copilot functionality with mostly safe changes
  • Score reflects some concerns around validation in the user-models API endpoint, potential dependency issues in create-menu, and security considerations in JSON sanitization
  • Pay close attention to apps/sim/app/api/copilot/user-models/route.ts and apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/create-menu/create-menu.tsx for validation and dependency issues

30 files reviewed, 9 comments

Edit Code Review Agent Settings | Greptile

Resolved conflicts by preferring staging's version for database/SSL-related files:
- apps/sim/.env.example
- apps/sim/socket-server/database/operations.ts
- apps/sim/socket-server/rooms/manager.ts
- packages/db/index.ts
- packages/db/scripts/*.ts (SSO provider scripts)

These changes were unrelated to the copilot workflow resize feature.

Main feature changes preserved:
- Fix for loop/parallel resize after copilot edits (workflow.tsx timing fix)
@vercel vercel bot temporarily deployed to Preview – docs October 4, 2025 01:49 Inactive
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – docs October 4, 2025 02:04 Inactive
@vercel vercel bot temporarily deployed to Preview – docs October 4, 2025 02:06 Inactive
@icecrasher321 icecrasher321 merged commit c42d2a3 into staging Oct 4, 2025
9 of 10 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/copilot-operations branch October 7, 2025 23: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.

4 participants