feat(tabs): close all, other, and other-database tabs from the File menu (#1972) - #1977
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Closes #1972.
Problem
Two asks in the issue:
What this does
Adds three commands to the File menu, after Close Tab:
None gets a shortcut out of the box. All three are rebindable in Settings > Keyboard under Navigation, which matches DataGrip (only
Cmd+Wof its six close commands is bound) and TablePlus.Close All Tabs closes every sibling window and empties the last one, landing on the "No tabs open" state that already existed in
MainEditorContentView. The window stays open and the connection stays live, which is the blank page the issue asked for.Close Tabs for Other Databases closes only windows where every tab was opened against a database other than the active one. It never touches the current window and is limited to the current connection. On engines that switch schemas rather than databases (BigQuery, Oracle) it reads Close Tabs for Other Schemas.
The reporter asked for a tab right-click menu. That is not buildable:
NSWindowTabexposes onlytitle,attributedTitle,toolTip, andaccessoryView,NSWindowTabGroupexposes no menu API, andNSWindowDelegatehas no tab callbacks. The File menu is the documented home, and the HIG's context-menu guidance points the same way ("in macOS, an app's menu bar menus list all the app's commands, including those in various context menus"). Option-clicking a tab's close button already closes the other tabs natively; the docs now say so.Why ask 2 is not implemented as asked
Auto-closing tabs on a database switch is deliberately not built. It was in this codebase and was removed twice:
switchSchemarantabManager.tabs = []and destroyed unsaved SQL. Reported as Query tabs are lost when switching schemas #1669, removed in fix(coordinator): keep open tabs when switching schemas #1677.switchDatabaseand shipped the per-tab database picker, so tabs for different databases coexist on purpose.Staleness is already handled:
handleTabChangere-points the connection to the selected tab's database, andexecuteQueryInternaldoes it again before running SQL. No comparable client auto-closes either. TablePlus shipped it, had it reported, and removed it two releases later; Sequel Ace, Sequel Pro, Postico and DataGrip do not. DataGrip's one auto-closing mechanism is its longest-running open complaint (IJPL-59306, open since 2018).Close Tabs for Other Databases gives the same outcome on the user's command instead of as a side effect of navigation.
Refactor
closeTab()was synchronous and fired a detachedTaskfor its save prompt, andperformClose()inferred "am I the last window in my group" from a livewindow.tabbedWindowscount. Neither can express "close N windows, one prompt at a time, with a caller-chosen survivor", so the close path is now one primitive:closeWindowAwaiting(asBatchSurvivor:) async -> WindowCloseOutcome.nilreproduces the old self-deciding behaviour; a batch passestruefor the window it keeps blank andfalsefor the ones it tears down.closeTab()is a two-line wrapper, soCmd+Wis unchanged.clearTabsInPlace()extracted from the old third branch.TabBatchClosePlanneris pure, Foundation only, and owns which windows close and which survives.The auto-detect path is equivalent to what it replaced:
if A { close } else if B { close } else { clear }becameif A || B { close } else { clear }, andcaptureClosingTabsForRecovery()still runs once, before any teardown, on every path.A batch closes siblings first and the survivor last, so cancelling part-way leaves the window the user is looking at untouched. Each window keeps the ordinary Save / Don't Save / Cancel prompt rather than a new bulk alert, and every closed tab still lands in Recently Closed, so a bulk close is undoable with
Cmd+Shift+T.Fixed along the way
closeTab()gated its prompt onhasUnsavedWorkInSelectedTab(), so closing a window that holds more than one tab (Redis key tabs, all-tables metadata) could discard unsaved work in a tab that was not on screen. It now uses the existinghasAnyUnsavedWork(), which is a strict superset and only ever adds a prompt.Tests
TabBatchClosePlannerTests: survivor selection, ordering, self-exclusion, and the database-match rules (foreign-only closes; mixed and unnamed windows are kept; an unknown active database closes nothing).CommandActionsBulkCloseTests: the survivor empties in place, database scoping across two coordinators on one connection, other connections stay out of scope, and menu enablement.SwitchDatabaseTestsreconciled. It defined a hand-rolledsimulateDatabaseSwitchthat didtabs = []and asserted tabs get cleared, without ever calling production code. It asserted behaviour removed by fix(coordinator): keep open tabs when switching schemas #1677 and feat(editor): per-tab database picker and tab interaction improvements #1776, so it would have misled anyone into restoring the wipe. Replaced with two tests that drive the realswitchDatabaseand lock the shipped behaviour.Not covered, and why: the multi-window alert sequencing needs real dirty on-screen sibling windows and simulated alert clicks.
AlertHelperis a static wrapper overNSAlertwith no injection seam, and native tab-group membership has no XCUITest query surface. That path had no coverage before this change either; this does not widen the gap.swiftlint lint --strictpasses on every changed file.Docs
docs/features/tabs.mdxdocumented "Close other tabs: right-click the tab (native macOS menu)". Closing is not among the selectors AppKit adds to the system tab menu, so that row is corrected to the Option-click gesture and the new command, alongside rows for the other two.docs/features/keyboard-shortcuts.mdxgains the three actions under Tabs and Windows.Test plan
Cmd+Tworks from there.Cmd+Shift+Treopens tabs closed by a bulk close.