[codex] Structure desktop SSH prompt presentation failures - #3429
Conversation
|
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 |
6c9ac97 to
a10b0f4
Compare
ApprovabilityVerdict: Approved Error handling improvements for SSH prompt presentation failures with structured operation classification. The author owns this code, changes are well-tested, and the runtime behavior change (preserving already-submitted passwords) is a robustness fix rather than new feature logic. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
a10b0f4 to
5ee7cfe
Compare
Dismissing prior approval to re-evaluate 5ee7cfe
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: Staged yields lose resolved password
- Wrapped the post-send presentation operations (window destroy checks, restore, focus) in an inner Effect.gen with Effect.ignore so their failures cannot shadow an already-resolved password from the deferred, while the window-closed listener and timeout still handle genuinely-gone windows.
Or push these changes by commenting:
@cursor push a7d1f74ac1
Preview (a7d1f74ac1)
diff --git a/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts b/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts
--- a/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts
+++ b/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts
@@ -413,34 +413,42 @@
yield* runPresentationOperation("send-prompt-request", () =>
window.value.webContents.send(SSH_PASSWORD_PROMPT_CHANNEL, promptRequest),
);
- const unavailableAfterSend = yield* runPresentationOperation("check-window-after-send", () =>
- window.value.isDestroyed(),
- );
- if (unavailableAfterSend) {
- return yield* new DesktopSshPromptWindowUnavailableError({
- destination: input.destination,
- requestId,
- stage: "after-send",
- });
- }
- const minimized = yield* runPresentationOperation("check-window-minimized", () =>
- window.value.isMinimized(),
- );
- if (minimized) {
- yield* runPresentationOperation("restore-window", () => window.value.restore());
- }
- const unavailableAfterRestore = yield* runPresentationOperation(
- "check-window-after-restore",
- () => window.value.isDestroyed(),
- );
- if (unavailableAfterRestore) {
- return yield* new DesktopSshPromptWindowUnavailableError({
- destination: input.destination,
- requestId,
- stage: "after-restore",
- });
- }
- yield* runPresentationOperation("focus-window", () => window.value.focus());
+ // Once the prompt is sent the renderer can resolve the password at any
+ // scheduling boundary. The remaining steps only improve visibility
+ // (focus / restore) so their failures must not shadow an already-resolved
+ // password. Wrap them as best-effort; the window-closed listener and
+ // timeout still protect against a truly-gone window.
+ yield* Effect.gen(function* () {
+ const unavailableAfterSend = yield* runPresentationOperation(
+ "check-window-after-send",
+ () => window.value.isDestroyed(),
+ );
+ if (unavailableAfterSend) {
+ return yield* new DesktopSshPromptWindowUnavailableError({
+ destination: input.destination,
+ requestId,
+ stage: "after-send",
+ });
+ }
+ const minimized = yield* runPresentationOperation("check-window-minimized", () =>
+ window.value.isMinimized(),
+ );
+ if (minimized) {
+ yield* runPresentationOperation("restore-window", () => window.value.restore());
+ }
+ const unavailableAfterRestore = yield* runPresentationOperation(
+ "check-window-after-restore",
+ () => window.value.isDestroyed(),
+ );
+ if (unavailableAfterRestore) {
+ return yield* new DesktopSshPromptWindowUnavailableError({
+ destination: input.destination,
+ requestId,
+ stage: "after-restore",
+ });
+ }
+ yield* runPresentationOperation("focus-window", () => window.value.focus());
+ }).pipe(Effect.ignore);
return yield* waitForPassword;
}).pipe(Effect.ensuring(cleanup));
});You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 5ee7cfe. Configure here.
Co-authored-by: codex <codex@users.noreply.github.com>


Summary
Verification
Note
Medium Risk
Touches SSH authentication UX and error mapping in the desktop app; behavior changes around edge cases (window state, renderer send failures) but is well covered by new tests.
Overview
Desktop SSH password prompts now classify failures by which Electron step failed and when the window became unavailable, instead of lumping everything into one generic window-unavailable path.
DesktopSshPromptPresentationErrorgains anoperationlabel (e.g.send-prompt-request,check-window-before-request) and nullablerequestId;DesktopSshPromptWindowUnavailableErroraddsstage(before-request,after-send, etc.) and richer messages. Therequest()flow is split into labeled steps viarunPresentationOperation, avoids throwing typed errors insideEffect.try, and usesEffect.ensuringso pending prompts and window close listeners are always cleaned up.If the user submits a password before a later presentation step throws,
preferSubmittedPasswordstill returns the password instead of failing the request. New tests cover renderer send failures, pre-request window checks, cleanup after failed delivery, and the late-failure + early-resolve case.Reviewed by Cursor Bugbot for commit 32a8c28. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure SSH prompt presentation failures by operation and stage in desktop
DesktopSshPromptPresentationErrornow includes a requiredoperationfield (e.g.'check-window-before-request','send-prompt-request') and allows a nullablerequestIdfor failures that occur before an ID is generated.DesktopSshPromptWindowUnavailableErrornow carries astagefield ('before-request','before-presentation','after-send','after-restore') and arequestId, with a dynamic message that includes stage and destination context.request()inDesktopSshPasswordPrompts.tsnow performs staged window checks and wraps each presentation step in arunPresentationOperationhelper that attaches the specific failing operation to any thrown error.Macroscope summarized 32a8c28.