Skip to content

Conversation

phucisstupid
Copy link
Contributor

@phucisstupid phucisstupid commented Aug 28, 2025

Added Vim Inspired Keys

  • shift+j, shift+k: Rotate through sidebar
  • d: Scroll down (half-page)
  • u: Scroll up (half-page)

Summary by CodeRabbit

  • New Features
    • Added keyboard shortcuts: Shift+J / Shift+K to cycle through the sidebar; D / U to scroll half a page down/up in the app view.
  • Bug Fixes
    • Improved temporary key-listener behavior so shortcuts are reliably removed after use and no longer linger or misfire.

Copy link

coderabbitai bot commented Aug 28, 2025

Walkthrough

Adds Shift+J/Shift+K bindings to rotate the sidebar, adds D/U to scroll half a page via a new scrollHalfPage(direction) function, and refactors scroll keyup cleanup to a named clear function with the listener using { once: true }.

Changes

Cohort / File(s) Summary of changes
Keyboard shortcuts and scrolling
Extensions/keyboardShortcut.js
- Added bindings: shift+jrotateSidebar(1), shift+krotateSidebar(-1), dscrollHalfPage(1), uscrollHalfPage(-1)
- Implemented `scrollHalfPage(direction /* 1

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant KS as KeyboardShortcut
  participant App as App View
  participant SB as Sidebar

  rect rgba(200,230,255,0.2)
    U->>KS: Press Shift+J
    KS->>SB: rotateSidebar(1)
    U->>KS: Press Shift+K
    KS->>SB: rotateSidebar(-1)
  end

  rect rgba(200,255,200,0.2)
    U->>KS: Press D
    KS->>App: scrollHalfPage(1)
    KS->>App: focusOnApp() for bounds
    U->>KS: Press U
    KS->>App: scrollHalfPage(-1)
    KS->>App: focusOnApp() for bounds
  end

  note over KS: Keyup cleanup uses named clear() and listener with { once: true }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I tap-tap keys with whiskered glee,
Shift+J, Shift+K—sidebar spins for me!
D hops down, U bounds back, neat,
Half-page leaps on fluffy feet.
One clear hop, cleanup done—my shortcuts fleet! 🐇⌨️

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 ea64a9c and 1dd4f07.

📒 Files selected for processing (1)
  • Extensions/keyboardShortcut.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Extensions/keyboardShortcut.js
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 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 @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit 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:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit 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 @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @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.

Copy link

@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: 1

🧹 Nitpick comments (3)
Extensions/keyboardShortcut.js (3)

47-50: Reconsider ‘d/u’ semantics; prefer Ctrl+D/Ctrl+U for Vim parity or ignore inputs to avoid hijacking typing

In Vim, half-page is Ctrl+D/Ctrl+U; plain ‘d’/‘u’ are delete/undo. Also, binding plain letters risks capturing typing outside inputs if Mousetrap’s input-ignoring behavior changes.

Option A (Vim-consistent):

-    d: { callback: () => scrollHalfPage(1) },
-    u: { callback: () => scrollHalfPage(-1) },
+    "ctrl+d": { callback: () => scrollHalfPage(1) },
+    "ctrl+u": { callback: () => scrollHalfPage(-1) },

Option B (keep ‘d/u’, but don’t fire while user is typing):

-    d: { callback: () => scrollHalfPage(1) },
-    u: { callback: () => scrollHalfPage(-1) },
+    d: { callback: (event) => { if (shouldIgnoreKey(event)) return; scrollHalfPage(1); } },
+    u: { callback: (event) => { if (shouldIgnoreKey(event)) return; scrollHalfPage(-1); } },

Add once (outside this hunk):

function shouldIgnoreKey(event) {
  const t = event.target;
  return !!t && (
    (t instanceof HTMLInputElement) ||
    (t instanceof HTMLTextAreaElement) ||
    t.isContentEditable === true
  );
}

128-130: Good cleanup with once; fix indentation to satisfy Biome

The named clear + { once: true } is solid. However, current indentation deviates from file style and triggers the formatter.

Apply formatting (tabs, aligned with surrounding code):

-      	const clear = () => clearInterval(scrollInterval);
-      	document.addEventListener("keyup", clear, { once: true });
+			const clear = () => clearInterval(scrollInterval);
+			document.addEventListener("keyup", clear, { once: true });

126-145: Biome CI is failing; run formatter or fix indentation in this range

GitHub Actions reports a Biome formatting failure for 126–145. Run: biome format Extensions/keyboardShortcut.js or apply the indentation fix above to clear CI.

📜 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 a549ca0 and ea64a9c.

📒 Files selected for processing (1)
  • Extensions/keyboardShortcut.js (4 hunks)
🧰 Additional context used
🪛 GitHub Actions: Code quality
Extensions/keyboardShortcut.js

[error] 126-145: Biome formatting check failed. File 'Extensions/keyboardShortcut.js' content differs from formatting output. Command 'biome ci . --files-ignore-unknown=true --diagnostic-level=error' reported the issue. Run 'biome format Extensions/keyboardShortcut.js' to fix.

🔇 Additional comments (1)
Extensions/keyboardShortcut.js (1)

138-146: scrollHalfPage implementation is correct

Bounds clamping and half-page delta are handled correctly.

Comment on lines +35 to +38
// Rotate through sidebar items using Shift+J/Shift+K (Vim-style).
"shift+j": { callback: () => rotateSidebar(1) },
"shift+k": { callback: () => rotateSidebar(-1) },

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Shift+J/K bindings look good; safeguard rotateSidebar index to avoid NaN crash

If findActiveIndex can’t find a match while activeLink or activePage exists, it returns undefined, making findActiveIndex(...) + direction become NaN and allItems[index] will throw. Add a fallback return at the end of findActiveIndex or coerce in rotateSidebar.

Add a fallback in findActiveIndex (outside this hunk):

function findActiveIndex(allItems) {
  // ...existing logic...
  return -1; // ensure a number is always returned
}

Optionally harden in rotateSidebar:

const activeIdx = findActiveIndex(allItems);
let index = (typeof activeIdx === "number" ? activeIdx : -1) + direction;
🤖 Prompt for AI Agents
In Extensions/keyboardShortcut.js around lines 35 to 38, the Shift+J/K handlers
call rotateSidebar which relies on findActiveIndex returning a number; if
findActiveIndex returns undefined the index math becomes NaN and accessing
allItems[index] will throw. Modify findActiveIndex (elsewhere in the file) to
always return a number (e.g., return -1 at the end) and additionally harden
rotateSidebar by coercing the result to a numeric fallback before adding
direction (e.g., treat non-number as -1) so index math cannot produce NaN.

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