fix(enhance): 取模型锚定 dock 修复恒走兜底;新增 enhance_config.json 热配置(供应商/模型/思考强度,零重启生效) - #1
Merged
c80361619 merged 1 commit intoSep 23, 2026
Conversation
根因:前端 currentModel() 全局搜 [data-model-current-value] 并按「offsetParent 可见+ 最靠下」挑节点。ZCode 输入框工具栏在 fixed 定位容器内(offsetParent 恒为 null)被可见 过滤整批误杀,后台残留的设置/工作流面板节点反而更靠下被取走,导致 modelValue/Label 恒为空 → 主进程四档解析全空 → ④兜底选中供应商表第一个可用供应商的第一个模型。 实测表现:报错模型不是用户所选(如选 glm-5.3-flash 却发出 deepseek-v4-flash-0731), 若该供应商 key 失效则 404 not supported by any configured account in this group, 且 404 被 classify 误判为「接口路径不对」。 修复: - currentModel() 先锚定 composer dock 再找模型按钮;dock 命中时不再因 offsetParent=null 丢弃(fixed 容器该属性本就恒为 null);全局兜底排除 workflow-run-settings-model 面板 - handler 新增⓪热配置档(最高优先级):每次点击热读 <root>/enhance_config.json, 支持自定义 providerId/modelId/maxTokens/temperature 及思考强度 (openai: reasoning_effort;anthropic: thinking.budget_tokens 自动抬高 max_tokens), 改文件即生效、无需重启;留空则行为与旧版完全一致 - classify 正则补 not supported,404 模型类错误不再误报路径问题 验证:patcher 语法/模板标记校验、zcode-enhance-prompt.js node --check、 tests/test_patcher.py 234 例(唯一失败项为 run.cmd 环境固有,与改动无关, 已用 stash 对照原版代码确认);实测「默认-永久」key 发 glm-5.3-flash 200, 失效 key 复现 404 逐字吻合。
c80361619
added a commit
that referenced
this pull request
Sep 23, 2026
合并外部贡献 PR #1(HUIdada1):enhance_config.json 热配置 + currentModel() 锚定 dock。 复核时发现两处会让新功能静默失效的问题,一并修掉并补 27 项回归测试。 ## 修复 1. **⓪热配置档被 ①ref 档覆盖**(新功能的核心缺陷) ①档写的是 `if(mv){...pick=...}`,没有 `!pick` 守卫。⓪档设好热配置后, ①档只要界面取值可读就无条件重跑并覆盖它。而同一个 PR 的 currentModel() 修复 正是让界面取值变得可读的 → 「enhance_config.json 指哪打哪」只在取值失灵时才生效, 与设计意图完全相反。tried 轨迹显示 config:P-A/model-a,请求却发给了 P-B/model-b。 修:①档补上 `!pick` 守卫(②③档本来就有)→ 四档语义统一为「先到先得」。 2. **how 恒为空串**(既有缺陷,新文档依赖它) `how` 声明后从未被赋值,成功响应永远返回 `how:""`。而 ENHANCE_CUSTOM_PLAN.md 教用户用 lastResult.how 判断走了 config/ref/fallback 哪一档 → 该排障法直接失效。 修:命中后回填 `how=String(pick.how||"")`。 ## 新增测试 tests/test_enhance_handler.py(27 项) 行为级:提取 handler 源码 → 替换 H/SYS/TPL 标记 → 真在 node 里跑,配本地假 HTTP 服务器断言**收到的请求体**。覆盖配置生效/覆盖界面选择/向后兼容/可用性守卫/ maxTokens/temperature/reasoning_effort/thinking.budget_tokens(含 clamp 与 max_tokens 抬高)/ 「注释掉的键不发」/坏 JSON 不崩。 源码级:钉死 ⓪档在①档之前、①档必须带 !pick、how 必须回填、classify 覆盖 not supported、 currentModel 锚定 dock 且不再因 offsetParent=null 丢弃。 负向验证:回退两处修复 → 5 项如期变红(含 test_hot_config_overrides_ui_selection)。 测试 234 → 261 全绿;两处 version 同步 0.6.4;README/SKILL.md/ENHANCE_CUSTOM_PLAN.md 同步。
Contributor
Author
|
补充说明:本分支现含两个相互独立的提交,可分开 review / cherry-pick:
另: |
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.
问题
用户报告「增强提示词」报 `HTTP 404: Model "deepseek-v4-flash-0731" is not supported by any configured account in this group",且无论界面选什么模型、怎么切换都稳定复现(报错模型固定是供应商表第一个可用供应商的第一个模型,与所选模型无关)。
根因(逐层实测验证)
currentModel()全局搜[data-model-current-value]并按「offsetParent 可见 + 最靠下」挑节点。但 ZCode 输入框工具栏位于 fixed 定位容器内(fixed 元素 offsetParent 恒为 null,被可见过滤整批误杀),后台又常驻设置/工作流面板的隐藏节点(它们反而「更靠下」)→modelValue/modelLabel恒为空。实测 app.asar:该属性本身挂在主界面模型按钮上(data-chat-toolbar-popover-trigger),属性没丢,问题纯在取值启发式。enhance_doctor.py的场景模拟(--model-value "" --model-label "")同样复现。is not supported,404 落入「接口路径可能不对(baseURL 是否需要 /v1)」误导排查方向。修改
zcode-enhance-prompt.js:currentModel()先锚定 composer dock 再找模型按钮(与 findInput 同一锚定策略);dock 命中时不再因 offsetParent=null 丢弃;全局兜底排除workflow-run-settings-model面板节点。zcode_patcher.py_ENHANCE_HANDLER:<root>/enhance_config.json,支持自定义providerId/modelId/maxTokens/temperature与思考强度(openai 协议reasoning_effort;anthropic 协议thinking.budget_tokens并自动抬高 max_tokens)。改文件即生效、无需重启;文件不存在或留空则行为与旧版完全一致(向后兼容)。not supported,404 模型类错误归入 model 档,不再误报路径问题。验证
zcode-enhance-prompt.js通过node --check;tests/test_patcher.py234 例,唯一失败项(test_cmd_runs_and_returns_zero,rc=9009)经 stash 对照原版代码确认为本机 run.cmd 环境固有,与本次改动无关;enhance_config.json指定供应商/模型后,点击增强 toast 显示已用「glm-5.3-flash」增强,改文件下次点击立即生效。详细分析与配置指南见
skills/zcode-tokenspeed/ENHANCE_CUSTOM_PLAN.md。