Repository navigation
Conversation
4 of 5 tasks
xinspark
force-pushed
the
fix/companion-link-detection
branch
2 times, most recently
from
October 30, 2026 20:07
69d953d to
15ccf0a
Compare
The link follows detection until the operator sets it, but two defects broke
that promise in the host process and on save.
Detection read only DSH_PROFILE_DIR/DSH_PROFILE. The launcher sets those for
shell calls, not for the host, so companionVersion({ sweep: false }) always
answered "not installed" there: the page showed the link on from the plugin
list while every preset treated it as off and replaced the official pwsh.
Walk up from the loaded package instead, which names the profile that holds
the row, and keep the environment and sweep roots as fallbacks.
changedFields read its baseline without detection while the draft was read
with it, so an unsaved link on an installed companion diffed as false -> true
and any save froze it into an explicit value. Read the baseline with the same
inputs: an untouched link writes nothing, a flipped one always writes.
Also name the row setting instead of the removed Compatibility mode when an
official tool has an OPS replacement.
xinspark
force-pushed
the
fix/companion-link-detection
branch
from
October 30, 2026 20:20
15ccf0a to
cc6086c
Compare
Contributor
Author
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.
Closes #513
现象
在
main@2c0b039上,「其他 → 联动 dsh 插件」开关(示例插件dsh-win-pwsh7)存在两条互相独立的问题:pwsh工具仍被ops_bash替换,报错原文dsh-ops <mode> mode replaced the official tool pwsh with ops_bash; … enable Compatibility mode.other.pwsh7Link: true写进该行配置;此后卸载联动插件也不会回落到关。详细复现与代码路径见 issue。本文只写改动与验证。
改动
1. 探测改为三条确定性来源(
src/settings/companion.ts)宿主进程里没有
DSH_PROFILE_DIR(启动器只把它注入工具子进程),而调用点传的是sweep: false,所以旧实现恒返回undefined。现在按以下顺序解析,命中即返回:DSH_PROFILE_DIR/DSH_PROFILE(启动器显式给出时优先);<profile>/node_modules/dsh-ops/lib/…逐级向上取node_modules——普通安装(registry /file:tarball)走这条;DSH_HOME(缺省~/.dsh)的profiles/*里找node_modules/dsh-ops,用realpathSync与本包根目录比较,相等者即「挂载我的那个 profile」——link:开发安装走这条;sweep仅作兜底,默认关闭。两处细节:
realpathSync两侧都解析:macOS 的/var、部分 Linux home 本身就是符号链接,只解析一侧会永远不相等(这轮 CI 第一版正是因为这个红在 macOS)。没有改
src/index.ts的两个调用点(:47的effective与:57的linked):两处都调同一个companionVersion,修在函数里同时覆盖,避免在两处重复表达同一判据。2. 保存基线与草稿用同一次检测(
src/client/row-schema.ts、src/client/row-form.tsx)changedFields(draft, raw, options)新增第三个参数,内部基线改为readRowValues(raw, options),RowForm保存时传入{ pwsh7Installed }。效果:true、基线true→ 不产生任何操作,继续跟随检测;3. 拒绝文案指向真实开关(
src/publication/replacements.ts)… or ask the operator to enable Compatibility mode.→… or turn off that replacement in the dsh-ops row settings.,并同步两处提到兼容模式的注释(src/modes/*现在是上游的兼容 shim,注释跟随上游,不再重复表述)。4. 双语文档与 CHANGELOG
docs/配置参考.md、docs/configuration-reference.md在各自新结构里补一段:未保存 = 没碰过、保存其它开关不写死、手动拨动一定落盘、检测在宿主进程里成立。docs/CHANGELOG.md的## [Unreleased]加中英条目。验证
构建与静态门
相关套件
新增 6 条断言(
settings-rows13 项、settings-ui18 项里):link:安装(junction 指向检出目录)也能探测到挂载它的 profile;panel.enabled;other.pwsh7Link: false;未装时手动开 → 写true;红绿
把第 1、2 处实现回退后:
恢复后
5 suite(s) passed。全量
两个失败与本改动无关,且有基线对照:
authority1/12、permissions3/15,均为临时目录写入ACCESS_DENIED (os error 5);用git stash撤掉本改动后同套件、同数量失败。56 skipped 因缺build:bash-ipc与 POSIX-only 套件。CI
run https://github.com/T-Auto/dsh-ops/actions/runs/41124823561 ——
pull_request/ success:CI required、node-floor、source-size、tools-trial、workflow-lint、validate-macos-intel、validate-posix(macOS arm64 / Linux x64)、validate-windows (win32-x64)全 pass;bench-smoke按设计 skipping。真机
desktop,file:tarball)pwsh工具返回7.6.9(WindowsApps版),ops_bash同时可用;cordis.patch.yml中pwsh7Link出现 0 次link:开发安装(profilework-exp)DSH_PROFILE_DIR时探测返回0.2.4(修复前undefined)取舍
other.pwsh7Link改成三态枚举:键名与「缺省=跟随检测、布尔=显式」的语义不变,修复只落在「何时写入」上,旧配置无需迁移。index.ts的两个调用点(见上)。residentTools、presets等 0.5.0-alpha3 新结构;本次改动只碰上面 9 个文件。环境
Windows 11 x64,Node v25.2.1,npm 11.6.2;基线上游
main@2c0b039;复现环境 DSH 0.2.1-rc.4、dsh-ops@0.5.0-alpha3、dsh-win-pwsh7@0.2.4。