fix(coding-teacher): restore context and read project files

This commit is contained in:
2026-09-22 19:12:59 +08:00
parent 7f5131e92f
commit 44e754a43e
14 changed files with 626 additions and 37 deletions

View File

@@ -527,7 +527,7 @@ async function installCodingFirstChatHost(
return respond(teacherTopic,201);
}
if (path.endsWith('/teacher-topics/teacher-topic/messages') && method === 'POST') {
teacherTopic={...teacherTopic,revision:2,requests:[{id:body!.requestId,text:body!.text,references:body!.references??[],createdAt:now,sourceCursor:{workerGeneration:1,seq:1},sourceCapturedAt:now,includedSourceMessageIds:[],omittedMessages:0,status:'completed',response:'先理解状态如何随点击变化,再修改代码。'}]};
teacherTopic={...teacherTopic,revision:2,requests:[{id:body!.requestId,text:body!.text,references:body!.references??[],createdAt:now,sourceCursor:{workerGeneration:1,seq:1},sourceCapturedAt:now,includedSourceMessageIds:[],omittedMessages:0,truncatedMessages:1,status:'completed',response:'先理解状态如何随点击变化,再修改代码。'}]};
return respond(teacherTopic,202);
}
if (path.endsWith('/teacher-topics/teacher-topic')) return respond(teacherTopic);
@@ -1722,9 +1722,11 @@ test('project teacher side chat returns advice to the coding draft without submi
await page.getByRole('button',{name:'问老师',exact:true}).click();
const teacher=page.getByTestId('teacher-chat-panel');
await expect(teacher.getByText('一起理解代码')).toBeVisible();
await expect(teacher.getByText('结合当前会话和项目文件答疑')).toBeVisible();
await teacher.getByRole('textbox',{name:'向老师提问'}).fill('帮我理解当前代码');
await teacher.getByRole('button',{name:'提问',exact:true}).click();
await expect(teacher.getByText('先理解状态如何随点击变化,再修改代码。')).toBeVisible();
await expect(teacher.getByText('较长的上下文已节选,老师可按需读取原文。')).toBeVisible();
await teacher.getByRole('button',{name:'带回主会话草稿'}).click();
await expect(composer).toHaveValue('保留我的草稿\n\n先理解状态如何随点击变化,再修改代码。');
const requests=(await readState(electronApp)).captured;