Skip to content

feat: Remote Connection Manager — trait-based adapters + auth + UI - #84

Merged
ajianaz merged 7 commits into
developfrom
feat/remote-connection-manager
Jul 1, 2026
Merged

ajianaz merged 7 commits into
developfrom
feat/remote-connection-manager

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Generic Connection Manager layer for CorIn — enables connecting to a remote uteke-serve (VPS) with HTTPS + auth, built once and extensible per-product via trait-based adapters.

Architecture: Trait-based Adapters (Opsi 2)

Generic Connection Layer (built once)
  ├── connections table + store (persistence)
  ├── ProductType enum + adapter traits
  ├── auth token + HTTPS on all requests
  └── Settings UI Connection tab

Product adapters (thin, per product):
  UtekeAdapter implements MemoryBackend trait
  (future: TrapFallAdapter, RunguAdapter, …)

What's new

Backend (Phases 0–3):

  • connections table with full CRUD persistence
  • ProductType enum + ProductAdapter / MemoryBackend traits
  • UtekeAdapter wraps UtekeClient, converts types, implements traits
  • UtekeClient auth: with_auth() constructor + authed() helper on every request
  • Config resolution priority: DB primary → UTEKE_SERVER_URL env → TOML → default
  • is_remote_url() — skips local auto-start when URL is remote
  • Auto-seeds default local connection on first boot (backward compat)

Frontend (Phases 4–5):

  • 6 Tauri commands: list_connections, add_connection, update_connection, delete_connection, test_connection, set_primary_connection
  • ipc.ts: connection.* wrappers + ConnectionInfo + HealthInfo types
  • ConnectionManager.svelte: connection cards (icon, URL, status badge), add form, test button w/ latency, set primary, delete confirm
  • Settings View: new Connections section

Adding a new product (future)

// 1 line: enum variant
ProductType::TrapFall

// ~2h: implement trait
impl ProductAdapter for TrapFallAdapter { ... }

// 1 line: register
// Done — config/auth/persistence/UI is free

Files changed

File Change
connections/mod.rs ProductType, Capabilities, ConnectionRow/Info/Config, HealthInfo, Memory, Stats, Room, GraphNode/Edge/Response
connections/traits.rs ProductAdapter + MemoryBackend trait definitions
connections/store.rs Full CRUD + set_primary + get_primary + seed_default
connections/adapters/uteke.rs UtekeAdapter wrapping UtekeClient with type conversions
uteke_client.rs auth_token field, with_auth(), authed() on all 18 methods
config.rs resolve_uteke_server() + is_remote_url()
lib.rs connections table schema, commands registered, remote-aware setup
commands.rs 6 connection CRUD commands
ipc.ts connection.* wrappers + types
ConnectionManager.svelte Full connection management UI
SettingsView.svelte Connections section

Closes #77 Closes #78 Closes #79 Closes #80 Closes #81 Closes #82
Related #37 (parent issue)

ajianaz added 5 commits July 1, 2026 15:55
Add the foundation for the generic connection layer:
- connections table in init_schema (id, name, product_type, url, auth, status, is_primary)
- store.rs: list, get, insert, update, delete, set_primary, get_primary, seed_default
- connections/mod.rs: ProductType enum, Capabilities, ConnectionRow/Info/Config, HealthInfo
- connections/traits.rs: ProductAdapter + MemoryBackend trait definitions
- connections/adapters/uteke.rs: placeholder stub
- Auto-seed default local uteke connection on first boot

No behavior change — existing features work identically.

Closes #77
- UtekeClient: add auth_token field, with_auth() constructor, authed() helper
  that injects bearer auth on every HTTP request
- All 18 UtekeClient methods now route through authed() — zero call-site changes
- UtekeAdapter: wraps UtekeClient, implements MemoryBackend trait
  with type conversions (UtekeMemory→Memory, RecallResult→Memory, etc.)
- async-trait dependency added for MemoryBackend trait
- reqwest default-tls already supports HTTPS
- Existing 24 commands.rs call sites compile unchanged

No behavior change — auth only activates when token is configured.

Closes #78
Phase 2: Config resolution with full priority chain
- resolve_uteke_server(conn): DB primary → UTEKE_SERVER_URL env → TOML → default
- Reads UTEKE_AUTH_TOKEN env for auth
- is_remote_url() helper to detect non-localhost URLs

Phase 3: Skip local auto-start when server is remote
- setup() uses resolve_uteke_server() instead of detect + ensure
- If URL is remote → no install/spawn of local uteke-serve
- If URL is local → existing behavior (auto-start + seed default connection)
- Auth token passed to UtekeClient::with_auth()

Closes #79
Closes #80
Add 6 generic Tauri commands for connection management:
- list_connections: list all connections (token redacted)
- add_connection: create new connection with type/url/auth
- update_connection: edit existing connection fields
- delete_connection: remove connection
- test_connection: health check → returns latency + status, updates DB
- set_primary_connection: switch active backend

All commands registered in invoke_handler.

Closes #81
Frontend for managing remote connections:
- ipc.ts: connection.* wrappers (list/add/update/delete/test/setPrimary)
  + ConnectionInfo + HealthInfo types
- ConnectionManager.svelte: connection cards with icon, name, URL, status
  badge, add/edit form, test button w/ latency, set primary, delete w/
  confirm, auth badge
- SettingsView.svelte: new 'Connections' section with lazy-loaded
  ConnectionManager

Closes #82
@ajianaz ajianaz added scope/backend Rust backend / Tauri commands scope/frontend Svelte UI components & screens scope/desktop Tauri desktop integration type/feature New feature phase/2-integration Phase 2 — Uteke-core Library labels Jul 1, 2026
ajianaz added 2 commits July 1, 2026 16:13
- Remove async-trait dep, use RPITIT for trait methods
- Remove redundant closures (|e| E(e) → E) in connection commands
- Collapse nested if-let in resolve_uteke_server
- Fix ref-immediately-deref in setup seed
- Add #[allow(clippy::too_many_arguments)] on store::insert
- Clone owned ConnectionConfig for health_check RPITIT call
- Clone moved values in type conversions
@ajianaz
ajianaz merged commit 2124a8e into develop Jul 1, 2026
8 checks passed
ajianaz added a commit that referenced this pull request Jul 1, 2026
…ngsModal (#86)

PR #84 added ConnectionManager into SettingsView.svelte, but SettingsView is
orphan dead code (never imported). App renders SettingsModal, whose tabs were
corin/general/data/agents only — so the Connections UI never appeared.

- Add 'connections' tab to SettingsModal
- Render ConnectionManager via async import under that tab
- Delete orphan SettingsView.svelte (no references anywhere)
@ajianaz
ajianaz deleted the feat/remote-connection-manager branch July 3, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase/2-integration Phase 2 — Uteke-core Library scope/backend Rust backend / Tauri commands scope/desktop Tauri desktop integration scope/frontend Svelte UI components & screens type/feature New feature

Projects

None yet

1 participant