Skip to content

Feat/add db#3

Merged
Sol1de merged 2 commits into
mainfrom
feat/add-db
May 2, 2026
Merged

Feat/add db#3
Sol1de merged 2 commits into
mainfrom
feat/add-db

Conversation

@Sol1de
Copy link
Copy Markdown
Owner

@Sol1de Sol1de commented May 2, 2026

No description provided.

@Sol1de Sol1de marked this pull request as ready for review May 2, 2026 21:06
@Sol1de Sol1de requested a review from Copilot May 2, 2026 21:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces SQLite persistence (SeaORM) to the Tauri backend and migrates the frontend from “stores” to “services” for state + backend communication, adding connection session tracking.

Changes:

  • Added SeaORM-backed SQLite database with migrations, entities, and commands for proxies, settings, and connection sessions.
  • Replaced Svelte stores (proxyStore, settingsStore, connectionStore) with service modules that encapsulate state + invoke() calls.
  • Updated UI components/pages to consume the new services and added app-start loading of proxies/settings.

Reviewed changes

Copilot reviewed 36 out of 37 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/lib/types/index.ts Updates shared TS types (proxy lastUsedAt + adds ConnectionSession).
src/lib/stores/settings.svelte.ts Removes localStorage-backed settings store (migrated to DB-backed service).
src/lib/stores/proxy.svelte.ts Removes in-memory proxy store (replaced by DB-backed proxy service).
src/lib/services/settings.service.svelte.ts Adds DB-backed settings service via Tauri commands.
src/lib/services/session.service.ts Adds session service wrapper for session commands.
src/lib/services/proxy.service.svelte.ts Adds DB-backed proxy service + reactive proxy state.
src/lib/services/connection.service.svelte.ts Refactors connection logic to use services + session tracking.
src/lib/pages/SettingsPage.svelte Switches page actions to settingsService.
src/lib/pages/ProxiesPage.svelte Switches page wiring to proxyService sheet state.
src/lib/components/settings/ConnectionSettings.svelte Switches settings form bindings to settingsService.
src/lib/components/proxies/ProxyTableRow.svelte Uses services for connect/delete; removes latency rendering.
src/lib/components/proxies/ProxyTable.svelte Renders proxies from proxyService and opens add sheet via service.
src/lib/components/proxies/ProxyFiltersBar.svelte Opens add proxy sheet via proxyService.
src/lib/components/proxies/AddProxySheet.svelte Persists new proxies via proxyService + adds error handling.
src/lib/components/layout/TopAppBar.svelte Opens add proxy sheet via proxyService.
src/lib/components/layout/Sidebar.svelte Uses connectionService to show connection status.
src/lib/components/dashboard/RecentProxiesTable.svelte Computes recent proxies via lastUsedAt and connects via connectionService.
src/lib/components/dashboard/QuickStats.svelte Reads connection state from connectionService.
src/lib/components/dashboard/ConnectionCard.svelte Uses connectionService/proxyService for connect/disconnect UI.
src/App.svelte Loads proxies/settings on startup via services and shows toast on failure.
src-tauri/src/lib.rs Adds DB + crypto integration and new Tauri commands for CRUD/settings/sessions.
src-tauri/src/db/mod.rs Initializes SQLite DB, runs migrations, seeds default settings row.
src-tauri/src/db/migrations/mod.rs Registers DB migrations.
src-tauri/src/db/migrations/m20240101_000001_create_proxies.rs Creates proxies table schema.
src-tauri/src/db/migrations/m20240101_000002_create_settings.rs Creates settings table schema.
src-tauri/src/db/migrations/m20240101_000003_create_connection_sessions.rs Creates connection_sessions table schema + FK to proxies.
src-tauri/src/db/entities/settings.rs Adds SeaORM settings entity model.
src-tauri/src/db/entities/proxy.rs Adds SeaORM proxy entity model.
src-tauri/src/db/entities/connection_session.rs Adds SeaORM connection session entity model.
src-tauri/src/db/entities/mod.rs Exposes entity modules.
src-tauri/src/db/entities/enums/mod.rs Exposes DB enum modules.
src-tauri/src/db/entities/enums/proxy.rs Adds SeaORM ActiveEnum definitions for protocol/status.
src-tauri/src/crypto.rs Adds AES-GCM encryption + HKDF key derivation for stored secrets.
src-tauri/Cargo.toml Bumps rust-version and adds SeaORM/crypto deps.
src-tauri/Cargo.lock Updates lockfile for new deps (format v4).
README.md Documents new services structure and DB-backed backend commands.
CLAUDE.md Updates project conventions for services + DB layout and command list.
Comments suppressed due to low confidence (1)

src/lib/services/connection.service.svelte.ts:53

  • If sessionService.open(...) fails after connect_proxy succeeds, the catch block resets frontend state to disconnected but does not call disconnect_proxy, leaving the system proxy potentially still enabled while the UI reports disconnected. Handle session creation failures explicitly (e.g., try { sessionId = ... } catch { await invoke('disconnect_proxy') ... }) or move session creation into the backend connect flow so connect is atomic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src-tauri/src/lib.rs
Comment thread src/lib/services/proxy.service.svelte.ts Outdated
Comment thread CLAUDE.md Outdated
Comment thread src/lib/pages/SettingsPage.svelte
Comment thread src/lib/components/proxies/ProxyTableRow.svelte
- Introduced a new service architecture for managing proxies and connections, replacing the previous store-based approach.
- Created `proxyService` and `connectionService` to handle proxy CRUD operations and connection management.
- Updated components to utilize the new services, enhancing maintainability and readability.
- Removed old proxy and settings stores to streamline the codebase.
- Added session management for tracking active connections and their states.
- Implemented database interactions for proxy and settings management.
- Enhanced error handling and user feedback through toast notifications.

feat: restructure database migrations to separate proxies, settings, and connection sessions

feat: update CLAUDE.md to clarify state management, services, and database integration

feat: update README.md to clarify project structure and Tauri commands

feat: enhance proxy and settings management with validation and error handling

feat: implement encryption and decryption for proxy credentials, update connection handling

feat: enhance proxy and settings management with new fields and error handling
…ord from Proxy TS type

Agent-Logs-Url: https://github.com/Sol1de/Whirm/sessions/bfe25f43-4b48-4ff7-8b15-bf72ed535efa

Co-authored-by: Sol1de <127517324+Sol1de@users.noreply.github.com>
Copilot finished work on behalf of Sol1de May 2, 2026 21:57
Copilot finished work on behalf of Sol1de May 2, 2026 21:58
@Sol1de Sol1de merged commit 06cd33a into main May 2, 2026
1 check passed
@Sol1de Sol1de deleted the feat/add-db branch May 2, 2026 22:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 37 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

src/lib/services/connection.service.svelte.ts:33

  • connect_proxy is invoked with { proxyId: proxy.id }, but the Rust command argument is named proxy_id. Unless you rename the Rust param or wrap it in an input struct, this will fail to deserialize at runtime. Align the invoke argument key with the Rust command signature.
    src/lib/services/connection.service.svelte.ts:48
  • After a successful connection, open_session updates last_used_at in the DB, but proxyService.proxies is never refreshed/updated locally. This means lastUsedAt-driven UI (e.g. recent proxies sorting) won’t reflect the new usage until a full reload. Consider updating the in-memory proxy entry (set lastUsedAt to new Date().toISOString()) or re-fetching proxies after opening the session.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src-tauri/src/lib.rs
Comment on lines +264 to +267
let mut result = new_proxy
.insert(&state.db)
.await
.map_err(|e| e.to_string())?;
Comment thread src-tauri/src/lib.rs
Comment on lines +279 to +302
}

let updated_proxy = proxy::ActiveModel {
id: Set(input.id),
name: Set(input.name),
host: Set(input.host),
port: Set(input.port),
protocol: Set(input.protocol),
country: Set(input.country),
country_code: Set(input.country_code),
username: Set(input.username),
password: match input.new_password {
Some(ref p) if !p.is_empty() => {
let key = crypto::derive_key()?;
Set(Some(crypto::encrypt(p, &key)?))
}
Some(_) => Set(None),
None => sea_orm::ActiveValue::NotSet,
},
status: Set(input.status),
category: Set(input.category),
updated_at: Set(Utc::now()),
..Default::default()
};
Comment thread src-tauri/src/lib.rs
Comment on lines +137 to +146
let saved = state
.saved_proxy
.lock()
.map_err(|_| "Corrupted mutex (poisoned lock)".to_string())?
.take();

match saved {
Some(proxy) => {
proxy
.set_system_proxy()
.map_err(|e| format!("Failed to restore system proxy: {e}"))?;
}
None => {
return Ok(());
}
if let Some(proxy) = saved {
proxy
.set_system_proxy()
.map_err(|e| format!("Failed to restore system proxy: {e}"))?;
Comment on lines +5 to +10
open(proxyId: string, ipAddress: string): Promise<string> {
return invoke<string>('open_session', { proxyId, ipAddress });
},
close(sessionId: string): Promise<void> {
return invoke<void>('close_session', { sessionId });
},
Comment thread src-tauri/src/db/mod.rs
Comment on lines +20 to +28
let db_path = data_dir.join("whirm.db");
let path_str = db_path
.to_str()
.ok_or("Invalid DB path (non-UTF8 characters)")?
.replace('\\', "/");

let connection_string = format!("sqlite://{}?mode=rwc", path_str);

let db = Database::connect(&connection_string)
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