cc-continuity 0.3.51__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.51 → cc_continuity-0.3.53}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/README.md +2 -2
  3. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/blink.py +70 -18
  5. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/blink_watch.py +42 -2
  6. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/ledger.py +41 -19
  7. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/progress_pane.py +11 -0
  8. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/statusline.py +275 -57
  9. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity.egg-info/PKG-INFO +1 -1
  10. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity.egg-info/SOURCES.txt +1 -0
  11. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/pyproject.toml +1 -1
  12. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_blink.py +45 -0
  13. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_blink_watch.py +135 -3
  14. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_progress_pane.py +35 -0
  15. cc_continuity-0.3.53/tests/test_statusline_cache.py +256 -0
  16. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/LICENSE +0 -0
  17. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/__main__.py +0 -0
  18. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/atomic.py +0 -0
  19. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/bootstrap.py +0 -0
  20. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/checkpoint.py +0 -0
  21. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/cli.py +0 -0
  22. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/config.py +0 -0
  23. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/daemon_supervisor.py +0 -0
  24. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/doctor.py +0 -0
  25. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/gitsnap.py +0 -0
  26. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/__init__.py +0 -0
  27. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/common.py +0 -0
  28. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/pre_compact.py +0 -0
  29. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/pre_tool_use.py +0 -0
  30. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/session_end.py +0 -0
  31. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/session_start.py +0 -0
  32. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/stop.py +0 -0
  33. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/task.py +0 -0
  34. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/tool_use.py +0 -0
  35. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hooks/user_prompt.py +0 -0
  36. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/hosting.py +0 -0
  37. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/install.py +0 -0
  38. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/launch.py +0 -0
  39. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/lock.py +0 -0
  40. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/managed.py +0 -0
  41. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/naming.py +0 -0
  42. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/notify.py +0 -0
  43. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/paths.py +0 -0
  44. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/power_plug.py +0 -0
  45. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/project.py +0 -0
  46. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/redact.py +0 -0
  47. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/rotator.py +0 -0
  48. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/settings_merge.py +0 -0
  49. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/skills.py +0 -0
  50. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/state.py +0 -0
  51. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/thresholds.py +0 -0
  52. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/transcript.py +0 -0
  53. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/validate.py +0 -0
  54. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/watchdog.py +0 -0
  55. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/watchdog_digest.py +0 -0
  56. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity/watchdogd.py +0 -0
  57. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity.egg-info/dependency_links.txt +0 -0
  58. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity.egg-info/entry_points.txt +0 -0
  59. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/cc_continuity.egg-info/top_level.txt +0 -0
  60. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/setup.cfg +0 -0
  61. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_atomic.py +0 -0
  62. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_bootstrap.py +0 -0
  63. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_changelog_notes.py +0 -0
  64. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_checkpoint.py +0 -0
  65. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_cli.py +0 -0
  66. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_cli_ledger.py +0 -0
  67. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_cli_log.py +0 -0
  68. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_config.py +0 -0
  69. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_daemon_supervisor.py +0 -0
  70. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_doctor.py +0 -0
  71. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_gitsnap.py +0 -0
  72. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_common.py +0 -0
  73. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_pre_compact.py +0 -0
  74. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_pre_tool_use.py +0 -0
  75. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_session_end.py +0 -0
  76. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_session_start.py +0 -0
  77. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_stop.py +0 -0
  78. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_task.py +0 -0
  79. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_tool_use.py +0 -0
  80. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hooks_user_prompt.py +0 -0
  81. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hosting.py +0 -0
  82. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_hygiene.py +0 -0
  83. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_install.py +0 -0
  84. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_integration_phase5.py +0 -0
  85. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_integration_phase6.py +0 -0
  86. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_integration_phase7.py +0 -0
  87. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_launch.py +0 -0
  88. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_ledger.py +0 -0
  89. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_lock.py +0 -0
  90. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_managed.py +0 -0
  91. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_naming.py +0 -0
  92. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_notify.py +0 -0
  93. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_notify_integration.py +0 -0
  94. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_paths.py +0 -0
  95. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_power_plug.py +0 -0
  96. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_project.py +0 -0
  97. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_readme_badges.py +0 -0
  98. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_readme_gif.py +0 -0
  99. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_redact.py +0 -0
  100. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_rotator.py +0 -0
  101. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_settings_merge.py +0 -0
  102. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_skills.py +0 -0
  103. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_state.py +0 -0
  104. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_status.py +0 -0
  105. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_statusline.py +0 -0
  106. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_thresholds.py +0 -0
  107. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_tmux_host.py +0 -0
  108. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_transcript.py +0 -0
  109. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_transcript_finalize.py +0 -0
  110. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_uninstall.py +0 -0
  111. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_validate.py +0 -0
  112. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_watchdog.py +0 -0
  113. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_watchdog_digest.py +0 -0
  114. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_watchdog_integration.py +0 -0
  115. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_watchdogd.py +0 -0
  116. {cc_continuity-0.3.51 → cc_continuity-0.3.53}/tests/test_wsl_doctor.py +0 -0
  117. {cc_continuity-0.3.51 → 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.51
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)).
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)).
44
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)).
45
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)).
46
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)).
47
- - **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)).
48
- - **2026-11-18**: The session chain went machine-readable: `cc-continuity history --json` prints it as one JSON array with stable keys (`nnn`, `name`, `session_id`, `created`, `state`). The state comes from each session's `state.json` with the same fallback the status rotation line uses, a project without a record prints `[]`, and the default human output is unchanged ([commit](https://github.com/pqant/claude-continuity/commit/180b761)).
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.51"
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,6 +94,41 @@ _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, *,
98
+ dwell_counts: bool = True) -> "tuple[float | None, bool]":
99
+ """``(pending_ts, selfwake_consumed)`` of the latest ``reply_ready``.
100
+
101
+ Raw split of the :func:`reply_pending` read, for callers that keep the
102
+ facts in a render cache between status line invocations (issue #77):
103
+ ``pending_ts`` is the latest unconsumed ``reply_ready`` ts (settle
104
+ NOT applied), and ``selfwake_consumed`` says a wake entry newer than
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.
110
+ """
111
+ try:
112
+ entries = read(session_dir)
113
+ except (OSError, ValueError):
114
+ return None, False
115
+ pending = None
116
+ for entry in entries:
117
+ t = entry.get("type")
118
+ if t == "reply_ready":
119
+ pending = entry.get("ts")
120
+ elif ((t == "user_prompt" and not entry.get("agent_id"))
121
+ or (t == "reply_read" and dwell_counts)):
122
+ pending = None
123
+ if pending is None:
124
+ return None, False
125
+ for entry in entries:
126
+ if (entry.get("type") in _RESUME_TYPES
127
+ and (entry.get("ts") or 0) > pending):
128
+ return pending, True # woke itself: never a wait for the user
129
+ return pending, False
130
+
131
+
97
132
  def reply_pending(session_dir: str | Path, *, settle: float = 0.0,
98
133
  now: float | None = None) -> float | None:
