refactor(quantizedsliding): 重构数量配置与按钮识别流程#1812
Merged
single-ptilopsis merged 7 commits intov2from Apr 1, 2026
Merged
Conversation
- 为 QuantizedSlidingAction 新增 GreenMask 参数 - 将滑块按钮识别和数量分支识别统一映射到 green_mask - 同步更新 Helper 管线与中英文开发文档
- 改为使用 Quantity.Target、Quantity.Box、Quantity.OnlyRec - 数量识别统一读取 Results.Best.AsOCR().Text - 同步更新 AutoStockpile 覆盖逻辑与中英文文档
- nodes.go 新增 IncreaseButton / DecreaseButton 节点常量 - overrides.go 将 green_mask 识别抽离至辅助节点,主节点改用 And 识别引用 - Helper.json 注册 QuantizedSlidingIncreaseButton 与 QuantizedSlidingDecreaseButton 节点
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题
给 AI 代理的提示
请根据这次代码评审中的评论进行修改:
## 单条评论
### 评论 1
<location path="agent/go-service/quantizedsliding/overrides.go" line_range="27-36" />
<code_context>
}
-func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam) map[string]any {
+func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam, quantityOnlyRec bool, greenMask bool) map[string]any {
quantityParam := map[string]any{
- "roi": append([]int(nil), quantityBox...),
</code_context>
<issue_to_address>
**建议:** `buildMainInitializationOverride` 中已经不再使用 `quantityFilter` 参数。
该函数仍然接收 `quantityFilter *quantityFilterParam`,但并未使用。如果这里已经不再需要它,请移除该参数,以简化 API 并避免让调用方困惑。如果它仍然应该影响行为(例如在流水线层面),请在构建 override 时使用它,而不是让它处于未使用状态。
建议实现:
```golang
func buildMainInitializationOverride(end []int, quantityBox []int, quantityOnlyRec bool, greenMask bool) map[string]any {
```
你还需要:
1. 查找所有 `buildMainInitializationOverride` 的使用位置,并从每个调用中移除 `quantityFilter` 参数(它之前很可能是第三个参数)。
2. 删除所有仅为满足该调用而存在、现已未使用的 `quantityFilter` 变量。
3. 如果 `quantityFilter` 仍然*应该*影响行为,那么与其完全移除它,不如在该函数中将其字段合并进 `quantityParam` / `override` 映射中;这需要基于 `quantityFilter` 的结构添加相应的条目。
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="agent/go-service/quantizedsliding/overrides.go" line_range="27-36" />
<code_context>
}
-func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam) map[string]any {
+func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam, quantityOnlyRec bool, greenMask bool) map[string]any {
quantityParam := map[string]any{
- "roi": append([]int(nil), quantityBox...),
</code_context>
<issue_to_address>
**suggestion:** The `quantityFilter` parameter is no longer used in `buildMainInitializationOverride`.
The function still takes `quantityFilter *quantityFilterParam`, but it’s not used. If it’s no longer needed here, remove the parameter to simplify the API and avoid confusing callers. If it should still affect behavior (e.g., at the pipeline level), please apply it when building the override rather than leaving it unused.
Suggested implementation:
```golang
func buildMainInitializationOverride(end []int, quantityBox []int, quantityOnlyRec bool, greenMask bool) map[string]any {
```
You’ll also need to:
1. Find all usages of `buildMainInitializationOverride` and remove the `quantityFilter` argument from each call (it will likely be the third argument previously).
2. Remove any now-unused `quantityFilter` variables that existed only to satisfy this call.
3. If `quantityFilter` *should* still influence behavior, instead of removing it entirely, you should incorporate its fields into the `quantityParam` / `override` maps in this function; that would require adding corresponding entries based on `quantityFilter`'s structure.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 重构了 QuantizedSliding 的数量配置结构与按钮识别覆盖流程,将数量相关参数收敛到 Quantity.*,并引入 GreenMask 与辅助按钮节点以提升模板匹配分支的可配置性;同时简化数量 OCR 读取链路并同步更新中英文开发文档与示例配置。
Changes:
- 将数量参数从
Target/QuantityBox/ConcatAllFilteredDigits调整为Quantity.Target/Quantity.Box/Quantity.OnlyRec,并同步 AutoStockpile 的运行时覆写逻辑与示例配置 - 为加减按钮引入 Helper 节点(TemplateMatch),运行时通过覆写 helper + click 节点来实现“模板识别后点击”的分支
- 数量 OCR 读取统一改为
Results.Best.AsOCR().Text路径,并更新中英文文档说明
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/zh_cn/developers/quantized-sliding.md | 同步参数结构、GreenMask/only_rec 与 OCR 读取口径的中文文档说明与示例 |
| docs/zh_cn/developers/auto-stockpile-maintain.md | 更新 AutoStockpile 运行时覆写字段为 Quantity.Target(中文) |
| docs/en_us/developers/quantized-sliding.md | 同步参数结构、GreenMask/only_rec 与 OCR 读取口径的英文文档说明与示例 |
| docs/en_us/developers/auto-stockpile-maintain.md | 更新 AutoStockpile 运行时覆写字段为 Quantity.Target(英文) |
| assets/resource/pipeline/QuantizedSliding/Helper.json | 新增滑块/按钮辅助识别节点与 OCR only_rec 字段,补齐 TemplateMatch 常用参数 |
| assets/resource/pipeline/AutoStockpile/Purchase.json | 更新 QuantizedSliding 调用参数为 Quantity{Target,Box,OnlyRec} |
| agent/go-service/quantizedsliding/types.go | 重构 custom_action_param 类型定义,引入 Quantity 与 GreenMask 等字段 |
| agent/go-service/quantizedsliding/params.go | 解析/归一化新参数结构,落地到 action 字段(含 OnlyRec/GreenMask) |
| agent/go-service/quantizedsliding/overrides.go | 调整运行时覆写:支持 quantity OCR only_rec、slider green_mask、按钮 helper 覆写与 And 识别 |
| agent/go-service/quantizedsliding/ocr.go | 简化数量 OCR 文本读取逻辑,固定使用 Best OCR 文本解析数字 |
| agent/go-service/quantizedsliding/nodes.go | 增加按钮 helper 节点常量 |
| agent/go-service/quantizedsliding/handlers.go | 适配新 OCR 读取与分支覆写接口(传入 GreenMask 等) |
| agent/go-service/autostockpile/overrides.go | AutoStockpile 覆写目标数量时改写 Quantity.Target |
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 在
buildTemplateMatchButtonHelperOverride/buildTemplateMatchButtonOverride中,显式设置的threshold: 0.8被去掉了,但文档中仍然描述的是固定的 0.8 阈值;建议重新显式设置该阈值,以避免依赖引擎默认值,并保持行为与文档一致。 resolveButtonHelperNode在遇到意料之外的nextNode值时,可能会返回空的 helper node 字符串,而这个值会被传入all_of列表;为了更安全,建议在映射时进行校验,当没有适用的 helper node 时,要么记录日志,要么跳过 template-match override。- 在
buildSwipeSpecificQuantityOverride中,类型断言clonedParam["Quantity"].(map[string]any)会在传入参数结构错误或缺失时触发 panic;建议使用类型 switch / ok-check 进行检查,在结构不符合预期时优雅失败,而不是直接假定结构正确。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- In `buildTemplateMatchButtonHelperOverride` / `buildTemplateMatchButtonOverride` the explicit `threshold: 0.8` was dropped, but the docs still describe a fixed 0.8 threshold; consider setting it explicitly again to avoid relying on engine defaults and to keep behavior aligned with the documentation.
- `resolveButtonHelperNode` can return an empty helper node string for unexpected `nextNode` values, which will then be passed into the `all_of` list; it may be safer to validate the mapping and either log or skip the template-match override when no helper node applies.
- In `buildSwipeSpecificQuantityOverride` the type assertion `clonedParam["Quantity"].(map[string]any)` will panic if the incoming param shape is wrong or missing; consider using a type switch / ok-check and failing gracefully instead of assuming the structure.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In
buildTemplateMatchButtonHelperOverride/buildTemplateMatchButtonOverridethe explicitthreshold: 0.8was dropped, but the docs still describe a fixed 0.8 threshold; consider setting it explicitly again to avoid relying on engine defaults and to keep behavior aligned with the documentation. resolveButtonHelperNodecan return an empty helper node string for unexpectednextNodevalues, which will then be passed into theall_oflist; it may be safer to validate the mapping and either log or skip the template-match override when no helper node applies.- In
buildSwipeSpecificQuantityOverridethe type assertionclonedParam["Quantity"].(map[string]any)will panic if the incoming param shape is wrong or missing; consider using a type switch / ok-check and failing gracefully instead of assuming the structure.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `buildTemplateMatchButtonHelperOverride` / `buildTemplateMatchButtonOverride` the explicit `threshold: 0.8` was dropped, but the docs still describe a fixed 0.8 threshold; consider setting it explicitly again to avoid relying on engine defaults and to keep behavior aligned with the documentation.
- `resolveButtonHelperNode` can return an empty helper node string for unexpected `nextNode` values, which will then be passed into the `all_of` list; it may be safer to validate the mapping and either log or skip the template-match override when no helper node applies.
- In `buildSwipeSpecificQuantityOverride` the type assertion `clonedParam["Quantity"].(map[string]any)` will panic if the incoming param shape is wrong or missing; consider using a type switch / ok-check and failing gracefully instead of assuming the structure.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Hey - 我发现了 2 个问题,并给出了一些高层次的反馈:
- 在
buildMainInitializationOverride中,greenMask参数被接收但从未使用;要么把它传递到相关的 TemplateMatch 参数中,要么从函数签名中移除它以避免混淆。 - 新的
buildTemplateMatchButtonHelperOverride去掉了之前硬编码的 TemplateMatchthreshold为 0.8;如果仍然希望保留这种行为,请显式设置threshold以维持之前的匹配敏感度。 - 对于
Quantity.OnlyRec,当前归一化逻辑在字段被省略时会将 override 默认为false,这会在流水线中强制关闭only_rec;可以考虑只在用户显式提供Quantity.OnlyRec时注入only_recoverride,从而保持流水线默认值可用。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `buildMainInitializationOverride`, the `greenMask` parameter is accepted but never used; either wire it through to the relevant TemplateMatch parameters or remove it from the signature to avoid confusion.
- The new `buildTemplateMatchButtonHelperOverride` drops the previously hardcoded TemplateMatch `threshold` of 0.8; if that behavior is still desired, explicitly set `threshold` to maintain the prior matching sensitivity.
- For `Quantity.OnlyRec`, the normalization currently defaults the override to `false` when the field is omitted, which forces `only_rec` off in the pipeline; consider only injecting the `only_rec` override when the user explicitly provides `Quantity.OnlyRec` so that pipeline defaults remain usable.
## Individual Comments
### Comment 1
<location path="agent/go-service/quantizedsliding/overrides.go" line_range="27-33" />
<code_context>
}
-func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam) map[string]any {
+func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam, quantityOnlyRec bool, greenMask bool) map[string]any {
quantityParam := map[string]any{
- "roi": append([]int(nil), quantityBox...),
+ "roi": append([]int(nil), quantityBox...),
+ "only_rec": quantityOnlyRec,
}
override := map[string]any{
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider either wiring `greenMask` into this override or removing it from the signature.
`greenMask` is passed from `handleMain` but never used when building this override. If it’s meant to affect template matching (like the button helper nodes), it should be included in the recognition params here; if not, the parameter should be removed from the function to avoid a no-op configuration option.
</issue_to_address>
### Comment 2
<location path="agent/go-service/quantizedsliding/overrides.go" line_range="124-130" />
<code_context>
}
-func buildTemplateMatchButtonOverride(template string, repeat int) map[string]any {
+func resolveButtonHelperNode(nextNode string) string {
+ switch nextNode {
+ case nodeQuantizedSlidingIncreaseQuantity:
+ return nodeQuantizedSlidingIncreaseButton
+ case nodeQuantizedSlidingDecreaseQuantity:
+ return nodeQuantizedSlidingDecreaseButton
+ default:
+ return ""
+ }
</code_context>
<issue_to_address>
**issue:** Handle or guard against unknown `nextNode` values when resolving the button helper node.
If `nextNode` is anything else, this returns an empty string, which in `buildCheckQuantityBranchOverride` produces a helper keyed by `""` and an `And` node with `all_of: [""]`. That’s probably unintended and fragile. If `nextNode` should always be one of the known constants, consider panicking/returning an error, or at least skipping helper/And creation in this case to avoid malformed pipeline entries.
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English
Hey - I've found 2 issues, and left some high level feedback:
- In
buildMainInitializationOverride, thegreenMaskparameter is accepted but never used; either wire it through to the relevant TemplateMatch parameters or remove it from the signature to avoid confusion. - The new
buildTemplateMatchButtonHelperOverridedrops the previously hardcoded TemplateMatchthresholdof 0.8; if that behavior is still desired, explicitly setthresholdto maintain the prior matching sensitivity. - For
Quantity.OnlyRec, the normalization currently defaults the override tofalsewhen the field is omitted, which forcesonly_recoff in the pipeline; consider only injecting theonly_recoverride when the user explicitly providesQuantity.OnlyRecso that pipeline defaults remain usable.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `buildMainInitializationOverride`, the `greenMask` parameter is accepted but never used; either wire it through to the relevant TemplateMatch parameters or remove it from the signature to avoid confusion.
- The new `buildTemplateMatchButtonHelperOverride` drops the previously hardcoded TemplateMatch `threshold` of 0.8; if that behavior is still desired, explicitly set `threshold` to maintain the prior matching sensitivity.
- For `Quantity.OnlyRec`, the normalization currently defaults the override to `false` when the field is omitted, which forces `only_rec` off in the pipeline; consider only injecting the `only_rec` override when the user explicitly provides `Quantity.OnlyRec` so that pipeline defaults remain usable.
## Individual Comments
### Comment 1
<location path="agent/go-service/quantizedsliding/overrides.go" line_range="27-33" />
<code_context>
}
-func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam) map[string]any {
+func buildMainInitializationOverride(end []int, quantityBox []int, quantityFilter *quantityFilterParam, quantityOnlyRec bool, greenMask bool) map[string]any {
quantityParam := map[string]any{
- "roi": append([]int(nil), quantityBox...),
+ "roi": append([]int(nil), quantityBox...),
+ "only_rec": quantityOnlyRec,
}
override := map[string]any{
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider either wiring `greenMask` into this override or removing it from the signature.
`greenMask` is passed from `handleMain` but never used when building this override. If it’s meant to affect template matching (like the button helper nodes), it should be included in the recognition params here; if not, the parameter should be removed from the function to avoid a no-op configuration option.
</issue_to_address>
### Comment 2
<location path="agent/go-service/quantizedsliding/overrides.go" line_range="124-130" />
<code_context>
}
-func buildTemplateMatchButtonOverride(template string, repeat int) map[string]any {
+func resolveButtonHelperNode(nextNode string) string {
+ switch nextNode {
+ case nodeQuantizedSlidingIncreaseQuantity:
+ return nodeQuantizedSlidingIncreaseButton
+ case nodeQuantizedSlidingDecreaseQuantity:
+ return nodeQuantizedSlidingDecreaseButton
+ default:
+ return ""
+ }
</code_context>
<issue_to_address>
**issue:** Handle or guard against unknown `nextNode` values when resolving the button helper node.
If `nextNode` is anything else, this returns an empty string, which in `buildCheckQuantityBranchOverride` produces a helper keyed by `""` and an `And` node with `all_of: [""]`. That’s probably unintended and fragile. If `nextNode` should always be one of the known constants, consider panicking/returning an error, or at least skipping helper/And creation in this case to avoid malformed pipeline entries.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
summary:
Summary by Sourcery
重构 QuantizedSliding 的数量配置和按钮识别逻辑,改为使用嵌套的 Quantity 对象以及标准化的 OCR 与模板匹配路径,并相应更新 AutoStockpile 集成逻辑和开发文档。
增强内容:
文档:
Original summary in English
Summary by Sourcery
Refactor QuantizedSliding quantity configuration and button recognition to use a nested Quantity object and standardized OCR and template-matching paths, and update AutoStockpile integration and developer docs accordingly.
Enhancements:
Documentation: