Skip to content

fix selecting languages in command menu#862

Merged
hatemhosny merged 2 commits intodevelopfrom
fix-command-menu
Aug 23, 2025
Merged

fix selecting languages in command menu#862
hatemhosny merged 2 commits intodevelopfrom
fix-command-menu

Conversation

@hatemhosny
Copy link
Copy Markdown
Collaborator

@hatemhosny hatemhosny commented Aug 23, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Language and processor selection now trigger reliably, improving editor switching and reducing missed selections.
    • Command menu opens consistently with Ctrl+K, regardless of prior visibility, ensuring predictable shortcut behavior.
    • App help scroller is hidden when the command menu opens to prevent UI overlap and improve focus.
  • Refactor

    • Simplified the command menu keyboard shortcut flow to reduce edge cases and improve responsiveness.

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 23, 2025

Deploy Preview for livecodes ready!

Name Link
🔨 Latest commit 58efd27
🔍 Latest deploy log https://app.netlify.com/projects/livecodes/deploys/68a9d8ff32a2100008150f7b
😎 Deploy Preview https://deploy-preview-862--livecodes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 23, 2025

Walkthrough

Command menu behavior updated: UI now triggers native click events for language and processor selections. Core always focuses the command interface on Ctrl+K, opens the command menu after a 500ms delay, and hides the app-help scroller when the menu opens.

Changes

Cohort / File(s) Change Summary
Command menu interactions (UI)
src/livecodes/UI/command-menu-actions.ts
Language selection now invokes the anchor's native click() on [data-editor][data-lang="..."] instead of dispatching a synthetic mousedown. Processor selection now dispatches a bubbled click event on the input selector instead of mousedown.
Hotkey and menu visibility (Core)
src/livecodes/core.ts
openCommandMenu now hides the app-help scroller via UI.getAppMenuHelpScroller()?.classList.add('hidden'). Ctrl+K flow always focuses the ninja and opens the command menu after 500ms; loadNinjaKeys is still called when ninja keys are uninitialized.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Core
  participant UI
  participant Ninja as NinjaKeys
  participant DOM as DOM Elements

  rect rgba(240,248,255,0.9)
    note over User,Core: Ctrl+K hotkey pressed
    User->>Core: Ctrl+K
    Core->>Ninja: focus()
    alt NinjaKeys not initialized
      Core->>Ninja: loadNinjaKeys()
    end
    Core-->>Core: wait 500ms
    Core->>UI: openCommandMenu()
    UI->>UI: getAppMenuHelpScroller()?.classList.add("hidden")
  end

  rect rgba(245,255,240,0.9)
    note over User,DOM: Selecting a command item
    alt Language selection
      UI->>DOM: query [data-editor][data-lang="{lang.name}"]
      UI->>DOM: anchor.click()
    else Processor selection
      UI->>DOM: query input selector
      UI->>DOM: dispatchEvent(new Event("click", { bubbles: true }))
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump the keys—K, command, and hop!
The help scroller hides, the menu pops.
No mousedown fuss, just tidy clicks,
Languages swap and processors mix.
A rabbit nods: the change is slick. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 43339a8 and 58efd27.

📒 Files selected for processing (1)
  • src/livecodes/UI/command-menu-actions.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/livecodes/UI/command-menu-actions.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Redirect rules - livecodes
  • GitHub Check: Header rules - livecodes
  • GitHub Check: Pages changed - livecodes
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: tests (18.x, 4)
  • GitHub Check: tests (18.x, 5)
  • GitHub Check: tests (18.x, 1)
  • GitHub Check: build (18.x)
  • GitHub Check: tests (18.x, 2)
  • GitHub Check: type-check (18.x)
  • GitHub Check: tests (18.x, 3)
  • GitHub Check: build
  • GitHub Check: type-check (18.x)
  • GitHub Check: build (18.x)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-command-menu

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hatemhosny hatemhosny changed the title fix(CommandMenu): fix selecting languages in command menu fix selecting languages in command menu Aug 23, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 23, 2025

Size Change: -82 B (-0.01%)

Total Size: 947 kB

