Expand description
Per-host SSH connection activity log.
Records (alias, timestamp) events each time purple opens an SSH
session, exec command or tunnel for a host. Persisted to
~/.purple/key_activity.json. The Keys tab reads this log to render
per-key sparklines, last-touch hints and “hosts touched in last 30d”
metrics by pivoting events through SshKeyInfo::linked_hosts at
render time. We log per alias rather than per key fingerprint so we
never have to attribute connects to a specific key file; the alias
mapping already encodes the link.
Structs§
Constants§
- DEMO_
NOW_ SECS - Fixed reference timestamp used by demo data seeding and by render-time helpers that need a deterministic “now”. Picked at the cutover date so visual goldens render deterministically; the date itself only matters in concert with the timestamps demo.rs seeds.
Functions§
- format_
created - Format a file mtime as
YYYY-MM-DD (<age> ago)for the Created label. Useshumanize_last_usefor the age tail so the rhythm matches the Last touch tile. - humanize_
last_ use - Format the gap between
nowandtsas a compactNu agolabel (Ncount,uunit). Mirrors the rhythm Linear / GitHub use:just now,14m ago,3h ago,2d ago,3w ago,2mo ago,1y ago. - now_
for_ render - Demo-aware “now” for render-time callers. Returns the frozen
DEMO_NOW_SECSwhen the process is in demo mode (so visual goldens land byte-stable), otherwise the wall clock. Record-time callers must usenow_secs()directly and pass the result through; mixing the two would let a render-time freeze leak into persisted events. - now_
secs - Current wall-clock epoch seconds. Demo-aware rendering uses
now_for_render()instead, which substitutesDEMO_NOW_SECSso sparkline rendering stays byte-stable across golden runs. - record_
and_ flush - Field-disjoint helper: record + flush the activity log without
holding
&mut App. Lets the event loop record a connect while another sub-state (FileBrowser, TunnelState) still holds a mutable borrow onApp, where theApp::record_key_usemethod would be rejected by the borrow checker. Caller passesnow; production call sites passnow_secs().