Repository navigation
fix(minimax-bot): 排队中的后台任务能停掉了 - #146
Merged
MyPrototypeWhat merged 1 commit intoNov 20, 2026
Merged
Conversation
Apageoflove
force-pushed
the
fix/minimax-bot-stop-queued
branch
2 times, most recently
from
November 20, 2026 01:16
f08d09e to
c8fe487
Compare
后台任务面板对 queued 也画停止按钮,但 stopHelper 只 abort helperRuns 里的 run 对象,而 run 要等 runHelper 启动时才注册。所以在排队窗口里按停止, stopHelper 走 !run 分支返回 stopped:false,不报错、不改状态、不留标记; save 完成后 runHelper 照常启动,任务跑完并把状态写成 done。 改成 stopHelper 找不到 run 时,若 helper 还是 queued 就标成 stopped、写 endedAt、存盘、广播;runHelper 开头加守卫,status 已是 stopped 就直接返回。 同一脚本对照:基线后台回合跑 2 次、状态 done;改完 0 次、状态 stopped。 新测试在 0.7.28 上红、在切片上绿。全量 414 条通过。
Apageoflove
force-pushed
the
fix/minimax-bot-stop-queued
branch
from
November 20, 2026 06:20
c8fe487 to
52a75d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
后台任务的停止按钮,对还在排队的任务按下去没有用。
panels.js 里那个 active 集合包含 queued,所以任务一创建、还没开始跑的时候,面板上就有停止按钮。可 stopHelper 是先到 helperRuns 里找一个 run 对象,找到才 abort。run 要等 runHelper 真正启动时才注册进去。所以在排队那段窗口里按停止,stopHelper 走 !run 那条分支返回 stopped:false,不报错、不改状态、不留任何标记。等 save 完成,runHelper 照常启动,任务跑完,状态变成 done。
我拿同一个脚本打两边,差别很直接:
基线那 2 次不是笔误,runHelper 里把 status 直接赋成 running,所以一个已经被标停的任务也会被拉起来跑完。
仓库里本来就有一条测试叫 a helper cancelled while its admission is persisted is marked stopped and never runs,看着像是覆盖了这个场景。它测的是 cancelChat,走的是 startHelper 里 isActiveTurn 那条路,turn 被取消了所以标停。但用户自己点停止的时候 turn 是活的,isActiveTurn 为真,根本走不到那一步。所以那条测试一直在过,缺陷一直在。
改法是两处。stopHelper 在找不到 run 时,如果这个 helper 还是 queued,就直接把它标成 stopped、写 endedAt、存盘、广播,返回 stopped: true。runHelper 开头加一句,status 已经是 stopped 就直接返回,不建 run 也不跑回合。
已经跑起来的任务不受影响,还是 abort 那个 controller。
测试加在 engine-reliability 里:把准入那次 save 卡住,等 helper 进了列表但 helperRuns 里还没有,这时调 stopHelper,放开 save,断言它停在 stopped 且没有多跑一个后台回合。这条在 0.7.28 上红,在切片上绿。全量 414 条过。
版本号到 0.7.32。0.7.29 到 0.7.31 被另外三条还开着的 PR 占着。
batch 型任务的停止按钮是另一条路径,走 /api/tasks/:id/stop,这次没动。它和 helper 用的是不同的队列,我没细看那边有没有同样的问题。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.