Fix shell integration idle HEAD-change polling

Closed
LA
2mo ago
+195-100

Summary

  • add regression coverage for idle HEAD changes while shell integration is polling PR state
  • clear stale PR metadata and refresh git branch state when HEAD changes under an idle shell
  • replace the timeout poll loop with a single watchdog so hung gh probes do not spin in the shell timeout path

Testing

  • python3 tests/test_issue_1138_sidebar_pr_polling.py (pass)
  • ./scripts/setup.sh (pass, reused cached GhosttyKit.xcframework)
  • ./scripts/reload.sh --tag task-shell-integration-hot-path-sleeps (pass)

Issues

  • Task: ensure cmux shell integration or anywhere on hot paths do not have hangs/sleeps

Summary by cubic

Fixes idle HEAD-change handling so the shell clears stale PR badges and refreshes branch/dirty status immediately, even while idle. Improves reliability of PR polling in bash and zsh and adds a watchdog to stop hung gh probes.

  • Bug Fixes

    • Detect .git/HEAD changes during idle polling; clear PR state, refresh branch/dirty badge, and force a new probe (bash and zsh).
    • Add regression test for idle branch switch; report_pr now includes --branch.
  • Refactors

    • Replace per-second timeout loop with a watchdog that kills hung gh probes.
    • Extract helpers for HEAD tracking and branch reporting; unify behavior across bash/zsh.

Summary by CodeRabbit

  • Bug Fixes

    • Improved git branch detection and reporting in shell integrations for more responsive updates when switching branches.
    • Enhanced timeout handling for PR polling operations with watchdog-based constraints.
  • Tests

    • Expanded test coverage for branch switching scenarios, including idle state transitions.