Skip to content

Fix desktop health flaps#1028

Merged
RhysSullivan merged 1 commit into
mainfrom
codex/fix-desktop-health-flaps
Jun 15, 2026
Merged

Fix desktop health flaps#1028
RhysSullivan merged 1 commit into
mainfrom
codex/fix-desktop-health-flaps

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Fixes desktop supervised daemon health flaps.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing ea93002 Commit Preview URL

Branch Preview URL
Jun 15 2026, 06:41 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud ea93002 Jun 15 2026, 06:42 AM

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@RhysSullivan RhysSullivan marked this pull request as ready for review June 15, 2026 06:44
@RhysSullivan RhysSullivan merged commit 49e1675 into main Jun 15, 2026
13 checks passed
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes supervised daemon health "flaps" — transient slow health responses were causing the desktop to incorrectly show the crash overlay and remove the daemon's manifest. The fix adds a miss counter that requires three consecutive failed health probes before declaring the daemon down, and stops deleting the manifest when the PID is still alive but the health endpoint is momentarily slow.

  • index.ts: Adds supervisedMonitorMisses (threshold 3) so a single slow or timed-out probe no longer triggers the crash overlay; the counter resets to 0 on any successful attach.
  • sidecar.ts: Preserves the server.json manifest when the daemon PID is alive but the health probe fails, so launchd-restarted daemons can reconnect instead of requiring a desktop restart; manifest is still removed when the PID is confirmed dead.
  • diagnostics.ts / e2e test: Adds ~/.executor/logs to the diagnostic zip, and replaces the stale-manifest probe test with a slow-live-daemon probe that validates the new debounce behavior while retaining the bearer-token security assertion.

Confidence Score: 5/5

Safe to merge — the changes are narrowly scoped to the supervised-daemon health-check path, the bearer-token security property is still validated by the updated e2e test, and the diagnostics addition is purely additive.

All three changed code paths (miss counter, manifest preservation, diagnostics export) are simple and correct. The new e2e scenario exercises the debounce path end-to-end and retains the bearer-token assertion from the test it replaces. The collectFiles function already handles a missing executor-logs directory gracefully.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/main/index.ts Adds a miss counter with a threshold of 3 before marking the supervised daemon as down; resets on successful attach and on monitor stop. Clean debounce implementation.
apps/desktop/src/main/sidecar.ts Stops removing the manifest when the daemon PID is alive but the health probe times out; only removes the manifest when the PID is dead. Log level upgraded from info to warn.
apps/desktop/src/main/diagnostics.ts Adds ~/.executor/logs to the diagnostics zip and manifest; collectFiles already handles a non-existent directory gracefully via try-catch.
e2e/desktop-packaged/supervised-regressions.test.ts Replaces the stale-manifest removal test with a slow-live-daemon test; retains bearer-token security assertions and adds new assertions verifying no crash overlay on transient slow probes and manifest survival.

Sequence Diagram

sequenceDiagram
    participant Timer as setInterval (10 s)
    participant Monitor as armSupervisedMonitor
    participant Sidecar as attachToSupervisedDaemon
    participant Health as isDaemonReachable
    participant UI as Main Window

    Note over Timer,UI: Normal operation
    Timer->>Monitor: tick
    Monitor->>Sidecar: attachToSupervisedDaemon()
    Sidecar->>Health: GET /api/health (1.5 s timeout x3)
    Health-->>Sidecar: 200 ok
    Sidecar-->>Monitor: SidecarConnection
    Monitor->>Monitor: "supervisedMonitorMisses = 0"

    Note over Timer,UI: Transient flap
    Timer->>Monitor: tick
    Monitor->>Sidecar: attachToSupervisedDaemon()
    Sidecar->>Health: GET /api/health - times out
    Health-->>Sidecar: false (PID alive, keep manifest)
    Sidecar-->>Monitor: null
    Monitor->>Monitor: "misses++ (1 < 3) return early"

    Timer->>Monitor: tick (miss 3)
    Monitor->>Sidecar: attachToSupervisedDaemon()
    Sidecar-->>Monitor: null
    Monitor->>Monitor: "misses++ (3 >= 3)"
    Monitor->>UI: show crash overlay

    Note over Timer,UI: Daemon recovers
    Timer->>Monitor: tick
    Monitor->>Sidecar: attachToSupervisedDaemon()
    Sidecar->>Health: GET /api/health
    Health-->>Sidecar: 200 ok
    Sidecar-->>Monitor: SidecarConnection
    Monitor->>Monitor: "supervisedMonitorMisses = 0"
    Monitor->>UI: reload original URL
Loading

Reviews (1): Last reviewed commit: "Fix desktop supervised daemon health fla..." | Re-trigger Greptile

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.

1 participant