99
134
  """Ts of the latest UNCONSUMED ``reply_ready`` entry, or None.
@@ -112,26 +147,13 @@ def reply_pending(session_dir: str | Path, *, settle: float = 0.0,
112
147
  wakes itself was never waiting for the user. ``now`` is injectable
113
148
  for tests; ``settle=0`` keeps the raw read.
114
149
  """
115
- try:
116
- entries = read(session_dir)
117
- except (OSError, ValueError):
150
+ pending, selfwake = reply_state(session_dir)
151
+ if pending is None or selfwake:
118
152
  return None
119
- pending = None
120
- for entry in entries:
121
- t = entry.get("type")
122
- if t == "reply_ready":
123
- pending = entry.get("ts")
124
- elif (t == "user_prompt" and not entry.get("agent_id")) or t == "reply_read":
125
- pending = None
126
- if pending is None:
127
- return None
128
- now = time.time() if now is None else now
129
- if settle > 0 and now - pending < settle:
130
- return None # settling: an auto-continue may still land
131
- for entry in entries:
132
- if (entry.get("type") in _RESUME_TYPES
133
- and (entry.get("ts") or 0) > pending):
134
- return None # woke itself: never a wait for the user
153
+ if settle > 0:
154
+ now = time.time() if now is None else now
155
+ if now - pending < settle:
156
+ return None # settling: an auto-continue may still land
135
157
  return pending
136
158
 
137
159
 
@@ -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: