docs(comments): 注释中文化 · internal/runtime/history(15 文件,纯替换)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- 只翻注释/文档字符串:剥离注释后代码行逐字节不变(机械校验只剩 4 条行尾注释的翻译,代码前缀全等)
- 交叉引用(design/16 §4.6、D4/B3、0010 迁移文件名)逐字保留
- 保留未译技术词:DDL/rowid/LIKE/LEFT JOIN/DTO/rune/WS/actor 及全部标识符与表名
- 顺带副作用:store.go、session_persona_test.go 由注释文字改变而变得 gofmt 干净(未运行 gofmt -w)
This commit is contained in:
AskaEth committed 2026-10-04 12:28:48 +08:00
1 parent b0fbb8bc0d
commit 09fba77f87
15 files changed
+430 -516

No files matched your search

+12 -12
View File
@@ -7,7 +7,7 @@ import (
"testing"
)
// titleOf returns the stored title of a session, failing the test when it is absent.
// titleOf 返回某个会话已存储的标题,缺失时使测试失败。
func titleOf(t *testing.T, st *Store, id string) string {
t.Helper()
sessions, err := st.ListSessions(context.Background())
@@ -28,12 +28,12 @@ func TestEnsureTitleFromFirstUserMessage(t *testing.T) {
st := newStore(t)
ctx := context.Background()
// The main session starts nameless.
// 主会话初始无名。
if got := titleOf(t, st, MainSessionID); got != "" {
t.Fatalf("initial main title = %q, want empty", got)
}
// The first user message names it, with whitespace runs collapsed.
// 第一条用户消息为它命名,空白串被折叠。
if _, err := st.AppendFull(ctx, Message{SessionID: MainSessionID, Role: RoleUser, Content: " 你好\n世界 "}); err != nil {
t.Fatalf("append first user: %v", err)
}
@@ -41,7 +41,7 @@ func TestEnsureTitleFromFirstUserMessage(t *testing.T) {
t.Fatalf("main title = %q, want 你好 世界", got)
}
// A later user message does not overwrite the established title.
// 之后的用户消息不会覆盖已确定的标题。
if _, err := st.AppendFull(ctx, Message{SessionID: MainSessionID, Role: RoleUser, Content: "second"}); err != nil {
t.Fatalf("append second user: %v", err)
}
@@ -55,7 +55,7 @@ func TestEnsureTitleTruncatesAndFallsBack(t *testing.T) {
st := newStore(t)
ctx := context.Background()
// A long first user message is truncated to 20 runes plus an ellipsis.
// 过长的首条用户消息被截断到 20 个 rune 并加省略号。
sub, err := st.NewSubSession(ctx, "owner")
if err != nil {
t.Fatalf("new sub: %v", err)
@@ -69,8 +69,8 @@ func TestEnsureTitleTruncatesAndFallsBack(t *testing.T) {
t.Fatalf("sub title = %q, want %q", got, want)
}
// An all-whitespace first message (e.g. an image-only turn) falls back to the
// session-type label, for both a sub and the main session.
// 纯空白的首条消息(例如纯图片回合)回退到会话类型标签,子会话与主会话
// 都是如此。
blank, err := st.NewSubSession(ctx, "owner")
if err != nil {
t.Fatalf("new blank sub: %v", err)
@@ -96,7 +96,7 @@ func TestEnsureTitleOnlyFromFirstUserMessage(t *testing.T) {
st := newStore(t)
ctx := context.Background()
// An assistant message first does not name the session.
// 首条是 assistant 消息不会为会话命名。
sub, err := st.NewSubSession(ctx, "owner")
if err != nil {
t.Fatalf("new sub: %v", err)
@@ -108,7 +108,7 @@ func TestEnsureTitleOnlyFromFirstUserMessage(t *testing.T) {
t.Fatalf("sub title after assistant = %q, want empty", got)
}
// The first user message afterwards still names it.
// 其后的第一条用户消息仍会为它命名。
if _, err := st.AppendFull(ctx, Message{SessionID: sub, Role: RoleUser, Content: "real question"}); err != nil {
t.Fatalf("append user: %v", err)
}
@@ -122,7 +122,7 @@ func TestRenameSession(t *testing.T) {
st := newStore(t)
ctx := context.Background()
// The fixed main session may be renamed (unlike deletion).
// 固定主会话可以重命名(与删除不同)。
if err := st.RenameSession(ctx, MainSessionID, "工作台"); err != nil {
t.Fatalf("rename main: %v", err)
}
@@ -130,7 +130,7 @@ func TestRenameSession(t *testing.T) {
t.Fatalf("main title = %q, want 工作台", got)
}
// A sub session may be renamed, and a rename overwrites an auto title.
// 子会话可以重命名,且重命名会覆盖自动标题。
sub, err := st.NewSubSession(ctx, "owner")
if err != nil {
t.Fatalf("new sub: %v", err)
@@ -145,7 +145,7 @@ func TestRenameSession(t *testing.T) {
t.Fatalf("sub title = %q, want 手动标题", got)
}
// An unknown id is reported as not found.
// 未知 id 报 not found。
if err := st.RenameSession(ctx, "web:missing", "x"); !errors.Is(err, ErrSessionNotFound) {
t.Fatalf("rename unknown err = %v, want ErrSessionNotFound", err)
}