cc-continuity 0.3.26__tar.gz → 0.3.28__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 (112) hide show
  1. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/README.md +5 -3
  3. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/blink.py +75 -8
  5. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/blink_watch.py +32 -0
  6. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/cli.py +6 -2
  7. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/config.py +13 -0
  8. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/progress_pane.py +14 -0
  9. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity.egg-info/PKG-INFO +1 -1
  10. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/pyproject.toml +1 -1
  11. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_blink.py +78 -7
  12. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_blink_watch.py +51 -2
  13. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_progress_pane.py +23 -0
  14. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/LICENSE +0 -0
  15. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/__main__.py +0 -0
  16. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/atomic.py +0 -0
  17. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/bootstrap.py +0 -0
  18. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/checkpoint.py +0 -0
  19. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/daemon_supervisor.py +0 -0
  20. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/doctor.py +0 -0
  21. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/gitsnap.py +0 -0
  22. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/__init__.py +0 -0
  23. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/common.py +0 -0
  24. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/pre_compact.py +0 -0
  25. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/pre_tool_use.py +0 -0
  26. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/session_end.py +0 -0
  27. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/session_start.py +0 -0
  28. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/stop.py +0 -0
  29. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/task.py +0 -0
  30. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/tool_use.py +0 -0
  31. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hooks/user_prompt.py +0 -0
  32. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/hosting.py +0 -0
  33. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/install.py +0 -0
  34. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/launch.py +0 -0
  35. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/ledger.py +0 -0
  36. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/lock.py +0 -0
  37. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/managed.py +0 -0
  38. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/naming.py +0 -0
  39. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/notify.py +0 -0
  40. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/paths.py +0 -0
  41. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/power_plug.py +0 -0
  42. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/project.py +0 -0
  43. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/redact.py +0 -0
  44. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/rotator.py +0 -0
  45. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/settings_merge.py +0 -0
  46. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/skills.py +0 -0
  47. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/state.py +0 -0
  48. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/statusline.py +0 -0
  49. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/thresholds.py +0 -0
  50. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/transcript.py +0 -0
  51. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/validate.py +0 -0
  52. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/watchdog.py +0 -0
  53. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/watchdog_digest.py +0 -0
  54. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity/watchdogd.py +0 -0
  55. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity.egg-info/SOURCES.txt +0 -0
  56. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity.egg-info/dependency_links.txt +0 -0
  57. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity.egg-info/entry_points.txt +0 -0
  58. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/cc_continuity.egg-info/top_level.txt +0 -0
  59. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/setup.cfg +0 -0
  60. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_atomic.py +0 -0
  61. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_bootstrap.py +0 -0
  62. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_checkpoint.py +0 -0
  63. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_cli.py +0 -0
  64. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_cli_ledger.py +0 -0
  65. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_config.py +0 -0
  66. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_daemon_supervisor.py +0 -0
  67. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_doctor.py +0 -0
  68. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_gitsnap.py +0 -0
  69. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_common.py +0 -0
  70. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_pre_compact.py +0 -0
  71. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_pre_tool_use.py +0 -0
  72. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_session_end.py +0 -0
  73. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_session_start.py +0 -0
  74. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_stop.py +0 -0
  75. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_task.py +0 -0
  76. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_tool_use.py +0 -0
  77. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hooks_user_prompt.py +0 -0
  78. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hosting.py +0 -0
  79. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_hygiene.py +0 -0
  80. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_install.py +0 -0
  81. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_integration_phase5.py +0 -0
  82. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_integration_phase6.py +0 -0
  83. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_integration_phase7.py +0 -0
  84. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_launch.py +0 -0
  85. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_ledger.py +0 -0
  86. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_lock.py +0 -0
  87. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_managed.py +0 -0
  88. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_naming.py +0 -0
  89. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_notify.py +0 -0
  90. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_notify_integration.py +0 -0
  91. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_paths.py +0 -0
  92. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_power_plug.py +0 -0
  93. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_project.py +0 -0
  94. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_redact.py +0 -0
  95. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_rotator.py +0 -0
  96. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_settings_merge.py +0 -0
  97. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_skills.py +0 -0
  98. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_state.py +0 -0
  99. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_status.py +0 -0
  100. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_statusline.py +0 -0
  101. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_thresholds.py +0 -0
  102. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_tmux_host.py +0 -0
  103. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_transcript.py +0 -0
  104. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_transcript_finalize.py +0 -0
  105. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_uninstall.py +0 -0
  106. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_validate.py +0 -0
  107. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_watchdog.py +0 -0
  108. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_watchdog_digest.py +0 -0
  109. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_watchdog_integration.py +0 -0
  110. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_watchdogd.py +0 -0
  111. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/tests/test_wsl_doctor.py +0 -0
  112. {cc_continuity-0.3.26 → cc_continuity-0.3.28}/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.26
