Skip to content

Add keyboard shortcut badges to block context menu#692

Merged
lawsie merged 5 commits into
flipcomputing:mainfrom
lawsie:kb-context-menu-badges
Jun 30, 2026
Merged

Add keyboard shortcut badges to block context menu#692
lawsie merged 5 commits into
flipcomputing:mainfrom
lawsie:kb-context-menu-badges

Conversation

@lawsie

@lawsie lawsie commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds badges (similar to Ctrl + G gizmo badges) to the block context menu ONLY while using keyboard navigation
  • Adds a previously missing K / Shift + K keyboard shortcut to allow keyboard users to add a comment
image

AI usage

Claude Opus 4.8 used throughout and wrote all code. All changes audited and accepted individually by a human.

Summary by CodeRabbit

  • New Features

    • Added keyboard shortcuts for commenting on blocks and deleting comments.
    • Keyboard users now see shortcut badges on the floating block toolbar.
  • Bug Fixes

    • Improved comment actions so the toolbar and context menu update correctly based on whether a block already has a comment.
    • Selection behavior now shows shortcut hints more consistently for keyboard navigation.
  • Documentation

    • Updated shortcut labels across supported languages for the new comment actions.

@lawsie lawsie changed the title Kb context menu badges Add keyboard shortcut badges to block context menu Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@lawsie, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b63c7757-089d-4374-bef5-1d587c907f27

📥 Commits

Reviewing files that changed from the base of the PR and between f48035f and 8d3dfef.

📒 Files selected for processing (2)
  • main/blocklyinit.js
  • ui/contextmenu.js
📝 Walkthrough

Walkthrough

Adds K (toggle comment bubble) and Shift+K (delete comment) keyboard shortcuts for Blockly blocks. New comment utilities are exported from ui/blocklyutil.js, shortcuts are registered in blocklyinit.js, the floating toolbar gains a keyboard badge overlay, the context menu comment item is updated, and translation strings are added to 8 locale files.

Changes

Comment Block Keyboard Shortcuts

Layer / File(s) Summary
Comment utility functions
ui/blocklyutil.js
Adds toggleBlockComment, getCommentIcon, toggleCommentBubble, and deleteBlockComment exports.
K / Shift+K shortcut registration
main/blocklyinit.js
Imports comment utilities and registers two shortcutRegistry entries for K (toggle bubble) and Shift+K (delete comment) with precondition guards (non-drag, non-readonly, non-shadow, non-locked).
Floating toolbar keyboard badge overlay
ui/contextmenu.js, style.css
Adds badgeOverlay DOM element, buttonShortcuts map, clearBadges/renderBadges helpers, updateCommentButton, and toolbarKeyboardMode state; updates showBlockToolbar/hideBlockToolbar and selection handler; adds CSS for .fc-toolbar-badges and .fc-toolbar-key-badge.
Context menu comment item refactor
ui/contextmenu.js
Centralizes renderShortcut helper (removes duplicate local copies), wraps blockComment menu item to show K vs Shift+K label and intercept "Add Comment" to open the bubble.
i18n strings and shortcuts panel
accessibility/keyboardui.js, locale/*.js
Adds shortcut_comment_block and shortcut_delete_comment to 8 locale files and registers both in the accessibility shortcuts panel.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • flipcomputing/flock#643: Modifies the same getShortcuts() function in accessibility/keyboardui.js to expand the shortcuts panel list.
  • flipcomputing/flock#687: Adds the floating toolbar and comment add/delete behavior in ui/contextmenu.js that this PR extends with keyboard mode and badge overlay.

Suggested reviewers

  • tracygardner

🐇 Tap K to show your thoughts,
Shift+K to wipe them clean,
Badges glow on keyboard mode,
The clearest comments seen!
hop hop 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding keyboard shortcut badges to the block context menu.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@main/blocklyinit.js`:
- Around line 1610-1655: Resolve `scope.focusedNode` to its owning source block
before falling back to `skippableFieldBlock()`: `commentTargetBlock()` currently
only returns the node when it already has `getCommentText`, so focused fields
inside a block are missed and the `comment_block`/`delete_comment_block`
shortcuts stay disabled. Update `commentTargetBlock()` to unwrap normal field
nodes to their parent/source block first, then keep the existing skippable-field
fallback, and ensure `commentEditable()` continues to gate the same block-like
target.

In `@ui/contextmenu.js`:
- Around line 201-212: The context menu comment action in item.callback
currently starts and immediately ends the Blockly event group before
toggleCommentBubble finishes, so the bubble open/focus work runs outside the
intended group. Update this handler to preserve and restore the previous group
state like the other registrations in contextmenu.js, and make the group span
the full toggleCommentBubble flow if you want its async bubble operations to
stay grouped with the comment creation. Use the item.callback wrapper and
Blockly.Events.setGroup handling to locate the fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 256d000d-c0e1-4b75-80c7-02eede3af732

📥 Commits

Reviewing files that changed from the base of the PR and between 0651b13 and f48035f.

📒 Files selected for processing (13)
  • accessibility/keyboardui.js
  • locale/de.js
  • locale/en.js
  • locale/es.js
  • locale/fr.js
  • locale/it.js
  • locale/pl.js
  • locale/pt.js
  • locale/sv.js
  • main/blocklyinit.js
  • style.css
  • ui/blocklyutil.js
  • ui/contextmenu.js

Comment thread main/blocklyinit.js
Comment thread ui/contextmenu.js
@lawsie lawsie merged commit de4e7ba into flipcomputing:main Jun 30, 2026
3 checks passed
@lawsie lawsie deleted the kb-context-menu-badges branch June 30, 2026 17:58
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