-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(copilot): fix context / json parsing edge cases #1542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…into feat/copilot-operations
…into feat/copilot-operations
…into feat/copilot-operations
There was a problem hiding this 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.tsandapps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/create-menu/create-menu.tsxfor validation and dependency issues
30 files reviewed, 9 comments
.../sim/app/workspace/[workspaceId]/w/components/sidebar/components/create-menu/create-menu.tsx
Show resolved
Hide resolved
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)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Summary
Fix several edge cases for JSON language copilot sees.
Type of Change
Testing
Tested manually and via training interface
Checklist