Skip to content

Internalize Windows sandbox backend / 内置 Windows 沙箱后端#6076

Merged
SivanCola merged 3 commits into
esengine:main-v2from
SivanCola:chore/internalize-windows-sandbox
Jul 6, 2026
Merged

Internalize Windows sandbox backend / 内置 Windows 沙箱后端#6076
SivanCola merged 3 commits into
esengine:main-v2from
SivanCola:chore/internalize-windows-sandbox

Conversation

@SivanCola

@SivanCola SivanCola commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Commit 1 — vendor (5fe20ebda):

  • Vendor the Windows sandbox backend into internal/winsandbox with its MIT license and source notice.
  • Switch Reasonix Windows sandbox helper code to the internal package.
  • Remove the external github.com/SivanCola/windows-sandbox dependency from root and desktop modules, and update sandbox docs.

Commit 2 — Windows sandbox fixes (387cc2251):

Root cause of the "bash returns empty output on Windows" reports (#6046, #6051, #6067, #6070, #6072): the sandbox wrapper relaunches os.Executable() as a hidden helper (__reasonix_windows_sandbox), but only the CLI routed that subcommand — the desktop binary did not. On desktop, every sandboxed command therefore started a second GUI instance, which the Wails single-instance lock forwarded to the running app before exiting 0 with no output. The 1.17.3 escape prompt (#6032) never fired because it keys on the helper's exit-code-126 failure marker, which a dispatch-less binary never prints.

  • Desktop helper route: desktop/main.go dispatches the helper subcommand before any Wails/single-instance setup, with cross-platform tests pinning the route (desktop/windows_sandbox_helper_test.go).
  • Fail closed without a route: entry points declare the route via sandbox.RegisterHelperDispatch(); on Windows Available() stays false without it and Command/CommandArgs refuse to wrap — mirroring the darwin/linux wrappers — so a future dispatch-less embedder hits the existing clear-error / escape-approval path instead of silently swallowing output.
  • Lock queue visibility ([Bug]: Shell调用始终返回空 #6067): per-root mutex waits are now sliced, emitting a one-line "waiting for another sandboxed command" notice after 2s instead of blocking silently for up to 10 minutes (WINDOWS_SANDBOX_LOCK_MS). First local modification to the vendored package, recorded in internal/winsandbox/NOTICE.md; covered by a new contention test.
  • Doctor diagnostics ([Bug]: bash sandbox requested but unavailable on this platform #5961 / [Bug]: Bash返回空 #6046 confusion): reasonix doctor reports the resolved shell (Git Bash vs PowerShell is the first thing to check for low-integrity launch failures) and warns when a project reasonix.toml pins [sandbox], which overrides Settings/user-config edits.
  • Docs: Windows sandbox troubleshooting section in GUIDE.md / GUIDE.zh-CN.md.

Fixes #6051, fixes #6067, fixes #6070, fixes #6072. Likely fixes #6046 (empty output matches the desktop dispatch gap; the "non-global workspace" detail there is unconfirmed). Improves diagnostics for #5961.

Verification

  • go test ./... (root) and cd desktop && go test ./... — all green, including the new desktop helper-route tests and winsandbox lock-notice test.
  • GOOS=windows GOARCH=amd64 go build ./... (root), go build . (desktop), and go test -c for internal/sandbox / internal/winsandbox / desktop — all compile.
  • go vet (host + GOOS=windows) and gofmt clean.
  • go list -m all in root and desktop has no SivanCola/windows-sandbox entry.
  • Windows runtime behavior (real AppContainer launches, lock contention) needs Windows CI; new tests follow the existing skip conventions.

@SivanCola SivanCola requested a review from esengine as a code owner July 6, 2026 07:12
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jul 6, 2026
…osed without it

The Windows bash sandbox relaunches os.Executable() as a hidden helper
process, but the desktop binary never routed that subcommand: every
sandboxed command started a second GUI instance that forwarded to the
running app via the single-instance lock and exited 0 with no output, so
bash silently returned empty on Windows (esengine#6046, esengine#6051, esengine#6067, esengine#6070,
esengine#6072). The 1.17.3 escape prompt never fired because it keys on the
helper's exit-code-126 failure marker, which a dispatch-less binary
never prints.

- desktop/main.go dispatches the helper subcommand before any
  Wails/single-instance setup, with tests pinning the route.
- Entry points now declare the route via
  sandbox.RegisterHelperDispatch(); on Windows, Available() stays false
  without it and Command/CommandArgs refuse to wrap, so a future
  dispatch-less embedder fails closed with the existing clear error and
  escape-approval path instead of swallowing output.
- Queueing behind another sandboxed command's per-root lock now emits a
  one-line notice (sliced mutex waits) instead of blocking silently for
  up to 10 minutes; recorded as a local modification in the winsandbox
  NOTICE.
- reasonix doctor reports the resolved shell (Git Bash vs PowerShell is
  the first thing to check for low-integrity launch failures) and warns
  when a project reasonix.toml pins [sandbox], which overrides
  Settings/user-config edits (esengine#5961 confusion).
- GUIDE/GUIDE.zh-CN gain a Windows sandbox troubleshooting note.
@github-actions github-actions Bot added the tui Terminal UI / CLI (internal/cli, internal/control) label Jul 6, 2026
@SivanCola SivanCola merged commit dce3b3a into esengine:main-v2 Jul 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

1 participant