-
Notifications
You must be signed in to change notification settings - Fork 2.5k
improvement(copilot): v0.2 #2086
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
* Fix template details * Fix deps
… consistent, smoothen out creation of profile (#1943) * fix(templates): view current ui * update UI to be less cluttered * make state management for creating user profile smoother * fix autoselect logic * fix lint
…ng (#1945) * fix(settings): fix broken api keys, help modal, logs, workflow renaming * fix build * cleanup * use emcn
… drag event directly (#1951)
* new gifs * changed wording * changed wording * lowercase * changed wording * remove blog stuff --------- Co-authored-by: aadamgough <[email protected]> Co-authored-by: waleed <[email protected]>
* feat(drizzle): added ods for analytics from drizzle * clean
* feat(docs): added docs analytics drizzle ods * fix build
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR introduces copilot v0.2 with significant architectural improvements to workflow editing and new capabilities for deployment and navigation. The changes center around a refactored diff system that now tracks baseline workflows separately from proposed changes, enabling better undo/redo integration. Key Changes
Architecture ImprovementsThe workflow diff engine now properly isolates baseline state from proposed changes, allowing copilot edits to be applied, previewed, accepted, or rejected without corrupting the undo/redo stack. The new Issues Found
Confidence Score: 3/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant CopilotUI as Copilot UI
participant CopilotStore as Copilot Store
participant Tool as Client Tool
participant DiffStore as Workflow Diff Store
participant WorkflowStore as Workflow Store
participant UndoRedo as Undo/Redo Store
participant API as Backend API
User->>CopilotUI: Send message with mode (ask/build/plan)
CopilotUI->>API: POST /api/copilot/chat
API-->>CopilotStore: SSE stream (tool_call events)
alt Tool Call: edit_workflow
CopilotStore->>Tool: Instantiate EditWorkflowClientTool
Tool->>API: Execute edit_workflow with operations
API-->>Tool: Return proposed WorkflowState
Tool->>DiffStore: setProposedChanges(proposedState)
DiffStore->>DiffStore: Capture baseline snapshot
DiffStore->>WorkflowStore: Apply diff markers to blocks
DiffStore-->>CopilotUI: Show diff preview
alt User accepts changes
User->>Tool: Click Accept
Tool->>DiffStore: acceptChanges()
DiffStore->>UndoRedo: runWithUndoRedoRecordingSuspended
DiffStore->>WorkflowStore: replaceWorkflowState(cleanState)
DiffStore->>API: PUT /api/workflows/{id}/state
DiffStore->>DiffStore: clearDiff()
DiffStore-->>CopilotUI: Hide diff preview
else User rejects changes
User->>Tool: Click Reject
Tool->>DiffStore: rejectChanges()
DiffStore->>UndoRedo: runWithUndoRedoRecordingSuspended
DiffStore->>WorkflowStore: replaceWorkflowState(baseline)
DiffStore->>DiffStore: clearDiff()
DiffStore-->>CopilotUI: Hide diff preview
end
end
alt Tool Call: deploy_workflow
CopilotStore->>Tool: Instantiate DeployWorkflowClientTool
Tool->>API: Check API keys
alt Has API keys
Tool->>API: POST /api/workflows/{id}/deploy
API-->>Tool: Deployment success + endpoint
Tool->>WorkflowStore: Update deployment status
Tool-->>CopilotUI: Show curl command
else No API keys
Tool->>CopilotUI: Open API keys modal
Tool-->>CopilotUI: Show "needs API key" message
end
end
alt Tool Call: navigate_ui
CopilotStore->>Tool: Instantiate NavigateUIClientTool
User->>Tool: Click Accept (Open)
Tool->>Tool: Resolve destination URL
Tool->>User: window.location.href = url
end
alt Undo/Redo Operations
User->>UndoRedo: Trigger undo
UndoRedo->>UndoRedo: Check if recording suspended
UndoRedo->>WorkflowStore: replaceWorkflowState(previousState)
UndoRedo->>API: Queue replaceWorkflowState operation
end
|
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.
84 files reviewed, 5 comments
|
|
||
| // Navigate if URL was set | ||
| if (navigationUrl) { | ||
| window.location.href = navigationUrl |
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.
logic: using window.location.href causes full page reload, losing client-side state and causing jarring UX
| window.location.href = navigationUrl | |
| window.history.pushState({}, '', navigationUrl) | |
| window.dispatchEvent(new PopStateEvent('popstate')) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/copilot/tools/client/navigation/navigate-ui.ts
Line: 207:207
Comment:
**logic:** using `window.location.href` causes full page reload, losing client-side state and causing jarring UX
```suggestion
window.history.pushState({}, '', navigationUrl)
window.dispatchEvent(new PopStateEvent('popstate'))
```
How can I resolve this? If you propose a fix, please make it concise.| edgeCount: affectedEdges?.length || 0, | ||
| }) | ||
| }, | ||
| [activeWorkflowId, userId, undoRedoStore] |
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.
syntax: changed from sync to async without updating return type in signature, could cause issues for callers expecting synchronous behavior
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/hooks/use-undo-redo.ts
Line: 328:328
Comment:
**syntax:** changed from sync to async without updating return type in signature, could cause issues for callers expecting synchronous behavior
How can I resolve this? If you propose a fix, please make it concise.| function cloneWorkflowState(state: WorkflowState): WorkflowState { | ||
| return { | ||
| ...state, | ||
| blocks: structuredClone(state.blocks || {}), | ||
| edges: structuredClone(state.edges || []), | ||
| loops: structuredClone(state.loops || {}), | ||
| parallels: structuredClone(state.parallels || {}), | ||
| } |
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.
logic: using structuredClone can fail on complex objects with functions, symbols, or DOM nodes (common in workflow blocks with callbacks)
| function cloneWorkflowState(state: WorkflowState): WorkflowState { | |
| return { | |
| ...state, | |
| blocks: structuredClone(state.blocks || {}), | |
| edges: structuredClone(state.edges || []), | |
| loops: structuredClone(state.loops || {}), | |
| parallels: structuredClone(state.parallels || {}), | |
| } | |
| function cloneWorkflowState(state: WorkflowState): WorkflowState { | |
| return JSON.parse(JSON.stringify({ | |
| ...state, | |
| blocks: state.blocks || {}, | |
| edges: state.edges || [], | |
| loops: state.loops || {}, | |
| parallels: state.parallels || {}, | |
| })) | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/stores/workflow-diff/store.ts
Line: 26:33
Comment:
**logic:** using `structuredClone` can fail on complex objects with functions, symbols, or DOM nodes (common in workflow blocks with callbacks)
```suggestion
function cloneWorkflowState(state: WorkflowState): WorkflowState {
return JSON.parse(JSON.stringify({
...state,
blocks: state.blocks || {},
edges: state.edges || [],
loops: state.loops || {},
parallels: state.parallels || {},
}))
}
```
How can I resolve this? If you propose a fix, please make it concise.| private getSanitizedWorkflowJson(workflowState: any): string | undefined { | ||
| const logger = createLogger('EditWorkflowClientTool') | ||
|
|
||
| if (!this.workflowId) { | ||
| logger.warn('No workflowId available for getting sanitized workflow JSON') | ||
| return undefined | ||
| } |
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.
style: returning undefined without error handling means silent failures won't be surfaced to copilot, making debugging difficult
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/copilot/tools/client/workflow/edit-workflow.ts
Line: 44:50
Comment:
**style:** returning `undefined` without error handling means silent failures won't be surfaced to copilot, making debugging difficult
How can I resolve this? If you propose a fix, please make it concise.| <div className='px-[10px] py-[8px]'> | ||
| <span className='font-mono text-muted-foreground text-xs'> | ||
| {method || 'GET'} | ||
| </span> | ||
| <input | ||
| type='text' | ||
| value={method || 'GET'} | ||
| onChange={(e) => setEditedParams({ ...editedParams, method: e.target.value })} | ||
| className='w-full bg-transparent font-mono text-muted-foreground text-xs outline-none focus:text-foreground' | ||
| /> |
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.
style: editing method directly without validation allows invalid HTTP methods like "GETT" or "post" (lowercase)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/copilot/components/inline-tool-call/inline-tool-call.tsx
Line: 543:549
Comment:
**style:** editing method directly without validation allows invalid HTTP methods like "GETT" or "post" (lowercase)
How can I resolve this? If you propose a fix, please make it concise.
Summary
New copilot version: improves existing tools, adds new copilot tools, improves diff store interactions
Type of Change
Testing
Manual
Checklist