Skip to content

Conversation

@xav-db
Copy link
Member

@xav-db xav-db commented Nov 26, 2025

NOTE: the cloud authority url is included, should probably be made into a GitHub env var on build.

Greptile Overview

Greptile Summary

This PR implements payment handling and cloud instance creation functionality for the Helix CLI, along with improved SSE (Server-Sent Events) stream handling and login modifications. The changes introduce a new create-cluster command that enables users to provision managed database clusters through a Stripe-integrated payment workflow. Key architectural improvements include refactoring authentication from WebSocket to SSE, adding real-time deployment progress tracking, and restructuring cloud configurations to support multiple environments and providers.

The implementation follows a two-phase approach: first creating instance configurations, then prompting users for cluster creation with clear payment implications. This gives users explicit control over when they incur charges while preserving configurations if they defer cluster creation.

PR Description Notes:

  • The hardcoded cloud authority URL should be converted to a GitHub environment variable during build

Important Files Changed

Filename Score Overview
helix-cli/src/commands/create_cluster.rs 3/5 New cluster creation command with Stripe payment integration and SSE handling, but has security and reliability concerns
helix-cli/src/sse_client.rs 4/5 New SSE client module for real-time communication with comprehensive event handling and proper error management
helix-cli/src/commands/integrations/helix.rs 4/5 Enhanced cloud deployment with SSE streaming, environment-aware configurations, and restructured payload format
helix-cli/src/commands/add.rs 4/5 Refactored to separate configuration creation from cluster provisioning with user consent prompts
helix-cli/src/commands/push.rs 4/5 Added cluster validation and implemented actual cloud deployment logic replacing TODO comments
helix-cli/src/commands/init.rs 4/5 Modified initialization flow to split configuration creation from cluster provisioning with interactive prompts
helix-cli/src/commands/auth.rs 3/5 Refactored authentication from WebSocket to SSE with improved error handling but includes unsafe unwrap()
helix-cli/src/main.rs 4/5 Added CreateCluster command integration and imported sse_client module following existing CLI patterns
helix-cli/src/lib.rs 4/5 Expanded command enums to support cloud deployment workflows and authentication actions
helix-cli/Cargo.toml 5/5 Updated dependencies to support SSE handling, progress bars, and web browser launching functionality
helix-cli/src/config.rs 5/5 Added environment variables support to CloudInstanceConfig with backward compatibility
helix-cli/src/commands/mod.rs 5/5 Added create_cluster module declaration following existing patterns
hql-tests/tests/add_n/helix.toml 3/5 Updated test configuration but includes hardcoded cluster_id which could affect test isolation
hql-tests/tests/user_test_1/schema.hx 4/5 Simplified from complex schema to basic User/Post template for better testing and documentation
hql-tests/tests/user_test_1/helix.toml 4/5 Enhanced with multiple environment configurations and BM25 search capabilities
hql-tests/tests/user_test_1/queries.hx 4/5 Streamlined from complex app management to simple user CRUD operations
.github/workflows/hql_tests.yml 5/5 Formatting standardization with no functional changes

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as "Helix CLI"
    participant HelixManager
    participant SseClient
    participant StripeCheckout
    participant HelixCloud as "Helix Cloud API"

    User->>CLI: "helix create-cluster instance_name"
    CLI->>CLI: "Load project context & validate instance"
    CLI->>CLI: "Check authentication credentials"
    
    alt Not authenticated
        CLI-->>User: "Error: Not logged in"
        Note over User,CLI: "User must run 'helix auth login' first"
    end
    
    CLI->>HelixCloud: "POST /create-cluster (SSE stream)"
    HelixCloud-->>CLI: "SSE: CheckoutRequired {url}"
    CLI->>User: "Opening Stripe checkout..."
    CLI->>StripeCheckout: "Open browser to payment URL"
    
    User->>StripeCheckout: "Complete payment"
    StripeCheckout->>HelixCloud: "Payment confirmation webhook"
    HelixCloud-->>CLI: "SSE: PaymentConfirmed"
    CLI->>User: "Payment confirmed!"
    
    HelixCloud-->>CLI: "SSE: CreatingProject"
    CLI->>User: "Creating cluster..."
    
    HelixCloud-->>CLI: "SSE: ProjectCreated {cluster_id}"
    CLI->>CLI: "Update helix.toml with cluster_id"
    CLI->>User: "Cluster created successfully!"
