Menu

#72 feat: added a new field in settings screen, regarding maxConnection c…

open
nobody
None
4 days ago
2026-03-06
Anonymous
No

Originally created by: ealvesss

PR Description

feat: make connection pool size configurable via Settings

Problem

The maximum number of database connections per pool was hardcoded in pool_manager.rs (10 for MySQL/PostgreSQL, 5 for SQLite), with no way for users to adjust it.

Changes

Backend (src-tauri/src/)

  • config.rs: Added max_connections: Option<u32> to AppConfig, its merge logic in save_config, and a get_pool_max_connections() helper that reads the config file without requiring AppHandle.</u32>
  • pool_manager.rs: Replaced all hardcoded .max_connections() values in MySQL, PostgreSQL, and SQLite pool creation with crate::config::get_pool_max_connections().

Frontend (src/)

  • contexts/SettingsContext.ts: Added maxConnections to the Settings interface and DEFAULT_SETTINGS.
  • pages/Settings.tsx: Added a number input for Connection Pool Size in the Data Editor section of the General settings tab.
  • i18n/locales/{en,it,es}.json: Added translation keys maxConnections, maxConnectionsDesc, and connections.

Behavior

  • The setting takes effect when a new connection pool is created. Users must disconnect and reconnect for changes to apply to existing connections.
  • Falls back to the default value if no config is present.

Discussion

  • Anonymous

    Anonymous - 2026-03-06

    Originally posted by: kilo-code-bot[bot]

    Code Review Summary

    Status: 2 Issues Found | Recommendation: Address before merge

    Overview

    Severity Count
    CRITICAL 2
    WARNING 0
    SUGGESTION 0
    Issue Details (click to expand) #### CRITICAL | File | Line | Issue | |------|------|-------| | `src-tauri/src/config.rs` | 145 | Duplicate `if config.plugins.is_some()` block - identical code exists on lines 141-143 | | `src/components/ui/NewConnectionModal.tsx` | 341 | Logic bug: setFormData unconditionally overwrites preserved form data, making driver-specific preservation ineffective |
    Files Reviewed (11 files) - `package-lock.json` - Generated file, skipped - `src-tauri/Cargo.lock` - Generated file, skipped - `src-tauri/src/commands.rs` - Pool invalidation on connection update - `src-tauri/src/config.rs` - Added DEFAULT_MAX_CONNECTIONS constant; has duplicate code issue - `src-tauri/src/models.rs` - Added max_connections field to ConnectionParams - `src-tauri/src/pool_manager.rs` - Configurable max_connections for MySQL/PostgreSQL pools - `src/components/ui/NewConnectionModal.tsx` - Added max_connections UI and driver-specific form preservation; has logic bug - `src/i18n/config.ts` - Formatting changes only - `src/i18n/locales/en.json` - Added translations for max connections - `src/i18n/locales/es.json` - Added translations for max connections - `src/i18n/locales/it.json` - Added translations for max connections - `src/i18n/locales/pt-br.json` - Empty file added - `src/pages/Connections.tsx` - Added key prop to NewConnectionModal - `src/pages/Settings.tsx` - Whitespace change only - `src/utils/connections.ts` - Added max_connections field to interface

    Fix these issues in Kilo Cloud

     
  • Anonymous

    Anonymous - 2026-03-07

    Originally posted by: debba

    @ealvesss Thanks for the contribution! The feature is well-structured overall, but there are a few issues to address before merging.

    I have 2 points I would change:

    1) DEFAULT_MAX_CONNECTIONS = 1is a regression** — the previous hardcoded values were10for MySQL/PostgreSQL and5for SQLite. Defaulting to1` will serialize all queries and cause significant performance degradation for users who haven't explicitly configured the setting.

    2) SQLite needs a separate cap — SQLite only supports one concurrent writer, so high pool values will cause SQLITE_BUSY / database is locked errors. It should be capped independently (e.g. params.max_connections.map(|v| v.min(5)).unwrap_or(5)), not share the same configurable value as MySQL/PostgreSQL.

    Design suggestion

    Rather than a global setting in the Settings page, consider moving max_connections to the individual connection configuration (ConnectionParams). This would allow users to set:

    • max_connections: 1 for a PostgreSQL connection behind pgBouncer
    • max_connections: 10 for a direct MySQL connection
    • SQLite capped at 5 regardless

    This approach is more flexible, more explicit, and makes the global AppConfig change unnecessary — which would simplify the diff considerably.

    What do you think?

     
  • Anonymous

    Anonymous - 2026-03-11

    Originally posted by: ealvesss

    @debba the "code-review" bots run again, after change the MR?

     
  • Anonymous

    Anonymous - 2026-03-12

    Originally posted by: debba

    @ealvesss Yes.
    Btw I cannot run the project because I have the following issues:

    error[E0382]: borrow of moved value: config.plugins
    --> src/config.rs:145:12
    |
    142 | existing_config.plugins = config.plugins;
    | -------------- value moved here
    ...
    145 | if config.plugins.is_some() {
    | ^^^^^^^^^^^^^^ value borrowed here after move
    |
    = note: move occurs because config.plugins has type std::option::Option<HashMap<std::string::String, config::PluginConfig>>, which does not implement the Copy trait

    For more information about this error, try rustc --explain E0382.
    error: could not compile tabularis (lib) due to 1 previous error

     
  • Anonymous

    Anonymous - 2026-03-16

    Originally posted by: ealvesss

    @ealvesss Yes. Btw I cannot run the project because I have the following issues:

    error[E0382]: borrow of moved value: config.plugins --> src/config.rs:145:12 | 142 | existing_config.plugins = config.plugins; | -------------- value moved here ... 145 | if config.plugins.is_some() { | ^^^^^^^^^^^^^^ value borrowed here after move | = note: move occurs because config.plugins has type std::option::Option<HashMap<std::string::String, config::PluginConfig>>, which does not implement the Copy trait

    For more information about this error, try rustc --explain E0382. error: could not compile tabularis (lib) due to 1 previous error

    here i can run properly.

    how can I reproduce this error?

     
  • Anonymous

    Anonymous - 2026-03-16

    Originally posted by: debba

    @ealvesss sent the bug, if you can fix it and resolve conflicts, I will approve the pull request

     
  • Anonymous

    Anonymous - 2026-03-19

    Originally posted by: ealvesss

    @ealvesss sent the bug, if you can fix it and resolve conflicts, I will approve the pull request

    I will do it soon. Probably tomorrow!

     

Log in to post a comment.

MongoDB Logo MongoDB