Skip to content

Conversation

@CodeMan62
Copy link

@CodeMan62 CodeMan62 commented Nov 25, 2025

Description

Added a spinner as sign of loading animation for deployments in CLI

Related Issues

#705

Closes #705

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • Version number has been updated in helix-cli/Cargo.toml and helixdb/Cargo.toml

Additional Notes

Here is a quick video
Screencast from 2025-11-25 14-25-14.webm

Greptile Overview

Greptile Summary

Implemented loading spinner animation for CLI deployment operations to address user feedback that the terminal appeared frozen during builds.

Key changes:

  • Added Spinner struct in utils.rs with async animation using tokio
  • Integrated spinner around Docker build operations in build.rs
  • Added spinners for both build and deployment phases in push.rs with provider-specific messages
  • Removed redundant status print statements from docker.rs to avoid interfering with spinner

Implementation details:

  • Spinner runs as a tokio task with braille pattern animation frames
  • Uses Arc<Mutex<String>> for thread-safe message updates
  • Properly cleans up via Drop trait to prevent resource leaks
  • Supports dynamic message updates during long operations

Important Files Changed

File Analysis

Filename Score Overview
helix-cli/src/utils.rs 4/5 Added Spinner struct with async animation loop using tokio, includes proper cleanup via Drop trait
helix-cli/src/commands/build.rs 5/5 Added spinner for Docker image build step, wrapping build_image call with start/stop
helix-cli/src/commands/push.rs 4/5 Added spinners for build and deployment phases, with dynamic messages for different cloud providers
helix-cli/src/docker.rs 5/5 Removed status print statements from build_image, delegating user feedback to spinner in calling code

Sequence Diagram

sequenceDiagram
    participant User
    participant BuildCmd as build.rs
    participant PushCmd as push.rs
    participant Spinner
    participant Docker as docker.rs
    participant CloudProvider

    Note over User,CloudProvider: Build Command Flow
    User->>BuildCmd: helix build
    BuildCmd->>Spinner: new("DOCKER", "Building...")
    BuildCmd->>Spinner: start()
    activate Spinner
    Note right of Spinner: Tokio task spawned<br/>Animation loop running
    BuildCmd->>Docker: build_image()
    Docker-->>BuildCmd: Result
    BuildCmd->>Spinner: stop()
    deactivate Spinner
    Note right of Spinner: Task aborted<br/>Line cleared
    BuildCmd-->>User: Success message

    Note over User,CloudProvider: Push Command Flow (Cloud)
    User->>PushCmd: helix push
    PushCmd->>Spinner: new("BUILD", "Building instance...")
    PushCmd->>Spinner: start()
    activate Spinner
    PushCmd->>BuildCmd: run()
    BuildCmd->>Docker: build_image()
    Docker-->>BuildCmd: Result
    BuildCmd-->>PushCmd: MetricsData
    PushCmd->>Spinner: stop()
    deactivate Spinner
    
    PushCmd->>Spinner: new("DEPLOY", "Deploying instance...")
    PushCmd->>Spinner: start()
    activate Spinner
    PushCmd->>Spinner: update("Deploying to Fly.io/ECR/Helix...")
    Note right of Spinner: Message updates<br/>while animating
    PushCmd->>CloudProvider: deploy()
    CloudProvider-->>PushCmd: Result
    PushCmd->>Spinner: stop()
    deactivate Spinner
    PushCmd-->>User: Success message
Loading

@CodeMan62 CodeMan62 changed the title Spinner Loading animation for deployments Nov 25, 2025
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.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +418 to +419
print!("\r");
std::io::Write::flush(&mut std::io::stdout()).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Line clear may not fully erase long spinner messages. Use ANSI escape code to clear entire line.

Suggested change
print!("\r");
std::io::Write::flush(&mut std::io::stdout()).unwrap();
print!("\r\x1B[2K");
std::io::Write::flush(&mut std::io::stdout()).unwrap();
Prompt To Fix With AI
This is a comment left during a code review.
Path: helix-cli/src/utils.rs
Line: 418:419

Comment:
**style:** Line clear may not fully erase long spinner messages. Use ANSI escape code to clear entire line.

```suggestion
        print!("\r\x1B[2K");
        std::io::Write::flush(&mut std::io::stdout()).unwrap();
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're absolutely right! The syntax in my suggestion was incorrect. The ANSI escape code should be a string literal, not separate parts. Here's the corrected version:

Suggested change
print!("\r");
std::io::Write::flush(&mut std::io::stdout()).unwrap();
print!("\r\x1B[2K");
std::io::Write::flush(&mut std::io::stdout()).unwrap();

The \x1B[2K is the ANSI escape sequence that clears the entire current line, ensuring that any leftover characters from longer spinner messages are completely erased before the cursor returns to the beginning of the line.

Copy link
Author

Choose a reason for hiding this comment

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

I don't think we need it you can take a look at image everything is smooth
image

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.

[Feature]: Loading animation for deployments in the CLI

1 participant