Skip to content

Commit 2db94a5

Browse files
authored
fix(mothership): say why a workflow copilot chat cannot read other chats (#9520)
1 parent e0b3427 commit 2db94a5

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎apps/sim/lib/mothership/chat/application/read-recall-chats.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,15 @@ describe("a chat's other chats", () => {
196196
readRecallChats.execute({ principal: organizationPrincipal(), input })
197197
).rejects.toMatchObject({ code: 'forbidden' })
198198
resetDbChainMock()
199-
// A workflow's copilot chat is no home chat, so it reads no home chats back.
199+
// A workflow's copilot chat is no home chat, so it reads no home chats back, and says so
200+
// rather than reporting its own chat missing.
200201
queueWorkspaceChat('agent', 'copilot')
201202
await expect(
202203
readRecallChats.execute({ principal: workspacePrincipal(), input })
203-
).rejects.toMatchObject({ code: 'not_found' })
204+
).rejects.toMatchObject({
205+
code: 'forbidden',
206+
message: "Reading other chats is available in home chats, not in a workflow's copilot chat",
207+
})
204208
resetDbChainMock()
205209
queueOrganizationChat()
206210
authBanMockFns.mockGetActivelyBannedUserIds.mockResolvedValue(['actor'])

‎apps/sim/lib/mothership/chat/application/read-recall-chats.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ export const readRecallChats = defineAuthorizedChatUseCase({
100100
},
101101
},
102102
async execute({ principal, context, input }): Promise<RecallChatsResponse> {
103-
if (context.type !== 'mothership') throw new OrchestrationError('not_found', 'Chat not found')
103+
if (context.type !== 'mothership') {
104+
throw new OrchestrationError(
105+
'forbidden',
106+
"Reading other chats is available in home chats, not in a workflow's copilot chat"
107+
)
108+
}
104109
if (context.mode !== 'agent' && context.mode !== 'plan') {
105110
throw new OrchestrationError('forbidden', 'Reading other chats requires an agent chat')
106111
}

0 commit comments

Comments
 (0)