Skip to content

[codex] Structure Electron menu failures#3317

Open
juliusmarminge wants to merge 1 commit into
mainfrom
codex/desktop-electron-menu-errors
Open

[codex] Structure Electron menu failures#3317
juliusmarminge wants to merge 1 commit into
mainfrom
codex/desktop-electron-menu-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • wrap Electron native menu construction and popup failures in a structured Schema error carrying operation, platform, window ID, item count, and the exact cause
  • preserve the existing defect semantics while keeping messages derived only from stable structured context
  • add focused coverage for application-menu, template-popup, and callback-based context-menu failures

Validation

  • vp test apps/desktop/src/electron/ElectronMenu.test.ts (7 tests)
  • vp check
  • vp run typecheck

Overlap

The ElectronMenu source file also appears in unrelated feature PR #3177 (version control command center); the test file does not. No active error-audit PR overlaps this slice.


Note

Low Risk
Desktop-only error-handling around Electron menus; behavior on success is unchanged and failures remain defects as before, with richer structure for logging and audits.

Overview
Electron menu native calls now fail with a structured ElectronMenuOperationError instead of raw thrown errors. setApplicationMenu, popupTemplate, and showContextMenu wrap buildFromTemplate / popup in Effect.try (or a guarded try/catch in the callback path) and map failures to defects via Effect.orDie, carrying operation, platform, window id, item count, and the original cause. User-facing message text is derived only from that metadata, not from the underlying error string.

Tests provide HostProcessPlatform as linux through a shared TestLayer and add coverage that each menu path surfaces the tagged error with the expected context when Electron mocks throw.

Reviewed by Cursor Bugbot for commit 1b7c676. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Structure Electron menu failures as typed ElectronMenuOperationError defects

  • Adds ElectronMenuOperationError, a tagged error class with fields operation, platform, windowId, itemCount, and cause, providing structured context for menu failures in ElectronMenu.ts.
  • Refactors setApplicationMenu, popupTemplate, and showContextMenu to catch failures, wrap them in ElectronMenuOperationError, and re-raise as defects via Effect.orDie or Effect.die.
  • The error message is standardized and does not echo the original cause message, keeping cause accessible only via the structured cause field.
  • popupTemplate now returns a no-op effect when the input template is empty.
  • Behavioral Change: all three menu methods now die (defect) on failure rather than failing with a typed error; callers relying on Effect.catchAll will no longer intercept these errors.

Macroscope summarized 1b7c676.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 63cc5ad4-e0c7-417a-9b83-4b085a6ffbd2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/desktop-electron-menu-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR wraps existing Electron menu operations with structured error handling, converting raw exceptions into typed ElectronMenuOperationError instances. The core menu logic is unchanged; only the error paths gain additional context (operation type, platform, window ID, item count).

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant