Skip to content

fix(desktop): remove auto-restart of terminal daemon in dev mode#897

Merged
Kitenite merged 2 commits into
mainfrom
kill-sig
Jan 22, 2026
Merged

fix(desktop): remove auto-restart of terminal daemon in dev mode#897
Kitenite merged 2 commits into
mainfrom
kill-sig

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 22, 2026

Summary

  • Remove the stale daemon detection logic that was killing and restarting the daemon on every app restart in development mode
  • Fix race condition in pty-subprocess dispose handler (wait for tree-kill callback before exiting)

Why

The mtime-based stale check was causing the daemon to restart on every app restart, and also caused issues when switching between git worktrees (ENOENT errors for the old Electron binary path).

Test plan

  • Start the app in dev mode, open a terminal
  • Restart the app - terminal session should persist
  • Kill the daemon manually via tray menu - should work

Summary by CodeRabbit

  • Bug Fixes
    • Streamlined daemon startup process and improved process cleanup behavior to ensure proper resource termination.

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

Remove the stale daemon detection logic that was killing and restarting
the daemon on every app restart in development. This was causing
unexpected terminal disconnections and issues when switching between
git worktrees.

The daemon now persists across app restarts. If users switch worktrees
and encounter issues, they can manually restart via the tray menu.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

This pull request removes daemon rebuild-detection logic from the terminal host client and refines subprocess disposal flow to ensure proper process cleanup. The changes eliminate script modification time tracking and related restart mechanisms in development mode, while adjusting the PTY subprocess handler to clear process references before invoking tree-kill.

Changes

Cohort / File(s) Summary
Terminal Host Client
apps/desktop/src/main/lib/terminal-host/client.ts
Removed SCRIPT_MTIME_PATH constant, isDaemonScriptStale() and saveDaemonScriptMtime() helper methods. Eliminated development-mode daemon restart logic in connectAndAuthenticate() and post-spawn mtime persistence in spawnDaemon().
PTY Subprocess Handler
apps/desktop/src/main/terminal-host/pty-subprocess.ts
Adjusted handleDispose() to clear ptyProcess before initiating tree-kill, return early, and move process.exit(0) from unconditional path into tree-kill callback. Ensures process tree termination precedes application exit.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A daemon's script no longer watched,
No restarts when timestamps are notched,
We cleared the mtime, let it rest,
And cleanup flows now pass the test—
Simpler paths, more stable quest! 🌿

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required template structure with sections like 'Description', 'Related Issues', 'Type of Change', 'Testing', and 'Additional Notes'. Restructure the description to follow the template format, including standard sections like Type of Change (mark 'Bug fix'), Testing details, and any related issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: removing auto-restart logic for the terminal daemon in development mode, which aligns with the primary modifications in the changeset.

✏️ 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 8b5cbc4 into main Jan 22, 2026
5 checks passed
@Kitenite Kitenite deleted the kill-sig branch January 22, 2026 08:25
@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