docs(gateway): WS 帧门相关 11 个文件的注释改中文(只改注释,代码零字节改动)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

主人 2026-10-03 拍板「注释一律中文」。本次先把本会话动过的文件就地翻;
不做全仓一次性翻译,存量按包分批排期(见 工作小结.md 待办)。

范围:ws_frame_scope.go / ws_frame_scope_test.go / broadcast.go / ws_hub_turn.go /
ws_hub_message_event.go / session_read.go / server.go / ws_hub_stream_scope_test.go /
history_write_broadcast_test.go / mood_test.go / extra_test.go
含中文的整行注释 18 → 382。

校验(判据 = "只改注释、零代码字节改动"):
- `git diff -U0 | 排除 +++/--- | 排除注释行/空行/行尾注释` → 为空
- 独立实现:两侧剥掉注释后逐行比对代码文本 → 11/11 文件全等,不一致数 0
- 行尾注释 7 行逐条列出,代码列与原文逐字节相同(gofmt 未要求重排)
- gofmt -l 干净;全树 go build/vet 绿;go test ./... = 58 包 ok / 0 FAIL;
  linux/amd64 + darwin/arm64 交叉编译绿
语义未删减:部分折行英文长句合并为更少行,故整行注释数 438 → 399。
This commit is contained in:
AskaEth committed 2026-10-03 22:07:56 +08:00
1 parent 770a83c3fb
commit fe1ff33115
11 files changed
+392 -431

No files matched your search

@@ -10,15 +10,15 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/history"
)
// These tests cover the D3 realtime-sync contract: a successful message edit or
// delete must reach the account's other browsers as a WS frame, not only the client
// that issued the REST call (otherwise every other browser has to re-read to converge).
// 这些测试覆盖 D3 实时同步契约:一次成功的消息编辑或删除必须以
// WS 帧到达该账号的其他浏览器,而不仅发起 REST 调用的客户端
// (否则其他每个浏览器都得重读才能收敛)。
// TestPatchMessageBroadcastsEdited covers ①: PATCH /api/v1/messages/{id} answers 200
// and pushes exactly one `message_edited` frame scoped to the edited message's own
// session, carrying the new content (and the mode/createdAt a client renders with).
// The frame's data is the updated message DTO with thinking stripped, matching the
// message_persisted contract; the REST reply keeps thinking (owner/admin-only read).
// TestPatchMessageBroadcastsEdited 覆盖 ①:PATCH /api/v1/messages/{id}
// 返回 200,并恰好推送一个 `message_edited` 帧,其作用域为被编辑消息
// 自身的会话,携带新内容(以及客户端渲染所用的 mode/createdAt)。该帧
// 的 data 是抹除了 thinking 的更新后消息 DTO,与 message_persisted
// 契约一致;REST 回复保留 thinking(仅 owner/admin 可读)。
func TestPatchMessageBroadcastsEdited(t *testing.T) {
t.Parallel()
ctx := context.Background()
@@ -51,7 +51,7 @@ func TestPatchMessageBroadcastsEdited(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.Fatalf("patch status = %d, want 200 (body=%s)", resp.StatusCode, body)
}
// The REST reply is the full DTO for the issuing client.
// REST 回复是发给发起方客户端的完整 DTO。
var reply historyMessage
if err := json.Unmarshal(decodeBody(t, body)["data"], &reply); err != nil {
t.Fatalf("decode reply: %v (body=%s)", err, body)
@@ -93,10 +93,9 @@ func TestPatchMessageBroadcastsEdited(t *testing.T) {
}
}
// TestDeleteMessageBroadcastsDeleted covers ②: DELETE /api/v1/messages/{id} answers
// 200, really removes the row, and pushes one `message_deleted` frame carrying the id
// plus the owning session (read before the row disappears) so a remote browser can
// drop it without re-reading.
// TestDeleteMessageBroadcastsDeleted 覆盖 ②:DELETE /api/v1/messages/{id}
// 返回 200,真正删除该行,并推送一个 `message_deleted` 帧,携带 id 以及
// 所属会话(在该行消失前读出),使远端浏览器无需重读即可移除它。
func TestDeleteMessageBroadcastsDeleted(t *testing.T) {
t.Parallel()
ctx := context.Background()
@@ -133,7 +132,7 @@ func TestDeleteMessageBroadcastsDeleted(t *testing.T) {
t.Fatal(err)
}
// The broadcast must not claim a delete that did not happen.
// 广播不得宣称一次并未发生的删除。
remaining, err := st.List(ctx, sub, 0, 50, "")
if err != nil {
t.Fatalf("list after delete: %v", err)
@@ -145,9 +144,9 @@ func TestDeleteMessageBroadcastsDeleted(t *testing.T) {
}
}
// TestDeleteMessageUnknownIDBroadcastsNothing pins the failure side: a 404 delete
// (unknown id) must not push a `message_deleted` frame, or a client would drop a
// message that still exists.
// TestDeleteMessageUnknownIDBroadcastsNothing 钉住失败侧:404 的删除
// (未知 id)不得推送 `message_deleted` 帧,否则客户端会丢掉一条仍然
// 存在的消息。
func TestDeleteMessageUnknownIDBroadcastsNothing(t *testing.T) {
t.Parallel()
srv, ts, jwt, _ := newHistoryEnv(t)