From 22ad75c38de490aeefaee158496493ad0b8ff78b Mon Sep 17 00:00:00 2001 From: "openai-code-agent[bot]" <242516109+Codex@users.noreply.github.com> Date: Mon, 30 Mar 2026 04:46:08 +0000 Subject: [PATCH 1/3] Initial plan From 5e5aff2043ef049a9766a4d56fc1875f48c817fc Mon Sep 17 00:00:00 2001 From: "openai-code-agent[bot]" <242516109+Codex@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:20:31 +0000 Subject: [PATCH 2/3] chore: auto-format in pre-commit hook Co-authored-by: JetSquirrel <20291255+JetSquirrel@users.noreply.github.com> --- .githooks/pre-commit | 29 +++++++++++++++-------------- CONTRIBUTING.md | 4 ++-- src/db.rs | 12 +++++++----- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 3fb1548..bb5a535 100644 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,22 +1,23 @@ #!/bin/sh -# Pre-commit hook to check Rust code formatting +# Pre-commit hook to format and lint Rust code automatically -echo "Running cargo fmt check..." -cargo fmt --check -if [ $? -ne 0 ]; then - echo "" - echo "ERROR: Code formatting issues found!" - echo "Please run 'cargo fmt' before committing." - exit 1 +set -e + +STAGED_RUST_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.rs') + +echo "Formatting Rust code (cargo fmt)..." +cargo fmt + +if [ -n "$STAGED_RUST_FILES" ]; then + printf '%s\n' "$STAGED_RUST_FILES" | while IFS= read -r file; do + [ -n "$file" ] && git add "$file" + done + echo "Re-staged formatted Rust files." +else + echo "No staged Rust files detected; formatted workspace." fi echo "Running cargo clippy..." cargo clippy -- -D warnings -if [ $? -ne 0 ]; then - echo "" - echo "ERROR: Clippy warnings found!" - echo "Please fix the issues before committing." - exit 1 -fi echo "Pre-commit checks passed!" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c7c88e2..5762aa8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,8 +69,8 @@ cargo clippy ### Code Style - Follow Rust's official style guidelines -- Run `cargo fmt` before committing (enforced by pre-commit hook) -- Run `cargo clippy` to catch common mistakes (enforced by pre-commit hook) +- Enable repo hooks (`git config core.hooksPath .githooks`); pre-commit automatically runs `cargo fmt`, re-stages formatted Rust files, and runs `cargo clippy` +- Run `cargo fmt` / `cargo clippy` manually when you want fast feedback - Write documentation for public APIs - Use meaningful variable and function names diff --git a/src/db.rs b/src/db.rs index 91a32d8..bc63868 100644 --- a/src/db.rs +++ b/src/db.rs @@ -728,7 +728,10 @@ pub fn delete_budget(account_id: &str) -> Result<()> { let db = get_connection()?; let conn = db.as_ref().unwrap(); - conn.execute("DELETE FROM budgets WHERE account_id = ?", params![account_id])?; + conn.execute( + "DELETE FROM budgets WHERE account_id = ?", + params![account_id], + )?; tracing::info!("Deleted budget for account {}", account_id); Ok(()) @@ -750,11 +753,10 @@ pub fn get_budget_status(account_id: &str) -> Result> { .ok_or_else(|| anyhow::anyhow!("Account not found"))?; // Get cached cost summary - let cost_summary = get_cached_cost_summary_with_account(account_id, &account.name, &account.provider)?; + let cost_summary = + get_cached_cost_summary_with_account(account_id, &account.name, &account.provider)?; - let current_cost = cost_summary - .map(|cs| cs.current_month_cost) - .unwrap_or(0.0); + let current_cost = cost_summary.map(|cs| cs.current_month_cost).unwrap_or(0.0); // Calculate metrics let percentage_used = if budget.monthly_budget > 0.0 { From 7e773936be33adf2eabfb8bd1b53fd4795e9fbd9 Mon Sep 17 00:00:00 2001 From: "openai-code-agent[bot]" <242516109+Codex@users.noreply.github.com> Date: Mon, 30 Mar 2026 08:43:12 +0000 Subject: [PATCH 3/3] fix: update input placeholders for gpui change Co-authored-by: JetSquirrel <20291255+JetSquirrel@users.noreply.github.com> --- src/ui/accounts.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/ui/accounts.rs b/src/ui/accounts.rs index e6c4db9..4c04a79 100644 --- a/src/ui/accounts.rs +++ b/src/ui/accounts.rs @@ -104,38 +104,38 @@ impl AccountsView { // Update input placeholders based on cloud provider match provider { CloudProvider::AWS => { - self.ak_input.update(cx, |state, _cx| { - state.set_placeholder("Access Key ID"); + self.ak_input.update(cx, |state, cx| { + state.set_placeholder("Access Key ID", window, cx); }); - self.sk_input.update(cx, |state, _cx| { - state.set_placeholder("Secret Access Key"); + self.sk_input.update(cx, |state, cx| { + state.set_placeholder("Secret Access Key", window, cx); }); - self.region_input.update(cx, |state, _cx| { - state.set_placeholder("Region (optional, default us-east-1)"); - state.set_default_value("us-east-1"); + self.region_input.update(cx, |state, cx| { + state.set_placeholder("Region (optional, default us-east-1)", window, cx); + state.set_value("us-east-1", window, cx); }); } CloudProvider::Aliyun => { - self.ak_input.update(cx, |state, _cx| { - state.set_placeholder("AccessKey ID"); + self.ak_input.update(cx, |state, cx| { + state.set_placeholder("AccessKey ID", window, cx); }); - self.sk_input.update(cx, |state, _cx| { - state.set_placeholder("AccessKey Secret"); + self.sk_input.update(cx, |state, cx| { + state.set_placeholder("AccessKey Secret", window, cx); }); - self.region_input.update(cx, |state, _cx| { - state.set_placeholder("Region (optional, default cn-hangzhou)"); - state.set_default_value("cn-hangzhou"); + self.region_input.update(cx, |state, cx| { + state.set_placeholder("Region (optional, default cn-hangzhou)", window, cx); + state.set_value("cn-hangzhou", window, cx); }); } CloudProvider::DeepSeek => { - self.ak_input.update(cx, |state, _cx| { - state.set_placeholder("API Key"); + self.ak_input.update(cx, |state, cx| { + state.set_placeholder("API Key", window, cx); }); - self.sk_input.update(cx, |state, _cx| { - state.set_placeholder("(Not required, leave empty)"); + self.sk_input.update(cx, |state, cx| { + state.set_placeholder("(Not required, leave empty)", window, cx); }); - self.region_input.update(cx, |state, _cx| { - state.set_placeholder("(Not required)"); + self.region_input.update(cx, |state, cx| { + state.set_placeholder("(Not required)", window, cx); }); }