Loading

Context used:

  • Context from dashboard - readme for helixdb (source)

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.

Additional Comments (4)

  1. helix-cli/src/commands/add.rs, line 192-194 (link)

    logic: Duplicate config save - this is already done on line 82 for Helix instances

  2. helix-cli/src/lib.rs, line 45-47 (link)

    logic: Region parameter uses Option<String> but has default_value - this creates confusing behavior where the Option will never be None

    Should this be a plain String since it always has a default value, or should the default_value be removed?

  3. helix-cli/src/commands/auth.rs, line 44 (link)

    logic: Using .unwrap() here will cause the program to panic if login fails. Consider propagating the error instead with ? operator for better error handling.

  4. helix-cli/src/commands/auth.rs, line 55 (link)

    logic: Memory leak: user_id.leak() creates a memory leak by converting the String to a static str. Consider using a different approach to satisfy the lifetime requirements without leaking memory.

17 files reviewed, 9 comments

Edit Code Review Agent Settings | Greptile


/// Update progress percentage
pub fn set_progress(&self, percentage: f64) {
self.progress_bar.set_position(percentage as u64);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Progress percentage cast from f64 to u64 could lose precision and truncate decimal values. Should fractional progress percentages be preserved or is integer precision sufficient?

Prompt To Fix With AI
This is a comment left during a code review.
Path: helix-cli/src/sse_client.rs
Line: 188:188

Comment:
**logic:** Progress percentage cast from f64 to u64 could lose precision and truncate decimal values. Should fractional progress percentages be preserved or is integer precision sufficient?

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

// Create cloud instance configuration (without cluster_id yet)
let cloud_config = helix_manager
.create_instance_config(project_name, region)
.create_instance_config(project_name, region.clone())
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Cloning region here is unnecessary since it's used again on line 142 - consider using a reference or moving the clone.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: helix-cli/src/commands/init.rs
Line: 111:111

Comment:
**style:** Cloning region here is unnecessary since it's used again on line 142 - consider using a reference or moving the clone.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

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

// The server will send CheckoutRequired, PaymentConfirmed, CreatingProject, ProjectCreated events
print_status("INITIATING", "Starting cluster creation...");

let create_url = format!("http://{}/create-cluster", *CLOUD_AUTHORITY);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Using HTTP instead of HTTPS for production cloud service communication is a security risk

Suggested change
let create_url = format!("http://{}/create-cluster", *CLOUD_AUTHORITY);
let create_url = format!("https://{}/create-cluster", *CLOUD_AUTHORITY);
Prompt To Fix With AI
This is a comment left during a code review.
Path: helix-cli/src/commands/create_cluster.rs
Line: 60:60

Comment:
**logic:** Using HTTP instead of HTTPS for production cloud service communication is a security risk

```suggestion
    let create_url = format!("https://{}/create-cluster", *CLOUD_AUTHORITY);
```

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

Comment on lines +64 to +68
let mut event_source = client
.post(&create_url)
.header("x-api-key", &credentials.helix_admin_key)
.header("Content-Type", "application/json")
.eventsource()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: POST request has Content-Type: application/json but no request body is being sent. Should the request include cluster parameters like instance_name and region in the body?

Prompt To Fix With AI
This is a comment left during a code review.
Path: helix-cli/src/commands/create_cluster.rs
Line: 64:68

Comment:
**logic:** POST request has Content-Type: application/json but no request body is being sent. Should the request include cluster parameters like instance_name and region in the body?

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

}
Ok(reqwest_eventsource::Event::Message(message)) => {
// Debug: print raw data
eprintln!("DEBUG: Received SSE data: {}", message.data);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Debug output using eprintln! should be removed or replaced with proper logging for production code

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: helix-cli/src/commands/create_cluster.rs
Line: 81:81

Comment:
**style:** Debug output using `eprintln!` should be removed or replaced with proper logging for production code

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

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

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.

3 participants