Skip to content

Conversation

@Brendonovich
Copy link
Contributor

@Brendonovich Brendonovich commented Oct 7, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Desktop app now prioritizes the environment variable for the server URL over the in-app setting, ensuring environments configured via deployment variables connect to the intended server. If the environment variable is not set, the app falls back to the saved setting, then to a default URL.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 7, 2025

Walkthrough

Reordered server_url resolution during app initialization: now checks VITE_SERVER_URL env var first, then GeneralSettingsStore’s server_url, then a hardcoded default. No public interfaces changed.

Changes

Cohort / File(s) Summary
App initialization: server_url resolution
apps/desktop/src-tauri/src/lib.rs
Reversed precedence for server_url lookup to: environment variable → settings store → default; previously settings store was checked before environment variable. Control flow updated accordingly; no exported declarations changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as App Init
  participant Env as Env (VITE_SERVER_URL)
  participant Settings as GeneralSettingsStore
  participant Default as Default URL

  User->>App: Launch
  App->>Env: Read VITE_SERVER_URL
  alt Env var present
    Env-->>App: server_url
    note right of App: Use env value (new precedence)
  else Env var absent
    App->>Settings: Read server_url
    alt Settings has value
      Settings-->>App: server_url
    else
      App->>Default: Use fallback
      Default-->>App: hardcoded URL
    end
  end
  App-->>User: App initialized with resolved server_url
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at URLs anew,
Env leads first, then settings queue;
If both are quiet, defaults hop in,
A tidy path for apps to begin.
Thump-thump! The flow now feels just right—
Carrots aligned, we launch in light. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title “prefer VITE_SERVER_URL env var” succinctly highlights the main change of prioritizing the environment variable in server_url resolution. It is concise, specific, and free of extraneous details, making the primary change easy to understand at a glance.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch use-vite-server-url-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/desktop/src-tauri/src/lib.rs (1)

2200-2208: Consider handling empty server_url values.

If server_url in GeneralSettingsStore is an empty string (e.g., from missing field with #[serde(default)] or user configuration), the current logic would use it instead of falling back to the default "https://cap.so". This could cause connection failures.

Apply this diff to treat empty strings as None:

                     server_url: std::option_env!("VITE_SERVER_URL")
                         .map(|s| s.to_string())
-                        .or_else(|| {
+                        .or_else(|| {
                             GeneralSettingsStore::get(&app)
                                 .ok()
                                 .flatten()
-                                .map(|v| v.server_url.clone())
+                                .and_then(|v| {
+                                    (!v.server_url.is_empty()).then(|| v.server_url.clone())
+                                })
                         })
                         .unwrap_or_else(|| "https://cap.so".to_string()),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba83312 and 0d7e138.

📒 Files selected for processing (1)
  • apps/desktop/src-tauri/src/lib.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx,rs}

📄 CodeRabbit inference engine (CLAUDE.md)

Do not add inline, block, or docstring comments in any language; code must be self-explanatory

Files:

  • apps/desktop/src-tauri/src/lib.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format Rust code using rustfmt and ensure all Rust code passes workspace-level clippy lints.
Rust modules should be named with snake_case, and crate directories should be in kebab-case.

Files:

  • apps/desktop/src-tauri/src/lib.rs
🧬 Code graph analysis (1)
apps/desktop/src-tauri/src/lib.rs (2)
apps/desktop/src/utils/tauri.ts (1)
  • GeneralSettingsStore (393-393)
apps/desktop/src-tauri/src/general_settings.rs (1)
  • get (183-194)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Analyze (rust)

@Brendonovich Brendonovich merged commit 99a7912 into main Oct 7, 2025
15 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.

2 participants