Skip to content

perf(menubar): skip unchanged native tray work - #561

Closed
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-menubar-native-update-cache
Closed

perf(menubar): skip unchanged native tray work#561
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-menubar-native-update-cache

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added per-extension native menubar update state for tray icon, title, tooltip, and serialized menu items.
  • Skips Menu.buildFromTemplate and tray.setContextMenu when serialized items are unchanged.
  • Skips redundant stable title, tooltip, and non-file-backed tray image updates while keeping file-backed tray icons refreshed on accepted updates.
  • Clears native update state on menubar-remove and in will-quit alongside tray/image cache teardown.

Why

Timer-like menu-bar extensions often send accepted payloads for title text changes while their native menu items remain identical. Rebuilding the Electron menu template and context menu every tick adds native work without changing click routing, because menu clicks still send the same item IDs to the renderer's current action map.

Compatibility impact

First payload creation, incomplete first icons, fallback icons/titles, emoji icons, disabled items, submenus, and serialized alternates keep their existing behavior. Empty tooltip payloads remain non-clearing. File-backed tray icons still refresh on accepted payloads so on-disk icon identity changes can be picked up.

How tested

  • node --test scripts/test-menubar-native-update-cache.mjs
  • node --test scripts/test-menubar-native-image-cache.mjs
  • node --test scripts/test-menubar-payload-cache.mjs
  • npm run build:main
  • npm test
  • lsp.status
  • lsp.diagnostics with severity: "error" on src/main/main.ts and src/main/menubar-native-update-cache.ts

Performance evidence

The new native update counter test models 60 accepted title ticks with unchanged serialized items. Before this change, that path performs 60 Menu.buildFromTemplate calls and 60 setContextMenu calls; after this change, it performs 1 of each. Existing native image cache evidence still reports repeated accepted payload decode/read/resize work reduced from 1620 operations to 81 over 20 updates.

Stack validation

Started from integration base 264fb89dc5c867d6c3d77bc4b95e26e235e326ea on stack branch fork/codex/perf-consolidated-integration-stack; before editing, HEAD and the stack branch both resolved to that commit.

Replaces

None

…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
… into codex/perf-consolidated-integration-stack
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated lifecycle/media wave-2 PR: #575

@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #575.

@JustYannicc JustYannicc closed this Jul 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.

1 participant