Files
loki/scripts
g-butandClaude Sonnet 4.6 3ac1f017e6 fix(daemon): reliable switch_agent — poll /proc + Ctrl+C fallback
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>
2026-05-18 23:41:29 +02:00
..