← All Pull Requests

Show capture datetime next to photo number in card header #7

Merged Released in 0.29.5 on 25 Nov 2026 opened by Drew Owens
Merges card-header-datetime → master

Show each photo's local capture date and time right next to its ref number in the card header (for example, #4 · 11:58 AM for shots taken today, #2 · Nov 18 9:03 AM for earlier days in the same year, and #1 · Nov 18, 2025 9:03 AM for prior years).

What changed

  • src/html/index.html:
    • Added fmtCardTime, fmtIsoLocal, and fmtTimeTooltip helpers to format each shot's existing backend timestamp in the viewer's local time zone.
    • Rendered <span class="rb-sep">·</span> and <time class="rb-ts"> immediately after #id in .card-refbar so every card header shows the capture date and time in both compact and classic modes, and across skinny webview and full pup views.
    • Added a tooltip (data-tooltip) on the timestamp with the full local date/time including seconds and timezone plus the full local ISO-8601 timestamp (and wired the same tooltip into .shot-card-meta and the zoom modal).
    • Kept the card header single-line and fluid with min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap on .rb-ts (and .rb-tag), using existing CSS theme tokens (var(--text2), var(--text3)) so contrast matches both dark and light themes.
    • Moved the hover-revealed delete button (.rb-del) to the end of .card-refbar so it stays pinned to the far right even on annotated shots with a caption pill.
    • Added a 60-second refresh timer so shots taken today gain their date label if the viewer stays open past midnight.
  • src/store.rs:
    • Added unit test timestamp_persists_in_sidecar_and_recovers verifying that Entry.timestamp is written to the JSON sidecar and recovered accurately on startup (no API schema changes were required since Entry.timestamp is already serialized in /api/shots and WebSocket frames).

Visual verification (dev instance)

Tested against an isolated dev server on a separate port and data directory with four test shots covering today (plain and annotated with a caption pill), two days ago (with a handle tag), and a prior year:

  • Before (skinny and pup views): card headers showed only #4, #3, and #2 rev-b beside the copy button, with no capture date or time.
  • After (skinny and pup views): card headers show #4 · 11:58 AM, #3 · 10:08 AM, #2 · Nov 18 9:03 AM rev-b, and #1 · Nov 18, 2025 9:03 AM cleanly on one 23px row with zero horizontal overflow at 1707px (pup) and 360px (skinny), and graceful ellipsis truncation at 180px. Before and after screenshots are attached in the comment below.

Tests run

  • cargo test (store::tests::timestamp_persists_in_sidecar_and_recovers passed)
  • cargo build (clean build)
  • Header CSS guard check on src/html/index.html (all required selectors present)
  • Node unit tests covering fmtCardTime, fmtIsoLocal, and fmtTimeTooltip (today, midnight, noon, older same year, prior year, invalid input, local ISO with seconds)
  • Live UI audit on an isolated dev server in a background pup window at 1707px, 360px, and 180px widths plus classic mode (outerHScroll: false, outerVScroll: false, zero card header overflow)

Opened by Drew's AI Agent on Drew's behalf

Diff Skip to comments (1)