3
+ Version: 0.3.28
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Requires-Python: >=3.11
6
6
  License-File: LICENSE
@@ -26,11 +26,13 @@ The five most recent updates, newest first. Each line links to its
26
26
  commit, so you can see what changed lately without digging through the
27
27
  log:
28
28
 
29
- - **2026-11-12**: Needs-human and blocked waits now bounce the iTerm2 Dock icon too, not just the tab: an unconsumed `needs_human` reason (a `signal needs-human` or a watchdog stall), a permission or selection prompt, or the blocked marker arm `RequestAttention=yes` on the client ttys, and the bounce is cancelled with `no` once the wait is answered or the tab has been read (focus dwell); a crashed poller's stranded bounce is healed by the startup sweep. The reply-ready blink deliberately stays tab-only ([commit](https://github.com/pqant/claude-continuity/commit/89d55c2)).
29
+ - **2026-11-12**: The Dock bounce can no longer be swallowed by macOS: a bounce written while the terminal app is frontmost (the system only bounces backgrounded apps) is re-fired the moment iTerm2 goes to the background: the poller and the animator watch the frontmost app on their ~1 s tick and re-write a still-armed bounce exactly once per foreground-to-background transition, never per tick ([commit](https://github.com/pqant/claude-continuity/commit/fe215b4)).
30
+ - **2026-11-12**: The Dock bounce now covers the reply-ready blink too: when a turn finishes and its tab is waiting to be read, the iTerm2 Dock icon bounces just like it does for needs-human waits, so a finished turn catches your eye while you work in another app. Set `"blink_reply_attention": false` in `~/.claude-continuity/config.json` to keep turn-ends tab-blink only ([commit](https://github.com/pqant/claude-continuity/commit/3dc9c0d)).
31
+ - **2026-11-12**: Needs-human and blocked waits now bounce the iTerm2 Dock icon too, not just the tab: an unconsumed `needs_human` reason (a `signal needs-human` or a watchdog stall), a permission or selection prompt, or the blocked marker arm `RequestAttention=yes` on the client ttys, and the bounce is cancelled with `no` once the wait is answered or the tab has been read (focus dwell); a crashed poller's stranded bounce is healed by the startup sweep ([commit](https://github.com/pqant/claude-continuity/commit/89d55c2)).
30
32
  - **2026-11-12**: Dead image chips no longer sit next to the live one: one paste is written as two records, and when the image cache is pruned before the export the record carrying only the `[Image: source: <path>]` line embedded nothing yet still opened its own non-clickable chip. Such an empty chip-only record now folds into the gallery of the block right in front of it; with no adjacent gallery it survives as a plain chip so the trace of the unrecoverable paste remains ([commit](https://github.com/pqant/claude-continuity/commit/fc86a4f)).
31
33
  - **2026-11-12**: Auto-rotation no longer stalls after a verified handoff: the rotator counted its own gate ledger entry (written a few milliseconds after the Stop timestamp) as session activity, so the rotation deferred and waited for a "next Stop" that never comes once the handoff ended the turn. Gate entries are now excluded exactly like state bookkeeping, and the pane rotates instead of sitting idle ([commit](https://github.com/pqant/claude-continuity/commit/e799446)).
32
- - **2026-11-12**: The `🖼 image` chip gained a second source: records that keep only the `[Image: source: <path>]` line (no base64 block) now have their file read from disk at export time and embedded, so those chips open in the lightbox too. The read is best-effort (whitelisted extensions, per-image cap), and missing, pruned or oversized files keep the plain chip ([commit](https://github.com/pqant/claude-continuity/commit/26d0144)).
33
- - **2026-11-11**: The `🖼 image` chip became a window: clicking it opens the real pasted image in a lightbox modal right on the transcript page (prev/next + `i / n` counter, Escape or backdrop click closes). Images are embedded as data URIs, so the export stays a single self-contained HTML file; a folded run of chips shares one merged gallery, and over-cap or non-whitelisted images keep the plain chip ([commit](https://github.com/pqant/claude-continuity/commit/369f9a4)).## How it works
34
+
35
+ ## How it works
34
36
 
35
37
  The whole flow in one picture: the automatic session loop, the optional
36
38
  watchdog, and the opt-in notifications:
@@ -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.26"
7
+ __version__ = "0.3.28"
@@ -298,6 +298,7 @@ class Blinker:
298
298
  self._log = log if log is not None else _debug_line
299
299
  self.enabled = config.blink_enabled(cfg)
300
300
  self._interval = config.blink_interval(cfg)
301
+ self._reply_attention = config.blink_reply_attention(cfg)
301
302
  self._fill = osc6_fill(
302
303
  RED_FILL if config.blink_no_color(cfg) else BLACK_FILL)
303
304
  self._blinking = False
@@ -370,11 +371,11 @@ class Blinker:
370
371
  def _attention(self, waiting: bool) -> None:
371
372
  """Dock bounce for the CURRENT tick (issue #59).
372
373
 
373
- Edge-triggered: bytes only cross when the state flips. Only
374
- needs-human/blocked/selection sources arm it; a reply-only wait
375
- must never bounce the Dock (user ruling 2026-11-12). Cancelling
376
- is harmless when iTerm2 already stopped on its own (the user
377
- clicked the Dock icon): a second "no" is a no-op.
374
+ Edge-triggered: bytes only cross when the state flips.
375
+ Needs-human/blocked/selection sources always arm it; a reply-only
376
+ wait arms too while blink_reply_attention is on (issue #60).
377
+ Cancelling is harmless when iTerm2 already stopped on its own
378
+ (the user clicked the Dock icon): a second "no" is a no-op.
378
379
  """
379
380
  if waiting == self._attention_armed:
380
381
  return
@@ -443,11 +444,14 @@ class Blinker:
443
444
  if pane_ask:
444
445
  count += 1
445
446
  gated = count > 0
446
- # Dock bounce sources (issue #59): the blocked and ask
447
- # families; a reply-only wait stays tab-blink only.
447
+ # Dock bounce sources (issues #59, #60): the blocked and ask
448
+ # families always arm; the reply marker arms too unless
449
+ # blink_reply_attention is off.
448
450
  waiting = bool(pane_ask
449
451
  or (text or "").count(MARKER_BLOCKED)
450
- or (text or "").count(MARKER_ASK))
452
+ or (text or "").count(MARKER_ASK)
453
+ or (self._reply_attention
454
+ and (text or "").count(MARKER_REPLY)))
451
455
  if gated and not self._blinking:
452
456
  self._start(now, waiting)
453
457
  return
@@ -477,6 +481,69 @@ class Blinker:
477
481
  except Exception:
478
482
  pass
479
483
 
484
+ def rearm_attention(self) -> None:
485
+ """Re-write the Dock bounce while it is still armed (issue #61).
486
+
487
+ macOS only bounces a BACKGROUNDED app, so the edge-triggered
488
+ "yes" of ``_attention`` can land while the terminal is frontmost
489
+ and get swallowed. The caller (``AppBounce``) asks for a re-write
490
+ when the app leaves the foreground. Silent unless armed: a wait
491
+ that ended (answered, or read via focus dwell) must not come
492
+ back to life here.
493
+ """
494
+ if not self._attention_armed:
495
+ return
496
+ for tty in self._ttys:
497
+ write_tty(tty, OSC1337_ATTENTION_ON, _open=self._tty_open)
498
+ self._log(f"attention rearmed window={self.window_id}")
499
+
500
+
501
+ class AppBounce:
502
+ """Re-fire armed Dock bounces when the terminal app leaves the foreground.
503
+
504
+ Issue #61 (verified live 2026-11-12): macOS bounces the Dock of a
505
+ BACKGROUNDED application only. ``Blinker._attention`` writes "yes"
506
+ once, at the edge where the wait opens - if the user is still inside
507
+ iTerm2 at that moment (another window or tab) the system swallows
508
+ the bytes and nothing retries when the app finally goes away. This
509
+ coordinator watches the frontmost app on the caller's ~1 s tick and
510
+ re-writes each still-armed blinker exactly on the observed
511
+ foreground-to-background edge. No periodic spam: holding in the
512
+ background re-fires nothing. A probe that yields None (or raises)
513
+ means "no info": state is held and nothing fires, the safe degrade
514
+ to the pre-#61 behavior.
515
+ """
516
+
517
+ # App names whose Dock is the one that bounces; anything else counts
518
+ # as background. Non-iTerm2 terminals receive a harmless "yes"
519
+ # rewrite (unknown OSC sequences are ignored there).
520
+ TERMINAL_APPS = frozenset({"iTerm2", "iTerm"})
521
+
522
+ def __init__(self, blinkers, *, frontmost_app=None):
523
+ self._blinkers = list(blinkers)
524
+ self._frontmost_app = frontmost_app
525
+ self._was_bg = None # no observed reading yet: never fire blind
526
+
527
+ def tick(self, t: float) -> None:
528
+ """One ~1 s tick: re-fire each armed blinker on the bg edge."""
529
+ probe = self._frontmost_app
530
+ if probe is None:
531
+ return
532
+ try:
533
+ app = probe()
534
+ except Exception:
535
+ app = None
536
+ if app is None:
537
+ return
538
+ bg = app not in self.TERMINAL_APPS
539
+ if bg and self._was_bg is False:
540
+ for blinker in self._blinkers:
541
+ try:
542
+ blinker.rearm_attention()
543
+ except Exception:
544
+ pass
545
+ self._was_bg = bg
546
+
480
547
 
481
548
  class FocusWatcher:
482
549
  """Focus-dwell suppression shared by the poller and the animator.
@@ -104,11 +104,33 @@ def _default_frontmost_tty():
104
104
  return None
105
105
 
106
106
 
107
+ def _default_frontmost_app():
108
+ """Name of the frontmost application (AppleScript); None unreadable.
109
+
110
+ Issue #61: macOS only bounces a BACKGROUNDED app, so the poller and
111
+ the animator re-fire a still-armed Dock bounce when the terminal
112
+ leaves the foreground. Any failure yields None (no info: the
113
+ ``AppBounce`` coordinator holds its state and never re-fires).
114
+ """
115
+ try:
116
+ r = subprocess.run(
117
+ ["osascript", "-e",
118
+ 'tell application "System Events" to name of first '
119
+ 'application process whose frontmost is true'],
120
+ capture_output=True, text=True, timeout=2.0)
121
+ if r.returncode == 0 and r.stdout.strip():
122
+ return r.stdout.strip()
123
+ except Exception:
124
+ pass
125
+ return None
126
+
127
+
107
128
  def watch(session_dir, *, pane_id: str, window_id: str, cfg: dict,
108
129
  _runner=subprocess.run, _bin_=None, _tty_open=open,
109
130
  _now=time.time, _sleep=time.sleep, _ticks=None, _blink=None,
110
131
  _state=None, _consec_fails: int = 6,
111
132
  _frontmost_tty=None, _client_ttys=None,
133
+ _frontmost_app=None,
112
134
  _dwell_ticks: int = 3, _reply_fade: float = 600.0,
113
135
  _settle: float | None = None,
114
136
  _focus_log=blink._debug_line) -> None:
@@ -161,6 +183,12 @@ def watch(session_dir, *, pane_id: str, window_id: str, cfg: dict,
161
183
  dwell_ticks=_dwell_ticks,
162
184
  label=window_id or "",
163
185
  log=_focus_log)
186
+ # app-background re-fire (issue #61): macOS swallows a bounce
187
+ # written while the terminal app is frontmost, so a still-armed
188
+ # bounce is re-written when the app leaves the foreground. The
189
+ # probe rides on the injected seam; None (the default) disables
190
+ # the re-fire entirely.
191
+ bounce = blink.AppBounce([blinker], frontmost_app=_frontmost_app)
164
192
  except Exception:
165
193
  return
166
194
  start = _now()
@@ -228,6 +256,10 @@ def watch(session_dir, *, pane_id: str, window_id: str, cfg: dict,
228
256
  blinker.on_text("", t, pane_text=None)
229
257
  else:
230
258
  blinker.on_text(text, t, pane_text=pane_text)
259
+ try:
260
+ bounce.tick(t)
261
+ except Exception:
262
+ pass
231
263
  i += 1
232
264
  if _ticks is not None and i >= _ticks:
233
265
  return
@@ -511,8 +511,11 @@ def cmd_progress_pane(args: argparse.Namespace) -> int:
511
511
  win = args.window_id or progress_pane.resolve_window_id()
512
512
  # focus dwell (user directive 2026-11-07): real iTerm2 frontmost tty
513
513
  # probe; None off-iTerm2 (the watcher then disables dwell itself)
514
+ # app-background re-fire (issue #61): frontmost app name probe for
515
+ # the Dock bounce re-write
514
516
  progress_pane.run_animator(window_id=win,
515
- _frontmost_tty=blink_watch._default_frontmost_tty)
517
+ _frontmost_tty=blink_watch._default_frontmost_tty,
518
+ _frontmost_app=blink_watch._default_frontmost_app)
516
519
  return 0
517
520
 
518
521
 
@@ -533,7 +536,8 @@ def cmd_blink_watch(args: argparse.Namespace) -> int:
533
536
  cfg = {}
534
537
  blink_watch.watch(args.session_dir, pane_id=args.pane,
535
538
  window_id=args.window, cfg=cfg,
536
- _frontmost_tty=blink_watch._default_frontmost_tty)
539
+ _frontmost_tty=blink_watch._default_frontmost_tty,
540
+ _frontmost_app=blink_watch._default_frontmost_app)
537
541
  return 0
538
542
 
539
543
 
@@ -257,6 +257,19 @@ def blink_reply(cfg: dict) -> bool:
257
257
  return v if isinstance(v, bool) else True
258
258
 
259
259
 
260
+ def blink_reply_attention(cfg: dict) -> bool:
261
+ """Whether the reply-ready blink also bounces the iTerm2 Dock (issue #60).
262
+
263
+ ``blink_reply_attention``: explicit false keeps the turn-end blink
264
+ tab-only; needs-human and blocked waits keep bouncing the Dock either
265
+ way. A missing key or any non-bool value degrades to True (user
266
+ ruling 2026-11-12: try it on by default, flip the key if it feels
267
+ noisy).
268
+ """
269
+ v = cfg.get("blink_reply_attention", True)
270
+ return v if isinstance(v, bool) else True
271
+
272
+
260
273
  def blink_reply_settle(cfg: dict) -> float:
261
274
  """Seconds a finished turn stays quiet before the reply blink arms.
262
275
 
@@ -492,6 +492,7 @@ def run_animator(window_id: str | None = None, *, _frames=None,
492
492
  _check_every=40, _blink=None, _tty_open=None,
493
493
  _runner=None, _pane_capture=None,
494
494
  _blink_poll=20, _frontmost_tty=None,
495
+ _frontmost_app=None,
495
496
  _dwell_ticks=3, _focus_log=blink._debug_line,
496
497
  _build_stamp=None, _build_poll=20,
497
498
  _restart=None, _reply_flag_read=None,
@@ -630,6 +631,12 @@ def run_animator(window_id: str | None = None, *, _frames=None,
630
631
  dwell_ticks=_dwell_ticks,
631
632
  label=window_id or "",
632
633
  log=_focus_log)
634
+ # app-background re-fire (issue #61): macOS only bounces a
635
+ # BACKGROUNDED app, so a still-armed bounce is re-written when the
636
+ # terminal leaves the foreground. The probe rides on the injected
637
+ # seam and runs only on the ~1 s blink-poll tick; None (the default)
638
+ # disables the re-fire entirely.
639
+ bounce = blink.AppBounce([blinker], frontmost_app=_frontmost_app)
633
640
  # Stale-build guard (issue #19): see ``_default_build_stamp``. Every
634
641
  # _build_poll frames (~1 s at 20 fps) the sources we run are re-statted;
635
642
  # a change breaks out through the SHARED exit path (restore runs once
@@ -781,6 +788,13 @@ def run_animator(window_id: str | None = None, *, _frames=None,
781
788
  suppressed = watcher.tick(t, src)
782
789
  except Exception:
783
790
  suppressed = False
791
+ # app-background re-fire (issue #61): on the same ~1 s
792
+ # cadence watch the terminal app leaving the foreground;
793
+ # a no-info reading never re-fires and never churns state.
794
+ try:
795
+ bounce.tick(t)
796
+ except Exception:
797
+ pass
784
798
  else:
785
799
  paint_text = cur_text
786
800
  if reply_live and blink.MARKER_REPLY not in (paint_text or ""):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.26
3
+ Version: 0.3.28
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Requires-Python: >=3.11
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cc-continuity"
7
- version = "0.3.26"
7
+ version = "0.3.28"
8
8
  description = "Zero-touch session rotation for Claude Code (local large-context model)"
9
9
  requires-python = ">=3.11"
10
10
  dependencies = [] # stdlib only at runtime (PRD §0.5)
@@ -317,9 +317,9 @@ def test_blinker_never_raises_on_broken_plumbing():
317
317
 
318
318
 
319
319
  # ------------------------------------------------- iTerm2 Dock attention
320
- # (issue #59): while a needs-human/BLOCKED wait is on screen the Dock icon
321
- # bounces via OSC 1337 RequestAttention; reply-only waits must stay silent
322
- # (user ruling 2026-11-12).
320
+ # (issues #59, #60): while a wait is on screen the Dock icon bounces via
321
+ # OSC 1337 RequestAttention; reply-ready waits bounce too unless the user
322
+ # opts out with blink_reply_attention=false (user ruling 2026-11-12).
323
323
 
324
324
 
325
325
  def test_attention_yes_on_blocked_start_and_no_on_restore():
@@ -335,15 +335,24 @@ def test_attention_yes_on_blocked_start_and_no_on_restore():
335
335
 
336
336
 
337
337
  def test_attention_never_fires_for_reply_only_wait():
338
- # A finished turn waiting for the next prompt is NOT a blocked wait.
338
+ # With blink_reply_attention false a finished turn waiting for the
339
+ # next prompt stays tab-blink only, never a Dock bounce (issue #60).
339
340
  r, tty = ScriptRunner(["orig", "/dev/ttys001"]), FakeTTY()
340
- b = _blinker(r, tty)
341
+ b = _blinker(r, tty, cfg={"blink_reply_attention": False})
341
342
  b.on_text(REPLY_TEXT, 0.0)
342
343
  b.on_text(REPLY_TEXT, 0.5)
343
344
  b.on_exit()
344
345
  assert b"RequestAttention" not in tty.bytes_for("/dev/ttys001")
345
346
 
346
347
 
348
+ def test_attention_arms_for_reply_wait_by_default():
349
+ # Reply-ready bounces the Dock out of the box (issue #60).
350
+ r, tty = ScriptRunner(["orig", "/dev/ttys001"]), FakeTTY()
351
+ b = _blinker(r, tty)
352
+ b.on_text(REPLY_TEXT, 0.0)
353
+ assert tty.bytes_for("/dev/ttys001") == blink.OSC1337_ATTENTION_ON
354
+
355
+
347
356
  def test_attention_yes_on_ask_marker():
348
357
  r, tty = ScriptRunner(["orig", "/dev/ttys001"]), FakeTTY()
349
358
  b = _blinker(r, tty)
@@ -360,8 +369,9 @@ def test_attention_yes_on_selection_pane():
360
369
 
361
370
  def test_attention_arms_once_mid_blink_and_disarms_when_source_clears():
362
371
  r, tty = ScriptRunner(["orig", "/dev/ttys001"]), FakeTTY()
363
- b = _blinker(r, tty, cfg={"blink_interval": 0.5})
364
- b.on_text(REPLY_TEXT, 0.0) # reply only: stays silent
372
+ b = _blinker(r, tty,
373
+ cfg={"blink_interval": 0.5, "blink_reply_attention": False})
374
+ b.on_text(REPLY_TEXT, 0.0) # reply opted out: silent
365
375
  b.on_text(REPLY_TEXT + " ⛔ BLOCKED", 0.1) # blocked joins: arm once
366
376
  b.on_text(REPLY_TEXT + " ⛔ BLOCKED", 0.2) # no re-write per tick
367
377
  assert tty.bytes_for("/dev/ttys001") == blink.OSC1337_ATTENTION_ON
@@ -435,6 +445,67 @@ def test_failed_clear_keeps_stored_name_for_later_sweep():
435
445
  assert store("blink_name") == "orig"
436
446
 
437
447
 
448
+ # ------------------------------------------- app-background re-bounce (#61)
449
+ #
450
+ # macOS bounces the Dock of a BACKGROUNDED app only: a "yes" written
451
+ # while iTerm2 is frontmost gets swallowed by the system (verified live
452
+ # 2026-11-12) and the edge-triggered single write is never retried when
453
+ # the user leaves the app. AppBounce re-writes a still-armed bounce via
454
+ # Blinker.rearm_attention, once per observed foreground-to-background
455
+ # edge (no periodic spam).
456
+
457
+
458
+ class _RearmRecorder:
459
+ """Blinker-shaped recorder counting AppBounce's re-fire calls."""
460
+
461
+ def __init__(self):
462
+ self.rearms = 0
463
+
464
+ def rearm_attention(self):
465
+ self.rearms += 1
466
+
467
+
468
+ def test_rearm_attention_rewrites_yes_when_armed():
469
+ # While a wait arms the bounce, a background transition must write
470
+ # "yes" a second time (the first one was swallowed on-foreground).
471
+ r, tty = ScriptRunner(["orig", "/dev/ttys001"]), FakeTTY()
472
+ b = _blinker(r, tty)
473
+ b.on_text(GATE, 0.0) # waiting: bounce armed
474
+ b.rearm_attention() # app left the foreground: re-fire
475
+ assert tty.bytes_for("/dev/ttys001") == (
476
+ blink.OSC1337_ATTENTION_ON + blink.OSC1337_ATTENTION_ON)
477
+
478
+
479
+ def test_rearm_attention_silent_when_disarmed():
480
+ # No wait open (nothing armed): a re-fire must not write a single
481
+ # byte - the bounce stays exactly as cancelled.
482
+ r, tty = ScriptRunner(["orig", "/dev/ttys001"]), FakeTTY()
483
+ b = _blinker(r, tty)
484
+ b.rearm_attention()
485
+ assert tty.files == {}
486
+
487
+
488
+ def test_app_bounce_fires_only_on_background_edge():
489
+ rec = _RearmRecorder()
490
+ apps = iter(["iTerm2", "Finder", "Finder", "iTerm2", "Finder", None])
491
+ bounce = blink.AppBounce([rec], frontmost_app=lambda: next(apps))
492
+ for k in range(6):
493
+ bounce.tick(k / 10.0)
494
+ # the two observed frontmost->background transitions fire; holding
495
+ # in the background (and the no-info reading) never re-fires.
496
+ assert rec.rearms == 2
497
+
498
+
499
+ def test_app_bounce_probe_none_never_fires():
500
+ # No focus info (probe yields None): nothing is known, so nothing
501
+ # fires and the state is held (safe degrade to the pre-#61 behavior).
502
+ rec = _RearmRecorder()
503
+ bounce = blink.AppBounce([rec], frontmost_app=lambda: None)
504
+ for k in range(4):
505
+ bounce.tick(k / 10.0)
506
+ assert rec.rearms == 0
507
+
508
+
438
509
  # ------------------------- AskUserQuestion / selection prompt (issue #11 follow-up)
439
510
  #
440
511
  # Live bug 2026-11-07 (connector-177): the AskUserQuestion dialog sat open
@@ -81,6 +81,7 @@ class _Probe:
81
81
  self.store = store
82
82
  self.ticks = []
83
83
  self.exits = 0
84
+ self.rearms = 0
84
85
 
85
86
  def on_text(self, text, now, pane_text=None):
86
87
  self.ticks.append((text, pane_text))
@@ -88,6 +89,9 @@ class _Probe:
88
89
  def on_exit(self):
89
90
  self.exits += 1
90
91
 
92
+ def rearm_attention(self):
93
+ self.rearms += 1
94
+
91
95
 
92
96
  class _FakeBlinkMod:
93
97
  """blink-shaped module: recording Blinker, scripted captures."""
@@ -358,7 +362,17 @@ def test_spawn_never_raises_on_runner_failure(cc_home, monkeypatch):
358
362
 
359
363
  def _run_watch(fake, *, cfg=None, ticks=1, now=0.0, frontmost=None,
360
364
  clients=frozenset(), dwell=3, fade=600.0,
361
- session_dir="/sess"):
365
+ frontmost_app=None, session_dir="/sess"):
366
+ if frontmost_app is None:
367
+ def app_fn():
368
+ return None
369
+ elif callable(frontmost_app):
370
+ app_fn = frontmost_app
371
+ else:
372
+ seq = iter(frontmost_app)
373
+
374
+ def app_fn():
375
+ return next(seq, None)
362
376
  blink_watch.watch(
363
377
  session_dir, pane_id="%7", window_id="@7", cfg=cfg or {}, _blink=fake,
364
378
  _runner=lambda argv, **kw: subprocess.CompletedProcess(argv, 0,
@@ -367,7 +381,8 @@ def _run_watch(fake, *, cfg=None, ticks=1, now=0.0, frontmost=None,
367
381
  _sleep=_sleep_noop, _ticks=ticks, _state=lambda d: "ACTIVE",
368
382
  _frontmost_tty=(frontmost if frontmost is not None else (lambda: None)),
369
383
  _client_ttys=clients if callable(clients) else (lambda: set(clients)),
370
- _dwell_ticks=dwell, _reply_fade=fade, _focus_log=None)
384
+ _dwell_ticks=dwell, _reply_fade=fade, _focus_log=None,
385
+ _frontmost_app=app_fn)
371
386
 
372
387
 
373
388
  def test_watch_reply_ready_blinks_without_block(cc_home, monkeypatch):
@@ -585,3 +600,37 @@ def test_watch_reply_cancelled_by_auto_continue(cc_home, tmp_path,
585
600
  session_dir=tmp_path)
586
601
  text, _ = fake.made[0].ticks[0]
587
602
  assert text == ""
603
+
604
+
605
+ # ------------------------------------------------- app-background re-bounce
606
+ #
607
+ # Issue #61: macOS swallows a Dock bounce written while the terminal app
608
+ # is frontmost, so the poller re-fires a still-armed bounce when the app
609
+ # LEAVES the foreground. Transition edge only: no per-tick spam while
610
+ # the user stays away.
611
+
612
+
613
+ def test_watch_app_background_edge_refires_bounce(cc_home, monkeypatch):
614
+ monkeypatch.setattr(blink_watch.ledger, "blocked_reason",
615
+ lambda d: "deploy approval")
616
+ monkeypatch.setattr(blink_watch.ledger, "reply_pending",
617
+ lambda d, **kw: None)
618
+ fake = _FakeBlinkMod(captures=[None])
619
+ _run_watch(fake, ticks=2, frontmost_app=["iTerm2", "Finder"])
620
+ # tick 1: still in iTerm2 (no edge); tick 2: Finder takes over: the
621
+ # armed bounce is re-written exactly once.
622
+ assert fake.made[0].rearms == 1
623
+
624
+
625
+ def test_watch_app_background_steady_never_refires(cc_home, monkeypatch):
626
+ monkeypatch.setattr(blink_watch.ledger, "blocked_reason",
627
+ lambda d: "deploy approval")
628
+ monkeypatch.setattr(blink_watch.ledger, "reply_pending",
629
+ lambda d, **kw: None)
630
+ fake = _FakeBlinkMod(captures=[None])
631
+ _run_watch(fake, ticks=3,
632
+ frontmost_app=["Finder", "Finder", "Finder"])
633
+ # no OBSERVED transition (the very first reading is already
634
+ # background): nothing is re-written - and holding in the background
635
+ # never spams either.
636
+ assert fake.made[0].rearms == 0
@@ -931,6 +931,7 @@ class _BlinkProbe:
931
931
  self.store = store
932
932
  self.texts = []
933
933
  self.exits = 0
934
+ self.rearms = 0
934
935
 
935
936
  def on_text(self, text, now, pane_text=None):
936
937
  self.texts.append((text, now, pane_text))
@@ -938,6 +939,9 @@ class _BlinkProbe:
938
939
  def on_exit(self):
939
940
  self.exits += 1
940
941
 
942
+ def rearm_attention(self):
943
+ self.rearms += 1
944
+
941
945
 
942
946
  class _FakeBlinkMod:
943
947
  def __init__(self):
@@ -1107,6 +1111,25 @@ def test_animator_focus_dwell_silences_blinker_ticks(cc_home, monkeypatch):
1107
1111
  assert texts[2] == ("", 0.2, None) # read state holds across frames
1108
1112
 
1109
1113
 
1114
+ def test_animator_app_background_edge_refires_bounce(cc_home, monkeypatch):
1115
+ # issue #61: on the ~1 s blink-poll cadence the animator watches the
1116
+ # terminal app leave the foreground and re-fires the armed bounce
1117
+ # (macOS only bounces a backgrounded app). Blink starts at frame 0
1118
+ # (armed), the background edge lands on the next blink poll.
1119
+ monkeypatch.delenv("TMUX_PANE", raising=False)
1120
+ fake = _FakeBlinkMod()
1121
+ clock = (k * 0.05 for k in range(1000))
1122
+ apps = iter(["iTerm2", "Finder"])
1123
+ progress_pane.run_animator(
1124
+ "12", _frames=45, _write=lambda b: None, _now=lambda: next(clock),
1125
+ _size=lambda: _size_obj(80), _text=lambda: "◆ 61% ok ⛔ BLOCKED",
1126
+ _mtime=lambda: 1, _sleep=lambda s: None, _blink=fake,
1127
+ _frontmost_app=lambda: next(apps, None))
1128
+ # bounce ticks at i=0 (iTerm2: foreground), i=20 (Finder: edge ->
1129
+ # re-fire once), i=40 (no info left: held).
1130
+ assert fake.made[0].rearms == 1
1131
+
1132
+
1110
1133
  # ---------------- stable gate key under text churn (focus dwell v2 fix)
1111
1134
  #
1112
1135
  # The watcher key must describe the GATE, not the raw text: while the
File without changes
File without changes