Repository navigation
Menus: create the hide and toggle actions of menu items when first used - #350405
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Conversation
Every build of menu actions created two actions per item to hide it, with a localized label, although only context menus use them. The command palette builds its whole menu for each query. Create them on first access; isHidden stays the value read when the menu is built. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot stopped reviewing on behalf of
Federico Brancasi (federicobrancasi) due to an error
November 25, 2026 15:56
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every build of menu actions (
IMenuService.getMenuActions,IMenu.getActions) gave each item two actions to hide it:hide, with a localized label, andtoggle. Only toolbars and a few context menus use them, but they were created for every item of every build. The command palette, for example, builds its whole menu, thousands of items, for each query.This PR creates them on first access and keeps the instances, so repeated reads return the same actions.
isHiddenstays a value read when the menu is built. Before, it read the toggle action'schecked, whichtoActioncopies once, andcompareActionsin the Source Control view compares it between builds to notice that an item was hidden or shown. Running the toggle still reads the current state, as before.No issue is associated; this came from profiling.
Measured on my machine
createMenuHidetook 15 to 42 ms per scenario, most of it from the command palette.createMenuHide, with the realtoActionandlocalize, 2,500 items like the command palette, median of 9 runs of 100 builds:Toolbars read
togglefor the items they show, so they still create it; the saving is where actions are built but their hide actions aren't read, such as the command palette.Why behavior is unchanged
No consumer of
hideActionscopies, spreads or serializes it; they pass it on or read its properties:MenuItemActionandSubmenuItemActionstore it, and analtaction passes it on.ToolBarinsrc/vs/platform/actions/browser/toolbar.tsreadstoggle,toggle.checked,hide,isHiddenandisModifiedFromDefault.menuActivityBar.tsreadstoggle.compareActionsinsrc/vs/workbench/contrib/scm/browser/util.tscomparesisHidden, which is why it stays a value.action.hideActionsthrough to a new action.How to test
No test is added: callers see the same actions and values. The existing tests of menus and toolbars cover hiding and toggling.
./scripts/test.sh --run src/vs/platform/actions/test/common/menuService.test.ts --run src/vs/platform/actions/test/browser/toolbar.test.ts --run src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasRegistryService.test.ts --run src/vs/sessions/test/browser/sessionActivityBar.test.ts --run src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts --run src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/hostFilter.contribution.test.ts --run src/vs/sessions/test/browser/mobileTitlebarPart.test.ts --run src/vs/workbench/contrib/sessions/test/browser/parts/sessionHeader.test.tsnode_modules/.bin/tsc --project ./src/tsconfig.json --noEmit --skipLibChecksrc/vs/platform/agentHost/, from my local Copilot SDK package being older than the one onmain)node_modules/.bin/oxlint src/vs/platform/actions/common/menuService.ts