Skip to content

Conversation

@JohnABardo
Copy link

@JohnABardo JohnABardo commented Jan 3, 2026

Keybinding Teacher Feature - PR Description

Description

This PR implements a Keybinding Teacher feature that helps users discover and learn keyboard shortcuts by showing notifications when they repeatedly use mouse/menu actions for commands that have keybindings.

Fixes #26729 (429 👍)
Related to #78091

As mentioned in #78091, the VS Code team expressed openness to accepting this as a core contribution.

What This Feature Does

The Keybinding Teacher monitors command execution and shows educational notifications when:

  1. A command is executed via UI (mouse/menu) rather than keyboard
  2. The command has an available keybinding
  3. The UI execution count reaches the configured threshold (default: every 3 times)
  4. The cooldown period has elapsed since the last notification (default: 60 minutes)
  5. The user has not dismissed suggestions for that command

Example Notification

image

Key Features

  • Smart Detection: Uses currentlyDispatchingCommandId to reliably distinguish keyboard shortcuts from UI actions
  • Modulo-Based Threshold: Shows notification every N uses (e.g., 3rd, 6th, 9th time) while preserving historical statistics
  • Configurable Cooldown: Prevents notification fatigue with adjustable time between suggestions
  • Dismissible Suggestions: Users can permanently dismiss suggestions for specific commands
  • Management Commands:
    • Keybinding Teacher: Manage Dismissed Suggestions - View and re-enable dismissed commands
    • Keybinding Teacher: Clear All Data - Reset all statistics and dismissed commands

Configuration Settings

All settings are under workbench.keybindingTeacher.*:

  • enabled (default: false): Enable the keybinding teacher
  • threshold (default: 3): Show suggestion every N UI executions
  • cooldownMinutes (default: 60): Minimum time between suggestions for the same command (0 = no cooldown)

Implementation Details

Core Changes

  1. Platform Layer (src/vs/platform/keybinding/):

    • Extended IKeybindingService interface with currentlyDispatchingCommandId property
    • Added public getter in AbstractKeybindingService to expose command dispatch state
    • Updated MockKeybindingService for test compatibility
  2. Workbench Contribution (src/vs/workbench/contrib/keybindingTeacher/):

    • IKeybindingTeacherService - Service interface
    • KeybindingTeacherService - Main implementation with command execution tracking
    • KeybindingTeacherStorage - Persistence layer using IStorageService
    • keybindingTeacherConfiguration.ts - Settings registration
    • keybindingTeacher.contribution.ts - Service and command registration

Design Decisions

  • High-Frequency Filter: Excludes cursor movement, delete, undo, redo, and clipboard commands
  • Storage Scope: Uses StorageScope.APPLICATION for cross-workspace persistence
  • UI/Keyboard Detection: Listens to onDidExecuteCommand and checks if currentlyDispatchingCommandId matches to determine execution source

Manual Testing Steps

  1. Enable and configure the feature:

    • Open Settings (Ctrl+, / Cmd+,)
    • Search for "keybinding teacher"
    • Enable Workbench › Keybinding Teacher: Enabled
    • Set Threshold to your desired value (e.g., 3)
    • Set Cooldown Minutes as needed (e.g., 0 for testing)
  2. Test basic notification:

    • Go to View > Command Palette N times (where N = your threshold value)
    • On the Nth execution, a notification should appear: "You can use Ctrl+Shift+P for 'show all commands'"
  3. Test dismiss functionality:

    • In the notification, click "Don't Show Again for This Command"
    • Go to View > Command Palette N + 1 more times
    • ✅ There should be NO popup (command is dismissed)
  4. Test Clear All Data:

    • Open Command Palette (F1)
    • Run Keybinding Teacher: Clear All Data
    • Confirm the action
    • Go to View > Command Palette N times
    • ✅ The popup should appear after N executions (data was properly cleared)
  5. Test Manage Dismissed Suggestions:

    • Dismiss the notification again using "Don't Show Again for This Command"
    • Go to View > Command Palette N + 1 times to verify no popup appears
    • Open Command Palette (F1)
    • Run Keybinding Teacher: Manage Dismissed Suggestions
    • Select workbench.action.showCommands from the list
    • Go to View > Command Palette N times
    • ✅ The popup should appear after N executions (re-enabling works and count was reset)
  6. Test keyboard shortcuts are NOT tracked:

    • Press Ctrl+Shift+P / Cmd+Shift+P directly 10+ times
    • ✅ Should NOT see any notifications (keybindings don't trigger the teacher)

Expected Behavior

  • Notifications only appear for UI actions (menu clicks), not keyboard shortcuts
  • Dismissed commands stay dismissed until re-enabled
  • Clearing data resets all statistics and dismissed states
  • Re-enabling a dismissed command starts counting fresh from 0
  • Settings changes take effect immediately without restart

Notes

  • Feature is experimental and disabled by default
  • No tests included in initial implementation (can be added if requested during review)
  • Ready for feedback and iteration based on team review

Copilot AI review requested due to automatic review settings January 3, 2026 03:32
@JohnABardo
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a Keybinding Teacher feature that helps users discover keyboard shortcuts by showing notifications when they repeatedly use mouse/menu actions for commands that have keybindings. The feature is experimental and disabled by default.

Key changes:

  • Extends IKeybindingService with currentlyDispatchingCommandId to distinguish keyboard vs UI command execution
  • Implements tracking service with configurable threshold and cooldown
  • Adds management commands for dismissed suggestions and data clearing

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/platform/keybinding/common/keybinding.ts Adds currentlyDispatchingCommandId property to IKeybindingService interface
src/vs/platform/keybinding/common/abstractKeybindingService.ts Implements public getter for currentlyDispatchingCommandId
src/vs/platform/keybinding/test/common/mockKeybindingService.ts Updates mock service with new property
src/vs/workbench/contrib/keybindingTeacher/common/keybindingTeacher.ts Defines service interface and types
src/vs/workbench/contrib/keybindingTeacher/common/keybindingTeacherConfiguration.ts Registers configuration settings
src/vs/workbench/contrib/keybindingTeacher/common/keybindingTeacherStorage.ts Implements persistence layer using storage service
src/vs/workbench/contrib/keybindingTeacher/browser/keybindingTeacherService.ts Main service implementation with command execution tracking
src/vs/workbench/contrib/keybindingTeacher/browser/keybindingTeacher.contribution.ts Service and command registration
src/vs/workbench/workbench.common.main.ts Imports keybinding teacher contribution

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

@sandy081 sandy081 assigned ulugbekna and unassigned sandy081 Jan 4, 2026
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.

VS Code keyboard shortcuts suggestion to learn

3 participants