Skip to content

fix: tab keeps old server profile when moved to SQLite #962

Closed

Description

@EVWorth

When the selected connection changes to a SQLite file, the active tab is pointed at it but keeps the profileId of the server it was on before. At the next start useStartupReconnect reconnects that profile and binds the tab back to the old server. #961 fixes the same stale profile for the rebind that happens on Run (#944); this is the other route to it.

Reproduce

  1. Connect to a saved MySQL profile and open a query tab on it.
  2. Open a SQLite file so it becomes the selected connection; the active tab follows it.
  3. Restart the app.

Expected: the tab is not tied to the MySQL profile any more. Actual (from reading the code, not run in the desktop app): the tab still carries the profile, so the profile is reconnected and the tab rebound to it.

grep -n "profile_id" src/components/layout/useConnectionSwitching.ts
43:    if (conn) setTabConnection(tabId, connectionId, database, conn.profile_id);
78:      requestTabConnection(active.id, connectionId, conn?.database ?? undefined, conn?.profile_id);

Cause

src/components/layout/useConnectionSwitching.ts:78 passes conn?.profile_id, which is undefined for a SQLite file because conn is looked up among server connections. setTabConnection (src/stores/editorStore.ts) reads an omitted profileId as "keep the current one". src/components/layout/useStartupReconnect.ts:18-32 then reconnects every tab's profileId.

Fix

After #961, setTabConnection accepts null to clear the profile. Widen requestTabConnection's profileId to string | null and pass conn?.profile_id ?? null at line 78 (check line 43 for the same case). Add a test in src/stores/__tests__/editorStore.test.ts or next to the hook: a tab moved from a server to a SQLite file has no profileId afterwards.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions