Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,15 @@ describe("a chat's other chats", () => {
readRecallChats.execute({ principal: organizationPrincipal(), input })
).rejects.toMatchObject({ code: 'forbidden' })
resetDbChainMock()
// A workflow's copilot chat is no home chat, so it reads no home chats back.
// A workflow's copilot chat is no home chat, so it reads no home chats back, and says so
// rather than reporting its own chat missing.
queueWorkspaceChat('agent', 'copilot')
await expect(
readRecallChats.execute({ principal: workspacePrincipal(), input })
).rejects.toMatchObject({ code: 'not_found' })
).rejects.toMatchObject({
code: 'forbidden',
message: "Reading other chats is available in home chats, not in a workflow's copilot chat",
})
resetDbChainMock()
queueOrganizationChat()
authBanMockFns.mockGetActivelyBannedUserIds.mockResolvedValue(['actor'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ export const readRecallChats = defineAuthorizedChatUseCase({
},
},
async execute({ principal, context, input }): Promise<RecallChatsResponse> {
if (context.type !== 'mothership') throw new OrchestrationError('not_found', 'Chat not found')
if (context.type !== 'mothership') {
throw new OrchestrationError(
'forbidden',
"Reading other chats is available in home chats, not in a workflow's copilot chat"
)
}
if (context.mode !== 'agent' && context.mode !== 'plan') {
throw new OrchestrationError('forbidden', 'Reading other chats requires an agent chat')
}
Expand Down
Loading