From 5fc59b6936b2d4a05f5f5192458145d0112431d3 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Sat, 3 Oct 2026 20:48:25 -0300 Subject: Show a single session as the page itself A page with one session and no memories (a shared link, or -s --html) skips the list, stats and filters: the reader becomes the page, with the title, the details (now with the Claude Code version) and the transcript. A single session is exported without memories. --- README.es.md | 4 ++++ README.md | 4 ++++ claude_logbook/__init__.py | 2 +- claude_logbook/cli.py | 5 +++-- claude_logbook/template.html | 46 +++++++++++++++++++++++++++++++++++++------- tests/test_cli.py | 8 ++++++++ 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/README.es.md b/README.es.md index d62583d..710a3e7 100644 --- a/README.es.md +++ b/README.es.md @@ -272,6 +272,10 @@ servidor, sin red, sin paso de build: lo copiás a otra máquina y sigue andando esa conversación directamente. - Teclado: `/` o `Ctrl`+`K` enfoca el buscador, `Esc` lo limpia o cierra el lector. +Una página con una sola sesión (`-s 3 --html`, o cualquier link compartido) no +muestra la lista: es directamente esa conversación, con título, datos y la +transcripción. Una sola sesión se exporta sin memorias. + Las fechas son relativas a **cuándo se leyeron los datos**, no a tu reloj, así que "hoy" sigue queriendo decir lo que quería decir cuando generaste la página. diff --git a/README.md b/README.md index d077269..c0f6b32 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,10 @@ works. - Keyboard: `/` or `Ctrl`+`K` focuses the search box, `Esc` clears it or closes the reader. +A page with a single session (`-s 3 --html`, or any shared link) skips the +list and is just that conversation: title, details and the transcript. A +single session is exported without memories. + Dates are relative to **when the data was read**, not to your clock, so "today" keeps meaning what it meant when you generated the page. diff --git a/claude_logbook/__init__.py b/claude_logbook/__init__.py index bcc14b2..0128116 100644 --- a/claude_logbook/__init__.py +++ b/claude_logbook/__init__.py @@ -3,6 +3,6 @@ No dependencies: standard library only. """ -__version__ = "1.5.1" +__version__ = "1.5.2" __all__ = ["__version__"] diff --git a/claude_logbook/cli.py b/claude_logbook/cli.py index 57385c1..64c6c01 100644 --- a/claude_logbook/cli.py +++ b/claude_logbook/cli.py @@ -293,9 +293,10 @@ def delete_targets(pool, args): def export_selection(sessions, args): """What --json and --html export: the -s session, or what the filters and -n leave. With no filter at all, everything, memories included; otherwise - only the memories of the projects that made it.""" + only the memories of the projects that made it. A single session (-s) goes + alone, as it would be shared: no memories.""" if args.show: - chosen = [pick(filtered(sessions, args), args.show)] + return [pick(filtered(sessions, args), args.show)], [] else: chosen = filtered(sessions, args) if args.limit: diff --git a/claude_logbook/template.html b/claude_logbook/template.html index 9fa37f6..cd3d8b5 100644 --- a/claude_logbook/template.html +++ b/claude_logbook/template.html @@ -78,6 +78,27 @@ } body.locked { overflow: hidden; } + /* ---------- single session ---------- + A page with one session and no memories (a shared link, or -s --html) + is that conversation: the reader becomes the page, no list around it. */ + body.single .wrap, body.single .scrim, body.single #rClose { display: none; } + body.single.locked { overflow: auto; } + body.single .reader { + position: static; + transform: none; + visibility: visible; + transition: none; + width: min(920px, 100%); + height: auto; + min-height: 100vh; + margin: 0 auto; + box-shadow: none; + border-left: 0; + } + body.single .reader-head { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; } + body.single .reader-head h2 { font-size: 22px; } + body.single .transcript { overflow: visible; padding: 28px 20px 96px; } + .wrap { max-width: 1180px; margin: 0 auto; padding: 40px 24px 96px; } /* ---------- masthead ---------- */ @@ -854,6 +875,7 @@ const PAYLOAD = JSON.parse(document.getElementById('payload').textContent); const DATA = PAYLOAD.s || []; const MEM = PAYLOAD.m || []; +const SINGLE = DATA.length === 1 && !MEM.length; // Snapshot = the most recent activity in the data, so that "today" stays true // relative to when the logs were read and not to the viewer's clock. const NOW = new Date(Math.max( @@ -1168,12 +1190,12 @@ function showReader() { scrimEl.classList.add('open'); readerEl.classList.add('open'); document.body.classList.add('locked'); - readerEl.focus(); + if (!SINGLE) readerEl.focus(); } function openChat(id) { const d = BY_ID.get(id); - if (!d || d.e) return; + if (!d || (d.e && !SINGLE)) return; open_ = { kind: 's', key: id }; lastFocus = document.activeElement; $('#rCopy').hidden = false; @@ -1184,8 +1206,9 @@ function openChat(id) { `${fmtDate(d.l)} · ${fmtTime(d.l)}`, `${d.u} yours / ${d.a} from Claude`, `${fmtDur(d.d)}`, + d.v ? `Claude Code ${esc(d.v)}` : '', `${d.id.slice(0, 8)}`, - ].join(''); + ].filter(Boolean).join(''); bodyEl.innerHTML = d.c.length ? d.c.map(m => m.r === 't' @@ -1196,7 +1219,7 @@ function openChat(id) { ).join('') : `

