perf(copilot): narrow getAccessibleCopilotChat projection#4720
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Introduces Reviewed by Cursor Bugbot for commit fe941f8. Configure here. |
Greptile SummaryThis PR tightens the DB projection in
Confidence Score: 5/5Safe to merge — the narrowed projection covers every field the single production caller consumes, and unrelated callers use different function variants. The column set in No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant GET as GET /api/copilot/chat
participant LC as lifecycle.ts
participant DB as copilot_chats
Client->>GET: "GET ?chatId=..."
GET->>LC: getAccessibleCopilotChat(chatId, userId)
LC->>DB: "SELECT id, userId, workflowId, workspaceId, type, title, messages, conversationId, resources, createdAt, updatedAt, model, planArtifact, config WHERE id=? AND userId=? LIMIT 1"
Note over DB: Drops previewYaml, pinned, lastSeenAt
DB-->>LC: CopilotChatLegacyDetailRow
LC->>LC: authorizeCopilotChatRow(chat, ...)
LC-->>GET: CopilotChatLegacyDetailRow or null
GET->>GET: transformChat(chat)
GET-->>Client: "{ success, chat }"
Reviews (1): Last reviewed commit: "perf(copilot): narrow getAccessibleCopil..." | Re-trigger Greptile |
Summary
getAccessibleCopilotChatinlib/copilot/chat/lifecycle.tsfromdb.select()(all columns) to an explicit projection that dropspreviewYaml(JSONB),pinned, andlastSeenAt— none of which the legacy chat detail endpoint returnscopilotChatLegacyDetailColumns(extendscopilotChatDetailColumnswithmodel,planArtifact,config) and aCopilotChatLegacyDetailRowtypeapp/api/copilot/chat/queries.ts:83) still gets every field itstransformChatresponse consumes (id, title, model, messages, planArtifact, config, conversationId, resources, createdAt, updatedAt + auth columns)copilot_chatsquery, p99 3.5sType of Change
Testing
Tested manually; existing test mocks (
{ id, userId, workflowId }shape) remain structurally compatible with the newCopilotChatLegacyDetailRowtype. Lint passes.Checklist