GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(desktop): drive renderer recovery with an explicit state machine by Hona · Pull Request #61908 · anomalyco/opencode

Conversation

@Hona

@Hona Hona commented Nov 5, 2026

Copy link
Copy Markdown
Member

Replaces the showing flag, the wait mode and the while loop in recovery.ts, and the sampling flag and timers in unresponsive.ts, with one explicit machine in packages/desktop/src/main/windows/recovery-machine.ts. wireWindowRecovery(win, name, { relaunch, reveal }) keeps its signature, and the machine still emits { type: "reveal" } before every dialog, so the hidden-window reveal from #61743 stays intact.

Bugs

# Sequence on dev Now
1 The "not responding" dialog is open, then the renderer crashes or a main-frame load fails. if (showing) return drops the fatal dialog. The user clicks Keep Waiting and sees a dead window with no prompt. Priority terminated > load-failed > unresponsive. A higher-priority incident aborts the open dialog (AbortSignal), flushes the sampler and opens its own dialog. The aborted dialog's answer is stale by attempt.
2 Export Logs from the "not responding" dialog, and the renderer recovers during the export. After the export, if (wait && sampling) sampler.start() samples a healthy window for 15 s and the loop reopens "OpenCode is not responding". renderer.responsive in exporting clears the incident. The export finishes and the window goes idle.
3 The renderer recovers while the "not responding" dialog is open. Only the sampler stops; the modal stays over a working window. renderer.responsive closes the dialog and flushes the sampler.
4 collectJavaScriptCallStack() from hang 1 resolves during hang 2. active() checks only the boolean, so the stale stack lands in hang 2's samples and a second timer loop starts. Each sampling session has its own attempt; late results from an earlier session are ignored.
5 exportDebug hangs: showing stays true forever and suppresses every later dialog. Closing the window dismisses a fatal dialog with cancelId (Quit) and quits every window. Export is bounded by EXPORT_TIMEOUT_MS (30 s), then the dialog reopens. A dialog answered after the window is destroyed dispatches window.closed, not Quit.

State

type RecoveryState =
  | { status: "idle"; attempt: number }
  | { status: "sampling"; attempt: number; sample: SampleSession } // Keep Waiting while the 15 s sampler runs
  | { status: "dialog"; attempt: number; incident: RecoveryIncident; sample: SampleSession | undefined }
  | { status: "exporting"; attempt: number; incident: RecoveryIncident | undefined; resumeSampling: boolean }
  | { status: "closed" }

type RecoveryIncident =
  | { kind: "unresponsive" }
  | { kind: "load-failed"; url: string; code: number; description: string }
  | { kind: "terminated"; reason: string; exitCode: number | undefined }
stateDiagram-v2
  [*] --> idle
  idle --> dialog: unresponsive / load.failed / process.gone
  dialog --> dialog: higher-priority incident (abort + reopen)
  dialog --> idle: responsive (unresponsive only) / Keep Waiting
  dialog --> sampling: Keep Waiting while sampling
  sampling --> idle: responsive / sample window elapsed
  sampling --> dialog: new incident
  dialog --> exporting: Export Logs
  exporting --> exporting: responsive clears incident / higher-priority incident
  exporting --> dialog: export settled or timed out, incident present
  exporting --> idle: export settled, incident cleared
  dialog --> closed: Relaunch / Quit
  idle --> closed: window.closed
  sampling --> closed: window.closed
  dialog --> closed: window.closed
  exporting --> closed: window.closed
Loading
  • transitionRecovery is pure. createRecoveryDriver owns the sample, sampling-period and export timers and the dialog AbortController, and runs each command isolated so one throwing command cannot skip the next.
  • A replacement dialog waits for the aborted one to dismiss before it attaches to the window.
  • The Electron adapter in recovery.ts maps selectDialog(state) to nativeT copy. All desktop.recovery.* keys and English text are unchanged.

Deleted

  • recovery.ts: let showing, the wait parameter, the sampling local held across await, the while (!win.isDestroyed()) loop.
  • unresponsive.ts (whole file): sampling, sampleTimer, stopTimer, the mutable samples map.