src/html/index.html+73−21
@@ -254,9 +254,12 @@ body.compact .card-popups .ph { padding-top: 4px; } /* ref/handle strip ABOVE the thumbnail (not on it, so a screenshot of the    thumbnail stays clean): one slim mono line, the NAME of the shot for    talking to your AI. */-.card-refbar { display: flex; align-items: center; gap: 8px; padding: 3px 10px 2px; min-height: 16px;+.card-refbar { display: flex; align-items: center; gap: 6px; padding: 3px 10px 2px; min-height: 16px;   font: 600 10.5px/1.3 'JetBrains Mono', monospace; color: var(--text3); }-.card-refbar .rb-ref { letter-spacing: .2px; }+.card-refbar .rb-ref { letter-spacing: .2px; flex-shrink: 0; }+.card-refbar .rb-sep { color: var(--text3); flex-shrink: 0; user-select: none; }+.card-refbar .rb-ts { color: var(--text2); font-weight: 500; white-space: nowrap;+  overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; cursor: help; } /* copy button (Ray, PR #5): hover-revealed like ⛶, never on the thumbnail */ .card-refbar .rb-copy svg { width: 13px; height: 13px; display: block; } .card-refbar .rb-copy { margin-left: 2px; padding: 2px 5px; border-radius: 5px; cursor: pointer; flex-shrink: 0;@@ -279,7 +282,7 @@ body.compact .card-popups .ph { padding-top: 4px; } .card-refbar .rb-del .lbl { font-size: 10.5px; padding: 0 2px; } @media (hover: none) { .card-refbar .rb-del { opacity: .8; } } .card-refbar .rb-tag { color: var(--accent-bright); background: rgba(0,184,176,.12); border: 1px solid rgba(0,184,176,.45);-  border-radius: 5px; padding: 0 6px; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+  border-radius: 5px; padding: 0 6px; max-width: 70%; min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* caption pill (gold): an annotated shot carries a longer caption from the    AI that sent it. It starts the caption here, cut to fit the narrow    sidebar, and hovering it reveals the full info overlay, like the ⓘ. */@@ -1040,6 +1043,34 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }     return (h%12||12)+':'+mm+(h<12?'am':'pm'); }   function fmtDate(ts){ const d=new Date(ts), mo=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][d.getMonth()];     return mo+' '+d.getDate()+', '+fmtTime(ts); }+  function fmtCardTime(ts, now){+    const d=new Date(ts);+    if (!ts || isNaN(d.getTime())) return '';+    const ref = now || new Date();+    const h = d.getHours(), mm = String(d.getMinutes()).padStart(2,'0');+    const clock = (h%12||12)+':'+mm+' '+(h<12?'AM':'PM');+    const sameDay = d.getFullYear()===ref.getFullYear() && d.getMonth()===ref.getMonth() && d.getDate()===ref.getDate();+    if (sameDay) return clock;+    const mo = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][d.getMonth()];+    if (d.getFullYear()===ref.getFullYear()) return mo+' '+d.getDate()+' '+clock;+    return mo+' '+d.getDate()+', '+d.getFullYear()+' '+clock;+  }+  function fmtIsoLocal(d){+    const p=n=>String(n).padStart(2,'0');+    const off=-d.getTimezoneOffset();+    const sign=off>=0?'+':'-';+    const abs=Math.abs(off);+    return d.getFullYear()+'-'+p(d.getMonth()+1)+'-'+p(d.getDate())+'T'++      p(d.getHours())+':'+p(d.getMinutes())+':'+p(d.getSeconds())++      sign+p(Math.floor(abs/60))+':'+p(abs%60);+  }+  function fmtTimeTooltip(ts){+    const d=new Date(ts);+    if (!ts || isNaN(d.getTime())) return '';+    const local=d.toLocaleString(undefined,{year:'numeric',month:'short',day:'numeric',+      hour:'numeric',minute:'2-digit',second:'2-digit',timeZoneName:'short'});+    return local+'\n'+fmtIsoLocal(d);+  }   // Which surface is showing this viewer? Explicit ?surface= wins (set by   // `shotlog open`/force-open = webview, or an opener that knows it's pup);   // otherwise infer mobile from the UA, else a plain browser.@@ -1238,7 +1269,7 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }     }     const meta=document.createElement('div'); meta.className='shot-card-meta';     const ts=document.createElement('span'); ts.className='ts'; ts.textContent=fmtDate(e.timestamp);-    ts.setAttribute('data-tooltip', new Date(e.timestamp).toLocaleString()); meta.appendChild(ts);+    ts.setAttribute('data-tooltip', fmtTimeTooltip(e.timestamp) || new Date(e.timestamp).toLocaleString()); meta.appendChild(ts);     // The REF (#id) and optional HANDLE (--tag): how a human points an AI at     // exactly this shot ("#42 is the one" / "heroG is the one").     { const s=document.createElement('span'); s.className='sep'; s.textContent='·'; meta.appendChild(s);@@ -1300,6 +1331,19 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }       const rn=document.createElement('span'); rn.className='rb-ref'; rn.textContent='#'+e.id;       rn.setAttribute('data-tooltip','Shot ref #'+e.id+': say "#'+e.id+'" to your AI to mean exactly this shot.'+(e.tag?'':' (An AI can also give a shot a handle: shotlog inject --tag heroG.)'));       rb.appendChild(rn);+      { const tsTxt = fmtCardTime(e.timestamp);+        if (tsTxt) {+          const sep = document.createElement('span'); sep.className='rb-sep'; sep.setAttribute('aria-hidden','true'); sep.textContent='·';+          rb.appendChild(sep);+          const dt = document.createElement('time'); dt.className='rb-ts';+          dt.textContent = tsTxt;+          dt.dataset.ts = e.timestamp;+          const parsed = new Date(e.timestamp);+          if (!isNaN(parsed.getTime())) dt.setAttribute('datetime', fmtIsoLocal(parsed));+          const tip = fmtTimeTooltip(e.timestamp);+          if (tip) dt.setAttribute('data-tooltip', tip);+          rb.appendChild(dt);+        } }       if (e.tag){ const tg=document.createElement('span'); tg.className='rb-tag'; tg.textContent=e.tag;         tg.setAttribute('data-tooltip','Handle "'+e.tag+'" given by the AI that injected this shot (--tag). Say "'+e.tag+'" to mean exactly this shot.');         rb.appendChild(tg); }@@ -1322,6 +1366,21 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }           } else { legacyCopy(txt, done); }         });         rb.appendChild(cp); }+      // The caption pill comes AFTER the copy button (Ray, 2026-10-16): the+      // button copies "#id handle", so it sits beside them, not past the caption.+      if (e.auto_description && e.description) {+        const cp=document.createElement('span'); cp.className='rb-cap'; cp.textContent=e.description;+        cp.setAttribute('aria-label','Caption: '+e.description);+        // Same reveal as the ⓘ: hover shows the full info overlay (caption,+        // prompt, file, chips); click toggles it for touch.+        // Hover INTENT, not a bare mouseenter: the pointer crosses this pill on+        // its way to the copy button, and an instant overlay got in the way.+        let capTimer=null;+        cp.addEventListener('mouseenter', ()=>{ capTimer=setTimeout(showInfo, 350); });+        cp.addEventListener('mouseleave', ()=>{ clearTimeout(capTimer); });+        cp.addEventListener('click', ev=>{ ev.stopPropagation(); clearTimeout(capTimer);+          if (info.classList.contains('show')) info.classList.remove('show'); else showInfo(); });+        rb.appendChild(cp); }       // DELETE one shot (John, 2026-10-21): hover-revealed trash at the far       // right of the ref bar; two clicks (the button itself becomes the       // confirmation, red, disarms after 4s), then the shot and its files are@@ -1339,21 +1398,6 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }               else { del.disabled=false; showToast('could not delete: '+(r.error||'unknown'), 6000); } })             .catch(()=>{ del.disabled=false; showToast('could not reach the broker', 4000); }); });         rb.appendChild(del); }-      // The caption pill comes AFTER the copy button (Ray, 2026-10-16): the-      // button copies "#id handle", so it sits beside them, not past the caption.-      if (e.auto_description && e.description) {-        const cp=document.createElement('span'); cp.className='rb-cap'; cp.textContent=e.description;-        cp.setAttribute('aria-label','Caption: '+e.description);-        // Same reveal as the ⓘ: hover shows the full info overlay (caption,-        // prompt, file, chips); click toggles it for touch.-        // Hover INTENT, not a bare mouseenter: the pointer crosses this pill on-        // its way to the copy button, and an instant overlay got in the way.-        let capTimer=null;-        cp.addEventListener('mouseenter', ()=>{ capTimer=setTimeout(showInfo, 350); });-        cp.addEventListener('mouseleave', ()=>{ clearTimeout(capTimer); });-        cp.addEventListener('click', ev=>{ ev.stopPropagation(); clearTimeout(capTimer);-          if (info.classList.contains('show')) info.classList.remove('show'); else showInfo(); });-        rb.appendChild(cp); }       c.appendChild(rb); }   // info (hidden in compact) -> refbar -> imgWrap (appended below)     // COMPACT mode's reveal chip: hover (or tap, on touch) the ⓘ on the image     // to overlay the full info block; it hides again when the pointer leaves@@ -1415,7 +1459,8 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }     mMeta.innerHTML='';     const add=(cls,txt,tip)=>{ const s=document.createElement('span'); if(cls)s.className=cls; s.textContent=txt; if(tip)s.setAttribute('data-tooltip',tip); mMeta.appendChild(s); };     const sep=()=>add('sep','·');-    add('ts',fmtDate(e.timestamp));+    if (e.id != null) { add('chip ref', '#' + e.id); sep(); }+    add('ts', fmtCardTime(e.timestamp) || fmtDate(e.timestamp), fmtTimeTooltip(e.timestamp));     if(e.w&&e.h){ sep(); add('dim-main',e.w+'×'+e.h);       if(e.orig_w&&e.orig_h&&(e.orig_w!==e.w||e.orig_h!==e.h)){ sep(); add('','orig '+e.orig_w+'×'+e.orig_h); } }     if(e.kb){ sep(); add('',e.kb+' KB'); }@@ -2277,7 +2322,14 @@ body:not(.compact) .card-refbar .rb-cap { display: none; }     }   }); -  // Refresh relative timestamps periodically (cards use absolute, but keep ts tooltips fresh) — no-op for now+  // Refresh card header datetimes every minute so "today" shots gain their date after midnight.+  setInterval(() => {+    const now = new Date();+    document.querySelectorAll('.card-refbar .rb-ts[data-ts]').forEach(el => {+      const txt = fmtCardTime(el.dataset.ts, now);+      if (txt && el.textContent !== txt) el.textContent = txt;+    });+  }, 60000); })(); </script> </body>
src/store.rs+71
@@ -883,3 +883,74 @@ impl Store {         pruned     } }++#[cfg(test)]+mod tests {+    use super::*;+    use std::time::{SystemTime, UNIX_EPOCH};++    fn temp_dir(name: &str) -> PathBuf {+        let nanos = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();+        let dir = std::env::temp_dir().join(format!("adom-shotlog-test-{name}-{nanos}"));+        fs::create_dir_all(&dir).unwrap();+        dir+    }++    #[tokio::test]+    async fn timestamp_persists_in_sidecar_and_recovers() {+        let dir = temp_dir("ts-recover");+        let ch_dir = dir.join("demo");+        fs::create_dir_all(&ch_dir).unwrap();+        let png = [+            0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a,+            0x00, 0x00, 0x00, 0x0d, b'I', b'H', b'D', b'R',+            0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,+            0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde,+        ];+        fs::write(ch_dir.join("older.png"), png).unwrap();+        let expected: DateTime<Utc> = "2026-11-18T15:03:42Z".parse().unwrap();+        fs::write(+            ch_dir.join("older.json"),+            serde_json::json!({+                "description": "Older shot",+                "source": "cli",+                "timestamp": expected.to_rfc3339(),+            })+            .to_string(),+        )+        .unwrap();++        let store = Store::new(dir.clone());+        store.recover().await;+        let entries = store.get_entries("demo").await;+        assert_eq!(entries.len(), 1);+        assert_eq!(entries[0].timestamp, expected);++        let added = store+            .add_entry(+                "demo",+                png.to_vec(),+                "fresh.png".into(),+                "Fresh shot".into(),+                "cli".into(),+                1,+                1,+                Some(1),+                Some(1),+                None,+                None,+                None,+                None,+                None,+                None,+                None,+            )+            .await;+        let sidecar: serde_json::Value =+            serde_json::from_str(&fs::read_to_string(ch_dir.join("fresh.json")).unwrap()).unwrap();+        let parsed: DateTime<Utc> = sidecar["timestamp"].as_str().unwrap().parse().unwrap();+        assert!((added.timestamp - parsed).num_seconds().abs() <= 2);++        let _ = fs::remove_dir_all(&dir);+    }+}

Comments

Drew Owens ·

Before and after screenshots from the isolated dev instance (skinny webview 360px and pup desktop views, order: before skinny, after skinny, before pup, after pup).

before-skinny

after-skinny

before-pup

after-pup

Log in to comment.