( chatId: string, userId: string )
| 177 | * (JSONB), `pinned`, and `lastSeenAt` — none of which the endpoint returns. |
| 178 | */ |
| 179 | export async function getAccessibleCopilotChat( |
| 180 | chatId: string, |
| 181 | userId: string |
| 182 | ): Promise<CopilotChatLegacyDetailRow | null> { |
| 183 | const [chat] = await db |
| 184 | .select(copilotChatLegacyDetailColumns) |
| 185 | .from(copilotChats) |
| 186 | .where(and(eq(copilotChats.id, chatId), eq(copilotChats.userId, userId))) |
| 187 | .limit(1) |
| 188 | |
| 189 | const authorized = await authorizeCopilotChatRow(chat, chatId, userId) |
| 190 | if (!authorized) return null |
| 191 | |
| 192 | const messages = await loadCopilotChatMessages(chatId) |
| 193 | return { ...authorized, messages } |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Load a copilot chat with the conversation transcript and resources after |
no test coverage detected