feat(tabs): undo for closing a query tab (#747) - #818
Open
Asgabani wants to merge 1 commit into
Open
Conversation
closeTab dropped a tab's query and name with no way back — a misclick on the close icon lost unsaved work outright. closeTab now keeps the just-closed tab (query, name, position) and offers a toast with an Undo action that restores it and makes it active again. Only the most recent close is recoverable; the close action itself stays confirmation-free per the issue's explicit constraint.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 #747.
What changed
closeTab(src/hooks/use-tab-manager.ts) dropped the closed tab's state immediately, so a misclick on the close icon lost an unsaved query with no recovery. It now:QueryTab— query text, name, type — and its original index) in a ref before removing it.sonner, matching the existingshowStarPromptToastpattern) with an "Undo" action.reopenLastClosedTab()splices the tab back into its original position and makes it active again.Deliberately only the single most-recently-closed tab is recoverable — closing a second tab before undoing the first drops the first. That matches the issue's framing (recovering from an immediate misclick, not a multi-level history) and keeps the implementation to one ref rather than a stack.
No confirmation step was added to the close action itself, per the issue's explicit constraint ("closing a tab is a frequent, usually intentional action").
Testing
Ran locally (
bun run format && bun run lint && bun run typecheck && bun run knip && bun run chart:check && bun run channels:showcase:check && bun run readme:check && bun run security:check && bun run test && bun run build, plusbun run build:lib && bun run attwsinceuseTabManageris reachable from the embeddable workspace export surface):bun run test:components: 39/39 groups pass.bun run test: same 13 pre-existing failures as a clean checkout (Helm binary not installed, missing built standalone zip). No live Postgres/MySQL in this sandbox.bun run test:coverage && bun run coverage:check: 100.00% line coverage on the merged lcov.bun run build,bun run build:lib,bun run attw: all succeed.If CI surfaces something this sandbox couldn't (Helm chart tests, live DB integration tests), happy to fix it up.