ℹ️ View Unchanged
Filename Size Change
./build/404.html 1 kB 0 B
./build/app.html 250 B 0 B
./build/index.html 2.48 kB +14 B (+0.57%)
./build/livecodes/app.js 111 kB +42 B (+0.04%)
./build/livecodes/app.css 22.4 kB 0 B
./build/livecodes/assets.js 8.57 kB -25 B (-0.29%)
./build/livecodes/assets/noop.js 18 B 0 B
./build/livecodes/assets/templates/diagrams-starter.html 2.19 kB 0 B
./build/livecodes/backup.js 3.69 kB +4 B (+0.11%)
./build/livecodes/blockly.js 13.2 kB 0 B
./build/livecodes/broadcast.js 1.19 kB -1 B (-0.08%)
./build/livecodes/bundle-types.js 4.35 kB 0 B
./build/livecodes/code-to-image.js 9.1 kB +2 B (+0.02%)
./build/livecodes/codejar.js 17.6 kB 0 B
./build/livecodes/codemirror.js 6.29 kB 0 B
./build/livecodes/compile.page.js 2.36 kB 0 B
./build/livecodes/compile.worker.js 14.1 kB 0 B
./build/livecodes/compiler-utils.js 3.15 kB 0 B
./build/livecodes/custom-editor-utils.js 198 B 0 B
./build/livecodes/deploy.js 6.85 kB -5 B (-0.07%)
./build/livecodes/editor-settings.js 17.6 kB -47 B (-0.27%)
./build/livecodes/embed-ui.js 5.52 kB -2 B (-0.04%)
./build/livecodes/embed.js 89 kB +3 B (0%)
./build/livecodes/export.js 3.87 kB 0 B
./build/livecodes/firebase.js 22.7 kB 0 B
./build/livecodes/format.worker.js 13.3 kB 0 B
./build/livecodes/google-fonts.js 7.12 kB 0 B
./build/livecodes/headless.js 77.7 kB -44 B (-0.06%)
./build/livecodes/i18n-ar-language-info.json 5.17 kB 0 B
./build/livecodes/i18n-ar-translation.json 9.32 kB 0 B
./build/livecodes/i18n-de-language-info.json 5.21 kB 0 B
./build/livecodes/i18n-de-translation.json 9.43 kB 0 B
./build/livecodes/i18n-en-language-info.json 4.5 kB 0 B
./build/livecodes/i18n-en-translation.json 8.02 kB 0 B
./build/livecodes/i18n-es-language-info.json 4.95 kB 0 B
./build/livecodes/i18n-es-translation.json 9.16 kB 0 B
./build/livecodes/i18n-fa-language-info.json 5.28 kB 0 B
./build/livecodes/i18n-fa-translation.json 9.46 kB 0 B
./build/livecodes/i18n-fr-language-info.json 5.13 kB 0 B
./build/livecodes/i18n-fr-translation.json 9.4 kB 0 B
./build/livecodes/i18n-hi-language-info.json 5.71 kB 0 B
./build/livecodes/i18n-hi-translation.json 9.94 kB 0 B
./build/livecodes/i18n-it-language-info.json 5 kB 0 B
./build/livecodes/i18n-it-translation.json 9.25 kB 0 B
./build/livecodes/i18n-ja-language-info.json 5.51 kB 0 B
./build/livecodes/i18n-ja-translation.json 9.6 kB 0 B
./build/livecodes/i18n-pt-language-info.json 4.99 kB 0 B
./build/livecodes/i18n-pt-translation.json 9.33 kB 0 B
./build/livecodes/i18n-ru-language-info.json 5.52 kB 0 B
./build/livecodes/i18n-ru-translation.json 10.3 kB 0 B
./build/livecodes/i18n-ur-language-info.json 5.73 kB 0 B
./build/livecodes/i18n-ur-translation.json 9.77 kB 0 B
./build/livecodes/i18n-zh-CN-language-info.json 4.87 kB 0 B
./build/livecodes/i18n-zh-CN-translation.json 8.63 kB 0 B
./build/livecodes/i18n.js 20.2 kB -49 B (-0.24%)
./build/livecodes/import-src.js 15.8 kB 0 B
./build/livecodes/import.js 14.4 kB +13 B (+0.09%)
./build/livecodes/index.js 5.34 kB +12 B (+0.23%)
./build/livecodes/lang-art-template-compiler.js 1.63 kB 0 B
./build/livecodes/lang-assemblyscript-compiler.js 290 B 0 B
./build/livecodes/lang-assemblyscript-script.js 386 B 0 B
./build/livecodes/lang-astro-compiler.js 2.32 kB 0 B
./build/livecodes/lang-clio-compiler.js 1.53 kB 0 B
./build/livecodes/lang-commonlisp-script.js 123 B 0 B
./build/livecodes/lang-cpp-script.js 1.73 kB 0 B
./build/livecodes/lang-cpp-wasm-script.js 2.82 kB 0 B
./build/livecodes/lang-csharp-wasm-script.js 2.16 kB 0 B
./build/livecodes/lang-diagrams-compiler-esm.js 5.08 kB 0 B
./build/livecodes/lang-dot-compiler.js 1.64 kB 0 B
./build/livecodes/lang-ejs-compiler.js 1.61 kB 0 B
./build/livecodes/lang-eta-compiler.js 1.63 kB 0 B
./build/livecodes/lang-fennel-compiler.js 1.59 kB 0 B
./build/livecodes/lang-gleam-compiler.js 3 kB 0 B
./build/livecodes/lang-haml-compiler.js 1.62 kB 0 B
./build/livecodes/lang-handlebars-compiler.js 1.9 kB 0 B
./build/livecodes/lang-imba-compiler.js 147 B 0 B
./build/livecodes/lang-java-script.js 4.03 kB 0 B
./build/livecodes/lang-jinja-compiler.js 1.63 kB 0 B
./build/livecodes/lang-julia-script.js 3.27 kB 0 B
./build/livecodes/lang-liquid-compiler.js 1.65 kB 0 B
./build/livecodes/lang-lua-wasm-script.js 205 B 0 B
./build/livecodes/lang-malina-compiler.js 2.91 kB 0 B
./build/livecodes/lang-mustache-compiler.js 1.63 kB 0 B
./build/livecodes/lang-nunjucks-compiler.js 1.91 kB 0 B
./build/livecodes/lang-perl-script.js 268 B 0 B
./build/livecodes/lang-php-wasm-script.js 347 B 0 B
./build/livecodes/lang-postgresql-compiler-esm.js 1.71 kB 0 B
./build/livecodes/lang-prolog-script.js 204 B 0 B
./build/livecodes/lang-pug-compiler.js 371 B 0 B
./build/livecodes/lang-python-wasm-script.js 1.9 kB 0 B
./build/livecodes/lang-r-script-esm.js 2.41 kB 0 B
./build/livecodes/lang-rescript-compiler-esm.js 2.13 kB 0 B
./build/livecodes/lang-rescript-formatter.js 1.49 kB 0 B
./build/livecodes/lang-riot-compiler.js 2.77 kB 0 B
./build/livecodes/lang-ruby-wasm-script.js 1.68 kB 0 B
./build/livecodes/lang-scss-compiler.js 1.69 kB 0 B
./build/livecodes/lang-solid-compiler.js 263 B 0 B
./build/livecodes/lang-sql-compiler.js 1.62 kB 0 B
./build/livecodes/lang-sql-script.js 1.93 kB 0 B
./build/livecodes/lang-svelte-compiler.js 4.56 kB 0 B
./build/livecodes/lang-tcl-script.js 1.8 kB 0 B
./build/livecodes/lang-teal-compiler.js 1.69 kB 0 B
./build/livecodes/lang-twig-compiler.js 1.62 kB 0 B
./build/livecodes/lang-vento-compiler.js 1.65 kB 0 B
./build/livecodes/lang-vue-compiler.js 5.99 kB 0 B
./build/livecodes/lang-vue2-compiler.js 3.43 kB 0 B
./build/livecodes/lang-wat-compiler.js 348 B 0 B
./build/livecodes/lang-wat-script.js 1.55 kB 0 B
./build/livecodes/language-info.js 7.65 kB -1 B (-0.01%)
./build/livecodes/monaco-lang-astro.js 947 B 0 B
./build/livecodes/monaco-lang-clio.js 639 B 0 B
./build/livecodes/monaco-lang-imba.js 7.35 kB 0 B
./build/livecodes/monaco-lang-wat.js 2.46 kB 0 B
./build/livecodes/monaco.js 10.1 kB 0 B
./build/livecodes/open.js 6.17 kB 0 B
./build/livecodes/processor-lightningcss-compiler.js 1.85 kB 0 B
./build/livecodes/processor-postcss-compiler.js 2 kB 0 B
./build/livecodes/processor-tailwindcss-compiler.js 5.03 kB 0 B
./build/livecodes/processor-unocss-compiler.js 355 B 0 B
./build/livecodes/processor-windicss-compiler.js 450 B 0 B
./build/livecodes/quill.css 697 B 0 B
./build/livecodes/quill.js 5.74 kB 0 B
./build/livecodes/resources.js 3.43 kB 0 B
./build/livecodes/result-utils.js 1.17 kB 0 B
./build/livecodes/share.js 3.79 kB +1 B (+0.03%)
./build/livecodes/snippets.js 6.03 kB +1 B (+0.02%)
./build/livecodes/sync-ui.js 3.23 kB 0 B
./build/livecodes/sync.js 3.52 kB 0 B
./build/livecodes/sync.worker.js 29.7 kB 0 B
./build/livecodes/templates.js 24.6 kB 0 B
./build/sdk/livecodes.js 3.95 kB 0 B
./build/sdk/livecodes.umd.js 4.03 kB 0 B
./build/sdk/package.json 293 B 0 B
./build/sdk/react.js 4.25 kB 0 B
./build/sdk/vue.js 4.34 kB 0 B

