* Implement proactive welcome agent for onboarding experience
- Added a new module `welcome_proactive` to handle immediate welcome messages after user onboarding completion, enhancing user engagement.
- Updated `set_onboarding_completed` to trigger the proactive welcome agent upon onboarding status change, ensuring timely delivery of welcome messages.
- Refactored the onboarding process to streamline the integration of proactive messaging, improving overall user experience.
- Enhanced documentation and logging for better observability of the onboarding flow and proactive message handling.
- Introduced tests to validate the functionality of the new welcome agent and its integration into the onboarding process.
* fix(socketio): auto-join "system" room so proactive messages reach clients
The proactive message subscriber emits with `client_id="system"`, but
connected Socket.IO clients only auto-joined a room named after their
own sid — so the welcome agent's message was published into an empty
room and never reached any frontend.
Adds `socket.join("system")` at connect time alongside the existing
per-sid join, so every client now receives broadcast proactive events
(welcome agent, morning briefing, cron announcements).
Also adds scripts/test-proactive-welcome.sh — end-to-end smoke test
that resets onboarding flags, spawns a fresh core on port 7789,
connects a Socket.IO listener, fires the RPC, and reports pass/miss
for every checkpoint in the pipeline including client-side delivery.
* fix(welcome): PR review — tighter gating, legacy-cron prune, safer harness
- Gate proactive welcome spawn on `!was_chat_completed` so a user
whose chat flow already completed (legacy tool path or manual flip)
doesn't get a second welcome.
- Prune legacy `welcome` cron jobs in `seed_proactive_agents`: one-
shot entries left behind by an interrupted earlier run would
otherwise double-deliver once the scheduler picks them up. Added
a unit test covering the prune + morning-briefing seed in the same
call.
- Add a post-publish debug log in `welcome_proactive::run_proactive_welcome`
so "reached end successfully" is distinguishable from "silently
bailed above" by reading the log alone.
- Replace ignored `socket.join(...)` results with a helper that logs
success + failure per room + client id. Silent join failures on the
"system" room make proactive delivery vanish without a trace.
- Harden the test harness:
* Back up CONFIG_PATH before mutating and restore on exit so the
developer's staging profile is never permanently changed (unless
`--keep-flags` is passed).
* Tolerate inline comments + trailing whitespace in the TOML
rewrite; append-at-end instead of prepend when a key is missing,
so the rewrite can't accidentally land inside a section header.
Not applied:
- Unit tests for `run_proactive_welcome` empty-response / serialization-
failure paths: empty response is already `anyhow::bail!`-guarded, and
the serde_json failure branch is unreachable given a `json!`-built
value. Testing either requires mocking `Agent::from_config_for_agent`
which has heavy registry/provider dependencies — cost > value.