User problem
When Codegraff starts a localhost development/demo server, that server can remain alive for days after the user has stopped looking at it. It is easy to forget because it runs silently in an old terminal/session. Over time, multiple dev servers, file watchers, HMR workers, and related descendants can accumulate and consume memory, CPU, battery, ports, and thermal headroom without the user realizing it.
This was observed during the investigation in #198: a Next.js server on port 3002 had been alive for more than three days. It was mostly CPU-idle, but still retained memory, workers, file watchers, open browser connections, and a port. The broader machine had accumulated many other stale session-owned processes as well.
Feature request
Codegraff should supervise localhost servers that it starts and apply an explicit idle lifecycle, for example:
- Running while the server is actively being used.
- Paused/sleeping after a configurable period with no meaningful user traffic or interaction.
- Stopped after a longer configurable idle period.
The exact defaults and pause mechanism are open to design, but the default should prevent forgotten localhost servers from running indefinitely and invisibly.
Important behavior
- Track the complete process group/tree, not only the initial
npm/shell PID.
- Record the command, cwd, detected listening ports, owning Codegraff session, start time, and last meaningful activity.
- Do not treat HMR/WebSocket keepalives from a forgotten browser tab as meaningful user activity forever.
- Warn visibly before pausing/stopping and log what happened.
- Provide an easy resume/restart action using the original command.
- Allow users to pin/keep alive a server that intentionally needs to run indefinitely.
- Make pause and stop thresholds configurable globally and per server/project.
- On Codegraff/session exit, either stop the server tree or explicitly transfer/retain it with user confirmation.
- Only manage processes launched and owned by Codegraff. Never stop an unrelated service merely because it listens on localhost.
UI/CLI visibility
There should be a place to see managed background resources, such as:
localhost:3002 my-website next dev idle 42m [Resume] [Stop] [Keep alive]
A CLI equivalent such as graff processes, graff servers, or graff cleanup would help users discover and clean up forgotten work.
Design note: “pause”
A raw SIGSTOP would retain memory and the port and cannot itself detect a new request. Alternatives could include:
- suspend and require manual/UI resume;
- terminate the real server while a lightweight supervisor retains metadata and offers one-click restart; or
- keep a lightweight port proxy that restarts the server on the next request.
The implementation should make the state clear rather than claiming a process is paused while it still consumes substantial resources.
Acceptance criteria
Related lifecycle/process-leak report: #198.
User problem
When Codegraff starts a localhost development/demo server, that server can remain alive for days after the user has stopped looking at it. It is easy to forget because it runs silently in an old terminal/session. Over time, multiple dev servers, file watchers, HMR workers, and related descendants can accumulate and consume memory, CPU, battery, ports, and thermal headroom without the user realizing it.
This was observed during the investigation in #198: a Next.js server on port 3002 had been alive for more than three days. It was mostly CPU-idle, but still retained memory, workers, file watchers, open browser connections, and a port. The broader machine had accumulated many other stale session-owned processes as well.
Feature request
Codegraff should supervise localhost servers that it starts and apply an explicit idle lifecycle, for example:
The exact defaults and pause mechanism are open to design, but the default should prevent forgotten localhost servers from running indefinitely and invisibly.
Important behavior
npm/shell PID.UI/CLI visibility
There should be a place to see managed background resources, such as:
A CLI equivalent such as
graff processes,graff servers, orgraff cleanupwould help users discover and clean up forgotten work.Design note: “pause”
A raw
SIGSTOPwould retain memory and the port and cannot itself detect a new request. Alternatives could include:The implementation should make the state clear rather than claiming a process is paused while it still consumes substantial resources.
Acceptance criteria
Related lifecycle/process-leak report: #198.