Skip to content

Conversation

@xav-db
Copy link
Member

@xav-db xav-db commented Jan 29, 2026

Greptile Overview

Greptile Summary

This PR adds a new restart command to the Helix CLI that stops and starts database instances (both local Docker-based and cloud Fly.io instances). The implementation follows existing patterns from start and stop commands with proper error handling, progress tracking, and instance validation.

Key changes:

  • restart.rs: New command handler with local/cloud branching logic
  • docker.rs: Added restart_instance() method using docker compose restart
  • Testing: Comprehensive lifecycle tests and CI workflow for cross-platform testing
  • Data dir fix: Changed HELIX_DATA_DIR to /data for consistent container paths

The restart command properly validates instance existence, checks for build artifacts, and handles both Docker/Podman runtimes. Cloud restart uses stop+start sequence via FlyManager. Test infrastructure includes isolated temp directories via HELIX_CACHE_DIR override.

Important Files Changed

Filename Overview
helix-cli/src/commands/restart.rs New restart command following established patterns. Handles local Docker restart efficiently and cloud Fly.io restart via stop+start. Minor style inconsistency with todo!/unimplemented! macros.
helix-cli/src/docker.rs Added restart_instance() method using docker compose restart. Changed HELIX_DATA_DIR to static /data for container consistency (intentional improvement).
helix-cli/src/project.rs Added HELIX_CACHE_DIR environment variable override for test isolation, properly documented and implemented.
helix-cli/src/tests/lifecycle_tests.rs Comprehensive lifecycle command tests covering error paths for start/stop/restart without Docker. Well-structured with clear test categories.
.github/workflows/cli_tests.yml New CI workflow for cross-platform CLI testing (Ubuntu/macOS/Windows). Includes cargo caching and runs both unit and integration tests.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as restart::run()
    participant Project as ProjectContext
    participant Docker as DockerManager
    participant Fly as FlyManager
    participant Container as Docker/Podman

    User->>CLI: helix restart [instance]
    CLI->>Project: find_and_load()
    Project-->>CLI: project context
    
    alt No instance provided & non-interactive
        CLI->>CLI: list_instances()
        CLI-->>User: Error: Available instances
    end
    
    CLI->>Project: get_instance(name)
    Project-->>CLI: instance_config
    
    alt Local Instance
        CLI->>Docker: new(project)
        CLI->>Docker: check_runtime_available()
        Docker-->>CLI: runtime OK
        CLI->>CLI: Check docker-compose.yml exists
        alt Compose file missing
            CLI-->>User: Error: Not built yet
        end
        CLI->>Docker: restart_instance(name)
        Docker->>Container: docker compose restart
        Container-->>Docker: success
        Docker-->>CLI: OK
        CLI-->>User: Container restarted
    else Cloud Instance (Fly.io)
        CLI->>CLI: Validate cluster_id
        CLI->>Fly: new(project, auth_type)
        Fly-->>CLI: fly manager
        CLI->>Fly: stop_instance(name)
        Fly->>Fly: flyctl scale count 0
        Fly-->>CLI: stopped
        CLI->>Fly: start_instance(name)
        Fly->>Fly: flyctl scale count 1
        Fly-->>CLI: started
        CLI-->>User: Cloud instance restarted
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@xav-db
Copy link
Member Author

xav-db commented Jan 29, 2026

@greptile

@xav-db xav-db merged commit abf1d1d into dev Jan 29, 2026
25 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