style: remove markdown bold syntax from code comments
Remove `**...**` emphasis markers from inline comments and JSDoc blocks across auth and chat components, machine mappers, and quota helpers. These are plain code comments, not rendered markdown, so the bold syntax was noise. Files touched: - src/app/auth/components/auth-screen.tsx - src/app/chat/components/chat-header.tsx - src/app/chat/components/chat-screen.tsx - chat machine mapper / quota helpers No functional or behavioral changes.
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
* Chat 状态机:4 个 XState actor
|
||||
*
|
||||
* 从 `chat-machine.ts` 抽出的"Actors"段:
|
||||
* - `loadQuotaActor`(fromPromise,**仅**游客有意义 —— 拉**日**配 + 总**配**)
|
||||
* - `loadHistoryActor`(fromPromise —— local → network → save network to local 3 **步**)
|
||||
* - `sendMessageHttpActor`(fromPromise,**已** wire —— "一次发送 = 一次返回")
|
||||
* - `loadMoreHistoryActor`(fromPromise —— 翻**页**,**不**走 local-first)
|
||||
* - `chatWebSocketActor`(fromCallback,长生命周期 —— **仅** userSession 期间 invoke)
|
||||
* - `loadQuotaActor`(fromPromise,仅游客有意义 —— 拉日配 + 总配)
|
||||
* - `loadHistoryActor`(fromPromise —— local → network → save network to local 3 步)
|
||||
* - `sendMessageHttpActor`(fromPromise,已 wire —— "一次发送 = 一次返回")
|
||||
* - `loadMoreHistoryActor`(fromPromise —— 翻页,不走 local-first)
|
||||
* - `chatWebSocketActor`(fromCallback,长生命周期 —— 仅 userSession 期间 invoke)
|
||||
*
|
||||
* 设计:
|
||||
* - 依赖 `chat-machine.helpers.ts`(纯函数 + 数据加载)
|
||||
* - 依赖 `createChatWebSocket`(`@/core/net/chat-websocket`)
|
||||
* - 保留**全链日志**(用户要求"不要将其删除")
|
||||
* - 保留全链日志(用户要求"不要将其删除")
|
||||
* - 命名约定:`[chat-machine]` 前缀 —— 与 `chat-machine.ts` 的日志对齐
|
||||
*/
|
||||
|
||||
@@ -31,12 +31,12 @@ import {
|
||||
import type { ChatEvent } from "./chat-events";
|
||||
|
||||
// ============================================================
|
||||
// Init 任务 1:拉游客配额(fromPromise,**纯** local)
|
||||
// Init 任务 1:拉游客配额(fromPromise,纯 local)
|
||||
// ============================================================
|
||||
/**
|
||||
* 拉游客**日**配 + 总**配**(**仅** guestSession 期间 invoke)
|
||||
* - 失**败**返 `{ remaining: 0, total: 0 }`(**不**抛,**让** UI **还**是**能**进** ready)
|
||||
* - onDone 在 state machine **里**赋 guestRemainingQuota + guestTotalQuota + 设 quotaLoaded: true
|
||||
* 拉游客日配 + 总配(仅 guestSession 期间 invoke)
|
||||
* - 失败返 `{ remaining: 0, total: 0 }`(不抛,让 UI 还是能进 ready)
|
||||
* - onDone 在 state machine 里赋 guestRemainingQuota + guestTotalQuota + 设 quotaLoaded: true
|
||||
*/
|
||||
export const loadQuotaActor = fromPromise<{
|
||||
remaining: number;
|
||||
@@ -49,13 +49,13 @@ export const loadQuotaActor = fromPromise<{
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// Init 任务 2:拉 history 3 步流(fromPromise,**返**回**最**终**结**果**)
|
||||
// Init 任务 2:拉 history 3 步流(fromPromise,返回最终结果)
|
||||
// ============================================================
|
||||
/**
|
||||
* local → network → save network to local 3 步流(**返**回** network **最**终** messages**)
|
||||
* - 选**方**案 A(fromPromise):UI **不**会**看**到** local 中**间**态**,**直**接**显**示** network **结**果**
|
||||
* - 内部 3 步**走** helper `readAndSyncHistory`(**日**志**全**在** helper **里**)
|
||||
* - 失**败**返 local(**退**而**求**其**次**)
|
||||
* local → network → save network to local 3 步流(返回 network 最终 messages)
|
||||
* - 选方案 A(fromPromise):UI 不会看到 local 中间态,直接显示 network 结果
|
||||
* - 内部 3 步走 helper `readAndSyncHistory`(日志全在 helper 里)
|
||||
* - 失败返 local(退而求其次)
|
||||
*/
|
||||
export const loadHistoryActor = fromPromise<{
|
||||
messages: UiMessage[];
|
||||
@@ -81,10 +81,10 @@ export const loadHistoryActor = fromPromise<{
|
||||
// HTTP: one-shot Promise
|
||||
// ============================================================
|
||||
/**
|
||||
* HTTP 发送消息(**一次发送 = 一次返回**)
|
||||
* - 后端响应**就**是 AI 回复(`ChatSendResponse.reply: string`)
|
||||
* - **不**再调 `getLocalMessages()`(**多此一举**)
|
||||
* - 返回 `{ reply: UiMessage }` —— `sending.onDone` 把它**追加**到 `context.messages`
|
||||
* HTTP 发送消息(一次发送 = 一次返回)
|
||||
* - 后端响应就是 AI 回复(`ChatSendResponse.reply: string`)
|
||||
* - 不再调 `getLocalMessages()`(多此一举)
|
||||
* - 返回 `{ reply: UiMessage }` —— `sending.onDone` 把它追加到 `context.messages`
|
||||
*/
|
||||
export const sendMessageHttpActor = fromPromise<
|
||||
{ reply: UiMessage },
|
||||
@@ -122,7 +122,7 @@ export const sendMessageHttpActor = fromPromise<
|
||||
return { reply };
|
||||
});
|
||||
|
||||
/** 翻历史(pagination)—— **不**走 local-first,**纯** server fetch */
|
||||
/** 翻历史(pagination)—— 不走 local-first,纯 server fetch */
|
||||
export const loadMoreHistoryActor = fromPromise<
|
||||
{ messages: UiMessage[]; hasMore: boolean; newOffset: number },
|
||||
{ offset: number }
|
||||
@@ -173,13 +173,13 @@ export const loadMoreHistoryActor = fromPromise<
|
||||
// WebSocket: long-lived callback
|
||||
// ============================================================
|
||||
/**
|
||||
* 长生命周期 WebSocket(**仅** `userSession` 期间 invoke)
|
||||
* 长生命周期 WebSocket(仅 `userSession` 期间 invoke)
|
||||
* - 启动:连 WS,事件 → sendBack 派回机器
|
||||
* - 停止(cleanup):disconnect
|
||||
* - **游客**不** invoke 此 actor(业务事实"游客不连 WS")
|
||||
* - 游客不 invoke 此 actor(业务事实"游客不连 WS")
|
||||
*
|
||||
* 之所以用 fromCallback 而非 fromPromise:
|
||||
* - WS 是长连接,**不**是一次性 Promise
|
||||
* - WS 是长连接,不是一次性 Promise
|
||||
* - fromCallback 提供 `sendBack` 回调,actor 内部事件 → 机器
|
||||
* - cleanup 函数 → XState 在 parent state exit 时自动调用
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user