Skip to content

fix(workspace): make restoreLastSelectedObject connection-type-aware #640

Description

@ZhuchkaTriplesix

Motivation & Problem

In #630, restoreLastSelectedObject() was added to MainScreenWorkspaceState to allow returning to the last open table/view when switching back from server overview/stats.

Currently, restoreLastSelectedObject() evaluates cached object references in a static sequential order:

if (lastSelectedPostgresObject != null) { ... }
if (lastSelectedMysqlObject != null) { ... }
if (lastSelectedSqliteObject != null) { ... }
if (lastSelectedExtensionObject != null) { ... }

If lastSelectedPostgresObject was previously set and the active connection is later switched to another engine without clearing or under custom state manipulation, it evaluates Postgres first and could invoke selectPostgresObject() with a non-Postgres connection.

Proposed Scope

  1. In MainScreenWorkspaceState.restoreLastSelectedObject():
    • Branch on activeConnection.type.toLowerCase():
      • 'postgres' / 'postgresql': restore lastSelectedPostgresObject
      • 'mysql': restore lastSelectedMysqlObject
      • 'sqlite': restore lastSelectedSqliteObject
      • default / extensions: restore lastSelectedExtensionObject
  2. In selectPostgresObject, selectMysqlObject, selectSqliteObject, selectExtensionObject:
    • Clear cached object references belonging to other driver types when setting a new active object.
  3. Add unit tests in main_screen_workspace_state_test.dart verifying that restoreLastSelectedObject() restores only objects matching the active connection's driver type.

Acceptance Criteria

  • restoreLastSelectedObject() restores only the object matching the active connection's driver type.
  • Unit tests verify that restoreLastSelectedObject() ignores cached objects belonging to different drivers.
  • All existing workspace state tests continue to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstabilityTheme parser epic label: stabilityuxUser experience, keyboard shortcuts and interactions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions