Skip to content

shell 执行加固:PS flags + 跨平台 prompt 借鉴 + Unix 登录 shell env - #5

Merged
tallcode merged 3 commits into
mainfrom
claude/windows-bash-exit-code-d5760d
Jul 15, 2026
Merged

tallcode merged 3 commits into
mainfrom
claude/windows-bash-exit-code-d5760d

Conversation

@tallcode

Copy link
Copy Markdown
Collaborator

承接 PR #4,借鉴 opencode / Claude Code 的 shell 层做的一组加固。

改动

  • PowerShell 调用:加 -NonInteractive -NoLogo(防交互提示卡死、去 5.1 横幅);os_hint 教 5.1 短路写法 cmd1; if ($?) { cmd2 }。
  • prompt 借鉴:读已知文件用 read 工具(不用 cat/Get-Content);Windows 带空格路径用调用运算符 & "...";PS 5.1 >/Out-File 默认 UTF-16+BOM 提示。
  • Unix 登录 shell env 注入(修 command not found):启动时(tokio 前)跑 $SHELL -l -i -c 抓 env,取 PATH + 增量合并;修 GUI 从访达启动只有极简 PATH、找不到用户装的工具(nvm/Homebrew/npm-global)的问题。5s 超时兜底,Windows no-op。实机验证:极简 PATH 启动 → hydrated PATH from login shell (/bin/zsh)。
  • Unix shell 探测:不再硬编码 bash——优先 $SHELL(bash/zsh)→ 探测 → 兜底 sh,拒绝 fish/nu;os_hint 如实报出探测到的 shell。

验证

  • agent:118 测试通过,x86_64-pc-windows-msvc 交叉检查干净,fmt/clippy 干净。
  • 登录 shell env 注入实机跑通。

🤖 Generated with Claude Code

tallcode and others added 3 commits July 15, 2026 21:58
…ning

Adopting two well-worn practices from opencode and Claude Code's shell layers:

- Invoke PowerShell with -NonInteractive -NoLogo (in addition to
  -NoProfile). The agent has no console to answer a prompt, so a command
  that blocks on one would hang until timeout; -NonInteractive fails fast
  instead. -NoLogo drops the 5.1 startup banner from captured output.
- os_hint now teaches the PowerShell 5.1 run-if-previous-succeeded form
  `cmd1; if ($?) { cmd2 }`, since a bare `;` (unlike `&&`) runs the next
  command unconditionally. pwsh 7 keeps the `&&`/`||` guidance.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Borrowed from opencode's and Claude Code's per-shell prompt contracts:

- A: the exploration guideline now carves out file reading — use the read
  tool for a known file's contents, not `cat` (Unix) / `Get-Content`
  (Windows). Listing/searching still go through the shell.
- B: the Windows shell description teaches the call operator for paths
  with spaces — `& "C:\Program Files\app\tool.exe" args` — a common
  PowerShell footgun where a bare quoted path is treated as a string.
- B': the redirection guideline notes that PowerShell 5.1's `>`/`Out-File`
  default to UTF-16-with-BOM, so `-Encoding utf8` is needed when another
  tool must read the file.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Two Unix borrows from opencode and Claude Code's shell layers.

#1 login-shell env hydration (fixes "command not found"):
A GUI launched from the Finder/dock inherits a minimal PATH
(/usr/bin:/bin), so `bash -c` never sees tools the user installed via
their shell rc (nvm/pyenv/conda, Homebrew, npm-global) — which is why
`future ...` came back "command not found". At startup, before any
thread or the tokio runtime (set_var is only sound single-threaded), run
`$SHELL -l -i -c` once to dump `env` between markers, then take PATH from
it and additively merge any vars the launcher didn't already set. 5s
timeout + spawn-failure fallback keep a hanging rc from blocking startup.
No-op on Windows (GUI processes already get the full registry PATH).
Mirrors what VS Code / fix-path do. Verified: starting with PATH=
/usr/bin:/bin, the agent logs "hydrated PATH from login shell (/bin/zsh)".

#2 Unix shell resolution:
shell_invocation no longer hardcodes "bash". It honors $SHELL when it is
bash/zsh (both POSIX-compatible with the `( … ) 2>&1` wrapper), else
probes bash then zsh on PATH, else falls back to sh. Never fish/nu —
their syntax would break the wrapper. os_hint now names the actual
resolved shell (e.g. zsh on macOS) instead of always saying "bash";
bash and zsh share command-line syntax so no separate syntax rules are
needed — only an accurate name.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@tallcode
tallcode merged commit 3f176c8 into main Jul 15, 2026
huichen pushed a commit that referenced this pull request Jul 16, 2026
…5760d

shell 执行加固:PS flags + 跨平台 prompt 借鉴 + Unix 登录 shell env
huichen pushed a commit that referenced this pull request Jul 16, 2026
…5760d

shell 执行加固:PS flags + 跨平台 prompt 借鉴 + Unix 登录 shell env
huichen pushed a commit that referenced this pull request Jul 16, 2026
…5760d

shell 执行加固:PS flags + 跨平台 prompt 借鉴 + Unix 登录 shell env
huichen pushed a commit that referenced this pull request Jul 16, 2026
…5760d

shell 执行加固:PS flags + 跨平台 prompt 借鉴 + Unix 登录 shell env
huichen pushed a commit that referenced this pull request Jul 16, 2026
…5760d

shell 执行加固:PS flags + 跨平台 prompt 借鉴 + Unix 登录 shell env
huichen added a commit that referenced this pull request Oct 13, 2026
- Wheel/trackpad scroll zooms with cursor as anchor point.
- Double-click toggles between fit-to-window and 100% actual size.
- Added on-screen zoom in/out/reset controls with scale indicator.
- Drag (or hold space and drag) to pan when zoomed; panning clamped to image bounds.
- Extracted pure zoom math to imageZoom.ts with full unit test coverage.
- Added UI tests for double-click toggle, wheel zoom bounds, and reset.
- Updated en/zh i18n strings for zoom controls.

Refs: remote-parity audit #5 (desktop image preview zoom)
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