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:
@@ -265,6 +265,46 @@ func (t *Tmux) NudgePane(pane, message string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AcceptBypassPermissionsWarning dismisses the Claude Code bypass permissions warning dialog.
|
||||
// When Claude starts with --dangerously-skip-permissions, it shows a warning dialog that
|
||||
// requires pressing Down arrow to select "Yes, I accept" and then Enter to confirm.
|
||||
// This function checks if the warning is present before sending keys to avoid interfering
|
||||
// with sessions that don't show the warning (e.g., already accepted or different config).
|
||||
//
|
||||
// Call this after starting Claude and waiting for it to initialize (WaitForCommand),
|
||||
// but before sending any prompts.
|
||||
func (t *Tmux) AcceptBypassPermissionsWarning(session string) error {
|
||||
// Wait for the dialog to potentially render
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
// Check if the bypass permissions warning is present
|
||||
content, err := t.CapturePane(session, 30)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Look for the characteristic warning text
|
||||
if !strings.Contains(content, "Bypass Permissions mode") {
|
||||
// Warning not present, nothing to do
|
||||
return nil
|
||||
}
|
||||
|
||||
// Press Down to select "Yes, I accept" (option 2)
|
||||
if _, err := t.run("send-keys", "-t", session, "Down"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Small delay to let selection update
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
// Press Enter to confirm
|
||||
if _, err := t.run("send-keys", "-t", session, "Enter"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPaneCommand returns the current command running in a pane.
|
||||
// Returns "bash", "zsh", "claude", "node", etc.
|
||||
func (t *Tmux) GetPaneCommand(session string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user