fix(e2e): stabilize authenticated unlock flows

This commit is contained in:
Codex
2026-07-22 16:53:09 +08:00
parent 8bd67b83c5
commit e813333607
16 changed files with 116 additions and 28 deletions
@@ -55,6 +55,7 @@ function makeChatState(overrides: Partial<ChatState> = {}): ChatState {
requiredCredits: 0,
shortfallCredits: 0,
historyLoaded: true,
networkHistoryLoaded: true,
historyTotal: 0,
historyLimit: 50,
nextHistoryOffset: 0,
@@ -267,6 +268,8 @@ describe("chat history pagination helpers", () => {
limit: 0,
});
expect(nextState.networkHistoryLoaded).toBe(true);
expect(nextState.historyLimit).toBe(50);
expect(nextState.nextHistoryOffset).toBe(50);
expect(nextState.historyTotal).toBe(120);
+3
View File
@@ -22,6 +22,8 @@ interface ChatState {
upgradeReason: MachineContext["upgradeReason"];
/** True as soon as a local snapshot or the first network result is renderable. */
historyLoaded: boolean;
/** True after the network history request has completed or failed. */
networkHistoryLoaded: boolean;
hasMoreHistory: boolean;
isLoadingMoreHistory: boolean;
unlockHistoryPromptVisible: boolean;
@@ -93,6 +95,7 @@ function selectChatState(state: ChatSnapshot): SelectedChatState {
upgradePromptVisible: state.context.upgradePromptVisible,
upgradeReason: state.context.upgradeReason,
historyLoaded: state.context.historyLoaded,
networkHistoryLoaded: state.context.networkHistoryLoaded,
hasMoreHistory:
state.context.historyLoaded &&
state.context.nextHistoryOffset < state.context.historyTotal,
+3
View File
@@ -46,6 +46,8 @@ export interface ChatState {
shortfallCredits: number;
/** history 首屏可展示标志(本地快照加载完成即可进入 ready)。 */
historyLoaded: boolean;
/** 网络历史已返回或已明确失败;用于避免过早判定深链消息不存在。 */
networkHistoryLoaded: boolean;
historyTotal: number;
historyLimit: number;
nextHistoryOffset: number;
@@ -80,6 +82,7 @@ export function createInitialChatState(
requiredCredits: 0,
shortfallCredits: 0,
historyLoaded: false,
networkHistoryLoaded: false,
historyTotal: 0,
historyLimit: 50,
nextHistoryOffset: 0,
+2
View File
@@ -29,6 +29,7 @@ export function applyNetworkHistoryLoadedOutput(
ChatState,
| "messages"
| "historyLoaded"
| "networkHistoryLoaded"
| "historyTotal"
| "historyLimit"
| "nextHistoryOffset"
@@ -47,6 +48,7 @@ export function applyNetworkHistoryLoadedOutput(
return {
messages: [...output.messages, ...optimisticTail],
historyLoaded: true,
networkHistoryLoaded: true,
historyTotal: Math.max(0, output.total),
historyLimit,
nextHistoryOffset: historyLimit,
+1
View File
@@ -55,6 +55,7 @@ const markHistoryLoadFailedAction = baseChatMachineSetup.assign(
const characterErrorCode = getCharacterErrorCode(event.error);
return {
historyLoaded: true,
networkHistoryLoaded: true,
characterErrorCode,
canSendMessage:
characterErrorCode === "CHARACTER_DISABLED" ||