Skip to content

Improve tmux idle detection with robust prompt recognition#4

Open
jsell-rh wants to merge 1 commit intomarkturansky:mainfrom
jsell-rh:fix/idle-detection-claude-code
Open

Improve tmux idle detection with robust prompt recognition#4
jsell-rh wants to merge 1 commit intomarkturansky:mainfrom
jsell-rh:fix/idle-detection-claude-code

Conversation

@jsell-rh
Copy link

@jsell-rh jsell-rh commented Mar 6, 2026

Summary

  • Rewrite tmuxIsIdle() to recognize a comprehensive set of idle indicators beyond just the Claude Code > prompt
  • Fix false "busy" detection when Claude Code auto-suggests a prompt after the character
  • Change default-on-error behavior from "assume busy" to "assume idle" to prevent agents from being falsely skipped during broadcasts

New idle patterns recognized

  • Shell prompts: $, %, #, >, , » with false-positive guards (rejects =>, ->, 50%, line #3)
  • Claude Code with suggestion: lines starting with are idle regardless of trailing text
  • Claude Code vim-mode status bar: -- INSERT --, -- NORMAL --
  • OpenCode status bar: ctrl+p commands
  • Heavy box-drawing: (U+2503) in addition to light (U+2502)
  • Generic keywords: "waiting for input", "ready", "type a message", "press enter"

Changes

  • internal/coordinator/tmux.go: New lineIsIdleIndicator() and isShellPrompt() functions, rewritten tmuxIsIdle()
  • internal/coordinator/server_test.go: 28 test cases for TestLineIsIdleIndicator, 16 for TestIsShellPrompt

Testing

  • All 37 tests pass with -race

Rewrite tmuxIsIdle to use a comprehensive set of idle indicators instead
of only matching the Claude Code '>' prompt. New patterns recognized:

- Shell prompts: $, %, #, >, ❯, » (with false-positive guards for
  '=>', '->', '50%', 'line #3')
- Claude Code ❯ prompt with auto-suggested text after it
- Claude Code vim-mode status bar ('-- INSERT --', '-- NORMAL --')
- OpenCode status bar ('ctrl+p commands')
- Generic idle keywords ('waiting for input', 'ready', etc.)
- Heavy box-drawing character ┃ (U+2503) in addition to light │ (U+2502)

Also changes the default-on-error behavior from 'assume busy' to
'assume idle', preventing agents from being falsely skipped during
broadcasts when pane capture fails transiently.

Includes comprehensive table-driven tests for lineIsIdleIndicator (28
cases) and isShellPrompt (16 cases).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant