feat: allow retry with new message (#10307)

fix AF-1630
This commit is contained in:
darkskygit
2025-02-20 06:07:53 +00:00
parent 50820482df
commit 13f1859cdf
9 changed files with 313 additions and 44 deletions
@@ -498,6 +498,15 @@ test('should be able to retry with api', async t => {
);
}
const cleanObject = (obj: any[]) =>
JSON.parse(
JSON.stringify(obj, (k, v) =>
['id', 'sessionId', 'createdAt'].includes(k) || v === null
? undefined
: v
)
);
// retry chat
{
const { id } = await createWorkspace(app);
@@ -514,10 +523,32 @@ test('should be able to retry with api', async t => {
// should only have 1 message
const histories = await getHistories(app, { workspaceId: id });
t.deepEqual(
histories.map(h => h.messages.map(m => m.content)),
[['generate text to text']],
'should be able to list history'
t.snapshot(
cleanObject(histories),
'should be able to list history after retry'
);
}
// retry chat with new message id
{
const { id } = await createWorkspace(app);
const sessionId = await createCopilotSession(
app,
id,
randomUUID(),
promptName
);
const messageId = await createCopilotMessage(app, sessionId);
await chatWithText(app, sessionId, messageId);
// retry with new message id
const newMessageId = await createCopilotMessage(app, sessionId);
await chatWithText(app, sessionId, newMessageId, '', true);
// should only have 1 message
const histories = await getHistories(app, { workspaceId: id });
t.snapshot(
cleanObject(histories),
'should be able to list history after retry'
);
}