feat: AI 回复说明替学生定了什么并问一个问题,“帮我写清楚”能看到题目和之前的对话
Deploy / deploy (build, debian, 22) (push) Canceled after 0s

- 生成回复分“做了什么 / 我替你定的 / 想一想”三项;只问问题时直接回答、不给代码
- 没有代码的回复发 code: null,不再清空网页;上下文保留最近一份带代码的回复
- 教练带上题目要求、最近的提问和 AI 上一次的说明,照搬题目不算写清楚

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-27 21:36:06 +08:00
1 parent 9fee688d95
commit 43c18cdb88
7 files changed
+155 -41

No files matched your search

+14 -1
View File
@@ -111,7 +111,7 @@ describe("streamChat", () => {
expect(out).toBe("你好世界")
expect(model).toBe(config.llmModel)
expect(thinking).toEqual({ type: "enabled" })
for await (const _ of streamGuidance([{ role: "user", content: "hi" }]));
for await (const _ of streamGuidance([{ role: "user", content: "hi" }], "题目:x"));
expect(thinking).toEqual({ type: "disabled" })
} finally {
Object.assign(config, saved)
@@ -140,6 +140,19 @@ test("trimHistory 只留最近 20 条,旧回复的代码换成占位", () => {
expect(out.filter((m) => m.content.includes("<p>"))).toHaveLength(1)
})
test("trimHistory 最后一条回复没有代码时,保留之前最新的那份代码", () => {
const out = trimHistory([
{ role: "user", content: "做个页面" },
{ role: "assistant", content: "第1版\n```html\n<p>1</p>\n```" },
{ role: "user", content: "加个按钮" },
{ role: "assistant", content: "第2版\n```html\n<p>2</p>\n```" },
{ role: "user", content: "为什么按钮是圆的?" },
{ role: "assistant", content: "因为加了 border-radius。" },
])
expect(out[3]!.content).toContain("<p>2</p>")
expect(out[1]!.content).not.toContain("<p>1</p>")
})
test("userFacingError 不透出接口原始返回", () => {
const quiet = console.error
console.error = () => {}