cc-continuity 0.3.52__tar.gz → 0.3.53__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/README.md +1 -1
  3. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/blink.py +70 -18
  5. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/blink_watch.py +42 -2
  6. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/ledger.py +8 -2
  7. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/progress_pane.py +11 -0
  8. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity.egg-info/PKG-INFO +1 -1
  9. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/pyproject.toml +1 -1
  10. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_blink.py +45 -0
  11. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_blink_watch.py +135 -3
  12. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_progress_pane.py +35 -0
  13. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/LICENSE +0 -0
  14. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/__main__.py +0 -0
  15. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/atomic.py +0 -0
  16. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/bootstrap.py +0 -0
  17. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/checkpoint.py +0 -0
  18. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/cli.py +0 -0
  19. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/config.py +0 -0
  20. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/daemon_supervisor.py +0 -0
  21. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/doctor.py +0 -0
  22. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/gitsnap.py +0 -0
  23. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/__init__.py +0 -0
  24. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/common.py +0 -0
  25. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/pre_compact.py +0 -0
  26. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/pre_tool_use.py +0 -0
  27. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/session_end.py +0 -0
  28. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/session_start.py +0 -0
  29. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/stop.py +0 -0
  30. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/task.py +0 -0
  31. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/tool_use.py +0 -0
  32. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hooks/user_prompt.py +0 -0
  33. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/hosting.py +0 -0
  34. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/install.py +0 -0
  35. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/launch.py +0 -0
  36. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/lock.py +0 -0
  37. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/managed.py +0 -0
  38. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/naming.py +0 -0
  39. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/notify.py +0 -0
  40. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/paths.py +0 -0
  41. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/power_plug.py +0 -0
  42. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/project.py +0 -0
  43. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/redact.py +0 -0
  44. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/rotator.py +0 -0
  45. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/settings_merge.py +0 -0
  46. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/skills.py +0 -0
  47. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/state.py +0 -0
  48. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/statusline.py +0 -0
  49. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/thresholds.py +0 -0
  50. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/transcript.py +0 -0
  51. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/validate.py +0 -0
  52. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/watchdog.py +0 -0
  53. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/watchdog_digest.py +0 -0
  54. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity/watchdogd.py +0 -0
  55. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity.egg-info/SOURCES.txt +0 -0
  56. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity.egg-info/dependency_links.txt +0 -0
  57. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity.egg-info/entry_points.txt +0 -0
  58. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/cc_continuity.egg-info/top_level.txt +0 -0
  59. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/setup.cfg +0 -0
  60. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_atomic.py +0 -0
  61. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_bootstrap.py +0 -0
  62. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_changelog_notes.py +0 -0
  63. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_checkpoint.py +0 -0
  64. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_cli.py +0 -0
  65. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_cli_ledger.py +0 -0
  66. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_cli_log.py +0 -0
  67. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_config.py +0 -0
  68. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_daemon_supervisor.py +0 -0
  69. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_doctor.py +0 -0
  70. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_gitsnap.py +0 -0
  71. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_common.py +0 -0
  72. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_pre_compact.py +0 -0
  73. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_pre_tool_use.py +0 -0
  74. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_session_end.py +0 -0
  75. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_session_start.py +0 -0
  76. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_stop.py +0 -0
  77. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_task.py +0 -0
  78. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_tool_use.py +0 -0
  79. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hooks_user_prompt.py +0 -0
  80. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hosting.py +0 -0
  81. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_hygiene.py +0 -0
  82. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_install.py +0 -0
  83. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_integration_phase5.py +0 -0
  84. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_integration_phase6.py +0 -0
  85. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_integration_phase7.py +0 -0
  86. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_launch.py +0 -0
  87. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_ledger.py +0 -0
  88. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_lock.py +0 -0
  89. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_managed.py +0 -0
  90. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_naming.py +0 -0
  91. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_notify.py +0 -0
  92. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_notify_integration.py +0 -0
  93. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_paths.py +0 -0
  94. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_power_plug.py +0 -0
  95. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_project.py +0 -0
  96. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_readme_badges.py +0 -0
  97. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_readme_gif.py +0 -0
  98. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_redact.py +0 -0
  99. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_rotator.py +0 -0
  100. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_settings_merge.py +0 -0
  101. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_skills.py +0 -0
  102. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_state.py +0 -0
  103. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_status.py +0 -0
  104. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_statusline.py +0 -0
  105. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_statusline_cache.py +0 -0
  106. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_thresholds.py +0 -0
  107. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_tmux_host.py +0 -0
  108. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_transcript.py +0 -0
  109. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_transcript_finalize.py +0 -0
  110. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_uninstall.py +0 -0
  111. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_validate.py +0 -0
  112. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_watchdog.py +0 -0
  113. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_watchdog_digest.py +0 -0
  114. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_watchdog_integration.py +0 -0
  115. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_watchdogd.py +0 -0
  116. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_wsl_doctor.py +0 -0
  117. {cc_continuity-0.3.52 → cc_continuity-0.3.53}/tests/test_wsl_install.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.52
