diff --git a/src/app/chat/chat-screen.tsx b/src/app/chat/chat-screen.tsx index 7cad1c97..ad89ca87 100644 --- a/src/app/chat/chat-screen.tsx +++ b/src/app/chat/chat-screen.tsx @@ -44,7 +44,7 @@ export function ChatScreen() { // 消息数量限制由后端统一返回 lockDetail,前端不再处理本地额度。 const showMessageLimitBanner = - state.upgradePromptVisible && state.upgradeReason === "daily_limit"; + state.upgradePromptVisible && state.upgradeReason === "weekly_limit"; const messageLimitTitle = "The limit for free chat times\nhas been reached"; const externalBrowserPromptShownRef = useRef(false); diff --git a/src/app/chat/components/chat-quota-exhausted-banner.tsx b/src/app/chat/components/chat-quota-exhausted-banner.tsx index 93358e59..1caebe8e 100644 --- a/src/app/chat/components/chat-quota-exhausted-banner.tsx +++ b/src/app/chat/components/chat-quota-exhausted-banner.tsx @@ -3,7 +3,7 @@ * ChatQuotaExhaustedBanner 游客配额耗尽横幅 * * 何时显示: - * - 后端返回 lockDetail.reason="daily_limit" 且 showUpgrade=true + * - 后端返回 lockDetail.reason="weekly_limit" 且 showUpgrade=true * * 视觉规格(与设计稿对齐): * - 粉→品红渐变背景(与 splash 渐变一致) diff --git a/src/stores/chat/__tests__/chat-machine.helpers.test.ts b/src/stores/chat/__tests__/chat-machine.helpers.test.ts index 97e308f2..80de88f6 100644 --- a/src/stores/chat/__tests__/chat-machine.helpers.test.ts +++ b/src/stores/chat/__tests__/chat-machine.helpers.test.ts @@ -132,7 +132,7 @@ describe("sendResponseToUiMessage", () => { }); describe("applyHttpSendOutput", () => { - it("removes the optimistic user message when the daily limit is reached", () => { + it("removes the optimistic user message when the weekly limit is reached", () => { const context = makeChatState({ messages: [ { @@ -151,11 +151,11 @@ describe("applyHttpSendOutput", () => { locked: true, showContent: false, showUpgrade: true, - reason: "daily_limit", + reason: "weekly_limit", hint: "Free message limit reached.", detail: { - type: "daily_msg_limit", - usedToday: 3, + type: "weekly_msg_limit", + usedThisWeek: 3, limit: 3, }, }, @@ -166,7 +166,7 @@ describe("applyHttpSendOutput", () => { expect(nextState.messages).toEqual([]); expect(nextState.isReplyingAI).toBe(false); expect(nextState.upgradePromptVisible).toBe(true); - expect(nextState.upgradeReason).toBe("daily_limit"); + expect(nextState.upgradeReason).toBe("weekly_limit"); }); }); @@ -262,7 +262,7 @@ describe("countLockedHistoryMessages", () => { isFromAI: true, date: "2026-06-29", locked: true, - lockReason: "daily_limit", + lockReason: "weekly_limit", }, { content: "user text", diff --git a/src/stores/chat/__tests__/chat-machine.transitions.test.ts b/src/stores/chat/__tests__/chat-machine.transitions.test.ts index 4bcabbcf..3b3a690d 100644 --- a/src/stores/chat/__tests__/chat-machine.transitions.test.ts +++ b/src/stores/chat/__tests__/chat-machine.transitions.test.ts @@ -437,7 +437,7 @@ describe("chatMachine transitions", () => { actor.stop(); }); - it("clears the daily limit prompt after payment succeeds", async () => { + it("clears the weekly limit prompt after payment succeeds", async () => { const actor = createActor(createTestChatMachine()).start(); actor.send({ type: "ChatUserLogin", token: "token" }); @@ -459,11 +459,11 @@ describe("chatMachine transitions", () => { locked: true, showContent: false, showUpgrade: true, - reason: "daily_limit", + reason: "weekly_limit", hint: "Free message limit reached.", detail: { - type: "daily_msg_limit", - usedToday: 3, + type: "weekly_msg_limit", + usedThisWeek: 3, limit: 3, }, }, @@ -473,7 +473,7 @@ describe("chatMachine transitions", () => { }); expect(actor.getSnapshot().context.upgradePromptVisible).toBe(true); - expect(actor.getSnapshot().context.upgradeReason).toBe("daily_limit"); + expect(actor.getSnapshot().context.upgradeReason).toBe("weekly_limit"); actor.send({ type: "ChatPaymentSucceeded" }); diff --git a/src/stores/chat/chat-machine.actors.ts b/src/stores/chat/chat-machine.actors.ts index e6547306..751e599f 100644 --- a/src/stores/chat/chat-machine.actors.ts +++ b/src/stores/chat/chat-machine.actors.ts @@ -156,12 +156,12 @@ async function sendMessageViaHttp(content: string): Promise<{ log.error("[chat-machine] sendMessageHttpActor failed", { error: result.error }); throw result.error; } - const isDailyLimit = + const isMessageLimit = result.data.lockDetail.locked && result.data.lockDetail.showUpgrade && - result.data.lockDetail.reason === "daily_limit"; + result.data.lockDetail.reason === "weekly_limit"; return { response: result.data, - reply: isDailyLimit ? null : sendResponseToUiMessage(result.data), + reply: isMessageLimit ? null : sendResponseToUiMessage(result.data), }; } diff --git a/src/stores/chat/chat-machine.helpers.ts b/src/stores/chat/chat-machine.helpers.ts index c7f4f773..d5269110 100644 --- a/src/stores/chat/chat-machine.helpers.ts +++ b/src/stores/chat/chat-machine.helpers.ts @@ -173,7 +173,7 @@ export function applyHttpSendOutput( const isMessageLimitBlocked = lockDetail.locked && lockDetail.showUpgrade && - lockDetail.reason === "daily_limit"; + lockDetail.reason === "weekly_limit"; if (isMessageLimitBlocked) { const lastMessage = context.messages[context.messages.length - 1]; @@ -186,7 +186,7 @@ export function applyHttpSendOutput( messages, ...finishPendingReply(context), upgradePromptVisible: true, - upgradeReason: "daily_limit", + upgradeReason: "weekly_limit", }; } diff --git a/src/stores/chat/chat-machine.ts b/src/stores/chat/chat-machine.ts index d9acd6c4..9bc10dd0 100644 --- a/src/stores/chat/chat-machine.ts +++ b/src/stores/chat/chat-machine.ts @@ -23,7 +23,7 @@ * * 配额: * - 前端不再处理本地消息额度;游客 / 注册用户均以后端响应为准。 - * - 后端返回 `lockDetail.reason="daily_limit"` 且需要升级时展示会员引导。 + * - 后端返回 `lockDetail.reason="weekly_limit"` 且需要升级时展示会员引导。 * */ diff --git a/src/stores/chat/chat-state.ts b/src/stores/chat/chat-state.ts index 15376a66..3c2ed108 100644 --- a/src/stores/chat/chat-state.ts +++ b/src/stores/chat/chat-state.ts @@ -5,7 +5,7 @@ export interface ChatState { isReplyingAI: boolean; pendingReplyCount: number; upgradePromptVisible: boolean; - upgradeReason: "daily_limit" | null; + upgradeReason: "weekly_limit" | null; isLoadingMore: boolean; hasMore: boolean; historyOffset: number;