cc-continuity 0.3.22__tar.gz → 0.3.24__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.22 → cc_continuity-0.3.24}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/README.md +2 -2
  3. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/rotator.py +8 -2
  5. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/transcript.py +45 -2
  6. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity.egg-info/PKG-INFO +1 -1
  7. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/pyproject.toml +1 -1
  8. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_rotator.py +25 -0
  9. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_transcript.py +66 -0
  10. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/LICENSE +0 -0
  11. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/__main__.py +0 -0
  12. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/atomic.py +0 -0
  13. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/blink.py +0 -0
  14. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/blink_watch.py +0 -0
  15. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/bootstrap.py +0 -0
  16. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/checkpoint.py +0 -0
  17. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/cli.py +0 -0
  18. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/config.py +0 -0
  19. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/daemon_supervisor.py +0 -0
  20. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/doctor.py +0 -0
  21. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/gitsnap.py +0 -0
  22. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/__init__.py +0 -0
  23. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/common.py +0 -0
  24. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/pre_compact.py +0 -0
  25. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/pre_tool_use.py +0 -0
  26. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/session_end.py +0 -0
  27. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/session_start.py +0 -0
  28. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/stop.py +0 -0
  29. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/task.py +0 -0
  30. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/tool_use.py +0 -0
  31. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hooks/user_prompt.py +0 -0
  32. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/hosting.py +0 -0
  33. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/install.py +0 -0
  34. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/launch.py +0 -0
  35. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/ledger.py +0 -0
  36. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/lock.py +0 -0
  37. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/managed.py +0 -0
  38. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/naming.py +0 -0
  39. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/notify.py +0 -0
  40. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/paths.py +0 -0
  41. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/power_plug.py +0 -0
  42. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/progress_pane.py +0 -0
  43. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/project.py +0 -0
  44. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/redact.py +0 -0
  45. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/settings_merge.py +0 -0
  46. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/skills.py +0 -0
  47. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/state.py +0 -0
  48. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/statusline.py +0 -0
  49. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/thresholds.py +0 -0
  50. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/validate.py +0 -0
  51. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/watchdog.py +0 -0
  52. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/watchdog_digest.py +0 -0
  53. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity/watchdogd.py +0 -0
  54. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity.egg-info/SOURCES.txt +0 -0
  55. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity.egg-info/dependency_links.txt +0 -0
  56. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity.egg-info/entry_points.txt +0 -0
  57. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/cc_continuity.egg-info/top_level.txt +0 -0
  58. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/setup.cfg +0 -0
  59. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_atomic.py +0 -0
  60. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_blink.py +0 -0
  61. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_blink_watch.py +0 -0
  62. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_bootstrap.py +0 -0
  63. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_checkpoint.py +0 -0
  64. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_cli.py +0 -0
  65. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_cli_ledger.py +0 -0
  66. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_config.py +0 -0
  67. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_daemon_supervisor.py +0 -0
  68. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_doctor.py +0 -0
  69. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_gitsnap.py +0 -0
  70. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_common.py +0 -0
  71. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_pre_compact.py +0 -0
  72. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_pre_tool_use.py +0 -0
  73. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_session_end.py +0 -0
  74. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_session_start.py +0 -0
  75. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_stop.py +0 -0
  76. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_task.py +0 -0
  77. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_tool_use.py +0 -0
  78. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hooks_user_prompt.py +0 -0
  79. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hosting.py +0 -0
  80. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_hygiene.py +0 -0
  81. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_install.py +0 -0
  82. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_integration_phase5.py +0 -0
  83. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_integration_phase6.py +0 -0
  84. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_integration_phase7.py +0 -0
  85. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_launch.py +0 -0
  86. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_ledger.py +0 -0
  87. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_lock.py +0 -0
  88. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_managed.py +0 -0
  89. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_naming.py +0 -0
  90. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_notify.py +0 -0
  91. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_notify_integration.py +0 -0
  92. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_paths.py +0 -0
  93. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_power_plug.py +0 -0
  94. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_progress_pane.py +0 -0
  95. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_project.py +0 -0
  96. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_redact.py +0 -0
  97. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_settings_merge.py +0 -0
  98. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_skills.py +0 -0
  99. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_state.py +0 -0
  100. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_status.py +0 -0
  101. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_statusline.py +0 -0
  102. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_thresholds.py +0 -0
  103. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_tmux_host.py +0 -0
  104. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_transcript_finalize.py +0 -0
  105. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_uninstall.py +0 -0
  106. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_validate.py +0 -0
  107. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_watchdog.py +0 -0
  108. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_watchdog_digest.py +0 -0
  109. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_watchdog_integration.py +0 -0
  110. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_watchdogd.py +0 -0
  111. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/tests/test_wsl_doctor.py +0 -0
  112. {cc_continuity-0.3.22 → cc_continuity-0.3.24}/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.22
