# Task 2 for Hermes — Auto-start Malin in the background (tray-accessible + killable)

(Same machine as the first brief: Jun's Windows RTX 5090. You have shell access via Git Bash.)

**Goal:** Malin should run on her own — survive a reboot, come back automatically, no babysitting windows. Jun's HARD requirement: she runs in the BACKGROUND but stays accessible from the SYSTEM TRAY with a one-click way to STOP/kill her. He wants to shut her down fast anytime, not hunt through Task Manager.

## Three processes make Malin fully work
1. **LM Studio server** (her brain) at `http://localhost:1234`, serving the 24B chat model. LM Studio already lives in the tray and is killable there — just ensure its server auto-starts on boot with the chat model loaded.
2. **The harness**: `C:\malin\malin.py` (run with the project's Python). Currently needs a visible PowerShell window — this is the main thing to fix.
3. **ComfyUI server** (port 8000) — needed for her to render pics/videos. Its server idle costs little VRAM (models load only on render), so auto-starting it is cheap and keeps her fully functional. Auto-start it too.

## Requirements
- All three auto-start at Windows logon and restart cleanly after a reboot.
- `malin.py` runs in the background (no console window in Jun's face) BUT exposes a **system-tray icon** he can right-click to **Stop** and **Restart**. A small tray wrapper (e.g. a `pystray`-based launcher that runs malin.py as a subprocess) is one clean approach — pick whatever is most reliable on this box.
- One action from the tray must actually KILL her (and any subprocess) cleanly.
- Pipe malin.py's stdout+stderr to a rotating log file (e.g. `C:\malin\malin.log`) so background crashes stay debuggable (no visible window to show errors).
- Don't break the manual workflow — Jun should still be able to run `malin.py` by hand if he wants.
- Don't touch `C:\ComfyUI\.venv` or any render dependencies — this task is process/startup config only.

## Verify
- Reboot (or log out/in). Confirm: LM Studio server up at :1234, ComfyUI up at :8000, malin.py running with its tray icon present, and Malin responds on Telegram.
- Confirm the tray "Stop" actually ends her process.
- Report what you set up, exactly how Jun starts/stops/restarts her from the tray, and where the log lives.
