{"record":{"id":"daf0c13253ef9c41","repo":"babalae/better-genshin-impact","slug":"currentstate","errorCode":null,"errorMessage":"状态 {CurrentState} 等待中间态转换超时","messagePattern":"状态 (.+?) 等待中间态转换超时","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/StateMachine/StateMachineBase.cs","lineNumber":745,"sourceCode":"                    case StateHandlerStatus.Success:\n                        // 成功：等待指定的目标状态，或当前状态的全部邻接状态。\n                        var transitionResult = result.TargetStates.Count > 0\n                            ? await WaitStateTransitionTo(result.TargetStates, transitionTimeout)\n                            : await WaitNextStateTransition(transitionTimeout);\n                        switch (transitionResult.Status)\n                        {\n                            case StateTransitionWaitStatus.ReachedTarget:\n                                CurrentStateRetryCount = 0; // 成功转换后重置重试计数\n                                stateRetryStopwatch.Restart();\n                                break;\n\n                            case StateTransitionWaitStatus.RetryCurrentState:\n                                RecordStateRetry(\"源状态持续可见，触发当前状态重试\", retryPolicy, stateRetryStopwatch);\n                                nextLoopInterval = retryInterval;\n                                break;\n\n                            case StateTransitionWaitStatus.IntermediateTimeout:\n                                throw new InvalidOperationException($\"状态 {CurrentState} 等待中间态转换超时\");\n                        }\n                        break;\n\n                    case StateHandlerStatus.Wait:\n                        // 可预期的等待：状态机继续循环，重新检测状态。\n                        Logger.LogDebug(\"Handler 返回 Wait，状态机继续等待\");\n                        break;\n\n                    case StateHandlerStatus.Retry:\n                        // 意外失败重试：检查重试次数。\n                        RecordStateRetry(\"Handler 返回 Retry\", retryPolicy, stateRetryStopwatch);\n                        nextLoopInterval = retryInterval;\n                        break;\n\n                    case StateHandlerStatus.Fail:\n                        // 失败：抛出异常。\n                        throw new InvalidOperationException($\"状态 {CurrentState} 的 Handler 返回失败\");\n                }","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/StateMachine/StateMachineBase.cs#L727-L763","documentation":"Thrown inside RunStateMachineUntil after a handler returns Success but WaitStateTransitionTo / WaitNextStateTransition returns StateTransitionWaitStatus.IntermediateTimeout. This means the handler reported success and the state machine waited for the UI to leave the current state toward a neighbor, but no transition was detected within GetTransitionTimeoutForState (default DefaultTransitionTimeout). The game UI stayed in an unexpected/intermediate state.","triggerScenarios":"A handler acted (e.g. clicked a button) and returned Success, then the transition waiter polled for a neighboring state but the game never entered any registered state within the transition timeout — e.g. a loading screen or unregistered intermediate UI appeared and persisted.","commonSituations":"Game shows an intermediate screen (loading, dialog, confirmation) that has no registered state detector; transition timeout too short for slow loads; game update introduced a new intermediate screen; capture failing during the wait so detection never succeeds.","solutions":["Increase the transition timeout for the state via RegisterStateTransitionTimeout.","Register a state detector for the intermediate screen so the transition is recognized rather than timing out.","Verify captures succeed during the wait (no '截图失败' warnings).","Confirm the handler's declared TargetStates match the real possible next states."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await RunStateMachineUntil(context, targets); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"等待中间态转换超时\"))\n{ Logger.LogError(ex, \"中间态转换超时\"); throw; }","preventionTips":["Register detectors for all realistic intermediate screens.","Set transition timeouts generously for states that precede loading screens."],"tags":["state-machine","transition-timeout","game-automation","ui-state"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}