Skip to content

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

Open
AnxForever wants to merge 1 commit into
Kuddev:mainfrom
AnxForever:fix/wslenv-hook-exe
Open

AnxForever wants to merge 1 commit into
Kuddev:mainfrom
AnxForever:fix/wslenv-hook-exe

Conversation

@AnxForever

Copy link
Copy Markdown
Contributor

Result / 用户结果

PEBREL_HOOK_EXE, and its legacy alias NEBULA_HOOK_EXE, now reach WSL panes as a /mnt/... path. They are translated the same way as PEBREL_CLI and PEBREL_BIN_DIR.

Before this change the variable did not cross WSLENV at all. Inside a WSL pane:

$ echo "hook=[$PEBREL_HOOK_EXE]"
hook=[]

The only value a user could find was the process-wide Windows one, D:/tools/Pebrel/runtime/pebrel-hook.exe, and Linux cannot execute that. A Claude Code hook wired with it on the WSL side fails on every event:

SessionStart:startup hook error
Failed with non-blocking status code: Error occurred while executing hook command:
ENOENT: no such file or directory, posix_spawn 'D:/tools/Pebrel/runtime/pebrel-hook.exe'

Only SessionStart shows the error. PostToolUse, UserPromptSubmit, Stop and the other events fail silently. The same hooks work when the path is /mnt/d/tools/Pebrel/runtime/pebrel-hook.exe, which is the value this change exports.

Design / 设计边界

  • Responsibility: agent_env.rs is the one place that decides what crosses into WSL through WSLENV. This adds PEBREL_HOOK_EXE/p and NEBULA_HOOK_EXE/p to WSLENV_ENTRIES, next to PEBREL_CLI/p and PEBREL_BIN_DIR/p.
  • Why here: the doc comment above the table already describes this failure: without /p, the guest shell gets a D:\… literal that nothing on the Linux side can execute. HOOK_EXE_ENV exists so that plugins can shell out to the hook bridge. It has the same process-wide scope as the other two paths (ai_hook.rs), so it belongs in the same table.
  • Unchanged: hook delivery itself. Pane identity already crosses through WSLENV, and the notify pipe is reachable from WSL. Injecting a hook payload from a WSL pane flips pebrel agent list to state_source: hook. The exported path was the only missing piece.
  • Compatibility: no interface, data-format or threading change. WSLENV_ENTRIES is #[cfg(windows)], so other platforms are unaffected, and the existing merge still preserves entries that are already in WSLENV.
  • Docs: docs/runtime-control-api.md lists the translated entries; this adds the hook path to that list.

Evidence / 验证依据

All checks ran on Windows x64 with the pinned toolchain (Rust 1.97.1):

  • cargo test --locked -p nebula --features gpui-test-support wslenv_entries_match_variables: passes.
  • Regression check: I removed the two table entries, kept the new assertion, and ran the same test. It fails:
    test agent_env::tests::wsl::wslenv_entries_match_variables ... FAILED
    PEBREL_HOOK_EXE missing from WSLENV passthrough: ["PEBREL_PANE_ID", "NEBULA_PANE_ID", "TERM_PROGRAM", "TERM_PROGRAM_VERSION", "COLORTERM", "PEBREL_CLI", "PEBREL_BIN_DIR", "PEBREL_PROCESS_ID", "PEBREL_RUNTIME_ENDPOINT", "NEBULA_CLI", "NEBULA_BIN_DIR"]
    
  • Full cargo test --locked -p nebula --features gpui-test-support, run on a v1.9.1-based branch that carries this commit: 2024 passed, 0 failed.
  • cargo fmt --all -- --check: clean. I ran it with --config newline_style=Auto because this Windows checkout uses CRLF.
  • python3 scripts/check_architecture.py --base origin/main: exit 0.
  • Not run: Linux and macOS, since the change is #[cfg(windows)]. I also haven't done an end-to-end check in a live WSL pane with a build of this exact branch.

Required Review / 必须确认

  • I followed CONTRIBUTING.md, docs/architecture.md, and docs/project-constraints.md.
  • I split responsibilities, not arbitrary line ranges; no duplicate behavior authority was added.
  • python3 scripts/check_architecture.py --base <PR-base-commit> passes; budgets were not inflated to fit the change.
  • Tests cover success and failure; platform/feature coverage limitations are stated.

WSLENV_ENTRIES carries /p for PEBREL_CLI and PEBREL_BIN_DIR but missed the
hook path, so a WSL pane received no PEBREL_HOOK_EXE at all, and the only
value a user could copy from (the process-wide Windows one) is a D:\
literal — the exact failure mode the doc comment above the list warns
about: 在 Linux 侧谁也执行不了.

Add PEBREL_HOOK_EXE/p and NEBULA_HOOK_EXE/p, and cover the new entry in
wslenv_entries_match_variables so a future rename fails the test instead of
silently dropping WSL reachability. docs/runtime-control-api.md lists the
translated entries; add the hook path there as well.
@AnxForever
AnxForever requested a review from Kuddev as a code owner September 24, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant