Skip to content

fix: auto-restart daemon when CLI binary is rebuilt#41

Merged
piotrski merged 3 commits intomainfrom
fix/daemon-auto-restart
Mar 16, 2026
Merged

fix: auto-restart daemon when CLI binary is rebuilt#41
piotrski merged 3 commits intomainfrom
fix/daemon-auto-restart

Conversation

@piotrski
Copy link
Copy Markdown
Collaborator

Summary

  • Detect when daemon.js has been rebuilt since the running daemon started (by comparing file mtime against startedAt timestamp)
  • Automatically stop and restart the daemon so CLI commands always run against the latest code
  • Eliminates the need to manually stop/start after every rebuild during development

Test plan

  • bun run build then run any CLI command — daemon should restart automatically
  • Verify status shows a fresh uptime after rebuild
  • Without rebuilding, CLI commands should reuse the existing daemon (no restart)

🤖 Generated with Claude Code

piotrski and others added 2 commits March 16, 2026 15:26
After a rebuild, the daemon keeps running old code. Now ensureDaemon()
compares daemon.js mtime against the daemon's startedAt timestamp and
restarts automatically if the script is newer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: daf3fcf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-react-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@piotrski piotrski merged commit 68bd0fc into main Mar 16, 2026
4 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51fc92ee4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +55 to +57
if (stat.mtimeMs > info.startedAt) {
// Daemon is stale — restart it
stopDaemon();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve daemon port when auto-restarting stale process

When the stale-daemon path runs here, ensureDaemon stops the existing daemon but then falls through to startup using only the function argument port; for most CLI commands that call ensureDaemon() (see cli.ts non-start path), this is undefined, so a daemon that was originally started on a custom port is silently restarted on the default 8097. After a rebuild, users on non-default ports will lose their connection target and see unexpected disconnect/no-app behavior. Reuse info.port during auto-restart unless an explicit port override was passed.

Useful? React with 👍 / 👎.

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