Skip to content

feat: Add Vim-style keyboard navigation for chat#2124

Open
Emt-lin wants to merge 1 commit intomasterfrom
vim-mode-1
Open

feat: Add Vim-style keyboard navigation for chat#2124
Emt-lin wants to merge 1 commit intomasterfrom
vim-mode-1

Conversation

@Emt-lin
Copy link
Copy Markdown
Collaborator

@Emt-lin Emt-lin commented Jan 20, 2026

Issues

This PR introduces Vim-style keyboard navigation to the chat interface, allowing users to navigate messages and control focus using keyboard shortcuts.

Features

  • Keyboard Navigation: Navigate chat messages using configurable keys (default: j/k for scroll, i to focus input, Escape to return to messages)
  • Smooth Scrolling: Time-based RAF loop provides consistent scrolling across all refresh rates (960px/s default)
  • Customizable Key Mappings: Users can configure navigation keys through settings UI with vim-style syntax (map <key> <action>)
  • Focus Management: Proper focus handling between messages area and input editor
  • Edge Case Handling: Handles IME composition, window blur, tab switching, and streaming states

Implementation

  • useVimNavigation hook (src/hooks/useVimNavigation.ts): Core navigation logic with RAF-based scrolling
  • VimEscapePlugin (src/components/chat-components/plugins/VimEscapePlugin.tsx): Lexical plugin for Escape key handling
  • Settings integration: Toggle and key mapping configuration in Basic Settings
  • Utilities: Parser and builder for vim-style key mappings with validation
  • Tests: Comprehensive test coverage for key mapping utilities

Test Plan

  • Enable Vim navigation in settings
  • Verify j/k scrolling works smoothly in messages area
  • Verify i focuses input from messages
  • Verify Escape returns to messages from input
  • Test custom key mappings configuration
  • Verify navigation stops on window blur/tab switch
  • Test with IME input (CJK languages)
  • Verify navigation doesn't interfere with streaming responses

Actual Effect

2026-01-20.17.26.38.mov
CleanShot 2026-01-20 at 17 39 38

@Emt-lin
Copy link
Copy Markdown
Collaborator Author

Emt-lin commented Jan 20, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65e15bf5ec

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Emt-lin
Copy link
Copy Markdown
Collaborator Author

Emt-lin commented Jan 20, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Emt-lin Emt-lin requested a review from logancyang January 21, 2026 07:54
@Emt-lin
Copy link
Copy Markdown
Collaborator Author

Emt-lin commented Jan 21, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 547ee75436

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Emt-lin
Copy link
Copy Markdown
Collaborator Author

Emt-lin commented Jan 22, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Add optional Vim-style keyboard navigation for the chat messages area:
- Hold j/k to continuously scroll messages (RAF-based smooth scrolling)
- Press i to focus the input editor
- Press Escape in input to return focus to messages
- Click non-interactive areas to focus messages container
- Configurable key mappings via settings UI (map <key> <action> format)

Includes settings validation (single-char, unique, case-insensitive keys),
accessibility labels on focusable regions, text selection preservation,
and proper cleanup of global listeners and animation frames.
@Emt-lin
Copy link
Copy Markdown
Collaborator Author

Emt-lin commented Mar 15, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Emt-lin Emt-lin requested review from logancyang and removed request for logancyang March 15, 2026 09:19
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