Skip to content

fix(desktop): restore auto-restart of stale daemon in dev mode#1032

Merged
Kitenite merged 1 commit into
mainfrom
kiet-ho/connection-error-dev
Jan 28, 2026
Merged

fix(desktop): restore auto-restart of stale daemon in dev mode#1032
Kitenite merged 1 commit into
mainfrom
kiet-ho/connection-error-dev

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 28, 2026

Summary

  • Restores the mtime-based detection that automatically restarts the terminal daemon when the script is rebuilt in dev mode
  • Fixes connection errors that occur when the daemon gets out of sync with the app after code changes
  • Partially reverts fix(desktop): remove auto-restart of terminal daemon in dev mode #897, keeping the pty-subprocess.ts fix (waiting for tree-kill callback)

Test plan

  • Run desktop app in dev mode
  • Make a change to terminal-host code and let it rebuild
  • Verify daemon automatically restarts on next terminal connection
  • Verify no connection errors occur

Summary by CodeRabbit

  • Chores
    • Enhanced daemon restart handling during development to automatically detect and recover from script rebuilds, improving stability when internal components change.

✏️ Tip: You can customize this high-level summary in your review settings.

Partially reverts 8b5cbc4 to restore the mtime-based detection that
automatically restarts the terminal daemon when the script is rebuilt
in development mode. This fixes connection errors that occur when the
daemon gets out of sync with the app after code changes.

Keeps the pty-subprocess.ts fix from the original commit (waiting for
tree-kill callback before exiting).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

A development mode enhancement that detects when the daemon script has been rebuilt and automatically restarts the daemon. The implementation tracks the daemon script's modification time and triggers a restart during connection attempts if changes are detected.

Changes

Cohort / File(s) Summary
Daemon Script Staleness Detection
apps/desktop/src/main/lib/terminal-host/client.ts
Added SCRIPT_MTIME_PATH constant, isDaemonScriptStale() and saveDaemonScriptMtime() private methods for tracking daemon script modifications. Integrated staleness check into dev-mode connection flow to detect rebuilt daemons, kill via PID file, spawn replacement, and record new mtime. Applied same logic in both dev branches of connect-and-authenticate workflow.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A daemon grows stale, the script's been rebuilt,
We check its timestamp with whisker-twitched guilt,
If mtime has shifted, we swiftly restart,
A fresh spawn awaits—development's art! 🔄✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(desktop): restore auto-restart of stale daemon in dev mode' accurately and clearly describes the main change: restoring auto-restart functionality for a stale daemon in development mode.
Description check ✅ Passed The pull request description includes a clear summary of changes, explains the problem being fixed, and provides a detailed test plan. It adequately covers the purpose and validation approach for the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Kitenite Kitenite merged commit ebb05c2 into main Jan 28, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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