3
+ Version: 0.3.24
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,11 @@ 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**: 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)).
30
+ - **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)).
29
31
  - **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)).
30
32
  - **2026-11-11**: The transcript page now stays out of the conversation's way: protocol plumbing is filtered out (slash-command XML from `/clear` and `/rename`, task notifications, Continuity Stop-hook feedback, skill base-directory lines, `No response requested.`), the CONTINUITY RESUME blob and CC's resume prompt collapse to one-line anchors (`↻ CONTINUITY RESUME cp-NNN · handoff.md`, `↻ CC resume`), and pasted images fold into a single `🖼 image` chip instead of raw metadata lines ([commit](https://github.com/pqant/claude-continuity/commit/6366583)).
31
33
  - **2026-11-11**: Deferred rotations now wake themselves up: when the rotator defers because the agent was still active after the Stop, it arms a bounded self-retry tick that re-checks a short delay later and drives the rotation itself once the session is quiet. The Stop hook stays the primary route, the tick is idempotent (rotation_id guard) and capped in attempts, and `"retry_deferred": false` in the config turns the path off ([commit](https://github.com/pqant/claude-continuity/commit/dacaab0)).
32
- - **2026-11-11**: DEGRADED handoffs now freeze themselves: the banner gained a direct order for the still-alive pre-rotation agent ("This file is finalized. Do not edit it and do not start any more work in this session; end your turn now."), so a finished handoff can no longer be reached into and edited after finalization ([commit](https://github.com/pqant/claude-continuity/commit/5b2a07e)).
33
- - **2026-11-11**: The HUD prev-task segment is now readable at a glance: the Active Usage line reads `⏱ Previous task completion 39m 15s` (spaced units; `1h 2m 03s` and `47s` too) instead of `⏱ prev task 39m15s`, while the turn clock prompt line keeps its compact shape ([commit](https://github.com/pqant/claude-continuity/commit/12dd90b)).
34
34
  ## How it works
35
35
 
36
36
  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.22"
7
+ __version__ = "0.3.24"
@@ -344,13 +344,19 @@ def _idle(key: str, nnn: int) -> bool:
344
344
  the last Stop. Entries with ``agent_id`` are subagent work and do NOT
345
345
  defer the rotation (P6-D6). ``type == "state"`` entries are our own
346
346
  transition bookkeeping (the Stop hook's CV→ROTATING move lands AFTER
347
- ``last_stop_ts``) and must not count as activity either."""
347
+ ``last_stop_ts``) and must not count as activity either. ``type ==
348
+ "gate"`` is the same self-written class: the Stop hook sets
349
+ ``last_stop_ts`` and only then logs the handoff gate decision
350
+ (stop.py), so a valid-draft Stop always appends a gate entry past
351
+ ``last_stop_ts`` - counting it would defer the rotation forever,
352
+ because the Stop that ends the handoff turn is the last Stop that
353
+ ever comes."""
348
354
  rec = state.load_state(key, nnn)
349
355
  if rec.get("turn_active"):
350
356
  return False
351
357
  last_stop = rec.get("last_stop_ts") or 0
352
358
  for entry in ledger.read(paths.session_dir(key, nnn)):
353
- if entry.get("agent_id") or entry.get("type") == "state":
359
+ if entry.get("agent_id") or entry.get("type") in ("state", "gate"):
354
360
  continue
355
361
  if entry.get("ts", 0) > last_stop:
356
362
  return False
@@ -11,6 +11,7 @@ finalize, validation, or resume (P9-D7). Stdlib only, English strings.
11
11
 
12
12
  from __future__ import annotations
13
13
 
14
+ import base64
14
15
  import html
15
16
  import json
16
17
  import re
@@ -57,6 +58,11 @@ _IMAGE_CHIP = "\U0001f5bc image"
57
58
  #: chip so the single-file export stays sane.
58
59
  _IMG_MEDIA = ("image/png", "image/jpeg", "image/gif", "image/webp")
59
60
  _MAX_IMG_B64 = 4_000_000
61
+ #: Path-only records (issue #56): extension -> media type for reading a
62
+ #: pasted image whose file is still sitting under ``.claude/image-cache``
63
+ #: (the directory is pruned later, so only the export can catch it).
64
+ _IMG_MIME = {".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
65
+ ".gif": "image/gif", ".webp": "image/webp"}
60
66
 
61
67
 
62
68
  def md_inline(s: str) -> str:
@@ -91,6 +97,29 @@ def _image_uri(block: dict) -> str:
91
97
  return f"data:{media};base64,{data}"
92
98
 
93
99
 
100
+ def _image_from_path(path: str) -> str:
101
+ """Data URI for a pasted image whose file is still on disk (issue #56).
102
+
103
+ Some records keep only the ``[Image: source: <path>]`` text line and
104
+ no base64 block; the bytes live under ``.claude/image-cache`` until
105
+ pruned, so the export (which runs at rotation time, minutes after the
106
+ paste) reads them best-effort. Non-whitelisted extensions, anything
107
+ unreadable, and data past ``_MAX_IMG_B64`` return an empty string so
108
+ the chip stays plain.
109
+ """
110
+ p = Path(path)
111
+ try:
112
+ media = _IMG_MIME.get(p.suffix.lower())
113
+ if media is None or not p.is_file():
114
+ return ""
115
+ data = base64.b64encode(p.read_bytes()).decode("ascii")
116
+ except OSError:
117
+ return ""
118
+ if not data or len(data) > _MAX_IMG_B64:
119
+ return ""
120
+ return f"data:{media};base64,{data}"
121
+
122
+
94
123
  def md_to_html(md: str) -> str:
95
124
  """Block-level markdown subset to an HTML fragment.
96
125
 
@@ -165,8 +194,9 @@ def parse_conversation(lines: list[str]) -> list[Block]:
165
194
  anchors; image metadata lines fold into a ``🖼 image`` chip (runs of
166
195
  chips collapse to one, their galleries merge). Embeddable base64
167
196
  image blocks attach to the block as ``data:`` URIs for the lightbox
168
- (issue #55). Runs of 3+ newlines in assistant text collapse to
169
- exactly two.
197
+ (issue #55); records that only carry the ``[Image: source: <path>]``
198
+ line read the file from disk when it is still present (issue #56).
199
+ Runs of 3+ newlines in assistant text collapse to exactly two.
170
200
  """
171
201
  out: list[Block] = []
172
202
  for raw in lines:
@@ -211,12 +241,25 @@ def parse_conversation(lines: list[str]) -> list[Block]:
211
241
  # Image metadata lines become a chip; human text in a mixed
212
242
  # record survives without them (issue #54).
213
243
  kept = []
244
+ src_paths: list[str] = []
214
245
  for ln in text.split("\n"):
215
246
  if ln.startswith(_IMAGE_PREFIXES):
216
247
  had_image = True
248
+ # Path-only records (issue #56): collect the disk path
249
+ # unless a base64 block already embeds this record.
250
+ if not imgs and ln.startswith("[Image: source:"):
251
+ p = ln.split("source:", 1)[1].strip()
252
+ if p.endswith("]"):
253
+ p = p[:-1].strip()
254
+ if p:
255
+ src_paths.append(p)
217
256
  else:
218
257
  kept.append(ln)
219
258
  text = "\n".join(kept).strip()
259
+ for p in src_paths:
260
+ uri = _image_from_path(p)
261
+ if uri:
262
+ imgs.append(uri)
220
263
  if not text:
221
264
  if not had_image and not imgs:
222
265
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.22
3
+ Version: 0.3.24
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.22"
7
+ version = "0.3.24"
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)
@@ -140,6 +140,31 @@ def test_idle_ignores_state_bookkeeping_after_stop(cc_home, tmp_path):
140
140
  assert rotator._idle(key, nnn) is True
141
141
 
142
142
 
143
+ def test_idle_ignores_gate_bookkeeping_after_stop(cc_home, tmp_path):
144
+ # The Stop hook sets last_stop_ts and only THEN records the handoff
145
+ # gate decision (stop.py: ledger.gate after update_fields), so a
146
+ # valid-draft Stop writes a "gate" entry with ts > last_stop_ts.
147
+ # The Stop that ends the handoff turn is the LAST Stop that ever
148
+ # comes, so this bookkeeping must not look like activity.
149
+ _, key, nnn = _quiet_session(cc_home, tmp_path)
150
+ time.sleep(0.01)
151
+ ledger.gate(paths.session_dir(key, nnn), action="silent",
152
+ state_from="HANDOFF_REQUESTED",
153
+ state_to="CHECKPOINT_VERIFIED")
154
+ assert rotator._idle(key, nnn) is True
155
+
156
+
157
+ def test_idle_ignores_gate_deny_bookkeeping_after_stop(cc_home, tmp_path):
158
+ # Same bookkeeping class with a denied call (the c9 post-handoff
159
+ # freeze gate logs gate entries with a tool field).
160
+ _, key, nnn = _quiet_session(cc_home, tmp_path)
161
+ time.sleep(0.01)
162
+ ledger.gate(paths.session_dir(key, nnn), action="deny",
163
+ state_from="CHECKPOINT_VERIFIED",
164
+ state_to="CHECKPOINT_VERIFIED", variant="c9", tool="Bash")
165
+ assert rotator._idle(key, nnn) is True
166
+
167
+
143
168
  # --- .started marker wait (PRD §11.6) -----------------------------------------
144
169
 
145
170
 
@@ -1,5 +1,6 @@
1
1
  """transcript.py: issue #8 - JSONL parsing, markdown rendering, HTML export."""
2
2
 
3
+ import base64
3
4
  import json
4
5
  from datetime import datetime
5
6
  from pathlib import Path
@@ -156,6 +157,71 @@ def test_render_markdown_ignores_images():
156
157
  assert "metin" in md and "base64" not in md
157
158
 
158
159
 
160
+ # --- issue #56: path-only image records read from disk at export ---------
161
+
162
+ PNG1x1 = ("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQ"
163
+ "DwAEhQGAhKmMIQAAAABJRU5ErkJggg==")
164
+
165
+
166
+ def _png(tmp_path, name="shot.png"):
167
+ p = tmp_path / name
168
+ p.write_bytes(base64.b64decode(PNG1x1))
169
+ return p
170
+
171
+
172
+ def test_path_only_record_embeds_disk_image(tmp_path):
173
+ png = _png(tmp_path)
174
+ blocks = transcript.parse_conversation([
175
+ _rec("user", f"[Image: source: {png}]")])
176
+ assert [t for _, t, _, _ in blocks] == ["🖼 image"]
177
+ assert list(blocks[0][3]) == [f"data:image/png;base64,{PNG1x1}"]
178
+
179
+
180
+ def test_mixed_text_and_source_path_keeps_text(tmp_path):
181
+ png = _png(tmp_path)
182
+ blocks = transcript.parse_conversation([
183
+ _rec("user", f"bunu gordun mu ???\n[Image: source: {png}]")])
184
+ assert len(blocks) == 1
185
+ assert blocks[0][1] == "bunu gordun mu ???"
186
+ assert list(blocks[0][3]) == [f"data:image/png;base64,{PNG1x1}"]
187
+
188
+
189
+ def test_unreadable_paths_stay_plain_chip(tmp_path):
190
+ missing = tmp_path / "gone.png"
191
+ adir = tmp_path / "dir.png"
192
+ adir.mkdir()
193
+ txt = tmp_path / "note.txt"
194
+ txt.write_bytes(b"not an image")
195
+ big = tmp_path / "big.png"
196
+ big.write_bytes(b"\x00" * (transcript._MAX_IMG_B64 + 1))
197
+ blocks = transcript.parse_conversation([
198
+ _rec("user", f"[Image: source: {missing}]"),
199
+ _rec("user", f"[Image: source: {adir}]"),
200
+ _rec("user", f"[Image: source: {txt}]"),
201
+ _rec("user", f"[Image: source: {big}]"),
202
+ _rec("user", "[Image: source: not-a-real-path]")])
203
+ assert [t for _, t, _, _ in blocks] == ["🖼 image"]
204
+ assert list(blocks[0][3]) == []
205
+
206
+
207
+ def test_base64_block_prevents_disk_reread(tmp_path):
208
+ png = _png(tmp_path)
209
+ blocks = transcript.parse_conversation([
210
+ _rec("user", [{"type": "text", "text": f"[Image: source: {png}]"},
211
+ _img(data="QQ==")])])
212
+ assert list(blocks[0][3]) == ["data:image/png;base64,QQ=="]
213
+
214
+
215
+ def test_multiple_source_lines_embed_in_order(tmp_path):
216
+ a = _png(tmp_path, "a.png")
217
+ b = _png(tmp_path, "b.jpg")
218
+ blocks = transcript.parse_conversation([
219
+ _rec("user", f"[Image: source: {a}]\n[Image: source: {b}]")])
220
+ assert [t for _, t, _, _ in blocks] == ["🖼 image"]
221
+ assert list(blocks[0][3]) == [f"data:image/png;base64,{PNG1x1}",
222
+ f"data:image/jpeg;base64,{PNG1x1}"]
223
+
224
+
159
225
  def test_table_fenced_and_escaping():
160
226
  md = "|a|b|\n|--|--|\n|1|b|\n\n<script>x</script>\n\n```\nprint(1)\n```\n\nplain **b** `c`"
161
227
  out = transcript.md_to_html(md)
File without changes
File without changes