Skip to content

Remap Caps Lock to Escape when keymap is enabled#18

Open
max-gaspers-scott wants to merge 1 commit into
mainfrom
remap-caps-lock-to-escape-12538920612504833576
Open

Remap Caps Lock to Escape when keymap is enabled#18
max-gaspers-scott wants to merge 1 commit into
mainfrom
remap-caps-lock-to-escape-12538920612504833576

Conversation

@max-gaspers-scott

@max-gaspers-scott max-gaspers-scott commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Updated the keymap functionality in frontend/src/App.js to correctly remap the Caps Lock key to the Escape key when the keymap is enabled. The fix involved consolidating the keymap state by removing the unused isKeymapActive variable and using keymapEnabled consistently. A new test file frontend/src/CapsLock.test.js was added to ensure the remapping works as expected.


PR created automatically by Jules for task 12538920612504833576 started by @coderFeedForwardAlg

Summary by CodeRabbit

  • Refactor

    • Consolidated keymap toggle state management for consistency.
  • Tests

    • Added test coverage for CapsLock behavior with keymap remapping enabled.

This change fixes the Caps Lock remapping functionality by using the
consistent `keymapEnabled` state instead of the unused `isKeymapActive`.
Redundant state is removed and a new test is added to verify the behavior.

Co-authored-by: coderFeedForwardAlg <76785692+coderFeedForwardAlg@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

App.js removes the redundant isKeymapActive state variable and updates the CapsLock key handler and its useCallback dependency array to reference the existing keymapEnabled state. A new test file verifies that CapsLock emits the Escape character over the socket when the keymap is enabled.

Changes

CapsLock keymap state consolidation

Layer / File(s) Summary
Remove isKeymapActive, use keymapEnabled
frontend/src/App.js
Removes the isKeymapActive state declaration, changes the CapsLock interception condition from isKeymapActive to keymapEnabled, and updates the useCallback dependency array to match.
CapsLock test harness and assertion
frontend/src/CapsLock.test.js
Adds a test file with window.io/socket mock, canvas stub, an activateKeymap helper that dispatches the keymap-enable keystroke sequence, and an assertion that CapsLock emits terminal-input with \x1b.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • max-gaspers-scott/VR-Terminal#16: Introduced the home-row keymap mode and the keymapEnabled state in App.js that this PR consolidates the CapsLock interception onto.

Poem

🐇 Hop hop, one state to rule them all,
isKeymapActive takes a fall.
keymapEnabled now holds the key,
CapsLock sends Escape — just wait and see!
The tests confirm with socket glee. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 directly and clearly describes the main change: remapping Caps Lock to Escape when keymap is enabled, which matches the primary purpose of the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remap-caps-lock-to-escape-12538920612504833576

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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@frontend/src/CapsLock.test.js`:
- Around line 36-38: The `jest.restoreAllMocks()` call in the afterEach hook
does not clean up direct assignments to the global window.io object, which can
leak state between tests and cause cross-test coupling. Add explicit cleanup in
the afterEach hook to delete or reset the window.io property after
jest.restoreAllMocks() is called, ensuring each test starts with a clean global
state.
🪄 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: 47978788-98bb-40e1-8b9b-b7fba3be05f0

📥 Commits

Reviewing files that changed from the base of the PR and between c598803 and fddde02.

📒 Files selected for processing (2)
  • frontend/src/App.js
  • frontend/src/CapsLock.test.js

Comment on lines +36 to +38
afterEach(() => {
jest.restoreAllMocks();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Clean up window.io explicitly in teardown.

jest.restoreAllMocks() won’t undo direct assignment to window.io, so this global can leak into later tests and cause cross-test coupling.

Suggested fix
  afterEach(() => {
    jest.restoreAllMocks();
+   delete window.io;
  });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
afterEach(() => {
jest.restoreAllMocks();
});
afterEach(() => {
jest.restoreAllMocks();
delete window.io;
});
🤖 Prompt for 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.

In `@frontend/src/CapsLock.test.js` around lines 36 - 38, The
`jest.restoreAllMocks()` call in the afterEach hook does not clean up direct
assignments to the global window.io object, which can leak state between tests
and cause cross-test coupling. Add explicit cleanup in the afterEach hook to
delete or reset the window.io property after jest.restoreAllMocks() is called,
ensuring each test starts with a clean global state.

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