feat(chat): handle credit-gated send responses

This commit is contained in:
2026-06-30 14:17:14 +08:00
parent f4d0f76466
commit 958a0f8ffd
12 changed files with 303 additions and 17 deletions
+15 -1
View File
@@ -1,11 +1,19 @@
import type { UiMessage } from "@/data/dto/chat";
export type ChatUpgradeReason = "weekly_limit" | "insufficient_credits";
export interface ChatState {
messages: UiMessage[];
isReplyingAI: boolean;
pendingReplyCount: number;
upgradePromptVisible: boolean;
upgradeReason: "weekly_limit" | null;
upgradeReason: ChatUpgradeReason | null;
canSendMessage: boolean;
cannotSendReason: string | null;
creditBalance: number;
creditsCharged: number;
requiredCredits: number;
shortfallCredits: number;
isLoadingMore: boolean;
hasMore: boolean;
historyOffset: number;
@@ -27,6 +35,12 @@ export const initialState: ChatState = {
pendingReplyCount: 0,
upgradePromptVisible: false,
upgradeReason: null,
canSendMessage: true,
cannotSendReason: null,
creditBalance: 0,
creditsCharged: 0,
requiredCredits: 0,
shortfallCredits: 0,
isLoadingMore: false,
hasMore: true,
historyOffset: 0,