cc-continuity 0.3.1__tar.gz → 0.3.2__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.
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/PKG-INFO +1 -1
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/README.md +9 -6
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/__init__.py +1 -1
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/checkpoint.py +6 -1
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/transcript.py +152 -14
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity.egg-info/PKG-INFO +1 -1
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/pyproject.toml +1 -1
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_transcript.py +120 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_transcript_finalize.py +17 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/LICENSE +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/__main__.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/atomic.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/blink.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/blink_watch.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/bootstrap.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/cli.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/config.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/daemon_supervisor.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/doctor.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/gitsnap.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/__init__.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/common.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/pre_compact.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/pre_tool_use.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/session_end.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/session_start.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/stop.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/task.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/tool_use.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hooks/user_prompt.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/hosting.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/install.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/launch.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/ledger.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/lock.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/managed.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/naming.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/notify.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/paths.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/power_plug.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/progress_pane.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/project.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/redact.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/rotator.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/settings_merge.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/skills.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/state.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/statusline.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/thresholds.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/validate.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/watchdog.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/watchdog_digest.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity/watchdogd.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity.egg-info/SOURCES.txt +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity.egg-info/dependency_links.txt +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity.egg-info/entry_points.txt +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/cc_continuity.egg-info/top_level.txt +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/setup.cfg +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_atomic.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_blink.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_blink_watch.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_bootstrap.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_checkpoint.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_cli.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_config.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_daemon_supervisor.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_doctor.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_gitsnap.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_common.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_pre_compact.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_pre_tool_use.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_session_end.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_session_start.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_stop.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_task.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_tool_use.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hooks_user_prompt.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hosting.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_hygiene.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_install.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_integration_phase5.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_integration_phase6.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_integration_phase7.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_launch.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_ledger.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_lock.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_managed.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_naming.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_notify.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_notify_integration.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_paths.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_power_plug.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_progress_pane.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_project.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_redact.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_rotator.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_settings_merge.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_skills.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_state.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_status.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_statusline.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_thresholds.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_tmux_host.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_uninstall.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_validate.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_watchdog.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_watchdog_digest.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_watchdog_integration.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_watchdogd.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_wsl_doctor.py +0 -0
- {cc_continuity-0.3.1 → cc_continuity-0.3.2}/tests/test_wsl_install.py +0 -0
|
@@ -26,6 +26,15 @@ 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-09**: Exported transcript pages now carry a session
|
|
30
|
+
switcher: a header dropdown lists the newest exports of the project
|
|
31
|
+
(the top ten plus the current page) and loads them over plain
|
|
32
|
+
`file://`
|
|
33
|
+
([commit](https://github.com/pqant/claude-continuity/commit/e22f4ac)).
|
|
34
|
+
- **2026-11-09**: The transcript header was rebuilt on a single grid:
|
|
35
|
+
the Sessions label sits under Session Time, the search box keeps a
|
|
36
|
+
fixed width, and labels read bold and high-contrast
|
|
37
|
+
([commit](https://github.com/pqant/claude-continuity/commit/18af742)).
|
|
29
38
|
- **2026-11-08**: An interactive architecture diagram of the whole system
|
|
30
39
|
(modules, dependencies and data flows) now ships in `docs/diagrams` as a
|
|
31
40
|
self-contained HTML page with guided views and export
|
|
@@ -36,12 +45,6 @@ log:
|
|
|
36
45
|
- **2026-11-08**: Progress frames are padded by rendered cells, so wide
|
|
37
46
|
glyphs never wrap into the next line
|
|
38
47
|
([commit](https://github.com/pqant/claude-continuity/commit/581fe93)).
|
|
39
|
-
- **2026-11-08**: The animator blink key carries the unconsumed reply ts,
|
|
40
|
-
so a reply arriving mid-blink is still delivered
|
|
41
|
-
([commit](https://github.com/pqant/claude-continuity/commit/54494b4)).
|
|
42
|
-
- **2026-11-08**: The reply flag is held through the settle window instead
|
|
43
|
-
of being cleared early
|
|
44
|
-
([commit](https://github.com/pqant/claude-continuity/commit/581ff6f)).
|
|
45
48
|
|
|
46
49
|
## How it works
|
|
47
50
|
|
|
@@ -590,7 +590,8 @@ def finalize(key: str, nnn: int, *, cfg: dict, root: Path,
|
|
|
590
590
|
metric, root, (metric or {}).get("session_id") or None)
|
|
591
591
|
if tpath is not None:
|
|
592
592
|
stem = transcript.export_session(
|
|
593
|
-
tpath, tmp, _transcript_meta(snapshot, metric)
|
|
593
|
+
tpath, tmp, _transcript_meta(snapshot, metric),
|
|
594
|
+
final_dir=pdir / "checkpoint")
|
|
594
595
|
except Exception:
|
|
595
596
|
stem = None
|
|
596
597
|
transcript.debug_log("export aborted: finalize guard")
|
|
@@ -633,6 +634,10 @@ def finalize(key: str, nnn: int, *, cfg: dict, root: Path,
|
|
|
633
634
|
shutil.rmtree(final)
|
|
634
635
|
os.rename(tmp, final)
|
|
635
636
|
atomic.fsync_dir(pdir)
|
|
637
|
+
# Issue #16: the switcher manifest lives at the project root;
|
|
638
|
+
# refresh it once the pair has landed (never raises, P9-D7).
|
|
639
|
+
if stem:
|
|
640
|
+
transcript.update_sessions_manifest(final)
|
|
636
641
|
step(8)
|
|
637
642
|
state._transition_unlocked(key, nnn, "CHECKPOINT_VERIFIED",
|
|
638
643
|
degraded=degraded)
|
|
@@ -153,13 +153,16 @@ _CSS = """
|
|
|
153
153
|
*{box-sizing:border-box}
|
|
154
154
|
body{margin:0;background:var(--bg);color:var(--fg);font:15.5px/1.6 -apple-system,system-ui,"Segoe UI",Roboto,sans-serif}
|
|
155
155
|
header{position:sticky;top:0;background:var(--hdr);border-bottom:1px solid var(--line);padding:10px 22px;z-index:9;box-shadow:0 1px 4px rgba(0,0,0,.06)}
|
|
156
|
-
.
|
|
157
|
-
.
|
|
158
|
-
.
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
.hd{font-size:13px;color:var(--muted);display:grid;grid-template-columns:max-content 1fr max-content 1fr;gap:6px 14px;align-items:center}
|
|
157
|
+
.hd .k{font-weight:600;color:var(--fg)}
|
|
158
|
+
.hd .v{color:var(--fg);font-weight:600;padding-left:2px}
|
|
159
|
+
.row2{display:flex;gap:12px;align-items:center;margin-top:6px;grid-column:1/3;flex-wrap:wrap}
|
|
160
|
+
.qbox{width:360px;max-width:100%;padding:7px 12px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg);font-size:14px}
|
|
161
|
+
label{font-size:13px;color:var(--fg);font-weight:600;white-space:nowrap}
|
|
161
162
|
button{padding:6px 12px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg);cursor:pointer;font-size:13px}
|
|
162
163
|
button:hover{border-color:var(--muted)}
|
|
164
|
+
select{padding:6px 10px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg);font-size:13px;max-width:340px}
|
|
165
|
+
select:disabled{opacity:.55}
|
|
163
166
|
#stats{font-size:12px;color:var(--muted);min-width:140px}
|
|
164
167
|
main{max-width:1160px;margin:0 auto;padding:10px 28px 80px}
|
|
165
168
|
section.block{padding:6px 14px 12px;margin:10px 0;border-radius:10px}
|
|
@@ -210,6 +213,107 @@ bt.onclick=()=>{i=(i+1)%3;root.dataset.theme=modes[i];localStorage.setItem('th',
|
|
|
210
213
|
"""
|
|
211
214
|
|
|
212
215
|
|
|
216
|
+
#: Manual month names for switcher labels: ``strftime("%b")`` follows the
|
|
217
|
+
#: machine locale and could emit a non-English month (hygiene requires
|
|
218
|
+
#: ASCII/English template strings).
|
|
219
|
+
_MONTHS = ("Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
220
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
|
|
221
|
+
_STEM_DT_RE = re.compile(r"_(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})$")
|
|
222
|
+
|
|
223
|
+
#: Switcher client script: populate the ``#s`` select from the manifest
|
|
224
|
+
#: global (newest first, first ten plus the current page when it falls
|
|
225
|
+
#: outside), switch by navigating the SAME viewer template over file://
|
|
226
|
+
#: (XHR is blocked there; the loaded page re-runs search/theme itself).
|
|
227
|
+
_SWITCH_JS = r"""
|
|
228
|
+
(function(){var sel=document.getElementById('s');if(!sel)return;
|
|
229
|
+
var all=(window.CC_SESSIONS||[]),cur=sel.getAttribute('data-cur')||'',up=sel.getAttribute('data-up')||'';
|
|
230
|
+
function find(a,h){for(var i=0;i<a.length;i++){if(a[i].href===h)return a[i];}return null;}
|
|
231
|
+
var top=all.slice(0,10);
|
|
232
|
+
if(cur&&!find(top,cur)){top.push(find(all,cur)||{href:cur,label:'(current session)'});}
|
|
233
|
+
for(var k=0;k<top.length;k++){var o=document.createElement('option');
|
|
234
|
+
o.value=top[k].href;o.textContent=top[k].label;sel.appendChild(o);}
|
|
235
|
+
if(cur)sel.value=cur;
|
|
236
|
+
sel.disabled=all.length<2;
|
|
237
|
+
var lbl=document.getElementById('slbl');
|
|
238
|
+
if(lbl)lbl.textContent=all.length>1?'Sessions':'Session';
|
|
239
|
+
sel.onchange=function(){if(this.value)location.href=up+this.value;};})();
|
|
240
|
+
"""
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _session_entry(html_path: Path, project_dir: Path) -> dict:
|
|
244
|
+
"""One manifest entry; ``_k`` is the private sort key (datetime)."""
|
|
245
|
+
stem = html_path.stem
|
|
246
|
+
m = _STEM_DT_RE.search(stem)
|
|
247
|
+
dt = None
|
|
248
|
+
if m:
|
|
249
|
+
try:
|
|
250
|
+
dt = datetime(*[int(g) for g in m.groups()])
|
|
251
|
+
except ValueError:
|
|
252
|
+
dt = None
|
|
253
|
+
if dt is None:
|
|
254
|
+
dt = datetime.fromtimestamp(html_path.stat().st_mtime)
|
|
255
|
+
label = stem
|
|
256
|
+
else:
|
|
257
|
+
label = f"{stem[:m.start()]} - {dt:%d} {_MONTHS[dt.month - 1]} {dt:%H:%M}"
|
|
258
|
+
return {"href": html_path.relative_to(project_dir).as_posix(),
|
|
259
|
+
"label": label, "_k": dt}
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def collect_sessions(project_dir: Path) -> list[dict]:
|
|
263
|
+
"""Every exported session HTML of one project, newest first.
|
|
264
|
+
|
|
265
|
+
Scans ``<project>/sessions/*/checkpoint/*.html``. Labels come from the
|
|
266
|
+
stem's ``_YYYY-MM-DD-HHMM`` tail (``name - DD Mon HH:MM``); a stem
|
|
267
|
+
without a parseable tail falls back to the raw stem with file mtime.
|
|
268
|
+
Unreadable files are skipped.
|
|
269
|
+
"""
|
|
270
|
+
entries = []
|
|
271
|
+
for p in project_dir.glob("sessions/*/checkpoint/*.html"):
|
|
272
|
+
try:
|
|
273
|
+
entries.append(_session_entry(p, project_dir))
|
|
274
|
+
except OSError:
|
|
275
|
+
continue
|
|
276
|
+
entries.sort(key=lambda e: e["_k"], reverse=True)
|
|
277
|
+
return [{"href": e["href"], "label": e["label"]} for e in entries]
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def render_manifest(entries: list[dict]) -> str:
|
|
281
|
+
"""``sessions.js`` body: one global assignment, ASCII JSON only."""
|
|
282
|
+
return ("window.CC_SESSIONS="
|
|
283
|
+
+ json.dumps(entries, ensure_ascii=True, separators=(",", ":")) + ";\n")
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def _checkpoint_project(dest_dir: Path) -> tuple[Path, str] | None:
|
|
287
|
+
"""``(project_dir, '../' prefix)`` when dest_dir is a real checkpoint
|
|
288
|
+
dir (``<project>/sessions/<NNN>/checkpoint``); ``None`` otherwise.
|
|
289
|
+
The page sits three levels under the project, hence ``../../../``."""
|
|
290
|
+
try:
|
|
291
|
+
if dest_dir.name != "checkpoint":
|
|
292
|
+
return None
|
|
293
|
+
if dest_dir.parents[1].name != "sessions" or not dest_dir.parents[0].name.isdigit():
|
|
294
|
+
return None
|
|
295
|
+
return dest_dir.parents[2], "../../../"
|
|
296
|
+
except IndexError:
|
|
297
|
+
return None
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def update_sessions_manifest(dest_dir: Path) -> None:
|
|
301
|
+
"""Best-effort refresh of ``<project>/sessions.js`` after one export.
|
|
302
|
+
|
|
303
|
+
Never raises (P9-D7): a manifest problem is one debug line; the export
|
|
304
|
+
pair stands on its own.
|
|
305
|
+
"""
|
|
306
|
+
try:
|
|
307
|
+
ctx = _checkpoint_project(dest_dir)
|
|
308
|
+
if ctx is None:
|
|
309
|
+
return
|
|
310
|
+
project, _up = ctx
|
|
311
|
+
body = render_manifest(collect_sessions(project))
|
|
312
|
+
atomic.write_bytes_fsync(project / "sessions.js", body.encode("utf-8"))
|
|
313
|
+
except Exception:
|
|
314
|
+
debug_log(f"manifest skipped: sessions.js for {dest_dir}")
|
|
315
|
+
|
|
316
|
+
|
|
213
317
|
def _ts_hms(ts: str | None) -> str:
|
|
214
318
|
"""Local HH:MM:SS for an ISO-8601 timestamp; empty when absent or bad."""
|
|
215
319
|
if not ts:
|
|
@@ -238,6 +342,17 @@ def render_html(blocks: list[Block], meta: dict) -> str:
|
|
|
238
342
|
"""
|
|
239
343
|
ratio = meta.get("ratio")
|
|
240
344
|
ratio_s = "n/a" if ratio is None else f"{float(ratio):.1%}"
|
|
345
|
+
ext = switch_js = ""
|
|
346
|
+
# Unwired pages keep empty grid cells so auto-flow columns stay aligned.
|
|
347
|
+
switch = "<span></span><span></span>"
|
|
348
|
+
if meta.get("manifest_src"):
|
|
349
|
+
src = html.escape(str(meta["manifest_src"]), quote=True)
|
|
350
|
+
cur = html.escape(str(meta.get("self_href") or ""), quote=True)
|
|
351
|
+
up = src[:src.rfind("/") + 1]
|
|
352
|
+
ext = f'<script src="{src}"></script>\n'
|
|
353
|
+
switch = (f'<label for="s" id="slbl">Sessions</label>'
|
|
354
|
+
f'<select id="s" data-cur="{cur}" data-up="{up}"></select>')
|
|
355
|
+
switch_js = _SWITCH_JS
|
|
241
356
|
sections = []
|
|
242
357
|
for role, text, ts in blocks:
|
|
243
358
|
cls = "user" if role == "user" else "asst"
|
|
@@ -251,20 +366,22 @@ def render_html(blocks: list[Block], meta: dict) -> str:
|
|
|
251
366
|
'<meta name="viewport" content="width=device-width,initial-scale=1">\n'
|
|
252
367
|
f'<title>{_meta_val(meta, "stem")} - session transcript</title>'
|
|
253
368
|
f'<style>{_CSS}</style></head><body>\n'
|
|
254
|
-
'<header><div class="
|
|
369
|
+
'<header><div class="hd">\n'
|
|
255
370
|
f'<span class="k">Session Name</span><span class="v">{_meta_val(meta, "name")} (cp-{_meta_val(meta, "nnn")})</span>\n'
|
|
256
371
|
f'<span class="k">Model</span><span class="v">{_meta_val(meta, "model")}</span>\n'
|
|
257
372
|
f'<span class="k">Project</span><span class="v">{_meta_val(meta, "project")}</span>\n'
|
|
258
373
|
f'<span class="k">Ratio at rotation</span><span class="v">{ratio_s}</span>\n'
|
|
259
374
|
f'<span class="k">Branch</span><span class="v">{_meta_val(meta, "branch")} @ {_meta_val(meta, "head")}</span>\n'
|
|
260
375
|
f'<span class="k">Session Time</span><span class="v">{_meta_val(meta, "span")}</span>\n'
|
|
261
|
-
'</
|
|
262
|
-
'<
|
|
263
|
-
'placeholder="
|
|
264
|
-
'
|
|
265
|
-
'<
|
|
376
|
+
'<label for="q">Search</label>\n'
|
|
377
|
+
'<input type="search" id="q" class="qbox" '
|
|
378
|
+
'placeholder="marks all matches, optional block filter">\n'
|
|
379
|
+
f'{switch}\n'
|
|
380
|
+
'<div class="row2"><label><input type="checkbox" id="f"> '
|
|
381
|
+
'matching blocks only</label>\n'
|
|
382
|
+
'<button id="t">theme</button><span id="stats"></span></div></div></header>\n'
|
|
266
383
|
f'<main>{"".join(sections)}</main>\n'
|
|
267
|
-
f'<script>{_JS}</script></body>')
|
|
384
|
+
f'{ext}<script>{_JS}{switch_js}</script></body>')
|
|
268
385
|
|
|
269
386
|
|
|
270
387
|
def resolve_transcript_path(metric: dict | None, root: Path, sid: str | None,
|
|
@@ -327,7 +444,8 @@ def render_markdown(blocks: list[Block], meta: dict) -> str:
|
|
|
327
444
|
|
|
328
445
|
|
|
329
446
|
def export_session(jsonl_path: Path, dest_dir: Path, meta: dict,
|
|
330
|
-
*, cap_bytes: int = 5 * 1024 * 1024
|
|
447
|
+
*, cap_bytes: int = 5 * 1024 * 1024,
|
|
448
|
+
final_dir: Path | None = None) -> str | None:
|
|
331
449
|
"""Best-effort readable export of one session JSONL (B3/B4).
|
|
332
450
|
|
|
333
451
|
Reads at most ``cap_bytes`` (past the cap the trailing partial line is
|
|
@@ -335,7 +453,11 @@ def export_session(jsonl_path: Path, dest_dir: Path, meta: dict,
|
|
|
335
453
|
``<stem>.md`` and ``<stem>.html`` into ``dest_dir`` with fsync'd plain
|
|
336
454
|
writes and returns the stem. ``span``/``stem`` are derived from the
|
|
337
455
|
first/last block timestamps (local; ``stem`` falls back to now) and
|
|
338
|
-
added to a meta copy.
|
|
456
|
+
added to a meta copy. ``final_dir`` (issue #16): where the pair will
|
|
457
|
+
live when ``dest_dir`` is only a staging dir (finalize's
|
|
458
|
+
``checkpoint.tmp-*``); the switcher wiring uses it and the in-place
|
|
459
|
+
manifest refresh is skipped (the mover refreshes at the final dir).
|
|
460
|
+
Never raises: unreadable source, empty parse, or
|
|
339
461
|
any write failure logs one debug line, leaves no half-written pair,
|
|
340
462
|
and returns ``None``.
|
|
341
463
|
"""
|
|
@@ -373,6 +495,14 @@ def export_session(jsonl_path: Path, dest_dir: Path, meta: dict,
|
|
|
373
495
|
export_meta = dict(meta)
|
|
374
496
|
export_meta["stem"] = stem
|
|
375
497
|
export_meta["span"] = span
|
|
498
|
+
eff = final_dir or dest_dir
|
|
499
|
+
ctx = _checkpoint_project(eff)
|
|
500
|
+
if ctx is not None:
|
|
501
|
+
project, up = ctx
|
|
502
|
+
export_meta["manifest_src"] = up + "sessions.js"
|
|
503
|
+
export_meta["manifest_up"] = up
|
|
504
|
+
export_meta["self_href"] = (eff.relative_to(project).as_posix()
|
|
505
|
+
+ "/" + stem + ".html")
|
|
376
506
|
dest_dir.mkdir(parents=True, exist_ok=True)
|
|
377
507
|
written: list[Path] = []
|
|
378
508
|
try:
|
|
@@ -392,6 +522,14 @@ def export_session(jsonl_path: Path, dest_dir: Path, meta: dict,
|
|
|
392
522
|
pass
|
|
393
523
|
debug_log(f"export skipped: write failed for {stem}")
|
|
394
524
|
return None
|
|
525
|
+
# Issue #16: refresh the per-project manifest the switcher reads.
|
|
526
|
+
# When exporting into a staging dir the mover refreshes at the
|
|
527
|
+
# final dir instead. Guarded belt-and-braces; never raises.
|
|
528
|
+
if final_dir is None:
|
|
529
|
+
try:
|
|
530
|
+
update_sessions_manifest(dest_dir)
|
|
531
|
+
except Exception:
|
|
532
|
+
debug_log(f"manifest skipped: refresh failed for {stem}")
|
|
395
533
|
return stem
|
|
396
534
|
except Exception:
|
|
397
535
|
debug_log(f"export skipped: unexpected error for {jsonl_path}")
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cc-continuity"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
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)
|
|
@@ -158,3 +158,123 @@ def test_export_failures_never_raise(tmp_path, cc_home, monkeypatch):
|
|
|
158
158
|
monkeypatch.setattr(transcript.atomic, "write_bytes_fsync", boom)
|
|
159
159
|
assert transcript.export_session(_fixture(tmp_path), tmp_path / "o2", _meta()) is None
|
|
160
160
|
assert not (tmp_path / "o2").exists() or not list((tmp_path / "o2").iterdir())
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# --- issue #16: session switcher (per-project sessions.js manifest) ---
|
|
164
|
+
|
|
165
|
+
def _proj_tree(tmp_path, nnn_stems):
|
|
166
|
+
"""Fake project dir holding sessions/<nnn>/checkpoint/<stem>.html files."""
|
|
167
|
+
proj = tmp_path / "projects" / "proj-abc12345"
|
|
168
|
+
for nnn, stem in nnn_stems:
|
|
169
|
+
d = proj / "sessions" / nnn / "checkpoint"
|
|
170
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
171
|
+
(d / f"{stem}.html").write_text("<html></html>", encoding="utf-8")
|
|
172
|
+
return proj
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_collect_sessions_newest_first(tmp_path):
|
|
176
|
+
proj = _proj_tree(tmp_path, [("166", "claude-continuity-166_2026-11-08-1000"),
|
|
177
|
+
("167", "claude-continuity-167_2026-11-08-1815")])
|
|
178
|
+
e = transcript.collect_sessions(proj)
|
|
179
|
+
assert [x["href"] for x in e] == ["sessions/167/checkpoint/claude-continuity-167_2026-11-08-1815.html",
|
|
180
|
+
"sessions/166/checkpoint/claude-continuity-166_2026-11-08-1000.html"]
|
|
181
|
+
assert e[0]["label"] == "claude-continuity-167 - 08 Nov 18:15"
|
|
182
|
+
assert all(x["href"].isascii() and x["label"].isascii() for x in e)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def test_collect_sessions_ignores_noise_and_falls_back_to_mtime(tmp_path):
|
|
186
|
+
proj = _proj_tree(tmp_path, [("001", "sess_a")]) # stem without a date part
|
|
187
|
+
(proj / "sessions" / "001" / "checkpoint" / "handoff.md").write_text("x", encoding="utf-8")
|
|
188
|
+
(proj / "sessions" / "002" / "checkpoint").mkdir(parents=True) # no export yet
|
|
189
|
+
e = transcript.collect_sessions(proj)
|
|
190
|
+
assert len(e) == 1
|
|
191
|
+
assert e[0]["href"] == "sessions/001/checkpoint/sess_a.html"
|
|
192
|
+
assert e[0]["label"] == "sess_a" # bad stem: label falls back to the stem
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_render_manifest_shape(tmp_path):
|
|
196
|
+
entries = [{"href": "sessions/001/checkpoint/a.html", "label": "a - 01 Jan 02:03"}]
|
|
197
|
+
s = transcript.render_manifest(entries)
|
|
198
|
+
assert s.startswith("window.CC_SESSIONS=") and s.isascii()
|
|
199
|
+
assert json.loads(s[s.index("["):s.rindex("]") + 1]) == entries
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def test_update_sessions_manifest_writes_project_file(tmp_path):
|
|
203
|
+
proj = _proj_tree(tmp_path, [("166", "s-166_2026-11-08-1000"),
|
|
204
|
+
("167", "s-167_2026-11-08-1815")])
|
|
205
|
+
transcript.update_sessions_manifest(proj / "sessions" / "166" / "checkpoint")
|
|
206
|
+
js = (proj / "sessions.js").read_text(encoding="utf-8")
|
|
207
|
+
assert js.startswith("window.CC_SESSIONS=")
|
|
208
|
+
assert "sessions/167/checkpoint/s-167_2026-11-08-1815.html" in js
|
|
209
|
+
assert "sessions/166/checkpoint/s-166_2026-11-08-1000.html" in js
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_update_sessions_manifest_wrong_shape_is_noop(tmp_path, cc_home):
|
|
213
|
+
# cc_home: the skip path logs through debug_log, never the real store.
|
|
214
|
+
out = tmp_path / "out"
|
|
215
|
+
out.mkdir()
|
|
216
|
+
transcript.update_sessions_manifest(out) # not <proj>/sessions/<nnn>/checkpoint
|
|
217
|
+
assert not list(tmp_path.rglob("sessions.js"))
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def test_render_html_switcher_when_wired():
|
|
221
|
+
meta = dict(META, manifest_src="../../sessions.js",
|
|
222
|
+
self_href="sessions/166/checkpoint/x.html")
|
|
223
|
+
d = transcript.render_html([("user", "hi", None)], meta)
|
|
224
|
+
assert '<select id="s"' in d and 'data-cur="sessions/166/checkpoint/x.html"' in d
|
|
225
|
+
assert 'src="../../sessions.js"' in d
|
|
226
|
+
assert d.isascii()
|
|
227
|
+
# User polish (2026-11-08): switcher shares the search row, both groups
|
|
228
|
+
# carry visible capitalized labels; the plural is resolved client-side.
|
|
229
|
+
# User polish round 3 (2026-11-08): ONE shared header grid so the
|
|
230
|
+
# Sessions label sits directly below Session Time (same column, always);
|
|
231
|
+
# the search box is a fixed short width, no greedy stretching.
|
|
232
|
+
assert d.count('class="hd"') == 1 and '<div class="controls">' not in d
|
|
233
|
+
assert "grid-template-columns:max-content 1fr max-content 1fr" in d
|
|
234
|
+
assert ".qbox{width:360px" in d
|
|
235
|
+
assert d.index('id="slbl"') > d.index("Session Time")
|
|
236
|
+
assert '<div class="row2">' in d and d.index('id="f"') > d.index('id="slbl"')
|
|
237
|
+
assert "'Sessions'" in d and "'Session'" in d # plural-aware JS
|
|
238
|
+
# User polish round 4 (2026-11-09): the header labels read bold and
|
|
239
|
+
# dark (key labels, Search, Sessions), not faded grey.
|
|
240
|
+
assert ".hd .k{font-weight:600;color:var(--fg)}" in d
|
|
241
|
+
assert "label{font-size:13px;color:var(--fg);font-weight:600" in d
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def test_render_html_no_switcher_when_unwired():
|
|
245
|
+
d = _doc() # META has no manifest keys (legacy call shape)
|
|
246
|
+
assert 'id="s"' not in d and "sessions.js" not in d
|
|
247
|
+
assert '<label for="q">Search</label>' in d # Search label is unconditional
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def test_export_session_writes_manifest(tmp_path):
|
|
251
|
+
proj = tmp_path / "proj"
|
|
252
|
+
dest = proj / "sessions" / "001" / "checkpoint"
|
|
253
|
+
stem = transcript.export_session(_fixture(tmp_path), dest, _meta())
|
|
254
|
+
assert stem
|
|
255
|
+
js = (proj / "sessions.js").read_text(encoding="utf-8")
|
|
256
|
+
assert f"sessions/001/checkpoint/{stem}.html" in js
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def test_export_relative_depth_matches_checkpoint_dirs(tmp_path):
|
|
260
|
+
# Browser-verified integration rule: the page lives at
|
|
261
|
+
# sessions/<NNN>/checkpoint/x.html (three levels under the project),
|
|
262
|
+
# so the manifest must resolve with ../../../ from the checkpoint dir.
|
|
263
|
+
proj = tmp_path / "proj"
|
|
264
|
+
dest = proj / "sessions" / "007" / "checkpoint"
|
|
265
|
+
stem = transcript.export_session(_fixture(tmp_path), dest, _meta())
|
|
266
|
+
page = (dest / f"{stem}.html").read_text(encoding="utf-8")
|
|
267
|
+
assert 'src="../../../sessions.js"' in page
|
|
268
|
+
assert 'data-up="../../../"' in page
|
|
269
|
+
assert 'data-cur="sessions/007/checkpoint/' in page
|
|
270
|
+
# and the resolved target must actually exist
|
|
271
|
+
assert (dest / "../../../sessions.js").resolve() == (proj / "sessions.js").resolve()
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def test_export_session_survives_manifest_failure(tmp_path, cc_home, monkeypatch):
|
|
275
|
+
def boom(dest_dir):
|
|
276
|
+
raise RuntimeError("simulated manifest loss")
|
|
277
|
+
monkeypatch.setattr(transcript, "update_sessions_manifest", boom)
|
|
278
|
+
dest = tmp_path / "proj" / "sessions" / "001" / "checkpoint"
|
|
279
|
+
assert transcript.export_session(_fixture(tmp_path), dest, _meta())
|
|
280
|
+
assert list(dest.glob("*.html"))
|
|
@@ -72,3 +72,20 @@ def test_insert_transcript_line_position():
|
|
|
72
72
|
i = next(i for i, l in enumerate(lines) if l.startswith("Transcript: "))
|
|
73
73
|
assert lines[i - 1].startswith("- ") and lines[i + 1] == ""
|
|
74
74
|
assert checkpoint.headings_in_order(out)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_finalize_writes_sessions_manifest(cc_home, tmp_path):
|
|
78
|
+
# Issue #16: the export also refreshes the per-project sessions.js so
|
|
79
|
+
# every viewer page can offer the session switcher over file://.
|
|
80
|
+
repo, key, nnn = _registered(tmp_path, draft=DRAFT_TEXT)
|
|
81
|
+
checkpoint.finalize(
|
|
82
|
+
key, nnn, cfg=_cfg_for(repo), root=repo,
|
|
83
|
+
metric={"session_id": SID, "transcript_path": str(_conv(tmp_path)),
|
|
84
|
+
"model": "m", "ratio": 0.5})
|
|
85
|
+
proj = paths.session_dir(key, nnn).parent.parent
|
|
86
|
+
js = (proj / "sessions.js").read_text(encoding="utf-8")
|
|
87
|
+
assert js.startswith("window.CC_SESSIONS=")
|
|
88
|
+
assert f"sessions/{nnn:03d}/checkpoint/" in js
|
|
89
|
+
# the checkpoint dir itself must stay manifest-free (SHA256SUMS shape)
|
|
90
|
+
final = paths.session_dir(key, nnn) / "checkpoint"
|
|
91
|
+
assert "sessions.js" not in {p.name for p in final.iterdir()}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|