Commit c3fec0a
authored
feat (cli): Loading animation for deployments and builds (#724)
## Description
Added a spinner as sign of loading animation for deployments in CLI
## Related Issues
#705
Closes #705
## Checklist when merging to main
<!-- Mark items with "x" when completed -->
- [x] No compiler warnings (if applicable)
- [x] Code is formatted with `rustfmt`
- [x] No useless or dead code (if applicable)
- [x] Code is easy to understand
- [x] Doc comments are used for all functions, enums, structs, and
fields (where appropriate)
- [x] All tests pass
- [x] Performance has not regressed (assuming change was not to fix a
bug)
- [x] 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](https://github.com/user-attachments/assets/c021588a-d56b-4a5c-90ff-b212a41f5f2b)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
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
<details><summary><h3>Important Files Changed</h3></summary>
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 |
</details>
</details>
<details><summary><h3>Sequence Diagram</h3></summary>
```mermaid
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
```
</details>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->4 files changed
+92
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| |||
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| 156 | + | |
| 157 | + | |
152 | 158 | | |
153 | 159 | | |
| 160 | + | |
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
| |||
160 | 167 | | |
161 | 168 | | |
162 | 169 | | |
| 170 | + | |
163 | 171 | | |
164 | 172 | | |
165 | 173 | | |
| |||
169 | 177 | | |
170 | 178 | | |
171 | 179 | | |
| 180 | + | |
172 | 181 | | |
173 | 182 | | |
174 | 183 | | |
175 | 184 | | |
| 185 | + | |
176 | 186 | | |
177 | 187 | | |
178 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
551 | 550 | | |
552 | 551 | | |
553 | 552 | | |
554 | 553 | | |
555 | 554 | | |
556 | 555 | | |
557 | | - | |
558 | 556 | | |
| 557 | + | |
559 | 558 | | |
560 | 559 | | |
561 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
0 commit comments