fix(env): translate PEBREL_HOOK_EXE across the WSL boundary (#290)

Forward the current and legacy hook executable variables through WSLENV with /p path translation. Document the boundary contract and cover the primary hook variable in the existing environment test.
This commit is contained in:
Anx authored and GitHub committed 2026-09-26 13:49:36 +08:00
1 parent 33e7b1d00d
commit 83f7246aa3
2 files changed
+10 -1

No files matched your search

+1 -1
View File
@@ -45,7 +45,7 @@ CLI 路径由环境给出,调用方无需根据展示名称猜测文件名。
还会绕开远端 pane 不得取用本地上下文的护栏。
2. **幂等。** 在 Pebrel 的 pane 里再开一个 Pebrel 是常规操作(嵌套 shell、`wsl.exe`、隔离实例)。
`PATH` 前置与 `WSLENV` 追加都按值判重,套多少层环境块都不增长。
3. **WSL 透传。** `WSLENV` 里带 `PEBREL_CLI/p`、`PEBREL_BIN_DIR/p`——`/p` 让 WSL 把 Windows
3. **WSL 透传。** `WSLENV` 里带 `PEBREL_CLI/p`、`PEBREL_BIN_DIR/p`、`PEBREL_HOOK_EXE/p`——`/p` 让 WSL 把 Windows
路径翻成 `/mnt/...`,否则来宾 shell 拿到的是一个执行不了的 `D:\…` 字面量。合并以环境表里的
现值为基准,因此与 `shell_detect::wsl_cwd_report_env` 的 cwd 上报条目互不覆盖。
+9
View File
@@ -175,10 +175,12 @@ const WSLENV_ENTRIES: &[&str] = &[
"COLORTERM",
"PEBREL_CLI/p",
"PEBREL_BIN_DIR/p",
"PEBREL_HOOK_EXE/p",
PROCESS_ENV,
crate::runtime_api::ENDPOINT_ENV,
"NEBULA_CLI/p",
"NEBULA_BIN_DIR/p",
"NEBULA_HOOK_EXE/p",
];
/// 把 [`WSLENV_ENTRIES`] 合并进 `WSLENV`,保留已有条目。
@@ -319,6 +321,13 @@ mod tests {
"{CLI_ENV} missing from WSLENV passthrough: {names:?}"
);
assert!(names.contains(&BIN_DIR_ENV), "{BIN_DIR_ENV} missing: {names:?}");
// Hook 的绝对路径同样是 `D:\…` 字面量,漏掉它 WSL 侧只能照抄出一个
// 跑不起来的命令(Issue: hook 接线在 WSL pane 里永远 ENOENT)。
let hook_exe = crate::ai_hook::HOOK_EXE_ENV;
assert!(
names.contains(&hook_exe),
"{hook_exe} missing from WSLENV passthrough: {names:?}"
);
assert!(names.contains(&PROCESS_ENV), "{PROCESS_ENV} missing: {names:?}");
assert!(names.contains(&crate::runtime_api::ENDPOINT_ENV));
assert!(names.contains(&"COLORTERM"));