refactor(chat): remove unused upgrade state fields
This commit is contained in:
@@ -38,8 +38,6 @@ function makeChatState(overrides: Partial<ChatState> = {}): ChatState {
|
||||
pendingReplyCount: 1,
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
isLoadingMore: false,
|
||||
hasMore: true,
|
||||
historyOffset: 0,
|
||||
@@ -169,12 +167,6 @@ describe("applyHttpSendOutput", () => {
|
||||
expect(nextState.isReplyingAI).toBe(false);
|
||||
expect(nextState.upgradePromptVisible).toBe(true);
|
||||
expect(nextState.upgradeReason).toBe("daily_limit");
|
||||
expect(nextState.upgradeHint).toBeNull();
|
||||
expect(nextState.upgradeDetail).toEqual({
|
||||
type: "daily_msg_limit",
|
||||
usedToday: 3,
|
||||
limit: 3,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -479,8 +479,6 @@ describe("chatMachine transitions", () => {
|
||||
|
||||
expect(actor.getSnapshot().context.upgradePromptVisible).toBe(false);
|
||||
expect(actor.getSnapshot().context.upgradeReason).toBeNull();
|
||||
expect(actor.getSnapshot().context.upgradeHint).toBeNull();
|
||||
expect(actor.getSnapshot().context.upgradeDetail).toBeNull();
|
||||
|
||||
actor.stop();
|
||||
});
|
||||
|
||||
@@ -23,8 +23,6 @@ interface ChatState {
|
||||
isReplyingAI: boolean;
|
||||
upgradePromptVisible: boolean;
|
||||
upgradeReason: MachineContext["upgradeReason"];
|
||||
upgradeHint: MachineContext["upgradeHint"];
|
||||
upgradeDetail: MachineContext["upgradeDetail"];
|
||||
isLoadingMore: boolean;
|
||||
hasMore: boolean;
|
||||
historyOffset: number;
|
||||
@@ -53,8 +51,6 @@ export function ChatProvider({ children }: ChatProviderProps) {
|
||||
isReplyingAI: state.context.isReplyingAI,
|
||||
upgradePromptVisible: state.context.upgradePromptVisible,
|
||||
upgradeReason: state.context.upgradeReason,
|
||||
upgradeHint: state.context.upgradeHint,
|
||||
upgradeDetail: state.context.upgradeDetail,
|
||||
isLoadingMore: state.context.isLoadingMore,
|
||||
hasMore: state.context.hasMore,
|
||||
historyOffset: state.context.historyOffset,
|
||||
|
||||
@@ -194,8 +194,6 @@ export function applyHttpSendOutput(
|
||||
...finishPendingReply(context),
|
||||
upgradePromptVisible: true,
|
||||
upgradeReason: "daily_limit",
|
||||
upgradeHint: null,
|
||||
upgradeDetail: normalizeLockDetail(lockDetail.detail),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -211,8 +209,6 @@ export function applyHttpSendOutput(
|
||||
...finishPendingReply(context),
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -221,8 +217,6 @@ export function applyHttpSendOutput(
|
||||
...finishPendingReply(context),
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -252,22 +246,6 @@ export function shouldPromptUnlockHistory(messages: readonly UiMessage[]): boole
|
||||
return countLockedHistoryMessages(messages) > 1;
|
||||
}
|
||||
|
||||
export function normalizeLockDetail(
|
||||
detail: Record<string, unknown> | null,
|
||||
): ChatState["upgradeDetail"] {
|
||||
if (!detail) return null;
|
||||
return {
|
||||
...(typeof detail.type === "string" ? { type: detail.type } : {}),
|
||||
...(typeof detail.usedToday === "number"
|
||||
? { usedToday: detail.usedToday }
|
||||
: {}),
|
||||
...(typeof detail.usedTotal === "number"
|
||||
? { usedTotal: detail.usedTotal }
|
||||
: {}),
|
||||
...(typeof detail.limit === "number" ? { limit: detail.limit } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Init 任务 2:history 3 步流(local → network → save)—— `loadHistoryActor` 调
|
||||
// ============================================================
|
||||
|
||||
@@ -109,8 +109,6 @@ export const chatMachine = setup({
|
||||
],
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -135,8 +133,6 @@ export const chatMachine = setup({
|
||||
],
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -161,8 +157,6 @@ export const chatMachine = setup({
|
||||
...beginPendingReply(context),
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -187,8 +181,6 @@ export const chatMachine = setup({
|
||||
...beginPendingReply(context),
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -214,8 +206,6 @@ export const chatMachine = setup({
|
||||
clearUpgradePrompt: assign(() => ({
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
})),
|
||||
|
||||
markPaymentUnlockPending: assign(() => ({
|
||||
|
||||
@@ -5,16 +5,7 @@ export interface ChatState {
|
||||
isReplyingAI: boolean;
|
||||
pendingReplyCount: number;
|
||||
upgradePromptVisible: boolean;
|
||||
upgradeReason: "daily_limit" | "image" | null;
|
||||
upgradeHint: string | null;
|
||||
upgradeDetail:
|
||||
| {
|
||||
type?: string;
|
||||
usedToday?: number;
|
||||
usedTotal?: number;
|
||||
limit?: number;
|
||||
}
|
||||
| null;
|
||||
upgradeReason: "daily_limit" | null;
|
||||
isLoadingMore: boolean;
|
||||
hasMore: boolean;
|
||||
historyOffset: number;
|
||||
@@ -36,8 +27,6 @@ export const initialState: ChatState = {
|
||||
pendingReplyCount: 0,
|
||||
upgradePromptVisible: false,
|
||||
upgradeReason: null,
|
||||
upgradeHint: null,
|
||||
upgradeDetail: null,
|
||||
isLoadingMore: false,
|
||||
hasMore: true,
|
||||
historyOffset: 0,
|
||||
|
||||
Reference in New Issue
Block a user