Skip to content

feat: zmx session persistence for pixels console#5

Merged
deevus merged 9 commits intomainfrom
worktree-zmx-console-persist
Mar 1, 2026
Merged

feat: zmx session persistence for pixels console#5
deevus merged 9 commits intomainfrom
worktree-zmx-console-persist

Conversation

@deevus
Copy link
Owner

@deevus deevus commented Mar 1, 2026

Summary

  • pixels console now attaches to a persistent zmx session by default, keeping shells alive across SSH disconnects (network drops, laptop sleep, terminal close). Reconnecting re-attaches to the same session with all processes still running.
  • New --session/-s flag (default "console") to name sessions, --no-persist to skip zmx. Graceful fallback when zmx is not installed.
  • New pixels sessions <name> command to list active/exited zmx sessions in a container.
  • Refactors all SSH functions to use a ConnConfig parameter object, replacing the repeated (host, user, keyPath) triple.

Test plan

  • go build compiles
  • go test ./... passes (including new TestConsoleArgs cases)
  • pixels console <name> attaches to zmx session "console"
  • Disconnect and pixels console <name> re-attaches to same session
  • pixels console <name> -s build creates/attaches to "build" session
  • pixels sessions <name> lists active sessions
  • pixels console <name> --no-persist opens plain SSH (no zmx)
  • Container without zmx: pixels console <name> falls back to plain SSH

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Mar 1, 2026

⬇️ Go test coverage decreased from 26.2% to 25.4% compared to 7dddb76
⚠️ 1 of 10 packages have zero coverage.
  • github.com/deevus/pixels

Updated Package Coverages:

# Package Name                                |  Prior |    New
- github.com/deevus/pixels/cmd                |   6.8% |   6.5%
+ github.com/deevus/pixels/internal/provision |  24.8% |  40.6%
- github.com/deevus/pixels/internal/ssh       |  29.0% |  18.4%
- github.com/deevus/pixels/internal/truenas   |  68.2% |  43.3%
View coverage for all packages
# Package Name                                | Coverage
- github.com/deevus/pixels                    |     0.0%
+ github.com/deevus/pixels/cmd                |     6.5%
+ github.com/deevus/pixels/internal/cache     |    93.8%
+ github.com/deevus/pixels/internal/config    |    94.0%
+ github.com/deevus/pixels/internal/dataset   |   100.0%
+ github.com/deevus/pixels/internal/egress    |    93.5%
+ github.com/deevus/pixels/internal/provision |    40.6%
+ github.com/deevus/pixels/internal/retry     |   100.0%
+ github.com/deevus/pixels/internal/ssh       |    18.4%
+ github.com/deevus/pixels/internal/truenas   |    43.3%

deevus and others added 7 commits March 1, 2026 11:39
`pixels console` now attaches to a persistent zmx session by default,
keeping shells alive across SSH disconnects. Reconnecting re-attaches
to the same session with all processes still running.

- Add `--session/-s` flag (default "console") to name the zmx session
- Add `--no-persist` flag to skip zmx and use plain SSH
- Graceful fallback to plain SSH when zmx is not installed
- New `pixels sessions <name>` command to list zmx sessions
- Refactor ssh package: introduce ConnConfig parameter object replacing
  the repeated (host, user, keyPath) triple across all SSH functions
- Add consoleArgs() helper for PTY-forced remote command execution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Provision containers with /etc/profile.d/pixels.sh (alias detach='zmx
detach') and /etc/motd showing detach hint. Add unit tests for
validSessionName, zmxCmd, Runner.conn, and consoleArgs no-key edge case.
Update console command help text and README with session persistence docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Executor interface with Exec/Output methods and MockExecutor for
testing. Runner methods now go through the interface instead of calling
ssh.ExecQuiet/OutputQuiet directly, enabling unit tests without real SSH.

Also fixes: --console now creates a zmx session (was plain SSH), MOTD
trailing newline for clean formatting, and adds isZFSPathChar test.

Coverage: provision 26% → 79%, total 21.5% → 32.5%.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The MOTD gets cleared when zmx attach takes over the terminal. Move
the detach hint to the pixels CLI, printed to stderr right before
ssh.Console when a zmx session is active.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Print the hint from /etc/profile.d/pixels.sh when ZMX_SESSION is set,
so it appears after zmx clears the screen. Remove the client-side
stderr print which was invisible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
zmx starts a non-login shell by default, which skips /etc/profile.d/.
Pass 'bash -l' as the command to zmx attach so the detach hint and
alias from pixels-profile.sh are sourced on session creation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@deevus deevus force-pushed the worktree-zmx-console-persist branch from a75d440 to 117a8de Compare March 1, 2026 11:40
deevus and others added 2 commits March 1, 2026 11:41
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coverage for internal/truenas goes from 68.8% to 83.8%. Tests cover
the rootfs path construction, config/write errors, cron job lifecycle
(create, run, delete), and ZFS path validation for unsafe characters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@deevus deevus merged commit 14e472e into main Mar 1, 2026
2 checks passed
@deevus deevus deleted the worktree-zmx-console-persist branch March 1, 2026 11:53
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