compressed-size-action

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Aug 23, 2025

Deploying livecodes with  Cloudflare Pages  Cloudflare Pages

Latest commit: 58efd27
Status: ✅  Deploy successful!
Preview URL: https://f5fca7c2.livecodes.pages.dev
Branch Preview URL: https://fix-command-menu.livecodes.pages.dev

View logs

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/livecodes/UI/command-menu-actions.ts (1)

245-250: Fix element typing and prefer native click over synthetic Event.

  • The queried element is an input, but the type argument is HTMLAnchorElement. This is a type mismatch and can hinder type-aware tooling/IDE features.
  • Use HTMLElement.click() instead of dispatching a generic Event('click') to ensure the native click behavior (including toggling checked and firing the full event chain) is triggered consistently.

Apply this diff:

-            document
-              .querySelector<HTMLAnchorElement>(
-                '.processor-item input[data-processor="' + processor.name + '"]',
-              )
-              ?.dispatchEvent(new Event('click', { bubbles: true }));
+            document
+              .querySelector<HTMLInputElement>(
+                `.processor-item input[data-processor="${CSS?.escape?.(processor.name) ?? processor.name}"]`,
+              )
+              ?.click();
🧹 Nitpick comments (2)
src/livecodes/UI/command-menu-actions.ts (1)

