Commit Graph

4 Commits

Author SHA1 Message Date
CheapestInference a81d376322 fix: robust foreground detection for macOS and multiple bug fixes
- Use `ps -o stat=` to check process foreground state directly,
  fixing macOS where tmux pane_current_command reports "zsh" instead
  of the child process. Falls back to pane_current_command safely.
- Fix print mode retry off-by-one (maxRetries=5 only gave 4 retries)
- Fix sendKeys failure leaving state unupdated (tight error loop)
- Validate customPatterns config entries (non-string/invalid regex crashed monitor)
- Parse "resets in: N hours" format (was detected but not time-parsed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 13:11:33 +02:00
CheapestInference 0652a23274 fix: improve foreground process detection for macOS compatibility
Expand default foreground command list beyond node/claude to include
npx, tsx, bun, deno. Log actual detected process name for debugging.
Add configurable foregroundCommands in ~/.claude-auto-retry.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 03:52:16 +02:00
CheapestInference db9f4f81af fix: multi-line TUI detection, stale scrollback, and false positives
The rate limit detection was fundamentally broken because Claude Code
renders rate limit messages across multiple lines in its TUI (Ink/React),
but all regex patterns required keywords on a single line.

Key fixes:
- Split detection into LIMIT_PATTERNS + RESET_PATTERNS with a 6-line
  sliding window, so multi-line TUI renders are detected correctly
- Capture only last 20 lines instead of 200 to avoid stale scrollback
- Add 30s post-retry cooldown to prevent re-detecting old messages
- Fix max-retries infinite loop (stay in waiting, check clear first)
- Add OSC/DCS sequence stripping for complete ANSI handling
- Parse relative times ("try again in 5 minutes") instead of 5h fallback
- Handle invalid timezones gracefully with fallback
- Fix zombie monitor on pane destruction (exit after 10 consecutive errors)
- Replace setInterval with recursive setTimeout to prevent concurrent ticks
- Restore user shell traps instead of clobbering them
- Remove overly broad /\blimit\b/ pattern that caused false positives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 10:58:16 +01:00
CheapestInference 1aad1e0313 feat: claude-auto-retry v0.1.0
Auto-retry Claude Code sessions when hitting Anthropic subscription rate limits.
Uses tmux monitoring + send-keys to detect rate limit messages, wait for reset,
and send "continue" automatically. Zero dependencies, zero workflow change.

- Shell wrapper intercepts `claude` command transparently
- Background monitor polls tmux pane for rate limit patterns
- Timezone-aware reset time parsing with DST safety
- Safe send-keys with foreground process verification
- --print mode: buffers output, retries cleanly for pipes
- Config validation prevents bad values from causing crashes
- 59 tests, 0 dependencies

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 11:43:36 +01:00