fix(sidebar): unify workflow and folder insertion ordering#3250
fix(sidebar): unify workflow and folder insertion ordering#3250waleedlatif1 merged 7 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryUnifies the sort order insertion logic across all workflow and folder creation/duplication paths. Previously, new items were placed at the top based only on siblings of the same type (e.g., workflow creation only checked other workflows). Now, all four code paths (workflow create, workflow duplicate, folder create, folder duplicate) compute the minimum sort order across both sibling workflows and sibling folders in the same parent scope, then insert at
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Create/Duplicate Request] --> B{Server or Client?}
B -->|Server API| C[Query min sort order from<br/>sibling workflows]
B -->|Server API| D[Query min sort order from<br/>sibling folders]
B -->|Client Optimistic| E[getTopInsertionSortOrder]
C --> F[Promise.all]
D --> F
F --> G[Reduce to global minimum]
E --> H[Filter workflows by<br/>workspaceId + folderId]
E --> I[Filter folders by<br/>workspaceId + parentId]
H --> J[Compute Math.min<br/>of all sibling sort orders]
I --> J
G --> K{min found?}
J --> L{siblings exist?}
K -->|Yes| M[sortOrder = min - 1]
K -->|No| N[sortOrder = 0]
L -->|Yes| O[sortOrder = min - 1]
L -->|No| P[sortOrder = 0]
M --> Q[Insert at top of list]
N --> Q
O --> Q
P --> Q
Last reviewed commit: 8662179 |
|
@cursor review |
|
@greptile |
|
@greptile |
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| } | ||
| } | ||
|
|
||
| // Helper to recursively duplicate folder structure |
There was a problem hiding this comment.
Response parentId diverges from inserted targetParentId
Low Severity
The DB insert uses targetParentId (computed with ?? on line 65), but the JSON response on line 160 still uses the old expression parentId || sourceFolder.parentId (with ||). The response parentId can differ from the value actually stored in the database — for instance, if parentId were an empty string, ?? would keep it while || would fall through to sourceFolder.parentId. The response parentId feeds the client store via mapFolder, so any mismatch means the client briefly shows the folder under the wrong parent until refetch.


Summary
Type of Change
Testing
Tested manually, added a bunch of unit tests
Checklist