Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Dec 24, 2025

Summary

This PR implements the requirements from issue #34:

  • Auto-exit by default: All isolation environments (screen, tmux, docker) now automatically exit after the target command completes execution. This ensures resources are freed immediately and provides uniform behavior across all backends.

  • New --keep-alive option: Added a new --keep-alive (-k) flag that keeps the isolation environment running after command completion. This is useful for debugging or interactive workflows.

  • Documentation:

    • Updated REQUIREMENTS.md with the new option and auto-exit behavior documentation
    • Added ARCHITECTURE.md describing the overall system architecture and design decisions

Changes

New Features

  • Add --keep-alive (-k) option to CLI
  • Implement auto-exit behavior for screen, tmux, and docker backends
  • Update help text to show the new option

Documentation

  • Add new section 6.5 "Auto-Exit Behavior" to REQUIREMENTS.md
  • Create ARCHITECTURE.md with system architecture documentation

Tests

  • Add tests for --keep-alive option parsing
  • Add tests for keep-alive message output in isolation runners

Test Plan

  • All existing tests pass
  • New tests for --keep-alive option pass
  • Lint checks pass
  • CI passes

Usage Examples

# Default: session exits after command completes
$ -i screen -d -- echo "hello"
# Output: Session will exit automatically after command completes.

# With keep-alive: session stays running
$ -i screen -d -k -- echo "hello"
# Output: Session will stay alive after command completes.

Fixes #34

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #34
@konard konard self-assigned this Dec 24, 2025
konard and others added 6 commits December 24, 2025 23:57
Add new --keep-alive (-k) flag to control isolation environment lifecycle.
By default, isolation environments (screen, tmux, docker) exit automatically
after the command completes. With --keep-alive, they stay alive for
debugging or interactive workflows.

Fixes #34

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

Co-Authored-By: Claude <[email protected]>
All isolation backends (screen, tmux, docker) now automatically exit
after command completion by default. This ensures:
- Resources are freed immediately
- No orphaned sessions/containers remain
- Uniform behavior across all backends

With --keep-alive option, the isolation environment stays alive after
the command completes, useful for debugging or interactive workflows.

Fixes #34

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

Co-Authored-By: Claude <[email protected]>
Add --keep-alive option to CLI help text and pass the keepAlive option
to the isolation runners.

Fixes #34

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

Co-Authored-By: Claude <[email protected]>
Add comprehensive tests for the new --keep-alive functionality:
- args-parser tests for flag parsing and validation
- isolation tests for message output verification

Fixes #34

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

Co-Authored-By: Claude <[email protected]>
Update REQUIREMENTS.md:
- Add --keep-alive option to isolation options section
- Add new section 6.5 for auto-exit behavior documentation

Add ARCHITECTURE.md:
- Document overall system architecture
- Describe isolation module design
- Explain auto-exit and keep-alive behavior
- Include file structure and design decisions

Fixes #34

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

Co-Authored-By: Claude <[email protected]>
New features in this release:
- Add --keep-alive option for isolation environments
- Ensure uniform auto-exit behavior across all isolation backends
- Add ARCHITECTURE.md documentation

Fixes #34

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

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Make sure in screen, tmux and docker isolations we by default exit after the target command is executed feat: Auto-exit isolation environments by default with --keep-alive option Dec 24, 2025
konard and others added 2 commits December 24, 2025 23:59
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add isDockerRunning() helper to properly check if docker daemon is running
- Fix CLAUDE.md missing newline at end of file

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

Co-Authored-By: Claude <[email protected]>
@konard konard marked this pull request as ready for review December 24, 2025 23:03
@konard
Copy link
Member Author

