daemon, agentenv: the service tools run through proc, and PI_DESKTOP_DATA_DIR is cleared in every sandbox

main has been red on ubuntu and macOS since 692a779d3's run (38376844048),
with two guards that each caught a commit run on chosen packages only:

- TestNoCommandBypassesProc: 5617281f5's daemon.run called exec.Command,
  so on Windows the service tools would open a console window. It now uses
  proc.Command.
- TestFolderVarsAreListed: cdb7b5ff7 made Sessions read PI-Desktop's data
  folder from $PI_DESKTOP_DATA_DIR without listing it in agentenv.Vars, so
  a test could read a developer's real PI-Desktop chats.

Run: go test -tags nogui -count=1 ./internal/agent ./internal/proc
./internal/daemon ./internal/agentenv ./internal/sessions (sandbox HOME),
all ok; both tests failed on the run above before; gofmt -l; go vet
darwin, GOOS=linux -tags nogui, GOOS=windows.
This commit is contained in:
yetone
2026-10-13 17:49:07 +08:00
parent 42216ea609
commit c6de0d2a54
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -75,6 +75,8 @@ var Vars = []string{
"REASONIX_HOME",
// Reasonix's state folder, where it reads REASONIX.md
"REASONIX_STATE_HOME",
// PI-Desktop's data folder, where Sessions reads its chat titles
"PI_DESKTOP_DATA_DIR",
// Mister Morph's config file
"MISTER_MORPH_CONFIG",
// T3 Code's base folder (its settings in userdata/)
+1 -1
View File
@@ -253,7 +253,7 @@ func environ() []string {
// run runs a service manager's tool, from PATH, and gives what it printed.
// A failure carries that text, which is what the user needs to read.
func run(name string, args ...string) (string, error) {
out, err := exec.Command(name, args...).CombinedOutput()
out, err := proc.Command(name, args...).CombinedOutput()
text := strings.TrimSpace(string(out))
if err != nil {
if errors.Is(err, exec.ErrNotFound) {