Skip to content

fix(handler): 去重对局消息并简化结算清理 - #113

Merged
llsccm merged 1 commit into
devfrom
codex/dedupe-game-lifecycle
Sep 13, 2026
Merged

fix(handler): 去重对局消息并简化结算清理#113
llsccm merged 1 commit into
devfrom
codex/dedupe-game-lifecycle

Conversation

@llsccm

@llsccm llsccm commented Sep 13, 2026

Copy link
Copy Markdown
Owner

变更内容

宿主连续输出同类型的 decodeGameRecordInitInfoMsgGameOver 时,原先会重复初始化或触发结算处理。现在由 logic 记录上一条消息类型,只处理连续消息中的第一条。

  • 结算窗口按固定顺序等待并关闭:战绩窗口 → MVP 窗口;山河图仅处理战绩窗口。
  • 开新局时取消旧结算任务,异步等待后检查任务及所属房间,防止旧任务影响新局。
  • 结算关闭任务的初始延时由 1000ms 调整为 500ms。

验证

  • pnpm lint 通过。
  • pnpm build 通过。
  • git diff --check 通过。
  • 未新增自动化测试;未进行真实游戏页面验收。

风险与备注

去重按相邻消息类型判断;中间出现其他类型消息后,同类型消息仍正常处理。被过滤的连续重复消息也不再进入协议录制。

Summary by CodeRabbit

  • Bug Fixes
    • 优化游戏结束后的窗口关闭流程,减少窗口状态异常导致的卡顿或错误。
    • 开始新游戏时会取消未完成的上一局结束处理,避免新旧流程相互影响。
    • 防止重复处理连续收到的初始化及游戏结束消息,提升游戏流程稳定性。
    • 游戏结束处理的等待间隔缩短,相关窗口可更快完成关闭。

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c6fd4fa3-fc1c-41fb-8e7a-9b15fdf7461b

📥 Commits

Reviewing files that changed from the base of the PR and between d6841c0 and ae58cda.

📒 Files selected for processing (3)
  • src/handler/MsgGameOver.js
  • src/handler/StartGame.js
  • src/logic.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

本次变更为结束游戏处理增加任务生命周期控制,并过滤连续重复的结束游戏消息。任务包含房间和窗口列表,可在新游戏开始或房间变化时取消,窗口关闭完成后执行对应房间的清理。

Changes

结束游戏处理流程

Layer / File(s) Summary
重复消息过滤
src/logic.js
logic 记录最近处理的消息类型,并跳过连续重复的 decodeGameRecordInitInfoMsgGameOver 消息。MsgGameOver 分支增加开发环境日志输出。
结束游戏任务生命周期
src/handler/MsgGameOver.js, src/handler/StartGame.js
handleGameOver() 创建包含房间和窗口列表的任务。窗口关闭前后会校验任务和房间是否仍有效。registerGamePlayers 会取消现有结束游戏任务。cleanupGame 支持按房间校验,handleLeaveTable 直接执行清理。

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to ae58c

No concrete merge-blocking behavior issue remains identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次变更的两个主要目标:去重对局消息,以及简化结算清理流程。标题简洁且与 PR 内容一致。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/dedupe-game-lifecycle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@llsccm
llsccm merged commit edcd4a4 into dev Sep 13, 2026
4 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