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:
2026-06-16 14:06:31 +08:00
parent 7506dcae3a
commit 9ffa30cc03
33 changed files with 206 additions and 206 deletions
+31 -31
View File
@@ -4,20 +4,20 @@
* 从 `chat-machine.ts` 抽出的"helpers"段:
* - 翻页大小常量
* - 仓库注入(接口类型 → 单例)
* - DTO ↔ UiMessage 映射(**纯函数** —— 可单测)
* - Result → number 映射(**纯函数** —— 可单测)
* - 2 **个**独立 init 任务**的**数据加载**
* - `readGuestQuota()` —— 游客**日**配 + 总**配****仅**游客有意义,**纯** ChatStorage
* - `readAndSyncHistory()` —— local → network → save network to local 3 **步**
* - DTO ↔ UiMessage 映射(纯函数 —— 可单测)
* - Result → number 映射(纯函数 —— 可单测)
* - 2 独立 init 任务数据加载:
* - `readGuestQuota()` —— 游客日配 + 总配(仅游客有意义, ChatStorage
* - `readAndSyncHistory()` —— local → network → save network to local 3
*
* 设计目标:
* - helpers **无 XState 依赖**(可独立 import / 测试)
* - helpers 无 XState 依赖(可独立 import / 测试)
* - actors 依赖 helpersimport
* - machine 依赖 actorsimport)—— **不**直接依赖 helpers
* - machine 依赖 actorsimport)—— 直接依赖 helpers
*
* 历史:
* - `readInitData` + `InitResult` 已**删****被** 2 **个**独立 helper **替**换**
* - `AuthStorage` import **已**删****只** `readInitData` 用过,**移**到** `chatInit` actor **上**层**调**用**
* - `readInitData` + `InitResult` 已删(被 2 个独立 helper 替换
* - `AuthStorage` import 已删(只 `readInitData` 用过,移到 `chatInit` actor 上层调用
*/
import type { UiMessage } from "@/models/chat/ui-message";
@@ -31,7 +31,7 @@ import { Result } from "@/utils/result";
// ============================================================
// Constants
// ============================================================
/** 翻历史每页大小(**仅** `loadMoreHistoryActor` 用) */
/** 翻历史每页大小( `loadMoreHistoryActor` 用) */
export const PAGE_SIZE = 20;
// ============================================================
@@ -44,7 +44,7 @@ export const chatRepo: IChatRepository = chatRepository;
// DTO ↔ UiMessage 映射
// ============================================================
/**
* ChatMessage[] → UiMessage[]**纯函数**
* ChatMessage[] → UiMessage[](纯函数)
* - 与 Dart `LocalMessage → ChatMessage` 等价
* - 业务事实:`role === "assistant"` → `isFromAI: true`
*/
@@ -63,9 +63,9 @@ export function localMessagesToUi(
}
/**
* ChatSendResponse → UiMessage**纯函数**
* - 业务事实:后端响应**就是** AI 的回复
* - 用后端 `timestamp`**不**用本地 time)—— 多设备/时区**一致**
* ChatSendResponse → UiMessage(纯函数)
* - 业务事实:后端响应就是 AI 的回复
* - 用后端 `timestamp`用本地 time)—— 多设备/时区一致
*/
export function sendResponseToUiMessage(response: ChatSendResponse): UiMessage {
return {
@@ -78,7 +78,7 @@ export function sendResponseToUiMessage(response: ChatSendResponse): UiMessage {
// ============================================================
// Result → number 映射
// ============================================================
/** 日配额 Result → number**纯函数** */
/** 日配额 Result → number(纯函数) */
export function mapQuotaResult(
r: Result<{ remaining: number } | null>,
fallback: number,
@@ -87,7 +87,7 @@ export function mapQuotaResult(
return fallback;
}
/** 总配额 Result → number**纯函数** */
/** 总配额 Result → number(纯函数) */
export function mapTotalQuotaResult(
r: Result<number | null>,
fallback: number,
@@ -118,26 +118,26 @@ export async function readGuestQuota(): Promise<{
// Init 任务 2history 3 步流(local → network → save)—— `loadHistoryActor` 调
// ============================================================
/**
* 拉 history **流**程(**每**步**都**记**日**志** —— 用户要求"**不**要**删**除**"
* 1. **读** localchatRepo.getLocalMessages)→ **返** localMessages
* 2. **读** networkchatRepo.getHistory)→ **返** networkMessages
* 3. **用** network **覆**盖** localchatRepo.saveMessagesToLocal)→ local **被**同步
* 拉 history 流程(每步都记日志 —— 用户要求"不要删除"
* 1. localchatRepo.getLocalMessages)→ localMessages
* 2. networkchatRepo.getHistory)→ networkMessages
* 3. network 覆盖 localchatRepo.saveMessagesToLocal)→ local 同步
*
* **返**回** network **最**终** messages**authorititative),**不**返** localUI **不**需**要**过渡**态**
* 返回 network 最终 messagesauthorititative),不返 localUI 不需要过渡态
*
* **保**留**日**志****前**缀 `[chat-machine]` 与 chat-machine.actors.ts **对**齐**
* 保留日志(前缀 `[chat-machine]` 与 chat-machine.actors.ts 对齐
*/
export async function readAndSyncHistory(): Promise<{
messages: UiMessage[]; // network **最**终** messagesauthorititative
messages: UiMessage[]; // network 最终 messagesauthorititative
hasMore: boolean;
newOffset: number;
localOverwritten: boolean; // true = local **已**被 network **覆**盖****写**入** ChatStorage
/** 真实从 local 读到的消息数(**调**试**用** */
localOverwritten: boolean; // true = local 被 network 覆盖(写入 ChatStorage
/** 真实从 local 读到的消息数(调试用 */
localCount: number;
/** 真实从 network 读到的消息数(**调**试**用** */
/** 真实从 network 读到的消息数(调试用 */
networkCount: number;
}> {
// 1. **读** local
// 1. local
const localResult = await chatRepo.getLocalMessages();
const localMessages =
Result.isOk(localResult) && localResult.data
@@ -147,16 +147,16 @@ export async function readAndSyncHistory(): Promise<{
count: localMessages.length,
});
// 2. **读** network
// 2. network
const networkResult = await chatRepo.getHistory(PAGE_SIZE, 0);
if (!Result.isOk(networkResult)) {
// network 失**败** —— **返**空 messages**不**让 UI 卡**住**
// network 失败 —— 返空 messages让 UI 卡
console.error(
"[chat-machine] loadHistory NETWORK FAILED",
networkResult.success ? null : (networkResult as { error: unknown }).error,
);
return {
messages: localMessages, // **退**而**求**其**次**:返 local**不**然**屏**幕**空**
messages: localMessages, // 退而求其次:返 local(不然屏幕空
hasMore: false,
newOffset: 0,
localOverwritten: false,
@@ -169,7 +169,7 @@ export async function readAndSyncHistory(): Promise<{
count: networkUi.length,
});
// 3. **用** network **覆**盖** local"**再**用**网**络**数**据**覆**盖**本**地**数**据"**这**句**的**字**面**实**现**
// 3. network 覆盖 local("再用网络数据覆盖本地数据"这句的字面实现
const saveResult = await chatRepo.saveMessagesToLocal(networkResult.data.messages);
const localOverwritten = Result.isOk(saveResult);
console.log("[chat-machine] loadHistory SAVE TO LOCAL DONE", {