Skip to content

Commit aec040b

Browse files
committed
fix(copilot): preserve docs search guidance (#6389)
1 parent a8f7f80 commit aec040b

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

apps/sim/lib/copilot/chat/process-contents.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,30 @@ describe('processContextsServer - docs contexts', () => {
328328
{
329329
type: 'docs',
330330
tag: '@Docs',
331-
content: JSON.stringify(results),
331+
content: JSON.stringify({ results }),
332+
},
333+
])
334+
})
335+
336+
it('preserves the search note when @Docs has no relevant matches', async () => {
337+
const note =
338+
'No relevant matches. This does NOT mean the docs lack this topic. Rephrase the query.'
339+
searchDocsExecute.mockResolvedValue({ results: [], query: 'new topic', totalResults: 0, note })
340+
341+
const result = await processContextsServer(
342+
[{ kind: 'docs', label: 'Docs' }],
343+
'user-1',
344+
'@Docs new topic',
345+
'ws-1',
346+
undefined,
347+
new ResolvedSecretTraceRegistry()
348+
)
349+
350+
expect(result).toEqual([
351+
{
352+
type: 'docs',
353+
tag: '@Docs',
354+
content: JSON.stringify({ results: [], note }),
332355
},
333356
])
334357
})

apps/sim/lib/copilot/chat/process-contents.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ export async function processContextsServer(
331331
resolvedSecretTraceRegistry,
332332
}
333333
)
334-
const content = JSON.stringify(res?.results || [])
334+
const content = JSON.stringify({
335+
results: res?.results || [],
336+
...(res?.note ? { note: res.note } : {}),
337+
})
335338
return { type: 'docs', tag: ctx.label ? `@${ctx.label}` : '@', content }
336339
} catch (e) {
337340
logger.error('Failed to process docs context', e)

0 commit comments

Comments
 (0)