fix: connection auto-reconnect, executable top-N SQL, and context-menu UX fixes - #130
Merged
Conversation
Store the ServerConfig for each active connection and add AppState::ensure_connection(), which recreates the adapter from the stored config when a session is lost or idle-evicted. Migrate all command lookups (browse, query, transfer, MCP bridge, capabilities) to it so user actions no longer fail with 'No active connection found'. The guardian's reconnect loop now recreates the adapter instead of pinging the stale one.
The 'query top 100' action emitted SELECT * FROM "table" LIMIT 100, where double quotes are string literals under MySQL's default mode, so the SQL was never executable. Quote identifiers per dialect (backticks for MySQL-family, brackets + TOP n for SQL Server, FETCH FIRST for Oracle) and escape embedded delimiters.
Right-clicking a database node in the all-databases view now shows an action list (New Query, Show ER Diagram, Refresh). The tree context menus also close when clicking or right-clicking anywhere outside the menu via a click-away overlay.
The home panel action list now shows a Disconnect item for connected connections, closing the active session instead of requiring the connect button toggle.
Add min-h-0 to the form area so overflow-y-auto actually constrains inside the max-h-[80vh] flex dialog; previously many columns pushed the modal past the viewport with no scrollbar.
When a connection is already active, the primary button now shows a log-out icon and 'Close Connection' tooltip instead of 'Connect', which implied reconnecting.
The card's primary button is now 'Open in Editor' (with an external-link icon) when the connection is already active, navigating to the queries page, and only shows 'Connect' when disconnected. Closing the connection moves exclusively to the action-list menu, so the editor entry point is never lost.
The log-out arrow was visually too close to the 'Open in Editor' icon in the card's primary button. Replaced with a power-off icon, the standard disconnect affordance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 6 issues reported against the treeview / connection management / data view UX.
Backend — connection auto-reconnect (the big one)
When a connection session was lost (server restart, dropped connection) or idle-evicted, any user action failed with a hard
No active connection found for server 'xxx'error because nothing ever recreated the connection handle. The agent/capabilities path already auto-reconnected; the main commands did not.AppStatenow stores theServerConfigper active connection and exposesensure_connection(), which transparently recreates the adapter (with SSH-tunnel resolution + connect timeout) when the handle is missing and notifies the guardian so the frontend flips back to CONNECTED.connect_serverstores the config;disconnect_serverremoves it; the capabilities auto-connect path stores it too.ensure_connection:browse.rs(20),query.rs(5),transfer.rs(9),mcp_bridge.rs,capabilities/commands.rs,cache.rs::get_or_create, and the guardian'stry_reconnect(which now recreates the adapter from config instead of pinging the stale one).Reconnect timed out after N secondsinstead of the opaque error.Frontend
SELECT * FROM "table" LIMIT 100— double quotes are string literals in MySQL's default mode, so it was never executable. Now quotes identifiers per dialect (backticks for MySQL-family,[brackets]+TOP nfor SQL Server,FETCH FIRSTfor Oracle) with delimiter escaping.min-h-0added to the form area of both edit dialogs so wide tables scroll insidemax-h-[80vh]instead of overflowing the modal.Verification
cargo check+cargo clippyclean (remaining warnings pre-existing)cargo test: 330 passedvue-tsc --noEmitcleannpm test: 455 passednpm run buildsucceeds