Skip to content

Conversation

@Kitenite
Copy link
Collaborator

@Kitenite Kitenite commented Jan 18, 2026

Summary

  • Add "Restart daemon" option in terminal settings page to restart the background terminal daemon process
  • Spawn daemon immediately when terminal persistence is enabled (no app restart needed)
  • Refactor restart daemon logic into shared helper function used by both tray and settings

Changes

  • Settings router: Spawn daemon when terminal persistence is enabled
  • Terminal router: Add restartDaemon mutation
  • Terminal host client: Add shared restartDaemon() helper, handle expected "Connection lost" error in shutdownIfRunning
  • Tray: Use shared restartDaemon() helper
  • Terminal settings page: Add "Restart daemon" section with description and button

Test plan

  • Enable terminal persistence toggle → daemon should spawn immediately
  • Click "Restart daemon" button → shows confirmation dialog
  • Confirm restart → kills all sessions and restarts daemon
  • Verify tray "Restart Daemon" menu item still works

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new "Restart Daemon" option in Terminal Settings to restart the terminal daemon with a confirmation dialog.
    • Terminal persistence now automatically ensures the daemon connection is established when enabled.
  • Improvements

    • Enhanced error handling for daemon shutdown operations to gracefully handle connection loss scenarios.

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

- Add "Restart daemon" section in terminal settings page
- Spawn daemon immediately when terminal persistence is enabled
- Refactor restart daemon logic into shared helper function
- Handle "Connection lost" error in shutdownIfRunning (expected when daemon shuts down)
- Invalidate daemon sessions query after toggling terminal persistence
@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

Warning

Rate limit exceeded

@Kitenite has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 916946e and 8390c4b.

📒 Files selected for processing (1)
  • apps/desktop/src/main/lib/terminal/index.ts
📝 Walkthrough

Walkthrough

This PR adds a daemon restart feature to terminal settings, making the setTerminalPersistence mutation asynchronous to ensure the terminal host client connects when enabling persistence, adding a new restartDaemon procedure to the terminal router, enhancing error handling in the terminal host client, and integrating restart UI with confirmation dialogs and optimistic updates in the settings page.

Changes

Cohort / File(s) Summary
Backend Routing
apps/desktop/src/lib/trpc/routers/settings/index.ts, apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
Enhanced settings router's setTerminalPersistence to async with post-update daemon connection side effect; introduced new restartDaemon mutation in terminal router with error handling and daemon-mode-enabled response.
Terminal Host Client
apps/desktop/src/main/lib/terminal-host/client.ts
Improved error handling in shutdownIfRunning to gracefully handle connection-lost scenarios; added new restartDaemon utility function that calls shutdown with session termination.
System Integration
apps/desktop/src/main/lib/tray/index.ts
Updated tray's restartDaemon to invoke the dedicated restartDaemonClient instead of direct client shutdown logic.
Terminal Settings UI
apps/desktop/src/renderer/routes/_authenticated/settings/terminal/page.tsx
Added restartDaemon mutation hook with optimistic UI updates, confirmation dialog state, error recovery logic, and new restart daemon section with button and confirmation AlertDialog component.

Sequence Diagram

sequenceDiagram
    participant User
    participant SettingsUI as Settings UI
    participant Router as TRPC Router
    participant HostClient as TerminalHostClient
    participant Daemon as Terminal Daemon

    User->>SettingsUI: Click "Restart Daemon"
    SettingsUI->>SettingsUI: Show confirmation dialog
    User->>SettingsUI: Confirm restart
    SettingsUI->>SettingsUI: Optimistic update (daemonEnabled: true, sessions: [])
    SettingsUI->>Router: Call restartDaemon mutation
    Router->>HostClient: restartDaemon()
    HostClient->>Daemon: shutdownIfRunning(killSessions: true)
    alt Daemon responds
        Daemon-->>HostClient: Connection lost (expected)
        HostClient->>HostClient: Handle gracefully
    else Connection error
        HostClient->>HostClient: Log error
    end
    HostClient-->>Router: Return success/failure
    Router-->>SettingsUI: Mutation complete
    SettingsUI->>SettingsUI: Show toast + refresh sessions
    SettingsUI->>User: Display updated state
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • AviPeltz

🐰 A hop through the settings, a dance with the daemon,
Restart buttons bloom where none had lain on,
Optimistic dreams, dialogues sweet,
Async/await waltz makes the restart complete!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature being added: a restart daemon option in terminal settings, matching the primary changes across all modified files.
Description check ✅ Passed The PR description provides a clear summary of changes, lists all modified components, and includes a test plan with checkboxes, following the repository's template structure with relevant sections filled out.

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


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 closed this Jan 19, 2026
@Kitenite Kitenite deleted the add-settings-restart-daemon branch January 19, 2026 00:32
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.

2 participants