Skip to content

fix: 修复截图订阅续期与重连后的生命周期 - #443

Open
MistEO wants to merge 1 commit into
mainfrom
codex/fix-screenshot-reconnect-lifecycle
Open

MistEO wants to merge 1 commit into
mainfrom
codex/fix-screenshot-reconnect-lifecycle

Conversation

@MistEO

@MistEO MistEO commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

截图订阅先于 controller 到达,或实例销毁时仍有订阅,原来的截图循环会在退出后立即反复启动。销毁后以同 ID 建立的新实例还会接收到旧订阅的截图请求。现在无 controller 时等待帧间隔,销毁实例时同步移除订阅,已断连的 controller 暂停主动截图。

Dashboard 和截图面板共用可取消的读取循环。每个视图使用独立订阅 ID 并每 10 秒续订,防止 30 秒订阅到期后画面冻结。重连、切换实例和折叠时,迟到的帧及旧定时器会退出。Dashboard 在任务运行中断连后仍提供 Stop。

基于 main c321532,经独立 review 未发现阻塞问题。回归保留普通 Stop 后对健康 controller 的复用。#393 涉及同一 Dashboard 文件的启动编排,合并时可能需要处理同文件冲突。

验证:

  • pnpm test:screenshots:26/26。实际挂载 React 组件,使用受控 Maa RPC 和 Chromium 虚拟时间,覆盖续订、多个视图、迟到帧、重连、切换和暂停。同组外部 fixture 在原 main 上 12 项通过、14 项失败。
  • Rust 截图生命周期单测:4/4,无需 Maa DLL。原有测试 EXE 在本机有 0xc0000139 加载问题,给临时副本嵌入 Common Controls v6 manifest 后实际执行,步骤见 tests/screenshots/README.md。
  • 原 controller DLL mock 工装的截图子集通过,涵盖 Stop 后截图恢复、失联不发截图、销毁与同 ID 重建隔离、退订退出。
  • pnpm test:119 passed、1 skipped;pnpm build、前端格式、Rust 格式及 diff 检查通过。

打包桌面 UI、真实设备和实际游戏画面未验证。已有的长间隔等待行为保留:后台正在等待 30 秒时,切换更快帧率仍可能等完旧间隔。

Sourcery 摘要

稳定后端与 UI 中的截图订阅和重连生命周期,避免视图或实例发生变化后仍有过时操作继续执行。

新功能:

  • 为 Dashboard 和截图面板添加共享且独立管理的截图流,并自动续订。
  • 即使控制器断开连接,只要已连接的实例仍在运行,任务的 Stop 控件就会保持可用。

错误修复:

  • 防止在没有控制器时截图循环反复重启,并隔离实例销毁及同 ID 实例重新创建后的订阅。
  • 防止过时的帧、计时器和订阅影响已断开连接、已切换、已折叠、已暂停或已替换的视图。
  • 防止向已断开连接的控制器发送截图请求,并在多次截图失败后停止数据流。

改进:

  • 将截图订阅和帧读取生命周期管理集中到可复用的前端 hook 中。
  • 为订阅不存在的实例时返回错误,并为多次截图失败添加本地化提示。

构建:

  • 添加专用的截图回归测试命令和配套的浏览器测试运行器配置。

文档:

  • 记录基于浏览器的截图生命周期测试和后端测试执行方法,包括 Windows 清单文件的解决方法。

测试:

  • 添加前端 Chromium 回归测试,覆盖续订、独立视图、过时帧、重连、实例切换、折叠、暂停和截图失败。
  • 添加 Rust 生命周期测试,覆盖实例不存在、控制器缺失、订阅过期以及同 ID 实例重新创建。
Original summary in English

Summary by Sourcery

Stabilize screenshot subscription and reconnection lifecycles across the backend and UI while preventing stale work from surviving view or instance changes.

New Features:

  • Add shared, independently managed screenshot streaming for the Dashboard and screenshot panel with automatic subscription renewal.
  • Keep task Stop controls available while a connected instance is running even after controller disconnection.

Bug Fixes:

  • Prevent screenshot loops from restarting repeatedly without a controller and isolate subscriptions across instance destruction and same-ID recreation.
  • Stop stale frames, timers, and subscriptions from affecting disconnected, switched, folded, paused, or replaced views.
  • Prevent screenshot capture requests from being sent to disconnected controllers and stop streams after repeated capture failures.

Enhancements:

  • Centralize screenshot subscription and frame-reading lifecycle management in a reusable frontend hook.
  • Return an error when subscribing to a nonexistent instance and add localized messaging for repeated capture failures.

Build:

  • Add a dedicated screenshot regression test command and supporting browser-test runner configuration.

Documentation:

  • Document browser-based screenshot lifecycle testing and backend test execution, including the Windows manifest workaround.

Tests:

  • Add frontend Chromium regression coverage for renewal, independent views, stale frames, reconnection, instance switching, folding, pausing, and capture failures.
  • Add Rust lifecycle tests covering missing instances, controller absence, subscription expiry, and same-ID instance recreation.

AI 使用信息:

  • Agent:Codex
  • 模型:gpt-6-astra(实现与内部复审),gpt-6.1-sol(额外交叉审查)
  • 思考强度:ultra(实现与内部复审),max(额外交叉审查)

@MistEO
MistEO marked this pull request as ready for review November 11, 2026 08:43
Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:43
@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Sorry @MistEO, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 hours and 8 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T08:45:21.804867Z 86071aa Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants