mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 22:08:18 +01:00
Mirrors the reliability fix applied to the TypeScript switch-agent route
(aa3a743) for the daemon execution path (cloud → daemon → local zellij).
Previously execute_switch_agent used a fixed `sleep 1` after injecting
the quit command, with no verification the old agent actually exited.
If the agent was stuck on a permission dialog the new agent's launch
command would be typed straight into the running session.
Changes:
- cockpit-daemon.sh: adds _is_agent_running_in_dir() to scan /proc for
the outgoing agent by basename+cwd; replaces sleep 1 with a 2s poll
loop, then sends Ctrl+C (key 3) + 600ms grace if still alive.
- agent-hook-lib.sh: adds send_raw_key_to_tab() — raw keycode injection
reusing existing session-discovery logic, parallel to inject_prompt().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>