fix(session): Auto-accept Claude bypass permissions warning dialog

When Claude starts with --dangerously-skip-permissions, it shows a warning
dialog requiring Down+Enter to accept. This blocked automated polecat and
agent startup.

Added AcceptBypassPermissionsWarning() to tmux package that:
- Checks if the warning dialog is present by capturing pane content
- Only sends Down+Enter if "Bypass Permissions mode" text is found
- Avoids interfering with sessions that don't show the warning

Updated all Claude startup locations:
- session/manager.go (polecat sessions)
- cmd/up.go (mayor, witness, crew, polecat cold starts)
- daemon/daemon.go (crashed polecat restarts)
- daemon/lifecycle.go (role session starts)
This commit is contained in:
kustrun
2026-01-02 20:27:26 +01:00
parent 3c4190597f
commit 94857fc913
5 changed files with 78 additions and 2 deletions

View File

@@ -193,12 +193,18 @@ func (m *Manager) Start(polecat string, opts StartOptions) error {
// Non-fatal warning - Claude might still start
}
// Accept bypass permissions warning dialog if it appears.
// When Claude starts with --dangerously-skip-permissions, it shows a warning that
// requires pressing Down to select "Yes, I accept" and Enter to confirm.
// This is needed for automated polecat startup.
_ = m.tmux.AcceptBypassPermissionsWarning(sessionID)
// Wait for Claude to be fully ready at the prompt (not just started)
// PRAGMATIC APPROACH: Use fixed delay rather than detection.
// WaitForClaudeReady has false positives (detects > in various contexts).
// Claude startup takes ~5-8 seconds on typical machines.
// 10 second delay is conservative but reliable.
time.Sleep(10 * time.Second)
// Reduced from 10s to 8s since AcceptBypassPermissionsWarning already adds ~1.2s.
time.Sleep(8 * time.Second)
// Inject startup nudge for predecessor discovery via /resume
// This becomes the session title in Claude Code's session picker