Skip to content

[P1][bug] auto-reconnect on launch is a single-shot try/catch; no backoff, no surface, no HealthChecker (FR-1.2.4 / ARCHITECTURE §3.1 HealthChecker) #276

Description

@EVWorth

Context

DESIGN_REQUIREMENTS §FR-1.2.4 mandates exponential backoff (1s/2s/4s/8s/16s/30s capped) and user notification. ARCHITECTURE §3.1 describes a HealthChecker background task emitting connection_lost events.

Problem

ConnectionTabs.tsx:41-77 calls connect() once per open profile on mount and the error path is catch {} (no surface). Tabs are left in profileId-only state — execute_query later fails with CoreError::NotFound instead of "reconnect attempt failed at startup". ARCHITECTURE's HealthChecker and connection_lost event are never emitted from anywhere.

Files

  • src/components/layout/ConnectionTabs.tsx:41-77 (esp. 65-67 catch)
  • src-tauri/src/commands/mod.rs (no health-check command)
  • docs/design/ARCHITECTURE.md:226-229, §5.7 (planned but unimplemented)

Repro

  1. Open SQLPilot with a query tab active against MySQL on 13306.
  2. docker stop mysql-test-container for >30s.
  3. The query tab stays in normal-looking state; any query yields "Connection not found" only when run.

Expected

Within 5s of MySQL going down, the tab turns yellow with "Reconnecting…". Within 30s of MySQL returning, the tab is green and a follow-up query runs cleanly. A toast/info banner explains if reconnect ultimately fails.

Proposed fix

Scope L. Backend: tokio interval task per active connection running SELECT 1, tracking consecutive failure count, emitting a Tauri connection_lost event past a threshold. Frontend: subscribe via listen(), surface "Reconnecting…" per tab badge, run exponential-backoff reconnect loop until success or user abort.

Acceptance

Kill DB-side connection mid-session; within 5s UI shows reconnecting state; DB-up recovery happens within 30s without user action; the named integration test test_auto_reconnect from TESTING_STRATEGY §4 lands.

Needs human verify

Yes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/connectionAudit areaauditTracks a feature-by-feature codebase audit findingkind/bugAudit finding categorykind/doc-driftAudit finding categoryseverity/p1Audit finding severity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions