Skip to content

feat: add run --cwd/--log-file, ls --full, clean --all#10

Merged
machado144 merged 3 commits into
mainfrom
feat/ls-full-clean-all-cwd
Jul 1, 2026
Merged

feat: add run --cwd/--log-file, ls --full, clean --all#10
machado144 merged 3 commits into
mainfrom
feat/ls-full-clean-all-cwd

Conversation

@machado144

Copy link
Copy Markdown
Contributor

Summary

  • Bug fix: run always ran the spawned process in the daemon's own cwd (wherever it happened to be auto-started from), not the caller's — now it defaults to the client's current directory, with --cwd <dir> to override (relative paths resolve against the caller's cwd).
  • run --log-file <path> tees full raw PTY output to a file, unbounded by the in-memory ring buffer (useful for long/noisy processes where log/log --new only ever see the buffered tail).
  • ls --full shows the untruncated command plus a CWD column instead of the default 60-char-truncated command.
  • clean --all (optionally with --force) stops every still-running process and removes everything in one shot, instead of requiring kill + clean.

Test plan

  • go build ./..., go vet ./...
  • go test ./... -race -timeout 120s (matches the release CI invocation)
  • New unit tests in services/process_manager_test.go: cwd is actually passed to the process, default cwd stays empty, log-file captures output the ring buffer discards, log-file open failures don't leak a registered process, CleanAll removes running + finished processes, and — the important edge case — a process that traps SIGTERM survives non-force CleanAll but dies under --force.
  • New protocol tests in services/daemon_service_test.go for Cwd/LogFile/All request fields.
  • New end-to-end CLI tests in integration/cli_test.go, including the regression test that proves run uses the client's cwd rather than the daemon's, --cwd overriding/resolving relatively, ls --full vs default truncation, and clean vs clean --all side effects.
  • golangci-lint run — no new findings (33 pre-existing errcheck issues, identical on main)
  • Docs updated: docs/COMMANDS.md flag tables and README.md common-commands table

Fix a correctness bug where spawned processes always inherited the
long-lived daemon's original working directory instead of the caller's —
`run` now defaults to the client's cwd and accepts --cwd to override it.

Also add --log-file to tee full raw output to disk (unbounded by the
in-memory ring buffer), ls --full to show the untruncated command and
cwd, and clean --all to stop and remove every process in one shot.
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Invalid PR Title

PR title must follow the Conventional Commits format since we use squash merge:

<type>[optional scope][!]: <description>

Allowed types: feat, fix, docs, style, refactor, test, chore, build, ci, perf, revert

Examples:

  • feat: add new feature
  • fix(daemon): resolve socket cleanup issue
  • feat!: breaking change
  • chore(deps): update dependencies

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

StructLint — All checks passed

70 rules validated against .structlint.yaml. No violations found.

View full run · Powered by StructLint

@machado144 machado144 changed the title run --cwd/--log-file, ls --full, clean --all feat: add run --cwd/--log-file, ls --full, clean --all Jul 1, 2026
…ed sleep

The fixed 300ms delay before signaling assumed the spawned shell had
already reached the trap statement, which isn't guaranteed on a slower
or more contended CI runner — flaked in CI with the process observed
already gone. Wait for a marker line the trap script itself prints
after installing the trap instead.
Spawn() already runs the given command through `sh -c`, so wrapping the
test command in another `sh -c '...'` forked an extra, unprotected outer
shell (no trap of its own). bash collapses that redundant wrapper via
its own tail-call exec optimization, masking the bug locally, but dash
(Ubuntu's /bin/sh, used by the CI runner) does not — the outer shell
died to the default SIGTERM handler and took the tracked process down
with it, regardless of whether the inner trap actually worked.

Reproduced and verified the fix against the actual CI shell (dash) in
a matching Ubuntu/Go container, not just locally.
@machado144 machado144 merged commit 8e8aa99 into main Jul 1, 2026
7 checks passed
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