Product calls

  • Fatal-dialog cancel (Escape) still means Quit, and Keep Waiting still keeps the sampler running. The only exception is a window that is already destroyed.
  • A second incident of the same priority is ignored while its dialog is open (same as dev).
  • When an export times out, the dialog reopens. The export keeps running in the background, and its late result is ignored.
  • A new hang that starts during an export (after the renderer recovered) reopens the dialog and starts sampling when the export settles, not mid-export.
  • New error log lines: failed to show recovery dialog, debug log export timed out, recovery command failed. failed to export debug logs is now scoped to window with the window name.

Deviations from the design

  • Commands do not carry delayMs; the driver reads the exported constants.
  • reveal runs before every open-dialog, including replacements and dialogs after an export. The reveal machine ignores it once the window is shown.
  • No Effect.addFinalizer in windowRecovery: it is not scoped, and each window's closed event already disposes its driver.
  • Dropped the isRecovering, isSampling and isRecoveryClosed selectors: nothing reads them.

Tests

recovery-machine.test.ts replays each bug through transitionRecovery, covers the priority matrix, stale dialog, export and sample results, and every exit (Relaunch, Quit, window close, export failure and timeout). Driver tests use fake timers for reveal ordering, dialog replacement, the destroyed-window Quit case and zero leaked timers.

The change is off the hot path, so it has no benchmark.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor">
  <rect x="20" y="6" width="200" height="60" opacity="0.35"/>
  <line x1="20" y1="14" x2="220" y2="14" opacity="0.35"/>
  <g opacity="0">
    <rect x="70" y="20" width="100" height="40" stroke-dasharray="3 2"/>
    <line x1="80" y1="30" x2="140" y2="30" opacity="0.6"/>
    <rect x="80" y="44" width="22" height="8" opacity="0.6"/>
    <rect x="109" y="44" width="22" height="8" opacity="0.6"/>
    <rect x="138" y="44" width="22" height="8" opacity="0.6"/>
    <animate attributeName="opacity" values="0;1;1;0;0" keyTimes="0;0.1;0.45;0.55;1" dur="4s" repeatCount="indefinite"/>
  </g>
  <g>
    <rect x="70" y="20" width="100" height="40" stroke-width="1.5"/>
    <line x1="80" y1="30" x2="150" y2="30"/>
    <line x1="80" y1="36" x2="130" y2="36" opacity="0.5"/>
    <rect x="80" y="44" width="22" height="8" fill="currentColor" fill-opacity="0.25"/>
    <rect x="109" y="44" width="22" height="8"/>
    <rect x="138" y="44" width="22" height="8"/>
    <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.5;0.6;0.92;1" dur="4s" repeatCount="indefinite"/>
  </g>
</svg>

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
fix(desktop): drive renderer recovery with an explicit state machine
6878e6a
@Hona
Hona requested a review from Brendonovich as a code owner November 5, 2026 03:40
Copilot AI balanced review requested due to automatic review settings November 5, 2026 03:40
Copilot AI reviewed Nov 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
opencodejr[bot]
opencodejr Bot reviewed Nov 5, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The change looks sound. I couldn't run it end to end: it's the Electron desktop app, and the sandbox has no display. In packages/desktop, the window tests pass (74). recovery-machine.test.ts passed three runs in a row, so the fake-timer driver tests look stable, and tsc -b is clean. I read transitionRecovery and the driver against each of the five bugs and found no regressions. Relaunch and Quit both leave the app (app.relaunch / app.quit), so making closed final is right. Logging samples when the window closes is safe because safeWindowURL handles a destroyed window. An aborted dialog's late answer is dropped, and its replacement waits for it to close. Electron 44 has Promise.try and the signal option on showMessageBox.

Public API: unchanged. Everything is internal to the desktop main process, and the desktop.recovery.* i18n keys are untouched.

No blocking concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Hona merged commit 483969a into dev Nov 5, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Hona
Hona deleted the recovery-machine branch November 5, 2026 03:45
@amrkmn amrkmn mentioned this pull request Nov 7, 2026
opencode 2.2.6 amrkmn/homebrew-tap#1217
Closed
1 task
This was referenced Nov 7, 2026
feat: opencode release v2.2.6 sprisa/opencode-server#84
Merged
Tool release: OpenCode 2 v2.2.6 (was v2.2.5) agent-sh/agnix#1808
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@opencodejr opencodejr[bot] opencodejr[bot] left review comments
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Hona
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.