Skip to content

fix(ps): list running project containers instead of counting claude processes#21

Merged
dlovell merged 1 commit into
mainfrom
fix-ps-list-containers
Jun 17, 2026
Merged

fix(ps): list running project containers instead of counting claude processes#21
dlovell merged 1 commit into
mainfrom
fix-ps-list-containers

Conversation

@dlovell

@dlovell dlovell commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • devcontainer ps was running pgrep -c claude inside the current container, counting child processes as "sessions". This reported misleading numbers (e.g. "3 sessions" from worker processes) while other branch containers were invisible.
  • Now uses docker ps --filter "name=^${PROJECT}-dev-" to list all running containers for the project, showing each by name with a total count.
  • Removes the --all flag (which searched across all docker containers for claude processes).

Test plan

  • Run devcontainer ps with multiple branch containers running — should list each container and show the correct count
  • Run devcontainer ps with no containers running — should show 0 containers running
  • Verify devcontainer --help reflects updated description

🤖 Generated with Claude Code

…rocesses

`devcontainer ps` was running `pgrep -c claude` inside the current
container, which counted child processes rather than containers. This
was confusing — reporting "3 sessions" when 3 claude worker processes
existed in one container, while other branch containers were invisible.

Now uses `docker ps --filter` to find all running containers matching
the project prefix, listing each by name with a total count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dlovell dlovell marked this pull request as ready for review June 17, 2026 17:56
@dlovell dlovell merged commit 4ec6d50 into main Jun 17, 2026
5 checks passed
@dlovell dlovell deleted the fix-ps-list-containers branch June 17, 2026 17:57
dlovell added a commit that referenced this pull request Jun 20, 2026
## Summary

- `((count++))` post-increment evaluates to 0 on the first loop
iteration, which is falsy in bash arithmetic (exit code 1). Under `set
-euo pipefail`, this silently kills the script before any output is
printed.
- `((++count))` pre-increment evaluates to 1 (truthy), so it succeeds
under `set -e`.

Regression from #21.

## Test plan

- [x] `devcontainer ps` with running containers — lists all and prints
correct count
- [x] `devcontainer ps` with no running containers — prints `0
containers running`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01AqKB4zPXLUXkTgQaMjHxDj

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
dlovell added a commit that referenced this pull request Jun 21, 2026
## Summary

- `devcontainer ps` and `devcontainer ps --all` currently produce
identical output. PR #21 removed the `--all` branch from the `ps`
command, after which the flag was silently consumed by `shift` and
ignored — even though shell completions still advertise it.
- This restores the `--all` branch: it scans every running Docker
container and reports only those with active claude sessions. The
default `ps` is unchanged — it still lists this project's containers
(filtered by `name=^${PROJECT}-dev-`) with per-container session counts.
- Kept the pre-increment fix (`((++count))`) from #22 and updated the
`--help` text. No completions change needed; they already listed `ps
--all`.

## Test plan

- [ ] `devcontainer ps` — lists only this project's containers with
session counts
- [ ] `devcontainer ps --all` — lists all running containers (across
projects) that have a claude session; differs from plain `ps` when other
projects are running
- [ ] `devcontainer ps --all` with no claude sessions anywhere — prints
`0 containers running`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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