Skip to content

Conversation

@Jakdaw
Copy link
Contributor

@Jakdaw Jakdaw commented Dec 8, 2025

At present, we bind both mod+enter and ctrl+enter to execute the current query. On Mac this results in both ctrl+enter and command+enter being bound, but on other platforms mod becomes ctrl and we bind ctrl+enter TWICE. Every shortcut invocation happens twice, and it's a race condition as to whether one server-side job or two are created. Instead, do our own translation and dedupe before binding.

Even without the race condition triggering it's easy to reproduce the bug:

  • Open Chrome browser on non-Mac platform
  • Start a new query - something that will take a few seconds - SELECT SLEEP(10)
  • Open up Chrome Developer Tools, watch network traffic
  • to execute the query
  • Note that it calls the query_results API twice rather than once, and polls the JobID twice every second rather than just once!

What type of PR is this?

  • Bug Fix

How is this tested?

Disclaimer: I don't have a Mac nor any JS experience!

…nt query.

On Mac this results in both ctrl+enter and command+enter being bound, but on
other platforms mod becomes ctrl and we bind ctrl+enter TWICE. Every shortcut
invocation happens twice, and it's a race condition as to whether one
server-side job or two are created. Instead, do our own translation and
dedupe before binding.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="client/app/services/KeyboardShortcuts.js">

<violation number="1" location="client/app/services/KeyboardShortcuts.js:44">
P1: The `unbind` function was not updated with the same key transformation logic. When binding `mod+enter`, it gets stored as `ctrl+enter` in handlers, but unbind will still look for `mod+enter`, causing silent failures when trying to remove handlers.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

.map(trim);
each(keys, k => {
// Translate platform‑specific modifiers and dedupe.
const transformed = rawKeys.map(k =>
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The unbind function was not updated with the same key transformation logic. When binding mod+enter, it gets stored as ctrl+enter in handlers, but unbind will still look for mod+enter, causing silent failures when trying to remove handlers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At client/app/services/KeyboardShortcuts.js, line 44:

<comment>The `unbind` function was not updated with the same key transformation logic. When binding `mod+enter`, it gets stored as `ctrl+enter` in handlers, but unbind will still look for `mod+enter`, causing silent failures when trying to remove handlers.</comment>

<file context>
@@ -35,11 +35,17 @@ const KeyboardShortcuts = {
         .map(trim);
-      each(keys, k =&gt; {
+      // Translate platform‑specific modifiers and dedupe.
+      const transformed = rawKeys.map(k =&gt;
+        k.replace(/mod/g, modKey.toLowerCase()).replace(/alt/g, altKey.toLowerCase())
+      );
</file context>

✅ Addressed in 82880ce

@yoshiokatsuneo
Copy link
Contributor

@Jakdaw Thank you for your contribution!
I'm just wondering that just changing shortcut definition from "mod+enter" to "command+enter" solves the problem.

@Jakdaw
Copy link
Contributor Author

Jakdaw commented Dec 9, 2025

@Jakdaw Thank you for your contribution! I'm just wondering that just changing shortcut definition from "mod+enter" to "command+enter" solves the problem.

No; I think the first keyboard combo is used to generate the human readable description for tool tips and the like. So if we replace "mod+enter" with "command+enter" the tooltips will be incorrect on non-Mac.

Removing "ctrl+enter" would have fixed it - I'm not sure why Mac users would want in addition to - but that got added 5 years ago, so I'd kinda take the view that that ship has sailed.

@yoshiokatsuneo
Copy link
Contributor

@Jakdaw

So if we replace "mod+enter" with "command+enter" the tooltips will be incorrect on non-Mac.
I see. You are right !

@yoshiokatsuneo
Copy link
Contributor

@Jakdaw

I tested on My Mac, and it looks "Command-Enter" does not work.
It looks because mod+enter is mapped to cmd+enter instead of command+enter on Mac.

…pple don't shorten "Command" on their keyboards, so makes more sense for the tooltip to use the whole word
@Jakdaw
Copy link
Contributor Author

Jakdaw commented Dec 9, 2025

@Jakdaw

I tested on My Mac, and it looks "Command-Enter" does not work. It looks because mod+enter is mapped to cmd+enter instead of command+enter on Mac.

Very good point - yes, looking at Mousetrap we should be sending it "command+enter" not "cmd+enter". For that matter Apple write the full "command" on their keyboards - so I'm going to change the string that's used both for mousetrap and for the tooltip, seems that "Command" is more appropriate there than "Cmd".

@Jakdaw
Copy link
Contributor Author

Jakdaw commented Dec 9, 2025

Hah - it seems old Mac's did have "Cmd" on the keyboard, but since about 2015 they appear to have changed to "command"; so there we go I'm bringing it up to date! Reminded why I normally stay the hell away from UIs ;-) Thanks for your help Tsuneo!

each(keys, k => {
// Translate platform-specific modifiers and dedupe.
const transformed = rawKeys.map(k =>
k.replace(/mod/g, modKey.toLowerCase())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just feeling that it might be better not to depends on "modKey", as "modKey" is not for mapping but for human readable name. (For example, the name might be localized in the future.)

How about just writing directly like below ?

   k.replace(/mod/g, (/Mac|iPod|iPhone|iPad/.test(navigator.platform) ? "command" : "ctrl") )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants