Skip to content

feat: add 'Explain with Claude Code' context menu actions#30

Merged
trmquang93 merged 1 commit intodevelopfrom
feature/context-menu-explain
Jun 8, 2025
Merged

feat: add 'Explain with Claude Code' context menu actions#30
trmquang93 merged 1 commit intodevelopfrom
feature/context-menu-explain

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

Add comprehensive right-click context menu integration for AI-powered code explanations across VSCode.

Features Added

Context Menu Actions

  • Editor (with selection): "Explain Selection with Claude Code"
  • Editor (no selection): "Explain File with Claude Code"
  • Explorer files: "Explain with Claude Code"
  • Explorer folders: "Explain Folder with Claude Code"

Smart Integration

  • ✅ Workspace-relative path resolution
  • ✅ Automatic terminal startup when needed
  • ✅ Line range detection for selections (@file.js#L10-15)
  • ✅ File/folder existence validation
  • ✅ Grouped menu items in unified section
  • ✅ Background terminal display (preserves focus)
  • ✅ Comprehensive error handling

Technical Implementation

  • Added 4 new VSCode commands with proper registration
  • Context menu contributions using appropriate when clauses
  • Leverages existing terminal management infrastructure
  • Error handling with user-friendly messages
  • Menu grouping for improved UX

User Experience

Users can now right-click on any file, folder, or code selection and instantly get AI explanations without manual setup or context switching.

Test Plan

  • Right-click file in Explorer → "Explain with Claude Code"
  • Right-click folder in Explorer → "Explain Folder with Claude Code"
  • Select code and right-click → "Explain Selection with Claude Code"
  • Right-click in editor (no selection) → "Explain File with Claude Code"
  • Verify terminal auto-starts when needed
  • Confirm menu items are grouped together
  • Test error handling for non-existent files

Add comprehensive right-click context menu integration for AI-powered code explanations:

• Editor context menus:
  - 'Explain Selection with Claude Code' (when text is selected)
  - 'Explain File with Claude Code' (when no text is selected)

• Explorer context menus:
  - 'Explain with Claude Code' (for files)
  - 'Explain Folder with Claude Code' (for folders)

Features:
- Smart workspace-relative path resolution
- Automatic terminal startup when needed
- Line range detection for code selections (@file.js#L10-15)
- Proper error handling with user-friendly messages
- File/folder existence validation
- Grouped menu items in 'claude' section for better UX

Technical improvements:
- Added space after terminal text input for better interaction
- Leverages existing terminal management and detection infrastructure
- Maintains focus on input panel after sending commands
- Shows terminal in background without stealing focus
@trmquang93 trmquang93 merged commit 117315c into develop Jun 8, 2025
@trmquang93 trmquang93 deleted the feature/context-menu-explain branch June 8, 2025 15:11
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