This session has no messages.

`; - if (location.hash.slice(1) !== id) history.replaceState(null, '', '#' + id); + if (!SINGLE && location.hash.slice(1) !== id) history.replaceState(null, '', '#' + id); showReader(); } @@ -1243,7 +1266,7 @@ function openMemory(name) { } function closeReader() { - if (!open_) return; + if (!open_ || SINGLE) return; open_ = null; if (location.hash) history.replaceState(null, '', location.pathname + location.search); scrimEl.classList.remove('open'); @@ -1265,7 +1288,7 @@ function openFromHash() { // The dialog is aria-modal: focus must stay inside while it is open. readerEl.addEventListener('keydown', e => { - if (e.key !== 'Tab') return; + if (e.key !== 'Tab' || SINGLE) return; const f = [...readerEl.querySelectorAll('button, [tabindex]:not([tabindex="-1"])')] .filter(el => el.offsetParent !== null); if (!f.length) return; @@ -1410,7 +1433,16 @@ $('#snap').textContent = `Snapshot read on ${pad(NOW.getDate())} ${MONTHS[NOW.ge document.body.dataset.mode = mode; fillProjects(); render(); -openFromHash(); +if (SINGLE) { + document.body.classList.add('single'); + readerEl.setAttribute('role', 'main'); + readerEl.removeAttribute('aria-modal'); + $('.rh-acts').prepend($('#theme')); + document.title = (DATA[0].t || 'Untitled session') + ' · Claude Code session'; + openChat(DATA[0].id); +} else { + openFromHash(); +} diff --git a/tests/test_cli.py b/tests/test_cli.py index 4538f24..37fd7d6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -151,6 +151,14 @@ class TestExport(CliCase): self.assertTrue(all(m["p"] == "/home/u/proj" for m in some)) self.assertLess(len(some), len(everything)) + def test_a_single_session_goes_without_memories(self): + simple_tree(self.root) + memory_tree(self.root) + _, out, _ = self.run_cli("-s", "aaaaaaaa", "--json") + data = json.loads(out) + self.assertEqual(len(data["s"]), 1) + self.assertEqual(data["m"], []) + def test_html_leaves_stdout_alone(self): # The summary goes to stderr so `--html /dev/stdout` keeps working. simple_tree(self.root) -- cgit v1.2.3