Skip to content

fix(okww): 为账号切换前添加游戏窗口与可执行登录态就绪轮询判定,兼容低性能设备启动延迟 - #512

Merged
AthenaHibou merged 6 commits into
AUTO-MAS-Project:devfrom
AthenaHibou:fix/okww-account-switch-wait-window
Sep 2, 2026
Merged

fix(okww): 为账号切换前添加游戏窗口与可执行登录态就绪轮询判定,兼容低性能设备启动延迟#512
AthenaHibou merged 6 commits into
AUTO-MAS-Project:devfrom
AthenaHibou:fix/okww-account-switch-wait-window

Conversation

@AthenaHibou

@AthenaHibou AthenaHibou commented Sep 1, 2026

Copy link
Copy Markdown
Member

改动摘要

  • 修复 OK-WW「运行前强制切换账号」在游戏启动阶段失败的问题:设备性能较差时,游戏进程拉起后 UnrealWindow 窗口往往延迟创建/亮相,账号切换紧随脚本配置的定长 WaitTime 之后立即执行,单次窗口枚举赶不上启动进度,导致误报「未找到鸣潮游戏窗口」。
  • 处理分两段在宽限内轮询等待:
    1. _find_game_hwnd_GAME_WINDOW_WAIT_SECONDS=60s 内按 1s 间隔轮询等待窗口就绪,未就绪不直接报错;
    2. 窗口出现后若仍停在启动过渡帧(警告弹窗/加载条),_switch_to_login 先轮询等待界面进入「登录页」或「已登录主菜单」之一的可执行态,未知态不再盲目按 ESC,超时才落回原有「ESC→终端→返回登录」兜底(覆盖已直接进入主场景的情形)。
  • 错误截图路径改用 _find_game_hwnd(wait=False) 单次枚举,避免失败后空等宽限期。
  • 命名超时常量带文档化理由;登录态轮询日志按约 5 条/轮询节流,避免刷屏。
  • changelog 已写入 v5.5.0-beta.3「修复BUG」。

验证

  • 编译/类型检查通过;需在多账号串行切换且设备性能一般的环境实测黑窗/警告/加载过渡帧的等待命中与兜底路径。

Sourcery 摘要

增强 OK-WW 账号切换功能,使其能够适应较慢设备上延迟创建游戏窗口和启动画面切换的情况。

错误修复:

  • 在启动期间等待游戏窗口和可用的登录状态,避免账号切换在慢速设备上失败。

功能增强:

  • 为延迟出现的启动画面添加有界轮询和回退处理,包括节流的进度日志记录,以及失败后立即查找诊断截图。

杂项:

  • 更新应用版本和变更日志至 v5.5.0-beta.3。
Original summary in English

Sourcery 总结

提升 OK-WW 账号切换对慢速设备启动延迟和过渡界面的兼容性。

修复:

  • 修复 OK-WW 在低性能设备上因游戏窗口或登录界面延迟就绪而导致账号切换失败的问题。

增强:

  • 为游戏窗口和可执行登录态增加有界轮询等待,并在启动过渡状态无进展时回退至原有返回登录流程。
  • 优化失败诊断截图和等待日志,避免重复等待及过量日志输出。

杂项:

  • 更新应用版本及变更日志至 v5.5.0-beta.3。
Original summary in English

Sourcery 摘要

提升 OK-WW 账号切换对慢速设备启动延迟和过渡界面的兼容性。

错误修复:

  • 修复 OK-WW 在低性能设备上因游戏窗口或登录界面延迟就绪而导致账号切换失败的问题。

功能增强:

  • 为游戏窗口和登录状态增加有界轮询等待,并在启动过渡状态长时间无进展时回退到原有的返回登录流程。
  • 优化失败诊断截图,以及等待期间的日志和 OCR 诊断输出,避免重复等待及过量输出。

维护事项:

  • 更新应用版本信息。
Original summary in English

Sourcery 摘要

使 OK-WW 账号切换能够适应较慢设备上游戏窗口延迟创建和启动界面转换的情况。

错误修复:

  • 通过等待游戏窗口以及可执行操作的登录或主菜单状态准备就绪,避免 OK-WW 账号切换在较慢设备上失败。
  • 当启动过程持续处于未知或卡滞状态时,回退到现有的返回登录流程。

