
Context Menu Manager is a complete, generic Visual Studio Code extension that empowers developers to inspect, organize, search, filter, and toggle context-menu items contributed by any installed extension (e.g., GitLens, C# Dev Kit, Python, Docker, Copilot, and more) from a clean, native developer UI.
Key Features
- 🔍 Generic Extension Discovery: Scans all installed extensions and dynamically discovers menu contributions without hardcoding.
- 📋 Multi-Location Menu Support: Inspects 15+ standard VS Code menu locations (
explorer/context, editor/context, editor/title, view/item/context, scm/resourceState/context, etc.) plus custom/dynamic locations.
- ⚡ Live Search & Filtering: Instant search across titles, command IDs, extension names, locations, and
when conditions. Filter by Enabled, Disabled, or Modified.
- 🛡️ Safe & Reversible Unofficial Patching: Safely disables menu items by wrapping conditions (
(originalWhen) && false) with atomic writes and formatting preservation.
- 💾 Automatic Pristine Backups: Creates byte-for-byte backups in
.context-menu-manager/package.json.backup before any modification.
- ↩ Instant Reset & One-Click Restore: Restore any single item, an entire extension, or all extensions to pristine unpatched manifests at any time.
- 🔄 Extension Update Migration: Automatically detects extension version bumps, preserves existing disabled item choices, and reapplies them onto the new version's manifest.
- 🎨 Native VS Code Look & Feel: Beautiful Webview interface utilizing native VS Code CSS variables, accordions, toggles, badges, and modal dialogs.
- 📝 Structured Output Logging: Dedicated output channel (
"Context Menu Manager") providing audit logs of scans, backups, patches, and updates.
Architecture Overview
flowchart TD
subgraph UI["Webview Interface"]
WebviewPanel["ContextMenuPanel"]
UIApp["Native VS Code Webview (HTML/CSS/TS)"]
end
subgraph Scanner["Scanner Engine"]
ExtScanner["ExtensionScanner"]
ManifestReader["ManifestReader (NLS & Commands)"]
MenuScanner["MenuScanner (15+ Menu Locations)"]
end
subgraph Core["Core & Safety Layer"]
ConfigStore["ConfigurationStore (globalState)"]
ManifestPatcher["ManifestPatcher (Atomic Writes)"]
BackupMgr["BackupManager (.context-menu-manager/)"]
PatchStateMgr["PatchStateManager"]
UpdateDet["UpdateDetector"]
Logger["OutputChannel Logger"]
end
ExtScanner --> ManifestReader
ManifestReader --> MenuScanner
MenuScanner --> WebviewPanel
WebviewPanel <--> UIApp
WebviewPanel --> ManifestPatcher
ManifestPatcher --> BackupMgr
ManifestPatcher --> PatchStateMgr
PatchStateMgr --> ConfigStore
UpdateDet --> ExtScanner
UpdateDet --> ManifestPatcher
How It Works: The Unofficial Patching Mechanism
The Technical Limitation
Visual Studio Code's official Extension API does not provide runtime APIs (e.g. vscode.menus.hide(...)) to suppress menu contributions declared in third-party extension manifests.
The Isolated Solution
Context Menu Manager implements a safe, isolated, and fully reversible manifest patching engine:
- Deterministic Identification: Generates stable item IDs (
${extensionId}::${menuLocation}::${command}::${group}::${whenHash}) resilient to manifest array reordering and version upgrades.
- Non-Destructive Transformation: When disabling an item, the original
when clause is preserved and augmented:
- If original
when is "resourceExtname == .cs": Patched when becomes "(resourceExtname == .cs) && false".
- If no
when condition was present: Patched when becomes "false".
- Pristine Backup: Before applying any changes, the original
package.json is preserved byte-for-byte in <extension-dir>/.context-menu-manager/package.json.backup.
- Exact Restoration: When an item is re-enabled or an extension is reset, the manifest is reconstructed from the pristine backup. If all items in an extension are enabled, the original
package.json is restored byte-for-byte.
- Atomic Writes: Manifest updates are written to a
.tmp file and atomically renamed to prevent partial writes.
Context Menu Manager automatically discovers and manages contributions in all VS Code menu locations, including:
| Menu Location |
Description |
explorer/context |
Context menu shown when right-clicking files or folders in Explorer |
editor/context |
Context menu shown when right-clicking inside an editor |
editor/title |
Actions shown on the top-right of editor tabs |
editor/title/context |
Context menu shown when right-clicking editor tab headers |
editor/lineNumber/context |
Context menu shown on editor line numbers/gutter |
view/item/context |
Context menu on items in custom tree views |
view/title |
Actions and menu in view headers and panels |
scm/resourceState/context |
Context menu for changed files in Source Control view |
scm/resourceFolder/context |
Context menu for folders in Source Control view |
scm/change/title |
Actions in the inline diff view header |
terminal/context |
Context menu inside Integrated Terminal |
debug/callStack/context |
Context menu in Debug Call Stack view |
debug/variables/context |
Context menu in Debug Variables view |
notebook/cell/title |
Actions shown on notebook cell headers |
notebook/cell/execute |
Actions in notebook cell execution gutter |
comments/commentThread/context |
Context menu on comment threads |
timeline/item/context |
Context menu on items in Timeline view |
| Dynamic Locations |
Any custom extension-contributed menu location |
Extension Commands
| Command |
Title |
Description |
contextMenuManager.open |
Context Menu Manager: Open Context Menu Manager |
Opens the visual management dashboard. |
contextMenuManager.scan |
Context Menu Manager: Scan Extensions & Context Menus |
Performs a full scan of all extensions. |
contextMenuManager.apply |
Context Menu Manager: Apply Pending Changes |
Applies pending changes and prompts for window reload. |
contextMenuManager.reset |
Context Menu Manager: Reset All Changes |
Restores all extension manifests to pristine backups. |
contextMenuManager.restoreBackups |
Context Menu Manager: Restore All Backups |
Restores all .context-menu-manager backups on disk. |
Getting Started & Development
Prerequisites
- Node.js (v18 or higher)
- npm (v9 or higher)
- VS Code (v1.85.0 or higher)
Build & Run Locally
Clone or navigate to the repository directory:
cd "Context Menu Manager"
Install dependencies:
npm install
Compile TypeScript:
npm run compile
Launch Extension Development Host:
Running Tests
Run the comprehensive unit test suite:
npm run test-unit
Packaging as VSIX
To package the extension into an installable .vsix file:
npx @vscode/vsce package
To install the .vsix in VS Code:
code --install-extension context-menu-manager-1.0.3.vsix
Safety Guarantees
- Never touches VS Code core files: Only operates on user-installed extension manifests.
- Never deletes extension source code or commands: Commands remain registered and executable via keyboard shortcuts or Command Palette.
- Preserves manifest formatting: Matches original indentation (2 spaces, 4 spaces, or tabs).
- Guaranteed backup preservation: Pristine backups are never overwritten by patched content.
- Resilient error handling: If any individual extension has a malformed or read-only manifest, it is logged and skipped without affecting other extensions.
License
MIT License. See LICENSE for details.