improvement(copilot): trim copilot_chats reads to lean projections#4629
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Updates multiple mutation/authorization routes (chat Slims the Reviewed by Cursor Bugbot for commit 59d25fe. Configure here. |
Greptile SummaryThis PR splits
Confidence Score: 5/5Safe to merge — auth logic is shared through a well-typed generic, all migrated routes only needed ownership verification, and the full-select path is preserved for callers that consume message content. The refactoring is narrow and mechanical: the authorization logic is unchanged, the No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Mutation Route
rename / delete / update-messages
checkpoints / mothership-delete] -->|chatId, userId| B[getAccessibleCopilotChatAuth]
C[Read Route
chat GET by chatId
resolveOrCreateChat] -->|chatId, userId| D[getAccessibleCopilotChat]
B --> E[db.select id, userId,
workflowId, workspaceId, type]
D --> F[db.select *]
E --> G[authorizeCopilotChatRow T]
F --> G
G --> H{chat exists?}
H -- No --> I[return null]
H -- Yes --> J{workflowId?}
J -- Yes --> K[authorizeWorkflowByWorkspacePermission]
J -- No --> L{workspaceId?}
L -- Yes --> M[checkWorkspaceAccess]
L -- No --> N[return chat]
K --> O{allowed?}
O -- No --> I
O -- Yes --> N
M --> P{hasAccess?}
P -- No --> I
P -- Yes --> N
Reviews (2): Last reviewed commit: "fix(copilot): exercise idempotent-delete..." | Re-trigger Greptile |
|
Fixed in 59d25fe — the idempotent-delete test now overrides |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 59d25fe. Configure here.
Summary
getAccessibleCopilotChatinto a leangetAccessibleCopilotChatAuth(auth-only projection) and the existing full-row helper; identical authorization logic shared via a genericmessages/planArtifact/config/resourceson the hot auth path/api/copilot/chat(and matching contractcopilotChatGetListItemSchema) to dropmessages/planArtifact/config; verified zero client consumers of those fieldsCopilotChatAuthRow/CopilotChatListRowfrom$inferSelectso types stay in sync with the schemaType of Change
Testing
Tested manually.
bun run type-check,bun run check:api-validation:strict, and 179/179 tests across copilot + mothership suites all green.Checklist