3
+ Version: 0.3.53
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -41,11 +41,11 @@ The five most recent updates, newest first. Each line links to its
41
41
  commit, so you can see what changed lately without digging through the
42
42
  log:
43
43
 
44
+ - **2026-11-21**: A reply you only glanced at keeps asking. The focus dwell used to consume the reply blink on the first look, so reading an answer and backgrounding the window without replying left the tab quiet with the answer pending; the poller and the pane animator now catch the window losing focus again while the reply is still unanswered and re-light the tab after a fresh settle window, until the user actually replies ([commit](https://github.com/pqant/claude-continuity/commit/8c17eb9)).
44
45
  - **2026-11-21**: The status line now runs its heavy work only at tool boundaries. Idle re-renders reuse the cached facts (session lookup, ledger reads, transcript parse, pane capture) while the shimmer sweep, the reply settle marker and the HUD ratio keep moving, the mode-1 pane feed only rewrites when the data changes, and a corrupt or missing cache always falls back to the full render ([commit](https://github.com/pqant/claude-continuity/commit/7601949)).
45
46
  - **2026-11-20**: The README now shows the product in motion. A short GIF sits in the How it works section: the animated context-usage segment sweeps while live, then the rotation handoff moments (`HANDOFF!`, `ROTATING`) and the fresh successor session follow, every frame drawn by the real status line code ([commit](https://github.com/pqant/claude-continuity/commit/73ede6c)).
46
47
  - **2026-11-19**: A warned session no longer idles on its own handoff. After the c1 rotation warning the model could write its `handoff.draft.md`, but drafts were only ever read in HANDOFF_REQUESTED, so the session waited at the prompt with a finished handoff on disk; the Stop hook now consumes a WARNED draft at turn end through the normal handoff path - a valid draft finalizes silently, an invalid one gets the usual guidance - and sessions that were never warned never rotate on a self-written draft ([commit](https://github.com/pqant/claude-continuity/commit/330d4db)).
47
48
  - **2026-11-19**: Two small observability wins for the push layer. `notify stop|notification --dry-run` renders the exact push (enabled state, title, priority and body) without sending anything or burning the one-push-per-minute bucket, and `watchdog status` now ends with a `last heartbeat: <local time> (<N>s ago)` line so a stalled daemon is visible at a glance; a missing or corrupt stamp reads `last heartbeat: never` ([commit](https://github.com/pqant/claude-continuity/commit/eb93cc1)).
48
- - **2026-11-18**: The rotation gate can no longer invert silently. `doctor` gained a `config-sanity` check that verifies `0 < warn_ratio <= rotate_ratio <= hard_ratio < 1`, a plausible `window_tokens` (>= 32768) and an http(s) `notify_endpoint`, naming the offending values in its detail; a typo like warn 0.80 / rotate 0.75 used to make rotations fire late or never. The check is warn-only, the values stay the user's call ([commit](https://github.com/pqant/claude-continuity/commit/c7381cc)).
49
49
  ## How it works
50
50
 
51
51
  The whole flow in one picture: the automatic session loop, the optional
@@ -4,4 +4,4 @@ Spec: docs/PRD.md (v1.0). Platform facts verified in docs/VERIFICATION.md.
4
4
  Standard library only at runtime; pytest is dev-only.
5
5
  """
6
6
 
7
- __version__ = "0.3.52"
7
+ __version__ = "0.3.53"
@@ -628,6 +628,14 @@ class FocusWatcher:
628
628
  self._label = f" {label}" if label else ""
629
629
  self._log = log
630
630
  self._outcome = None
631
+ # reply re-arm (issue #78): while the caller holds an unanswered
632
+ # dwell-read reply it arms the watcher; the armed probes record
633
+ # the focused-to-unfocused edge (``lost_at``) even on ticks where
634
+ # the dwell path would not probe at all (empty key, stored read).
635
+ self.armed = False
636
+ self.lost_at = None
637
+ self._was_focused = False
638
+ self._last_front = None
631
639
 
632
640
  def _note(self, event: str, key: str, extra: str = "") -> None:
633
641
  if self._log is None:
@@ -637,6 +645,57 @@ class FocusWatcher:
637
645
  except Exception:
638
646
  pass
639
647
 
648
+ def _probe(self, t: float, key: str) -> "bool | None":
649
+ """One focus probe; tracks the focused-to-unfocused edge (#78).
650
+
651
+ Returns the focused verdict; None when no focus source is wired
652
+ (dwell stays disabled). The edge is what the callers' re-arm
653
+ ladders gate on, so it survives even while the key is suppressed.
654
+ """
655
+ if self._frontmost is None or self._clients is None:
656
+ return None
657
+ front = None
658
+ focused = False
659
+ outcome = "error"
660
+ try:
661
+ front = self._frontmost()
662
+ self._last_front = front
663
+ if front is None:
664
+ outcome = "none"
665
+ else:
666
+ focused = front in self._clients()
667
+ outcome = "focus" if focused else "idle"
668
+ except Exception:
669
+ outcome = "error"
670
+ if outcome != self._outcome:
671
+ self._note(f"probe-{outcome}", key,
672
+ f" front={front!r}" if front is not None else "")
673
+ self._outcome = outcome
674
+ if focused:
675
+ self._was_focused = True
676
+ elif self._was_focused:
677
+ self.lost_at = t
678
+ self._was_focused = False
679
+ self._note("lost", key)
680
+ return focused
681
+
682
+ def rearm(self) -> None:
683
+ """Make the current key unread again (issue #78 reply re-arm).
684
+
685
+ Drops the stored read (and the dwell counters) so a situation the
686
+ user already acknowledged blinks again - used when the user takes
687
+ the window to the background while a reply is still unanswered.
688
+ The lost edge goes with it: the next loss must be a fresh edge.
689
+ """
690
+ try:
691
+ self._store("read", None)
692
+ except Exception:
693
+ pass
694
+ self._dwell = 0
695
+ self._last_key = None
696
+ self.lost_at = None
697
+ self._was_focused = False
698
+
640
699
  def tick(self, t: float, key: str, on_read=None) -> bool:
641
700
  """One poll tick; True means the blink must be suppressed now.
642
701
 
@@ -648,6 +707,8 @@ class FocusWatcher:
648
707
  if not key:
649
708
  self._dwell = 0
650
709
  self._last_key = None
710
+ if self.armed:
711
+ self._probe(t, key)
651
712
  return False
652
713
  try:
653
714
  stored = self._store("read")
@@ -658,26 +719,16 @@ class FocusWatcher:
658
719
  self._note("suppress-stored", key)
659
720
  self._outcome = "read"
660
721
  self._dwell = 0
722
+ if self.armed:
723
+ # #78: the read holds and the key is stable, so the
724
+ # dwell path below would never probe; the armed probe is
725
+ # the only thing that can see the user leave the tab.
726
+ self._probe(t, key)
661
727
  return True
662
- if self._frontmost is None or self._clients is None:
728
+ focused = self._probe(t, key)
729
+ if focused is None:
663
730
  self._dwell = 0
664
731
  return False
665
- front = None
666
- focused = False
667
- outcome = "error"
668
- try:
669
- front = self._frontmost()
670
- if front is None:
671
- outcome = "none"
672
- else:
673
- focused = front in self._clients()
674
- outcome = "focus" if focused else "idle"
675
- except Exception:
676
- outcome = "error"
677
- if outcome != self._outcome:
678
- self._note(f"probe-{outcome}", key,
679
- f" front={front!r}" if front is not None else "")
680
- self._outcome = outcome
681
732
  if not focused:
682
733
  self._dwell = 0
683
734
  self._last_key = key
@@ -699,7 +750,8 @@ class FocusWatcher:
699
750
  if self._dwell < self._dwell_ticks:
700
751
  return False
701
752
  self._dwell = 0
702
- self._note("suppress", key, f" front={front!r}")
753
+ self.lost_at = None
754
+ self._note("suppress", key, f" front={self._last_front!r}")
703
755
  try:
704
756
  self._store("read", key)
705
757
  except Exception:
@@ -205,6 +205,11 @@ def watch(session_dir, *, pane_id: str, window_id: str, cfg: dict,
205
205
  start = _now()
206
206
  fails = 0
207
207
  pane_text: str | None = None
208
+ # reply re-arm (issue #78): ts of the dwell-read reply that is still
209
+ # unanswered; the ladder below re-lights the tab when the user takes
210
+ # the window to the background again. ``live`` marks an open re-arm:
211
+ # the blink stays lit from the loss edge until the dwell reads it.
212
+ rearm = {"ts": None, "live": False}
208
213
  i = 0
209
214
  try:
210
215
  while True:
@@ -239,6 +244,35 @@ def watch(session_dir, *, pane_id: str, window_id: str, cfg: dict,
239
244
  reply = None
240
245
  if reply is not None and t - reply > _reply_fade:
241
246
  reply = None # unfocusable context: fade, never strand
247
+ # reply re-arm (issue #78): the dwell consumed the entry
248
+ # (the on_read below appends reply_read). While the user has
249
+ # not answered (no newer main-session user_prompt, no
250
+ # self-wake) and the entry has not faded, the window going
251
+ # to the background again re-arms the blink after a fresh
252
+ # settle window - the tab lights up until the answer lands.
253
+ if reply is not None:
254
+ rearm["ts"] = None # a live (fresh) reply owns it
255
+ rearm["live"] = False
256
+ elif rearm["ts"] is not None:
257
+ try:
258
+ pending, selfwake = ledger.reply_state(
259
+ session_dir, dwell_counts=False)
260
+ except Exception:
261
+ pending, selfwake = None, True
262
+ if selfwake or pending != rearm["ts"]:
263
+ rearm["ts"] = None # answered (or self-woken): stop
264
+ rearm["live"] = False
265
+ elif t - rearm["ts"] > _reply_fade:
266
+ rearm["ts"] = None # faded: never resurrect
267
+ rearm["live"] = False
268
+ elif rearm["live"]:
269
+ reply = rearm["ts"] # open re-arm: keep blinking
270
+ elif (watcher.lost_at is not None
271
+ and t - watcher.lost_at >= settle):
272
+ watcher.rearm() # the read is dropped, blink back
273
+ rearm["live"] = True
274
+ reply = rearm["ts"]
275
+ watcher.armed = rearm["ts"] is not None
242
276
  parts = []
243
277
  if blocked:
244
278
  parts.append(blink_mod.MARKER_BLOCKED)
@@ -257,8 +291,14 @@ def watch(session_dir, *, pane_id: str, window_id: str, cfg: dict,
257
291
  (blocked,
258
292
  repr(reply) if reply is not None else "",
259
293
  pane_text) if p)
260
- on_read = ((lambda _key: ledger.mark_reply_read(session_dir))
261
- if reply is not None else None)
294
+ on_read = None
295
+ if reply is not None:
296
+ # the dwell read consumes the entry (reply_read) and
297
+ # opens the re-arm window for this same ts (#78).
298
+ def on_read(_key, _ts=reply):
299
+ ledger.mark_reply_read(session_dir)
300
+ rearm["ts"] = _ts
301
+ rearm["live"] = False # read: wait for a fresh loss
262
302
  try:
263
303
  suppress = watcher.tick(t, key, on_read)
264
304
  except Exception:
@@ -94,7 +94,8 @@ _RESUME_TYPES = frozenset({"tool_use", "tool_failure", "task_created",
94
94
  "task_completed", "stop"})
95
95
 
96
96
 
97
- def reply_state(session_dir: str | Path) -> "tuple[float | None, bool]":
97
+ def reply_state(session_dir: str | Path, *,
98
+ dwell_counts: bool = True) -> "tuple[float | None, bool]":
98
99
  """``(pending_ts, selfwake_consumed)`` of the latest ``reply_ready``.
99
100
 
100
101
  Raw split of the :func:`reply_pending` read, for callers that keep the
@@ -102,6 +103,10 @@ def reply_state(session_dir: str | Path) -> "tuple[float | None, bool]":
102
103
  ``pending_ts`` is the latest unconsumed ``reply_ready`` ts (settle
103
104
  NOT applied), and ``selfwake_consumed`` says a wake entry newer than
104
105
  that reply marks the wait as self-answered. Never raises.
106
+
107
+ ``dwell_counts=False`` (issue #78 re-arm check) ignores ``reply_read``
108
+ entries: the focus dwell that silenced the blink did not ANSWER the
109
+ reply - only a main-session ``user_prompt`` does.
105
110
  """
106
111
  try:
107
112
  entries = read(session_dir)
@@ -112,7 +117,8 @@ def reply_state(session_dir: str | Path) -> "tuple[float | None, bool]":
112
117
  t = entry.get("type")
113
118
  if t == "reply_ready":
114
119
  pending = entry.get("ts")
115
- elif (t == "user_prompt" and not entry.get("agent_id")) or t == "reply_read":
120
+ elif ((t == "user_prompt" and not entry.get("agent_id"))
121
+ or (t == "reply_read" and dwell_counts)):
116
122
  pending = None
117
123
  if pending is None:
118
124
  return None, False
@@ -815,6 +815,17 @@ def run_animator(window_id: str | None = None, *, _frames=None,
815
815
  pane_text is not None,
816
816
  reply_id,
817
817
  blocked_reason) if p)
818
+ # reply re-arm (issue #78): the saved read silenced the
819
+ # tab; if the user takes the window to the background
820
+ # again while the reply is still pending (flag up, the
821
+ # ledger read above still reports it), the read is
822
+ # dropped after a fresh settle window so the tab blinks
823
+ # again. The armed probe is the only focus probe on the
824
+ # suppressed ticks (the key is stable there).
825
+ watcher.armed = bool(reply_id)
826
+ if (reply_id and watcher.lost_at is not None
827
+ and t - watcher.lost_at >= settle):
828
+ watcher.rearm()
818
829
  try:
819
830
  suppressed = watcher.tick(t, src)
820
831
  except Exception:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.52
3
+ Version: 0.3.53
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cc-continuity"
7
- version = "0.3.52"
7
+ version = "0.3.53"
8
8
  description = "Zero-touch session rotation for Claude Code (local large-context model)"
9
9
  requires-python = ">=3.11"
10
10
  classifiers = [
@@ -898,3 +898,48 @@ def test_reply_flag_guards(cc_home, monkeypatch):
898
898
  monkeypatch.setenv("TMUX_PANE", "%64")
899
899
  assert blink.write_reply_flag("/x", settle=15.0,
900
900
  runner=_failing_runner) is None
901
+
902
+
903
+ # ------------------------------------------- FocusWatcher re-arm (issue #78)
904
+
905
+
906
+ def test_focus_watcher_rearm_clears_the_read_state():
907
+ # issue #78: after the dwell read the reply, the poller/animator
908
+ # loses focus while the reply is still unanswered: rearm() drops the
909
+ # read state so the same key is unread again and the tab lights up.
910
+ store = _store_dict()
911
+ fronts = iter(["/dev/ttys001", "/dev/ttys001", None])
912
+ w = blink.FocusWatcher(store, frontmost=lambda: next(fronts, None),
913
+ clients=lambda: {"/dev/ttys001"}, dwell_ticks=2,
914
+ log=None)
915
+ assert w.tick(0.0, "K") is False
916
+ assert w.tick(1.0, "K") is True # dwell: read stored
917
+ assert store("read") == "K"
918
+ w.rearm()
919
+ assert store("read") is None
920
+ assert w.tick(2.0, "K") is False # unfocused: blinks again
921
+ assert w.lost_at is None # rearm cleared stale edge
922
+
923
+
924
+ def test_focus_watcher_lost_edge_tracks_only_when_armed():
925
+ # issue #78: the extra focus probe (the one that records the
926
+ # focused-to-unfocused edge) must stay OFF for every idle tick that
927
+ # has nothing to re-arm; the caller arms the window between the
928
+ # dwell read and the answer/fade.
929
+ fronts = iter(["/dev/ttys001", None, None])
930
+ calls = []
931
+
932
+ def front():
933
+ calls.append(1)
934
+ return next(fronts, None)
935
+ store = _store_dict()
936
+ w = blink.FocusWatcher(store, frontmost=front,
937
+ clients=lambda: {"/dev/ttys001"}, dwell_ticks=2,
938
+ log=None)
939
+ assert w.tick(0.0, "") is False # unarmed: no probe
940
+ assert calls == []
941
+ w.armed = True
942
+ assert w.tick(1.0, "") is False # armed probe: focused
943
+ assert w.lost_at is None
944
+ assert w.tick(2.0, "") is False # armed probe: lost
945
+ assert w.lost_at == 2.0
@@ -11,7 +11,7 @@ the ledger's unconsumed needs_human reason.
11
11
 
12
12
  import subprocess
13
13
 
14
- from cc_continuity import blink, blink_watch, paths, progress_pane
14
+ from cc_continuity import blink, blink_watch, ledger, paths, progress_pane
15
15
 
16
16
 
17
17
  _DIALOG_REGION = ("❯ 1. (A) go\n"
@@ -360,7 +360,8 @@ def test_spawn_never_raises_on_runner_failure(cc_home, monkeypatch):
360
360
  # tab until the user focuses it; the poller needs no status line render.
361
361
 
362
362
 
363
- def _run_watch(fake, *, cfg=None, ticks=1, now=0.0, frontmost=None,
363
+ def _run_watch(fake, *, cfg=None, ticks=1, now=0.0, step=0.0,
364
+ frontmost=None,
364
365
  clients=frozenset(), dwell=3, fade=600.0,
365
366
  frontmost_app=None, session_dir="/sess"):
366
367
  if frontmost_app is None:
@@ -373,11 +374,16 @@ def _run_watch(fake, *, cfg=None, ticks=1, now=0.0, frontmost=None,
373
374
 
374
375
  def app_fn():
375
376
  return next(seq, None)
377
+ clock = {"t": now - step}
378
+
379
+ def _now():
380
+ clock["t"] += step
381
+ return clock["t"]
376
382
  blink_watch.watch(
377
383
  session_dir, pane_id="%7", window_id="@7", cfg=cfg or {}, _blink=fake,
378
384
  _runner=lambda argv, **kw: subprocess.CompletedProcess(argv, 0,
379
385
  b"", b""),
380
- _bin_="tmux", _tty_open=_tty_open, _now=lambda: now,
386
+ _bin_="tmux", _tty_open=_tty_open, _now=_now,
381
387
  _sleep=_sleep_noop, _ticks=ticks, _state=lambda d: "ACTIVE",
382
388
  _frontmost_tty=(frontmost if frontmost is not None else (lambda: None)),
383
389
  _client_ttys=clients if callable(clients) else (lambda: set(clients)),
@@ -681,3 +687,129 @@ def test_frontmost_tty_falls_through_when_app_unreadable(monkeypatch):
681
687
  # the raw tty query still answers (pre-#62 degrade path).
682
688
  _fake_osascript(monkeypatch, app_fail=True, tty_out="/dev/ttys001\n")
683
689
  assert _REAL_FRONTMOST_TTY() == "/dev/ttys001"
690
+
691
+
692
+ # ------------------------------------------------- reply re-arm after dwell
693
+ #
694
+ # Issue #78: the dwell consumes the reply (reply_read), the user reads
695
+ # the answer and takes the window to the background WITHOUT replying:
696
+ # today nothing re-arms and the tab goes quiet with the answer pending.
697
+ # The poller must blink again once focus is lost (after a fresh settle
698
+ # window), and the re-arm must stop once the user replies (user_prompt)
699
+ # or the reply has faded.
700
+
701
+ _F = "/dev/ttys001"
702
+
703
+
704
+ def _seed_reply(tmp_path, ts=0.0):
705
+ sd = str(tmp_path / "s78")
706
+ ledger.append(sd, {"type": "reply_ready", "ts": ts})
707
+ return sd
708
+
709
+
710
+ def test_watch_reply_rearms_after_dwell_and_focus_loss(cc_home, tmp_path):
711
+ # real ledger: dwell consumes (one reply_read), focus loss re-arms
712
+ # after the settle window; the reply is never answered.
713
+ sd = _seed_reply(tmp_path)
714
+ fronts = iter([None, _F, _F, _F, None, None, None, None, None, None])
715
+ fake = _FakeBlinkMod(captures=[""] * 10)
716
+ _run_watch(fake, cfg={"blink_reply_settle": 5}, ticks=10, now=5.0,
717
+ step=1.0, dwell=2,
718
+ frontmost=lambda: next(fronts, None),
719
+ clients=lambda: {_F}, session_dir=sd)
720
+ texts = [t for t, _ in fake.made[0].ticks]
721
+ assert blink.MARKER_REPLY in texts[0] # blinking (settled)
722
+ assert blink.MARKER_REPLY in texts[1] # focused, dwelling
723
+ assert texts[2] == "" # dwell reached: consumed
724
+ assert all(t == "" for t in texts[3:9]) # still focused / settling
725
+ assert blink.MARKER_REPLY in texts[9] # lost + settle -> RE-ARM
726
+ types = [e["type"] for e in ledger.read(sd)]
727
+ assert types.count("reply_read") == 1
728
+
729
+
730
+ def test_watch_reply_rearm_holds_through_the_settle_window(cc_home,
731
+ tmp_path):
732
+ # the re-arm waits a FRESH settle window from the focus-loss edge:
733
+ # brief Cmd+Tab blinks must not light the tab back up.
734
+ sd = _seed_reply(tmp_path)
735
+ fronts = iter([None, _F, _F, None, None, None, None, None])
736
+ fake = _FakeBlinkMod(captures=[""] * 8)
737
+ _run_watch(fake, cfg={"blink_reply_settle": 5}, ticks=8, now=5.0,
738
+ step=1.0, dwell=2,
739
+ frontmost=lambda: next(fronts, None),
740
+ clients=lambda: {_F}, session_dir=sd)
741
+ texts = [t for t, _ in fake.made[0].ticks]
742
+ assert blink.MARKER_REPLY in texts[0]
743
+ assert texts[2] == "" # consumed at t=7
744
+ # lost at t=8 (index 3); re-arm only from t=8+5 (index 8, never
745
+ # reached): the whole tail stays dark
746
+ assert all(t == "" for t in texts[3:8])
747
+
748
+
749
+ def test_watch_reply_no_rearm_after_user_prompt(cc_home, tmp_path):
750
+ # acceptance half two: once the user replies (main-session
751
+ # user_prompt), losing focus again must NOT blink.
752
+ sd = _seed_reply(tmp_path)
753
+ seq = [None, _F, _F, _F, None, None, None, None, None, None]
754
+ calls = {"n": 0}
755
+
756
+ def front():
757
+ i = calls["n"]
758
+ calls["n"] += 1
759
+ if i == 3: # still focused, t=8
760
+ ledger.append(sd, {"type": "user_prompt"})
761
+ return seq[i]
762
+ fake = _FakeBlinkMod(captures=[""] * 10)
763
+ _run_watch(fake, cfg={"blink_reply_settle": 5}, ticks=10, now=5.0,
764
+ step=1.0, dwell=2, frontmost=front,
765
+ clients=lambda: {_F}, session_dir=sd)
766
+ texts = [t for t, _ in fake.made[0].ticks]
767
+ assert blink.MARKER_REPLY in texts[0]
768
+ assert texts[2] == "" # dwell consumed
769
+ assert all(t == "" for t in texts[3:10]) # answered: stays dark
770
+ types = [e["type"] for e in ledger.read(sd)]
771
+ assert types.count("reply_read") == 1
772
+
773
+
774
+ def test_watch_reply_rearm_stops_after_fade(cc_home, tmp_path):
775
+ # an unanswered-but-faded reply never resurfaces (fade caps the
776
+ # re-arm loop exactly as it caps the first blink).
777
+ sd = _seed_reply(tmp_path)
778
+ fronts = iter([None, _F, _F, None, None, None])
779
+ fake = _FakeBlinkMod(captures=[""] * 6)
780
+ _run_watch(fake, cfg={"blink_reply_settle": 5}, ticks=6, now=5.0,
781
+ step=80.0, fade=300.0, dwell=2,
782
+ frontmost=lambda: next(fronts, None),
783
+ clients=lambda: {_F}, session_dir=sd)
784
+ texts = [t for t, _ in fake.made[0].ticks]
785
+ assert blink.MARKER_REPLY in texts[0]
786
+ assert blink.MARKER_REPLY in texts[1]
787
+ assert texts[2] == "" # consumed at t=165
788
+ # lost at t=245; at t=325 the settle gate is open but the reply is
789
+ # older than the fade: no re-arm, and it never comes back.
790
+ assert all(t == "" for t in texts[3:6])
791
+
792
+
793
+ def test_watch_reply_rearm_cycles_until_answer(cc_home, tmp_path):
794
+ # two focus/away cycles blink twice (one reply_read per dwell);
795
+ # the ledger entry keeps re-arming while nobody replies.
796
+ sd = _seed_reply(tmp_path)
797
+ seq = [None, _F, _F, _F, None, None, None, None, None, None,
798
+ _F, _F, None, None, None, None, None, None]
799
+ front_it = iter(seq)
800
+ fake = _FakeBlinkMod(captures=[""] * 18)
801
+ _run_watch(fake, cfg={"blink_reply_settle": 5}, ticks=18, now=5.0,
802
+ step=1.0, dwell=2,
803
+ frontmost=lambda: next(front_it, None),
804
+ clients=lambda: {_F}, session_dir=sd)
805
+ texts = [t for t, _ in fake.made[0].ticks]
806
+ assert blink.MARKER_REPLY in texts[0]
807
+ assert texts[2] == "" # dwell 1 consumed
808
+ assert all(t == "" for t in texts[3:9])
809
+ assert blink.MARKER_REPLY in texts[9] # re-arm 1 (t=14)
810
+ assert blink.MARKER_REPLY in texts[10] # re-focused, dwelling
811
+ assert texts[11] == "" # dwell 2 consumed
812
+ assert all(t == "" for t in texts[12:17])
813
+ assert blink.MARKER_REPLY in texts[17] # re-arm 2 (t=22)
814
+ types = [e["type"] for e in ledger.read(sd)]
815
+ assert types.count("reply_read") == 2
@@ -652,6 +652,41 @@ def test_animator_reply_gate_key_carries_reply_ts(cc_home, monkeypatch):
652
652
  assert any("200.0" in k for k in keys) # second reply: fresh key
653
653
 
654
654
 
655
+ def test_animator_reply_rearms_after_focus_loss(cc_home, monkeypatch):
656
+ # issue #78 (mode 1): the dwell read the reply (saved read in the
657
+ # pane record); the user then takes the window to the background
658
+ # WITHOUT answering. After a fresh settle window the tab must blink
659
+ # again - the animator, not just the poller, owns this surface.
660
+ monkeypatch.delenv("TMUX_PANE", raising=False)
661
+ monkeypatch.setattr(progress_pane.blink, "list_client_ttys",
662
+ lambda *a, **k: {"/dev/ttys001"})
663
+ fake = _FakeBlinkMod()
664
+ written = []
665
+ fronts = iter([None, "/dev/ttys001", "/dev/ttys001",
666
+ None, None, None, None, None])
667
+ state = {"n": 0}
668
+
669
+ def clock():
670
+ state["n"] += 1
671
+ return 100.0 + (state["n"] - 1) // 40 # one second per blink poll
672
+
673
+ progress_pane.run_animator(
674
+ "12", _frames=121, _write=written.append, _now=clock,
675
+ _size=lambda: _size_obj(40), _text=lambda: "◆ 9% ok",
676
+ _mtime=lambda: 1, _sleep=lambda s: None, _blink=fake,
677
+ _frontmost_tty=lambda: next(fronts, None), _dwell_ticks=1,
678
+ _focus_log=None,
679
+ _reply_flag_read=lambda w: {"session_dir": "SD", "ts": 100.0,
680
+ "settle": 2.0},
681
+ _reply_pending=lambda sd, settle, now: 100.0,
682
+ _reply_flag_clear=lambda w: None)
683
+ texts = [t for t, _ts, _p in fake.made[0].texts]
684
+ assert all("\U0001f550 REPLY" in t for t in texts[0:20]) # blinking
685
+ assert all(t == "" for t in texts[20:100]) # dwell read; away, settling
686
+ # lost at poll t=103 (frame 60); settle 2 s -> re-arm at t=105
687
+ assert all("\U0001f550 REPLY" in t for t in texts[100:121])
688
+
689
+
655
690
  def test_animator_injects_blocked_chip_from_ledger(cc_home, monkeypatch):
656
691
  # Issue #63 (live 2026-11-12 scripted probe): mode 1 never spawns the
657
692
  # blink-watch poller ("the animator owns the blink") and the animator
File without changes
File without changes