Repository navigation
Description
Summary
Add lifecycle management for dashboard utility runtimes so cwd-keyed helper processes do not remain cached indefinitely after they become idle.
Discovered while reviewing the scoped-model dashboard work in #433.
Current behavior
Dashboard endpoints that need a project-specific utility runtime call ensureUtilityRuntime(cwd). The runtime pool starts and caches one helper child process for each distinct cwd.
The cached process is reused for later requests to the same cwd, but it is only removed when the dashboard shuts down. There is currently:
- no idle timeout;
- no upper bound on the utility-runtime cache;
- no reuse of an existing live session runtime for the same cwd.
The scoped-model editor makes this path more visible because changing project context loads settings and models through a cwd-specific utility runtime.
User impact
A normal user will usually notice nothing. During a long-running dashboard session, however, visiting settings for many project folders can leave one background helper process running for every visited folder. The dashboard may also retain both a live session runtime and a separate utility runtime for the same project.
This can gradually increase process count and memory use. A paired local client could also deliberately request many existing directories and accelerate that accumulation.
This is not currently known to cause data loss or incorrect settings.
Proposed behavior
Manage cwd-keyed utility runtimes as bounded, reusable resources. Possible approaches include:
- stop and remove utility runtimes after an idle timeout;
- enforce a bounded least-recently-used cache;
- safely reuse an existing same-cwd runtime where its ownership and lifecycle permit it;
- combine these approaches.
The implementation must not terminate a helper while a request is active or couple utility-runtime lifetime unsafely to a user session.
Acceptance criteria
- Utility runtimes that are no longer in use do not remain alive indefinitely.
- Eviction never interrupts an active request.
- A later request for an evicted cwd starts or acquires a usable runtime transparently.
- Runtime shutdown removes cached entries and child processes cleanly.
- Repeated access to the same cwd does not create duplicate utility helpers.
- Tests cover idle eviction, reuse, concurrent requests, shutdown, and recreation after eviction.
- Runtime lifecycle behavior and configuration are documented where appropriate.
Activity