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
@@ -1,6 +1,9 @@
import { fromCallback, fromPromise } from "xstate";
import { DEFAULT_CHARACTER_ID } from "@/data/constants/character";
import {
DEFAULT_CHARACTER,
DEFAULT_CHARACTER_ID,
} from "@/data/constants/character";
import {
ChatSendResponseSchema,
UnlockPrivateResponseSchema,
@@ -36,6 +39,7 @@ export interface TestUnlockMessageOutput {
export const TEST_CHAT_MACHINE_INPUT = {
characterId: DEFAULT_CHARACTER_ID,
emptyChatGreeting: DEFAULT_CHARACTER.emptyChatGreeting,
};
export function makeChatSendResponse(): ChatSendResponse {
@@ -109,7 +113,10 @@ export function createTestChatMachine(
return () => undefined;
},
),
unlockHistory: fromPromise<UnlockHistoryOutput, { characterId: string }>(
unlockHistory: fromPromise<
UnlockHistoryOutput,
{ characterId: string; emptyChatGreeting: string }
>(
async () => {
if (options.unlockHistoryError) {
throw options.unlockHistoryError;