mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix: use correct user id in forked session (#7710)
This commit is contained in:
@@ -571,6 +571,7 @@ export class ChatSessionService {
|
||||
|
||||
const forkedState = {
|
||||
...state,
|
||||
userId: options.userId,
|
||||
sessionId: randomUUID(),
|
||||
messages: [],
|
||||
parentSessionId: options.sessionId,
|
||||
|
||||
@@ -273,7 +273,7 @@ test('should be able to manage chat session', async t => {
|
||||
});
|
||||
|
||||
test('should be able to fork chat session', async t => {
|
||||
const { prompt, session } = t.context;
|
||||
const { auth, prompt, session } = t.context;
|
||||
|
||||
await prompt.set('prompt', 'model', [
|
||||
{ role: 'system', content: 'hello {{word}}' },
|
||||
@@ -305,8 +305,10 @@ test('should be able to fork chat session', async t => {
|
||||
...commonParams,
|
||||
});
|
||||
t.not(sessionId, forkedSessionId1, 'should fork a new session');
|
||||
|
||||
const newUser = await auth.signUp('test', 'darksky.1@affine.pro', '123456');
|
||||
const forkedSessionId2 = await session.fork({
|
||||
userId,
|
||||
userId: newUser.id,
|
||||
sessionId,
|
||||
latestMessageId,
|
||||
...commonParams,
|
||||
@@ -335,10 +337,13 @@ test('should be able to fork chat session', async t => {
|
||||
);
|
||||
}
|
||||
|
||||
// check second times forked session messages
|
||||
// check second times forked session
|
||||
{
|
||||
const s2 = (await session.get(forkedSessionId2))!;
|
||||
|
||||
// should overwrite user id
|
||||
t.is(s2.config.userId, newUser.id, 'should have same user id');
|
||||
|
||||
const finalMessages = s2
|
||||
.finish(params) // @ts-expect-error
|
||||
.map(({ id: _, createdAt: __, ...m }) => m);
|
||||
|
||||
Reference in New Issue
Block a user