feat(chat): unlock paid messages before payment

This commit is contained in:
2026-06-30 18:56:17 +08:00
parent 5f94105bc6
commit e7a9e7abe5
21 changed files with 774 additions and 31 deletions
+20
View File
@@ -1,7 +1,17 @@
import type { UiMessage } from "@/data/dto/chat";
import type { PendingChatUnlockKind } from "@/lib/navigation/chat_unlock_session";
export type ChatUpgradeReason = "weekly_limit" | "insufficient_credits";
export interface ChatUnlockPaywallRequest {
messageId: string;
kind: PendingChatUnlockKind;
reason: string;
creditBalance: number;
requiredCredits: number;
shortfallCredits: number;
}
export interface ChatState {
messages: UiMessage[];
isReplyingAI: boolean;
@@ -27,6 +37,11 @@ export interface ChatState {
lockedHistoryCount: number;
isUnlockingHistory: boolean;
unlockHistoryError: string | null;
isUnlockingMessage: boolean;
unlockingMessageId: string | null;
unlockingMessageKind: PendingChatUnlockKind | null;
unlockMessageError: string | null;
unlockPaywallRequest: ChatUnlockPaywallRequest | null;
}
export const initialState: ChatState = {
@@ -50,4 +65,9 @@ export const initialState: ChatState = {
lockedHistoryCount: 0,
isUnlockingHistory: false,
unlockHistoryError: null,
isUnlockingMessage: false,
unlockingMessageId: null,
unlockingMessageKind: null,
unlockMessageError: null,
unlockPaywallRequest: null,
};