Skip to content

refactor: modularize supervisor.rs into focused submodules#175

Merged
jdx merged 1 commit intomainfrom
refactor/modularize-supervisor
Jan 19, 2026
Merged

refactor: modularize supervisor.rs into focused submodules#175
jdx merged 1 commit intomainfrom
refactor/modularize-supervisor

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

  • Split the 1,715-line supervisor.rs into a supervisor/ directory with focused modules
  • No functional changes - public API remains unchanged
  • All 77 tests pass

New Module Structure

Module Lines Purpose
mod.rs ~115 Supervisor struct, public API, startup/shutdown, refresh orchestration, signals
state.rs ~125 State access layer - all daemon/shell CRUD operations
lifecycle.rs ~470 run(), run_once(), stop() - process spawning and monitoring
autostop.rs ~120 Autostop logic, boot daemon startup
retry.rs ~85 Retry logic with exponential backoff
watchers.rs ~270 Background tasks (interval, cron, file watching)
ipc_handlers.rs ~70 IPC request dispatch

Test plan

  • All 77 tests pass (cargo nextest run)
  • No clippy warnings (cargo clippy --all-targets --all-features -- -D warnings)
  • Format checks pass (cargo fmt --check)

🤖 Generated with Claude Code


Note

Reorganizes the supervisor into cohesive modules for clarity and maintainability with no behavioral changes.

  • Introduces supervisor/mod.rs to wire startup, signals, refresh, IPC server, and shared state
  • Extracts state CRUD to state.rs (re-exports UpsertDaemonOpts)
  • Moves process lifecycle (run, run_once, stop) and regex cache to lifecycle.rs
  • Separates autostop and boot daemon startup into autostop.rs
  • Isolates retry/backoff logic in retry.rs and cron/interval/file watchers in watchers.rs
  • Splits IPC loop and request dispatch into ipc_handlers.rs
  • Removes src/supervisor.rs and maintains the same public API surface

Written by Cursor Bugbot for commit dfa78c9. This will update automatically on new commits. Configure here.

Split the 1,715-line supervisor.rs into a supervisor/ directory with
focused modules for better maintainability:

- mod.rs: Supervisor struct, public API, startup/shutdown, signals
- state.rs: State access layer (daemon/shell CRUD operations)
- lifecycle.rs: run(), run_once(), stop() - process spawning/monitoring
- autostop.rs: Autostop logic and boot daemon startup
- retry.rs: Retry logic with exponential backoff
- watchers.rs: Background tasks (interval, cron, file watching)
- ipc_handlers.rs: IPC request dispatch

No functional changes - public API remains unchanged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 19, 2026 18:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the monolithic 1,715-line supervisor.rs file into a modular directory structure with focused submodules, improving code organization and maintainability without changing functionality.

Changes:

  • Split supervisor.rs into seven focused modules under src/supervisor/
  • Moved helper functions and types to appropriate modules
  • Re-exported necessary types in mod.rs for backward compatibility

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/supervisor/mod.rs Main module file defining Supervisor struct, public API, and coordinating submodules
src/supervisor/state.rs State access layer for daemon/shell CRUD operations
src/supervisor/lifecycle.rs Core daemon lifecycle management (run, run_once, stop)
src/supervisor/autostop.rs Autostop logic and boot daemon startup functionality
src/supervisor/retry.rs Retry logic with exponential backoff for failed daemons
src/supervisor/watchers.rs Background tasks for interval, cron, and file watching
src/supervisor/ipc_handlers.rs IPC request dispatch and handling
src/supervisor.rs Removed original monolithic file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jdx jdx merged commit 6874350 into main Jan 19, 2026
4 checks passed
@jdx jdx deleted the refactor/modularize-supervisor branch January 19, 2026 18:31
@jdx jdx mentioned this pull request Jan 19, 2026
jdx added a commit that referenced this pull request Jan 20, 2026
## 🤖 New release

* `pitchfork-cli`: 1.1.0 -> 1.2.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [1.2.0](v1.1.0...v1.2.0) -
2026-01-19

### Added

- enhance miette error diagnostics with source highlighting and URLs
([#183](#183))
- add structured IPC error types with miette diagnostics
([#181](#181))
- add structured config error types with file path context
([#182](#182))
- add config editor to TUI for creating and editing daemons
([#171](#171))
- add custom diagnostic error types with miette
([#180](#180))

### Other

- improve miette error handling adoption
([#177](#177))
- modularize supervisor.rs into focused submodules
([#175](#175))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Release 1.2.0**
> 
> - Bump version to `1.2.0` in `Cargo.toml`, `Cargo.lock`,
`docs/cli/commands.json`, `docs/cli/index.md`, and `pitchfork.usage.kdl`
> - Regenerate CLI docs/usage specs to reflect the new version
> - Update `CHANGELOG.md` with highlights: enhanced `miette` diagnostics
(source highlighting, URLs), structured IPC/config error types, custom
diagnostic errors, TUI config editor; plus adoption improvements and
supervisor modularization
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
32b3259. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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