feat(connections): open a connection in a dedicated window#409
Open
debba wants to merge 1 commit into
Open
Conversation
Add an "Open in New Window" action to both connection context menus (the open-connections sidebar rail and the Connections page) that opens a connection in its own standalone window, plus the cross-window plumbing to keep everything consistent. Behaviour: - Validate connectivity BEFORE spawning the window: the connection is test_connection'd first and the window is only created on success, so a failing connection surfaces the error in the originating window instead of in a freshly-opened empty one. - A connection opened in a new window is "owned" by that window: it is detached from the originating window's sidebar rail (its process-global pool stays warm and is reused by the new window). - Connection open-state is shared across all windows: a connection open in any window shows as open in every window's Connections page. Backed by the health-check active-connection registry, broadcast via a new `connections:active-changed` event and seeded through get_active_connections. - Disconnecting a connection closes its dedicated window (the main window is never auto-closed). Closing a dedicated window also tears down its connection so nothing leaks. - "Open in New Window" is disabled when the current window has no open connection. Backend: - New connection_window module (open_connection_window command) with a CloseRequested handler that disconnects the bound connection; window label connection-window-* added to capabilities. - health_check: broadcast the active-connection set on register/disconnect/ health-failure; add active_connections() + get_active_connections command. Frontend: - New hooks: useOpenConnectionInNewWindow, useAutoConnectFromUrl, useConnectionWindowLifecycle. - DatabaseProvider: globallyOpenConnectionIds + isConnectionOpenAnywhere and a detachConnection helper; Connections page / cards reflect global state. - i18n key sidebar.openInNewWindow added to all 8 locales. Tests: unit tests for the new hooks and the window-label sanitizer; removed the now-unused hasConnectionMenuItems helper and its tests.
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.
Overview
Adds an "Open in New Window" action to the connection context menus (the open-connections sidebar rail and the Connections page) that opens a connection in its own standalone window, together with the cross-window plumbing needed to keep connection state consistent across every window.
Behaviour
Opening
test_connection'd first; the window is created only if the connection succeeds. A failing connection now surfaces the error in the originating window (with a spinner on the card while validating) instead of opening an empty window that then errors.Ownership & sidebar
Cross-window state sync
connections:active-changedevent and seeded on window start viaget_active_connections.Lifecycle
Guards
Implementation
Backend (
src-tauri/)connection_window.rs(new):open_connection_windowcommand — creates/focuses aconnection-window-<id>window loading/?connect=<id>; aCloseRequestedhandler disconnects the bound connection on close.capabilities/default.json: whitelistconnection-window-*.health_check.rs: broadcast the active-connection set on register / disconnect / health-failure; addactive_connections()+emit_active_changed().commands.rs:register_active_connectionanddisconnect_connectionnow emit the broadcast; newget_active_connectionscommand.Frontend (
src/)useOpenConnectionInNewWindow(validate → open → detach),useAutoConnectFromUrl(auto-connect the dedicated window on startup),useConnectionWindowLifecycle(close the dedicated window when its connection goes away).DatabaseProvider:globallyOpenConnectionIds+isConnectionOpenAnywhere, plus adetachConnectionhelper (removes from a window's UI without closing the pool).sidebar.openInNewWindowadded to all 8 locales.Tests / cleanup
useOpenConnectionInNewWindow,useAutoConnectFromUrl,useConnectionWindowLifecycle, and the Rust window-label sanitizer.hasConnectionMenuItemshelper and its tests.Verification
npm run build(tsc -b + vite) — ✅npm run lint— ✅ 0 errorsnpx vitest run— ✅ 2706 passedcargo test— ✅ 770 passedcargo clippy --all-targets— ✅ 0 errorsNotes
gitnexus_detect_changes/ impact analysis could not be run; changes are largely additive.