Skip to content

fix(menu): prevent guardProc buffer wipe race & eliminate login-shell overhead - #6502

Open
shrijit37 wants to merge 1 commit into
basecamp:quattrofrom
shrijit37:fix-menu-guard-race
Open

fix(menu): prevent guardProc buffer wipe race & eliminate login-shell overhead#6502
shrijit37 wants to merge 1 commit into
basecamp:quattrofrom
shrijit37:fix-menu-guard-race

Conversation

@shrijit37

Copy link
Copy Markdown

Summary

When opening or toggling the Omarchy menu (such as via the physical keyboard power button omarchy-menu toggle system), the menu intermittently opens completely empty ("Nothing here yet") or fails to display submenus/items.

Root Cause Analysis

  1. Buffer Wipe Race: evaluateGuards() clears guardProc.collected = "" and attempts to start guardProc (bash -lc script). If evaluateGuards() is invoked while guardProc is already running in background, guardProc.collected is wiped mid-flight. When guardProc.onExited eventually runs, it parses a truncated stdout buffer.
  2. Destructive whenResults Overwrite: guardProc.onExited overwrites root.whenResults and root.checkedResults with the partial/empty output, causing isVisible() checks to return false for valid items/submenus and rendering an empty state ("Nothing here yet").
  3. Login Shell Overhead: Running bash -lc loads startup profile scripts (~/.bashrc, ~/.bash_profile, etc.) on every guard pass, adding unnecessary latency to evaluation.

Fix

  • Queue Concurrent Guard Runs: If guardProc.running is true when evaluateGuards() is called, mark guardEvaluationPending = true and return without touching guardProc.collected. Re-run evaluateGuards() when guardProc exits if pending.
  • Preserve Existing Results: Merge new whenResults and checkedResults into existing result maps in onExited so partial output never wipes known valid item visibility states.
  • Non-login Shell: Use bash -c instead of bash -lc to avoid startup profile overhead.

- Prevent clearing in-flight guardProc stdout buffer when evaluateGuards is called concurrently.
- Queue pending guard evaluations until active guardProc completes.
- Preserve existing whenResults and checkedResults across guard evaluations to prevent items/submenus from disappearing on partial runs.
- Use 'bash -c' instead of 'bash -lc' to eliminate login-shell startup overhead per guard pass.
Copilot AI review requested due to automatic review settings August 2, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes concurrent menu guard evaluation races and reduces guard startup latency.

Changes:

  • Queues guard reevaluation while a pass is running.
  • Preserves prior guard results when parsing partial output.
  • Replaces login-shell execution with bash -c.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +954 to +956
if (guardProc.running) {
root.guardEvaluationPending = true
return
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.

2 participants