fix: Ctrl+Enter always runs query in the last opened console tab#240
Merged
debba merged 1 commit intoMay 21, 2026
Merged
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by kimi-k2.6 · 310,852 tokens |
Collaborator
|
Awesome as usual :) |
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.
Problem
When multiple Console tabs are open,
Ctrl+Enteralways executed the query of the last openedtab instead of the tab currently in the foreground.
Root cause
Monaco's
editor.addCommand()registers keybindings in a global registry — last registrationwins across all editor instances on the page. Two compounding issues caused this:
Editor.tsx– stale closure + global overridehandleEditorMountcallededitor.addCommand(CtrlCmd+Enter, handleRunButton), wherehandleRunButtonis auseCallbackthat closes overactiveTabat the time of registration.Because
onMountis only passed for the active tab, this command was registered anew everytime a tab was opened — each time globally overriding the binding for all editors with a
handler still pointing to the newly opened tab.
SqlEditorWrapper.tsx– stale closureThe
addCommandclosure capturedonRunonce at editor mount time. Even when the parentre-rendered with a fresh
handleRunButton, the Monaco command kept calling the original stalereference.
Fix
SqlEditorWrapper.tsx— introduceonRunRefupdated synchronously on every render. TheaddCommandclosure readsonRunRef.currentso it always dispatches to the current handlerregardless of when the editor mounted.
Editor.tsx— remove the duplicateaddCommand(CtrlCmd+Enter, handleRunButton)fromhandleEditorMount.SqlEditorWrapperalready owns this binding; theEditor.tsxcall existedonly to override it with a stale closure on each new tab open.
Behaviour after fix
Ctrl+Enter(andCmd+Enteron macOS) executes the query in whichever Console tab iscurrently active, regardless of how many tabs are open or the order in which they were opened.
run-selectionandexplain-selectioncontext-menu actions are unaffected (they alreadyused stable refs via
addAction).