feat(characters): support character-scoped conversations

This commit is contained in:
2026-07-17 11:42:31 +08:00
parent 93efcb6604
commit 2796010971
85 changed files with 1645 additions and 251 deletions
+11 -5
View File
@@ -1,6 +1,6 @@
import { createChatPromotionState } from "../helper/promotion";
import { shouldPromptUnlockHistory } from "../helper/unlock";
import { initialState } from "../chat-state";
import { createInitialChatState } from "../chat-state";
import {
guestInitializingState,
historyPaginationTransitions,
@@ -19,20 +19,20 @@ import {
const startGuestSessionAction = unlockMachineSetup.assign(
({ context }) => ({
...initialState,
...createInitialChatState(context.characterId),
promotion: context.promotion,
}),
);
const startUserSessionAction = unlockMachineSetup.assign(
({ context }) => ({
...initialState,
...createInitialChatState(context.characterId),
promotion: context.promotion,
}),
);
const clearChatSessionAction = unlockMachineSetup.assign(() => ({
...initialState,
const clearChatSessionAction = unlockMachineSetup.assign(({ context }) => ({
...createInitialChatState(context.characterId),
}));
const injectPromotionAction = unlockMachineSetup.assign(({ event }) => {
@@ -75,14 +75,17 @@ const guestSessionState = chatMachineSetup.createStateConfig({
{
id: "messageQueue",
src: "httpMessageQueue",
input: ({ context }) => ({ characterId: context.characterId }),
},
{
id: "loadHistory",
src: "loadHistory",
input: ({ context }) => ({ characterId: context.characterId }),
},
{
id: "loadMoreHistory",
src: "loadMoreHistory",
input: ({ context }) => ({ characterId: context.characterId }),
},
],
on: {
@@ -154,14 +157,17 @@ const userSessionState = chatMachineSetup.createStateConfig({
{
id: "messageQueue",
src: "httpMessageQueue",
input: ({ context }) => ({ characterId: context.characterId }),
},
{
id: "loadHistory",
src: "loadHistory",
input: ({ context }) => ({ characterId: context.characterId }),
},
{
id: "loadMoreHistory",
src: "loadMoreHistory",
input: ({ context }) => ({ characterId: context.characterId }),
},
],
on: {