fix(local-llm): stop the managed daemon when the last session exits
Open Source Local First Ai Agent
Brought to you by:
sosidudku
Originally created by: sosidudku1
Closes [#52].
The managed llama-server is spawned detached so it survives the CLI on purpose, and the clean-exit path (q, Ctrl+C, SIGTERM) already stops it. The complaint in [#52] turned out to be the terminal-close path: closing the window sends SIGHUP, which had no handler, so the process died before orchestrator.shutdown() ran and the daemon kept holding RAM/VRAM until a manual models stop.
localModels.managed.stopOnExit flag, default true. Closing the last session frees the memory; false keeps the model warm between sessions for operators who prefer the old behavior. Config v33 → v34; older files transparently inherit true. Standalone daemons started with atomic-agent models start are never touched, same as before.<dataDir>/sessions/<pid> marker files, same liveness pattern as telegram-lockfile.ts): only the last live session stops the daemon. This also fixes a pre-existing bug: with two parallel TUI windows, the first one to exit killed the model out from under the second. Stale markers from crashed sessions are reclaimed on scan.session-registry.test.ts: register/release, own-pid exclusion, live-other detection (via process.ppid), stale-marker reclamation.stopOnExit: false, leaves the daemon alone while another live session exists, never touches an unsupervised daemon.false, v33 file inheriting true.tsc --noEmit clean; full suite has the same pre-existing failures as main (verified against a clean checkout).ps shows llama-server gone.stopOnExit: false: daemon survives exit and the next TUI start adopts the warm model.This PR and the telegram follow-up both bump USER_CONFIG_VERSION 33 → 34 for their own field. Whichever merges second gets a trivial rebase to 35.
Ticket changed by: Ooooze