Repository navigation
fix: 工具面开关改为「重启生效」——不再在存活会话上重建工具面 - #41
Merged
Merged
Conversation
`pwshTool` / `experimentalNative` 是 volatile 字段,宿主把设置卡上的编辑实时交给
运行中的行。插件在 `loader/volatile-update` 上对**每个存活 agent** 重跑 `reconcile()`,
而 `reconcile()` 会先解开自己的 pwsh 掩码再读工具面——这次读取与宿主重组的时序不保证
稳定:既可能把「面里没有 pwsh」误判成「preset 掩码接管」而撤掉自己注册的 bash,也让
一次纯展示开关的改动触发工具面重建。
真机事故(dsh 0.2.1-rc.5 + 插件 0.47.2,win32):把 `pwshTool` 关掉之后,存活会话的
`request/header.tools` 从 59 掉到 31,丢掉的 29 个正是官方 preset 的工具
(`read`/`write`/`edit`/`glob`/`grep`/`bash`/`gitbash_native`/`pwsh`/`web_search`/
`web_fetch`/`todo_write`/`exit_plan_mode`/`schedule_*`/`skill`/`present` 等),只剩
profile 级插件工具;重启 DSH 后恢复。
改动:
- 每个 agent 在**首次观测**时快照 `{ pwshVisible, experimental }`,此后一律按快照判定,
不再读 live 开关;
- `loader/volatile-update` 命中这两个开关时只写一行日志
(`tool-face switch changed (...)`),不再重建任何存活 agent 的工具面;
- `tools/pre-execute` 的 pwsh 拒绝判定跟随该 agent 的快照(保留
`deps.pwshEnabled?.() !== true` 字面量,上游 smoke 断言锁它);
- 设置卡四个工具面开关(variant / experimental / pwsh / fctx)的中英 hint 增加
「改动需重启 DSH 后生效」提示。
行为契约变化:开关只对**新会话**或重启后的会话生效,运行中的会话保持它创建时的工具面。
测试:`runtime-regressions` 的「活体跟随两次翻转」改为「冻结 + 只记日志」,并新增
「翻转只对 NEW agent 生效」用例(fixture 的 mask 改为 per-agent)。全量 346 项全通过。
未覆盖:丢掉的 29 个工具超出本插件可影响的范围,宿主侧「preset 工具整批消失」的完整
链路仍需宿主日志确认;本改动消除插件侧触发点,并让 UI 说明真实生效时机。
Owner
|
按维护者评审,我已在这个 PR 上补了一版并推到
如果这个方向没问题,我就按 |
Owner
|
已按
合入后的 head 是 |
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.
症状
在设置卡把
pwshTool关掉之后,存活会话的工具面被清空:request/header.tools从 59 个掉到 31 个,丢掉的 29 个正是官方 preset 的工具,只剩 profile 级插件工具。重启 DSH 才恢复。真机环境:Windows、dsh
0.2.1-rc.5、本插件0.47.2。证据
同一会话(
session.v4.jsonl.zstd)里request/header的工具数时间线:丢失的 29 个工具(对比 59 与 31 两份工具表):
保留的 31 个全部来自 profile 级插件(hindsight / team / github / watch / unlag / subagent / working_directory 等)——即 preset 的工具整批消失,不是单个工具被隐藏。
插件侧成因
pwshTool/experimentalNative是 volatile 字段,宿主把设置卡上的编辑实时交给运行中的行。插件在loader/volatile-update上的处理是:而
reconcile()的第一步是解开自己的 pwsh 掩码再读工具面(这是 PR #36 为「开方向翻转」引入的)。这次读取与宿主重组工具面的时序不保证稳定:读到「面里没有 pwsh」时,stand down分支会把它当成「preset 掩码接管了工具集」,撤掉自己注册的 bash——两种失败方向都发生在一次纯展示开关的改动上。插件不该在这条路径上重建任何存活会话的工具面;而且 UI 从未提示这个开关会动工具面。
改动
src/inline-tools.jsnewState()增加toolFace;reconcile()在该 agent 首次观测时快照{ pwshVisible, experimental },此后一律按快照判定;②loader/volatile-update命中这两个开关时只写一行日志,不再逐个 agent 重算;③tools/pre-execute的 pwsh 拒绝判定跟随快照(保留deps.pwshEnabled?.() !== true字面量,现有 smoke 断言锁它)src/client.jsvariant/experimental/pwsh/fctx)的中英 hint 增加「⚠ 改动需重启 DSH 后生效;运行中会话的工具面会被冻结在原值」README.md/README_EN.mdpwshTool会改 bash description、一次性作废缓存」改为「只影响新会话/重启后的会话」CHANGELOG.md[Unreleased]条目(症状、根因、修法、真机证据)tests/runtime-regressions.mjs日志新增一行,便于用户对照:
行为契约变化
开关不再对已存在的会话生效:新会话或重启后生效。这是有意的偏离——上游当前设计是活体跟随,而活体跟随在这台机器上直接导致了事故。
验证
npm test:346 项,346 pass,0 fail(本机 Windows,Node 24)。想请维护者判断的两点
bash/gitbash_native/gitbash_to_native_path/pwsh/gb_*/terminal_*)。我能提供的只有上面的工具表时间线与宿主日志线索;如果这属于宿主的重组时序问题,这一条或许该转成 DSH 的 issue,本 PR 只作为插件侧止血。