v0.4.5: copilot updates, kb improvements, payment failure fix#1544
v0.4.5: copilot updates, kb improvements, payment failure fix#1544icecrasher321 merged 5 commits intomainfrom
Conversation
…ar subs as well (#1541)
* Add get ops examples * input format incorrectly created by copilot should not crash workflow * fix tool edits triggering overall delta * fix(db): add more options for SSL connection, add envvar for base64 db cert (#1533) * fix trigger additions * fix nested outputs for triggers * add condition subblock sanitization * fix custom tools json * Model selector * fix response format sanitization * remove dead code * fix export sanitization * Update migration * fix import race cond * Copilot settings * fix response format * stop loops/parallels copilot generation from breaking diff view * fix lint * Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix tests * fix lint --------- Co-authored-by: Siddharth Ganesan <siddharthganesan@gmail.com> Co-authored-by: Waleed <walif6@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Greptile Overview
Summary
This PR introduces significant improvements to the Sim Studio platform with two major focuses: enhanced billing enforcement and comprehensive copilot feature updates.Billing Enforcement Improvements:
The PR expands payment failure handling to include regular subscription invoices, not just overage billing. Previously, users would only be blocked for failed overage payments but could continue using the platform with failed subscription payments. Now, the handleInvoicePaymentFailed function blocks users immediately after the first payment failure (attemptCount >= 1) for any type of invoice, ensuring consistent billing enforcement across all payment types.
Copilot Feature Enhancements:
The copilot system receives substantial updates addressing context and JSON parsing edge cases. Key improvements include:
-
Model Management: New user-configurable model selection allowing users to enable/disable specific AI models (GPT-5, Claude-4 variants, O3). This is implemented through a new database column
copilot_enabled_modelsand API endpoint/api/copilot/user-models. -
Universal Availability: Copilot functionality is now available in both hosted and self-hosted environments by removing
isHostedconditions from settings components. -
Enhanced Workflow Processing: Improved workflow editing with topological sorting for proper parent-child block creation, better input sanitization for complex data types, and enhanced JSON parsing for response formats and tool configurations.
-
Improved State Management: Better handling of trigger mode outputs, parentId remapping in workflow diffs, and optimized input delta computation to track only changed fields.
-
UI Improvements: Simplified model selection interface, responsive text truncation based on panel width, and better user experience with optimistic updates.
The changes integrate well with the existing ReactFlow-based workflow system and Zustand state management, maintaining architectural consistency while expanding functionality. The version bump from 1.0.0 to 1.0.1 reflects these bug fixes and improvements in the copilot system.
Changed Files
| Filename | Score | Overview |
|---|---|---|
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx |
5/5 | Simplified copilot navigation label and removed hosting restrictions |
packages/db/schema.ts |
5/5 | Added copilotEnabledModels JSONB field to settings table |
apps/sim/app/api/copilot/chat/route.test.ts |
5/5 | Updated version numbers from 1.0.0 to 1.0.1 in test expectations |
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/copilot.tsx |
5/5 | Added panelWidth prop threading for responsive behavior |
packages/db/migrations/meta/_journal.json |
5/5 | Added migration entry for copilot enabled models column |
apps/sim/lib/sim-agent/constants.ts |
5/5 | Bumped SIM_AGENT_VERSION from 1.0.0 to 1.0.1 |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/create-menu/create-menu.tsx |
4/5 | Refactored workflow import to use database-first approach |
apps/sim/stores/copilot/types.ts |
5/5 | Added enabledModels field and setter to CopilotState interface |
apps/sim/hooks/use-collaborative-workflow.ts |
4/5 | Enhanced block output handling based on trigger mode |
apps/sim/lib/billing/webhooks/invoices.ts |
4/5 | Extended payment failure blocking to all invoice types |
apps/sim/stores/copilot/store.ts |
4/5 | Added new client tool, changed prefetch default, and enabled models functionality |
apps/sim/stores/workflows/workflow/store.ts |
4/5 | Improved block output determination for trigger vs regular modes |
apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts |
4/5 | Enhanced workflow editing with topological sorting and better error handling |
packages/db/migrations/0096_tranquil_arachne.sql |
5/5 | Database migration adding copilot_enabled_models column |
packages/db/migrations/meta/0096_snapshot.json |
4/5 | Comprehensive database schema snapshot with new copilot and billing features |
apps/sim/lib/workflows/diff/diff-engine.ts |
5/5 | Fixed parentId remapping to maintain parent-child relationships |
apps/sim/lib/workflows/training/compute-edit-sequence.ts |
4/5 | Improved workflow diff computation with better nested node handling |
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx |
4/5 | Added model filtering, UI improvements, and responsive behavior |
apps/sim/lib/workflows/json-sanitizer.ts |
3/5 | Expanded sanitization for complex data types with potential edge case issues |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/settings-modal.tsx |
5/5 | Removed hosting restrictions for copilot settings panel |
apps/sim/lib/workflows/block-outputs.ts |
4/5 | Added trigger mode support and improved null safety |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/copilot/copilot.tsx |
4/5 | Added comprehensive model management functionality |
apps/sim/app/api/copilot/user-models/route.ts |
3/5 | New API endpoint for user model preferences with potential database issues |
apps/sim/lib/copilot/tools/client/examples/get-operations-examples.ts |
4/5 | New client tool for operation examples display |
Confidence score: 4/5
- This PR introduces significant functionality improvements with generally well-structured code changes
- Score reflects some complexity in workflow processing logic and potential edge cases in JSON sanitization that could benefit from thorough testing
- Pay close attention to the billing webhook changes, JSON sanitizer modifications, and new API endpoints
24 files reviewed, 5 comments
| {agentPrefetch && | ||
| !['gpt-4o', 'gpt-4.1', 'gpt-5-fast'].includes(selectedModel) && ( | ||
| <span className='ml-1 font-semibold'>Lite</span> | ||
| )} | ||
| </span> |
There was a problem hiding this comment.
logic: Logic inversion: now shows 'Lite' when agentPrefetch is true, but comment on line 3261 still refers to 'turning off Lite mode' which is confusing
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: 3212:3216
Comment:
**logic:** Logic inversion: now shows 'Lite' when `agentPrefetch` is true, but comment on line 3261 still refers to 'turning off Lite mode' which is confusing
How can I resolve this? If you propose a fix, please make it concise.| let inputs: Record<string, string | number | string[][] | object> | ||
|
|
||
| if (block.type === 'loop' || block.type === 'parallel') { | ||
| // Extract configuration from block.data | ||
| if (block.data?.loopType) inputs.loopType = block.data.loopType | ||
| if (block.data?.count !== undefined) inputs.iterations = block.data.count | ||
| if (block.data?.collection !== undefined) inputs.collection = block.data.collection | ||
| if (block.data?.parallelType) inputs.parallelType = block.data.parallelType | ||
| const loopInputs: Record<string, string | number | string[][] | object> = {} | ||
| if (block.data?.loopType) loopInputs.loopType = block.data.loopType | ||
| if (block.data?.count !== undefined) loopInputs.iterations = block.data.count | ||
| if (block.data?.collection !== undefined) loopInputs.collection = block.data.collection | ||
| if (block.data?.parallelType) loopInputs.parallelType = block.data.parallelType | ||
| inputs = loopInputs |
There was a problem hiding this comment.
style: Variable inputs is declared without initialization, then conditionally assigned. Consider initializing as empty object
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/workflows/json-sanitizer.ts
Line: 299:308
Comment:
**style:** Variable `inputs` is declared without initialization, then conditionally assigned. Consider initializing as empty object
How can I resolve this? If you propose a fix, please make it concise.| if ( | ||
| inputFormatValue !== null && | ||
| inputFormatValue !== undefined && | ||
| !Array.isArray(inputFormatValue) | ||
| ) { | ||
| inputFormatValue = [] | ||
| } |
There was a problem hiding this comment.
style: The null check logic is duplicated at lines 80-87. Consider extracting this into a helper function for better maintainability.
Context Used: Context from dashboard - Group optional parameters into an options object for better maintainability when defining functions ... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/workflows/block-outputs.ts
Line: 52:58
Comment:
**style:** The null check logic is duplicated at lines 80-87. Consider extracting this into a helper function for better maintainability.
**Context Used:** Context from `dashboard` - Group optional parameters into an options object for better maintainability when defining functions ... ([source](https://app.greptile.com/review/custom-context?memory=3b7b0948-a7d1-42f5-b9cd-2848dc8dfead))
How can I resolve this? If you propose a fix, please make it concise.| const [created] = await db | ||
| .insert(settings) | ||
| .values({ | ||
| id: userId, | ||
| userId, | ||
| copilotEnabledModels: {}, | ||
| }) | ||
| .returning() |
There was a problem hiding this comment.
logic: The created variable is declared but never used, and the insert operation could potentially fail if the user already has settings
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/api/copilot/user-models/route.ts
Line: 71:78
Comment:
**logic:** The `created` variable is declared but never used, and the insert operation could potentially fail if the user already has settings
How can I resolve this? If you propose a fix, please make it concise.| async execute(): Promise<void> { | ||
| return | ||
| } |
There was a problem hiding this comment.
logic: Empty execute method - ensure this is intentional. If this tool should perform actual work, add implementation.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/copilot/tools/client/examples/get-operations-examples.ts
Line: 28:30
Comment:
**logic:** Empty execute method - ensure this is intentional. If this tool should perform actual work, add implementation.
How can I resolve this? If you propose a fix, please make it concise.…rsistence (#1546) * fix autolayout and custom tools persistence * fix * fix preserving positions within subflow * more fixes * fix resizing * consolidate constants
…#1539) * feat(kb): added json/yaml parser+chunker, added dedicated csv chunker * ack PR comments * improved kb upload
Summary