konard commented Dec 24, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $9.643676 USD
  • Calculated by Anthropic: $6.262892 USD
  • Difference: $-3.380784 (-35.06%)
    📎 Log file uploaded as GitHub Gist (1067KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Dec 24, 2025

We should use docker ps -a, screen -ls and similar for tmux to verify that by default after executing the command the list is clear. In docker it should be at least exited. In screen not in a list, for tmux the same. So in all cases active resources should be released. But as the file system in docker should be preserved by default, we need to make sure we add --auto-remove-docker-container option, that not only will ensure docker container exited and stoped, but also removed after command finish. But by default --auto-remove-docker-container should be disabled, as we may want to reenter docker and get other files, not only logs. All these should also be added to tests.

@konard konard marked this pull request as draft December 24, 2025 23:20
@konard
Copy link
Member Author

konard commented Dec 24, 2025

🤖 AI Work Session Started

Starting automated work session at 2025-12-24T23:20:17.891Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

…r-container option

This commit implements the requirements from PR feedback:

## Resource Cleanup Verification Tests
- Add comprehensive tests using `screen -ls`, `tmux ls`, and `docker ps -a` to verify that isolation environments release resources after command execution
- Verify that screen and tmux sessions auto-exit and disappear from session lists
- Verify that Docker containers exit and stop (but preserve filesystem by default)
- Add tests for --keep-alive behavior to ensure sessions stay alive when requested

## --auto-remove-docker-container Option
- Add new CLI option to automatically remove Docker containers after exit
- Disabled by default to preserve container filesystem for re-entry and file retrieval
- When enabled, uses Docker's `--rm` flag to remove container after exit
- Independent of --keep-alive flag
- Only valid with `--isolated docker`

## Documentation Updates
- Update REQUIREMENTS.md with new option and Docker filesystem preservation behavior
- Explain default behavior (filesystem preserved) vs. auto-remove behavior
- Update CLI help text with new option

## Tests
- Add new test file `test/docker-autoremove.test.js` for auto-remove functionality
- Add resource cleanup verification tests in `test/isolation.test.js`
- All tests properly skip when backends are not available

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

Co-Authored-By: Claude <[email protected]>
@konard konard marked this pull request as ready for review December 24, 2025 23:29
@konard
Copy link
Member Author

konard commented Dec 24, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.121219 USD
  • Calculated by Anthropic: $2.333478 USD
  • Difference: $-1.787741 (-43.38%)
    📎 Log file uploaded as GitHub Gist (819KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard marked this pull request as draft December 25, 2025 00:16
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 AI Work Session Started

Starting automated work session at 2025-12-25T00:16:38.431Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

@konard
Copy link
Member Author

konard commented Dec 25, 2025

Checks should pass, also README.md must be updated.

Split test/isolation.test.js (1027 lines) into two files:
- test/isolation.test.js (658 lines) - core isolation tests
- test/isolation-cleanup.test.js (377 lines) - resource cleanup tests

This change addresses the CI lint failure where the file size check
requires JavaScript files to be under 1000 lines.

All tests continue to pass and functionality remains unchanged.

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

Co-Authored-By: Claude <[email protected]>
@konard konard marked this pull request as ready for review December 25, 2025 00:23
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.469295 USD
  • Calculated by Anthropic: $0.871726 USD
  • Difference: $-0.597569 (-40.67%)
    📎 Log file uploaded as GitHub Gist (369KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Dec 25, 2025

Double check all our requirements are met, changes in the repository are as best as they can, and also that we really do test all and every possible test cases.

@konard konard marked this pull request as draft December 25, 2025 09:13
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 AI Work Session Started

Starting automated work session at 2025-12-25T09:13:06.121Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

Update README.md with:
- Add --keep-alive and --auto-remove-docker-container to Isolation Options table
- Add new "Auto-Exit Behavior" section explaining default behavior
- Include usage examples for keep-alive option

Also add tests for --auto-remove-docker-container option parsing in args-parser.test.js.

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

Co-Authored-By: Claude <[email protected]>
@konard konard marked this pull request as ready for review December 25, 2025 09:20
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.474221 USD
  • Calculated by Anthropic: $2.672982 USD
  • Difference: $-1.801239 (-40.26%)
    📎 Log file uploaded as GitHub Gist (598KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 8849179 into main Dec 25, 2025
8 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.

Make sure in screen, tmux and docker isolations we by default exit after the target command is executed

2 participants