feat(runtime): IM 主人私聊补历史转录(与 Web 主会话同源:抽共享 transcript 包 + OwnerEnvFor 单入口)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

This commit is contained in:
AskaEth committed 2026-10-05 11:36:18 +08:00
1 parent df8fc660c0
commit 9b903a89bc
14 files changed
+676 -181

No files matched your search

@@ -21,6 +21,7 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/history"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/loop"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/transcript"
)
// TestChatDocumentsStreamPathCarriesDocuments 钉住 `stream:true` 这条转发路径:
@@ -92,7 +93,7 @@ func TestTranscriptMessageKeepsDocumentReference(t *testing.T) {
if err != nil {
t.Fatalf("encode document: %v", err)
}
msg := transcriptMessage(history.Message{ID: "m1", Role: history.RoleUser, Content: "读一下", Document: raw})
msg := transcript.Message(history.Message{ID: "m1", Role: history.RoleUser, Content: "读一下", Document: raw})
docs := chatDocumentsOf([]model.Message{msg})
if len(docs) != 1 {
t.Fatalf("文档引用没能重建回来:%+v", msg)
@@ -103,17 +104,17 @@ func TestTranscriptMessageKeepsDocumentReference(t *testing.T) {
}
// 没有附件的消息照旧没有文档部件;坏列不 panic 也不产生部件(打 WARN)。
if got := chatDocumentsOf([]model.Message{
transcriptMessage(history.Message{ID: "m2", Role: history.RoleUser, Content: "无附件"}),
transcript.Message(history.Message{ID: "m2", Role: history.RoleUser, Content: "无附件"}),
}); len(got) != 0 {
t.Fatalf("无附件消息产生了文档部件:%+v", got)
}
if got := chatDocumentsOf([]model.Message{
transcriptMessage(history.Message{ID: "m3", Role: history.RoleUser, Content: "坏列", Document: "{not json"}),
transcript.Message(history.Message{ID: "m3", Role: history.RoleUser, Content: "坏列", Document: "{not json"}),
}); len(got) != 0 {
t.Fatalf("坏列产生了文档部件:%+v", got)
}
// 助手回合的说话者标注不受本次改动影响;附件不会落到非用户回合上。
assistant := transcriptMessage(history.Message{
assistant := transcript.Message(history.Message{
ID: "m4", Role: history.RoleAssistant, Content: "答复", PersonaID: "cyrene", Document: raw,
})
if assistant.SenderName != "cyrene" {