216-221: Remove debug log; use safe selector construction for data-lang.

  • console.log(lang.name) is a stray debug log and should be removed to avoid noisy consoles in production.
  • Build the selector with template literals and CSS.escape to guard against special characters in lang.name.

Apply this diff:

-            console.log(lang.name);
-            document
-              .querySelector<HTMLAnchorElement>('a[data-editor][data-lang="' + lang.name + '"]')
-              ?.click();
+            const selector = `a[data-editor][data-lang="${CSS?.escape?.(lang.name) ?? lang.name}"]`;
+            document.querySelector<HTMLAnchorElement>(selector)?.click();
src/livecodes/core.ts (1)

2833-2844: Focus timing: focus after opening for more reliable a11y.

Focusing the ninja element before it’s opened may be a no-op in some browsers or custom-element implementations. Focusing immediately after the menu opens is more reliable.

Apply this diff:

-      ninja.focus();
-      requestAnimationFrame(() => openCommandMenu());
+      requestAnimationFrame(() => {
+        openCommandMenu();
+        // Focus after open to ensure the element is focusable/visible.
+        requestAnimationFrame(() => ninja.focus());
+      });

Please sanity-check the following flows on macOS (Cmd) and Windows/Linux (Ctrl):

  • Press-and-release Ctrl/Cmd+K: command menu opens and receives keyboard focus.
  • Chorded sequences like Ctrl/Cmd+K, Ctrl/Cmd+0 within 500ms: command menu does NOT open prematurely.
  • Help menu visibility: open help, then open command menu (help scroller should hide), then reopen help (it should show again).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4082e05 and 43339a8.

📒 Files selected for processing (2)
  • src/livecodes/UI/command-menu-actions.ts (2 hunks)
  • src/livecodes/core.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Redirect rules - livecodes
  • GitHub Check: Header rules - livecodes
  • GitHub Check: Pages changed - livecodes
  • GitHub Check: build (18.x)
  • GitHub Check: tests (18.x, 1)
  • GitHub Check: tests (18.x, 4)
  • GitHub Check: tests (18.x, 5)
  • GitHub Check: type-check (18.x)
  • GitHub Check: tests (18.x, 3)
  • GitHub Check: tests (18.x, 2)
  • GitHub Check: build
  • GitHub Check: build (18.x)
  • GitHub Check: type-check (18.x)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
src/livecodes/core.ts (1)

2801-2804: Good UX: hide help scroller when opening the command menu.

Hiding the app-help scroller avoids visual conflicts when the command menu opens. Change looks correct and low risk.

@sonarqubecloud
Copy link
Copy Markdown

@hatemhosny hatemhosny merged commit 708bf08 into develop Aug 23, 2025
22 checks passed
@hatemhosny hatemhosny deleted the fix-command-menu branch August 23, 2025 19:37
@coderabbitai coderabbitai Bot mentioned this pull request Aug 23, 2025
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.

1 participant