mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +08:00
feat(core): support fork session without latestMessageId (#12587)
Close [AI-86](https://linear.app/affine-design/issue/AI-86) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Improved chat session forking to allow creating a fork without specifying the latest message, enabling more flexible session management. - **Bug Fixes** - Forking a chat session with an invalid latest message ID now correctly returns an error. - **Tests** - Added and updated test cases to cover session forking with missing or invalid latest message IDs, ensuring robust behavior in these scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -281,7 +281,7 @@ test('should fork session correctly', async t => {
|
||||
const assertForkSession = async (
|
||||
workspaceId: string,
|
||||
sessionId: string,
|
||||
lastMessageId: string,
|
||||
lastMessageId: string | undefined,
|
||||
error: string,
|
||||
asserter = async (x: any) => {
|
||||
const forkedSessionId = await x;
|
||||
@@ -330,6 +330,27 @@ test('should fork session correctly', async t => {
|
||||
);
|
||||
}
|
||||
|
||||
// should be able to fork session without latestMessageId (copy all messages)
|
||||
{
|
||||
forkedSessionId = await assertForkSession(
|
||||
id,
|
||||
sessionId,
|
||||
undefined,
|
||||
'should be able to fork session without latestMessageId'
|
||||
);
|
||||
}
|
||||
|
||||
// should not be able to fork session with wrong latestMessageId
|
||||
{
|
||||
await assertForkSession(id, sessionId, 'wrong-message-id', '', async x => {
|
||||
await t.throwsAsync(
|
||||
x,
|
||||
{ instanceOf: Error },
|
||||
'should not able to fork session with wrong latestMessageId'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const u2 = await app.signupV1('u2@affine.pro');
|
||||
await assertForkSession(id, sessionId, randomUUID(), '', async x => {
|
||||
|
||||
Reference in New Issue
Block a user