refactor(characters): drive shared UI from active character

This commit is contained in:
2026-07-17 19:33:59 +08:00
parent 8bb1e21886
commit 7bd5defa5e
42 changed files with 335 additions and 118 deletions
+7 -1
View File
@@ -2,7 +2,10 @@ import type { UiMessage } from "@/stores/chat/ui-message";
import type { PendingChatUnlockKind } from "@/lib/navigation/chat_unlock_session";
import type { ChatLockType } from "@/data/schemas/chat";
import type { PendingChatPromotion } from "@/data/storage/navigation";
import { DEFAULT_CHARACTER_ID } from "@/data/constants/character";
import {
DEFAULT_CHARACTER,
DEFAULT_CHARACTER_ID,
} from "@/data/constants/character";
import type { ChatPromotionState } from "./helper/promotion";
export type ChatUpgradeReason = "insufficient_credits";
@@ -26,6 +29,7 @@ export interface ChatUnlockPaywallRequest
export interface ChatState {
characterId: string;
emptyChatGreeting: string;
messages: UiMessage[];
promotion: ChatPromotionState | null;
outgoingMessageRevision: number;
@@ -55,9 +59,11 @@ export interface ChatState {
export function createInitialChatState(
characterId: string = DEFAULT_CHARACTER_ID,
emptyChatGreeting: string = DEFAULT_CHARACTER.emptyChatGreeting,
): ChatState {
return {
characterId,
emptyChatGreeting,
messages: [],
promotion: null,
outgoingMessageRevision: 0,