[codex] add structured Electron dialog errors - #3284
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Adds structured error classes for Electron dialog operations without changing dialog behavior itself. The changes are self-contained error handling improvements with comprehensive test coverage. The unresolved comment identifies a potential edge case in error construction, not a runtime behavioral issue. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate 513653f
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Unsafe message length in catch
- Added optional chaining (options.message?.length ?? null) and updated the messageLength schema to Schema.NullOr(Schema.Number) to safely handle the optional message field, consistent with how titleLength and detailLength are already handled.
Or push these changes by commenting:
@cursor push 17d1f18c8c
Preview (17d1f18c8c)
diff --git a/apps/desktop/src/electron/ElectronDialog.ts b/apps/desktop/src/electron/ElectronDialog.ts
--- a/apps/desktop/src/electron/ElectronDialog.ts
+++ b/apps/desktop/src/electron/ElectronDialog.ts
@@ -42,7 +42,7 @@
{
type: Schema.NullOr(Schema.Literals(["none", "info", "error", "question", "warning"])),
titleLength: Schema.NullOr(Schema.Number),
- messageLength: Schema.Number,
+ messageLength: Schema.NullOr(Schema.Number),
detailLength: Schema.NullOr(Schema.Number),
buttonCount: Schema.Number,
cause: Schema.Defect(),
@@ -177,7 +177,7 @@
new ElectronDialogShowMessageBoxError({
type: options.type ?? null,
titleLength: options.title?.length ?? null,
- messageLength: options.message.length,
+ messageLength: options.message?.length ?? null,
detailLength: options.detail?.length ?? null,
buttonCount: options.buttons?.length ?? 0,
cause,You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 513653f. Configure here.


Summary
Verification
vp test apps/desktop/src/electron/ElectronDialog.test.tsvp check(0 errors; 20 existing warnings)vp run typecheckSensitive-context follow-up\n- confirmation, message-box, and error-box payload text is represented only by lengths and counts\n- owner window, dialog type, and intentional folder default paths remain available for correlation\n- all original Electron causes remain intact
Note
Medium Risk
Changes failure channels for dialog APIs (typed failures vs generic rejections; error box as defects), which callers must handle correctly though happy-path behavior is unchanged.
Overview
Electron dialog failures are now typed, schema-backed errors instead of raw promise rejections.
pickFolder,confirm, andshowMessageBoxuseEffect.tryPromiseand fail with operation-specific tagged errors that keep the original cause plus safe metadata (window id, path, prompt/message lengths, button counts)—not full user-facing strings inmessage. AnElectronDialogErrorunion andisElectronDialogErrorare exported for callers.showErrorBoxwraps sync throws inElectronDialogShowErrorBoxErrorandEffect.orDie, so those failures surface as defects rather than recoverable typed errors.New tests assert error shape, predicate usage, and that messages omit prompt/title/content and cause text.
Reviewed by Cursor Bugbot for commit 513653f. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add structured error types to
ElectronDialogmethods for failures and defectsSchema.TaggedErrorClasstypes (ElectronDialogPickFolderError,ElectronDialogConfirmError,ElectronDialogShowMessageBoxError,ElectronDialogShowErrorBoxError) in ElectronDialog.ts, each carrying summarized request context (e.g. lengths, IDs) and the original cause.Effect.promise/Effect.synccalls withEffect.tryPromise/Effect.tryso rejections and throws are caught and wrapped in the appropriate typed error.showErrorBoxfailures are converted to defects viaEffect.orDie, matching Electron's fire-and-forget semantics.ElectronDialogErrorunion type andisElectronDialogErrorpredicate for runtime type-checking.pickFolder,confirm, andshowMessageBoxnow fail with typed errors instead of untyped rejections;showErrorBoxnow dies with a typed defect instead of completing silently on throw.Macroscope summarized 513653f.