改进:

  • 通过限制进度输出和 OCR 转储的频率,同时在失败截图时立即查找窗口,改进启动诊断。

杂项:

  • 将应用版本和更新日志更新至 v5.5.0-beta.3。
Original summary in English

Summary by Sourcery

Make OK-WW account switching resilient to delayed game-window creation and startup-screen transitions on slower devices.

Bug Fixes:

  • Prevent OK-WW account switching from failing on slower devices by waiting for the game window and an actionable login or main-menu state to become ready.
  • Fall back to the existing return-to-login flow when startup remains in an unknown or stalled state.

Enhancements:

  • Improve startup diagnostics by throttling progress output and OCR dumps, while using an immediate window lookup for failure screenshots.

Chores:

  • Update the application version and changelog to v5.5.0-beta.3.

@sourcery-ai

sourcery-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

审查者指南

本次修改通过两阶段轮询提升 OK-WW 账号切换对慢速启动的兼容性:先等待 UnrealWindow 出现,再等待登录页或已登录主菜单等可执行态;超时后复用原有返回登录流程,并在错误截图场景使用即时窗口枚举避免重复等待。

两阶段 OK-WW 账号切换就绪流程的时序图

sequenceDiagram
    participant Switch as AccountSwitch
    participant Window as UnrealWindow
    participant Game as GameUI

    Switch->>Window: _find_game_hwnd(wait=True)
    loop Up to _GAME_WINDOW_WAIT_SECONDS
        Switch->>Window: EnumWindows()
        alt Window found
            Window-->>Switch: hwnd
        else Window not ready
            Switch->>Switch: sleep(_WINDOW_POLL_INTERVAL)
        end
    end

    Switch->>Game: _wait_for_actionable_state(hwnd, on_log)
    loop Up to _SWITCH_STABILIZE_SECONDS
        Switch->>Game: _on_login_page(hwnd)
        Switch->>Game: _on_logged_in_menu(hwnd)
        alt Login page or logged-in menu detected
            Game-->>Switch: actionable state
        else Transition frame or unknown state
            Switch->>Switch: sleep(1)
        end
    end

    alt Login page
        Switch->>Game: _select_and_login(hwnd, suffix, on_log)
    else Logged-in menu
        Switch->>Game: _logout_from_menu(hwnd, on_log)
    else Stabilization timeout
        Switch->>Game: _return_to_login(hwnd, on_log)
    end
Loading

延迟发现游戏窗口和捕获错误的流程图

flowchart TD
    A[Account switching starts] --> B["_find_game_hwnd(wait=True)"]
    B --> C{UnrealWindow found?}
    C -- No, within 60s --> D["sleep(_WINDOW_POLL_INTERVAL)"]
    D --> B
    C -- Yes --> E["_switch_to_login(hwnd, on_log)"]
    C -- No, timeout --> F[Raise window-not-found error]
    E --> G{Account switching fails?}
    G -- No --> H[Continue]
    G -- Yes --> I["_find_game_hwnd(wait=False)"]
    I --> J["_save_error_screenshot(hwnd)"]
Loading

文件级变更

变更 详情 文件
增加游戏窗口就绪轮询,吸收低性能设备上的启动延迟。
  • 为窗口查找增加可选等待模式,默认在 60 秒宽限期内按 1 秒间隔枚举。
  • 保留非等待模式供错误截图使用,避免失败处理再次阻塞。
  • 通过文档化超时常量和重试日志说明启动等待行为。
app/task/Okww/tools/account_switch.py
增加启动过渡帧到可执行登录态的稳定等待与兜底处理。
  • 在账号切换前轮询识别登录页或已登录主菜单,最长等待 45 秒。
  • 未知或超时状态不再立即发送 ESC,改走原有返回登录兜底流程。
  • 将状态等待日志按约每 5 次轮询节流。
app/task/Okww/tools/account_switch.py
更新版本变更记录。
  • 将本次 OK-WW 账号切换修复记录到 v5.5.0-beta.3。
res/version.json

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以回复审查评论并使用 @sourcery-ai issue,从该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,随时(重新)生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能会非常有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你希望从新的审查开始,这项功能尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义你的使用体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

本次修改通过两阶段轮询提升 OK-WW 账号切换对慢速启动的兼容性:先等待 UnrealWindow 出现,再等待登录页或已登录主菜单等可执行态;超时后复用原有返回登录流程,并在错误截图场景使用即时窗口枚举避免重复等待。

Sequence diagram for the two-stage OK-WW account switching readiness flow

sequenceDiagram
    participant Switch as AccountSwitch
    participant Window as UnrealWindow
    participant Game as GameUI

    Switch->>Window: _find_game_hwnd(wait=True)
    loop Up to _GAME_WINDOW_WAIT_SECONDS
        Switch->>Window: EnumWindows()
        alt Window found
            Window-->>Switch: hwnd
        else Window not ready
            Switch->>Switch: sleep(_WINDOW_POLL_INTERVAL)
        end
    end

    Switch->>Game: _wait_for_actionable_state(hwnd, on_log)
    loop Up to _SWITCH_STABILIZE_SECONDS
        Switch->>Game: _on_login_page(hwnd)
        Switch->>Game: _on_logged_in_menu(hwnd)
        alt Login page or logged-in menu detected
            Game-->>Switch: actionable state
        else Transition frame or unknown state
            Switch->>Switch: sleep(1)
        end
    end

    alt Login page
        Switch->>Game: _select_and_login(hwnd, suffix, on_log)
    else Logged-in menu
        Switch->>Game: _logout_from_menu(hwnd, on_log)
    else Stabilization timeout
        Switch->>Game: _return_to_login(hwnd, on_log)
    end
Loading

Flow diagram for delayed game-window discovery and error capture

flowchart TD
    A[Account switching starts] --> B["_find_game_hwnd(wait=True)"]
    B --> C{UnrealWindow found?}
    C -- No, within 60s --> D["sleep(_WINDOW_POLL_INTERVAL)"]
    D --> B
    C -- Yes --> E["_switch_to_login(hwnd, on_log)"]
    C -- No, timeout --> F[Raise window-not-found error]
    E --> G{Account switching fails?}
    G -- No --> H[Continue]
    G -- Yes --> I["_find_game_hwnd(wait=False)"]
    I --> J["_save_error_screenshot(hwnd)"]
Loading

File-Level Changes

Change Details Files
增加游戏窗口就绪轮询,吸收低性能设备上的启动延迟。
  • 为窗口查找增加可选等待模式,默认在 60 秒宽限期内按 1 秒间隔枚举。
  • 保留非等待模式供错误截图使用,避免失败处理再次阻塞。
  • 通过文档化超时常量和重试日志说明启动等待行为。
app/task/Okww/tools/account_switch.py
增加启动过渡帧到可执行登录态的稳定等待与兜底处理。
  • 在账号切换前轮询识别登录页或已登录主菜单,最长等待 45 秒。
  • 未知或超时状态不再立即发送 ESC,改走原有返回登录兜底流程。
  • 将状态等待日志按约每 5 次轮询节流。
app/task/Okww/tools/account_switch.py
更新版本变更记录。
  • 将本次 OK-WW 账号切换修复记录到 v5.5.0-beta.3。
res/version.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿——我已经审阅了你的更改,看起来很棒!

Sourcery 评估

需要人工审阅。 如果轮询或屏幕状态检测有误,自动化流程可能会不必要地等待,或者在游戏处于意外的过渡状态时发送注销/返回登录操作,从而中断当前会话或需要手动重试。回滚可以防止未来出现错误分类,并且由此产生的会话状态是受限且可恢复的,而不是不可逆的数据或访问权限变更。


Sourcery 对开源项目免费——如果您喜欢我们的评审,请考虑分享它们 ✨
帮助我变得更有用!请对每条评论点击 👍 或 👎,我会利用反馈来改进评审。
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the polling or screen-state detection is wrong, the automation could wait unnecessarily or send the logout/return-to-login actions while the game is in an unexpected transition state, disrupting the current session or requiring a manual retry. Reverting prevents future misclassification, and the resulting session state is bounded and recoverable rather than an irreversible data or access change.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@AthenaHibou
AthenaHibou merged commit 2074b3d into AUTO-MAS-Project:dev Sep 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant