Expand description
Past-sessions catalog: the UI-free engine behind the /sessions Past tab.
Everything here is synchronous and pure over injected paths, so callers
run it on spawn_blocking (or a plain thread) and never on a draw loop:
load_catalog— every session header joined withindex.jsonl(cwd / profile / turns / duration). Headers only, never message history.PreviewCache— sidecar cache of first/last user message + true message count, keyed by id + (mtime, bytes), refreshed incrementally.Query/parse_query— free text + power tokens.build_view— noise hiding, facets with counts, sorting; plusday_groupsfor the day headers.deep_search— cancellable streaming full-text scan of bodies.rename_past_session— rename under the session’s own.lock.
Nothing in this module ever deletes a session (owner decision).
Structs§
- Catalog
- The loaded catalog.
entriesis in no particular order — usebuild_viewfor display order. - Catalog
Entry - One past session as the Past tab sees it.
- Catalog
Paths - Where the catalog reads and writes. Every path is injectable so tests and
benches never touch the real
~/.synaps-cli. - Clock
- “Now” plus the zone used for calendar maths.
- Date
Bound - A resolved date token: the local day and its UTC start instant.
- DayGroup
- A run of consecutive rows sharing a local day.
- DeepHit
- Deep
Search Options - Deep
Summary - Facet
Count - One sidebar row.
- Facet
Selection - Active facet choices from the sidebar (all
None/false = no filter). - Facets
- Facet counts. Each group is counted with the query, noise filter and the OTHER groups’ selections applied — never its own — so picking a project still shows how many sessions each other project has.
- Noise
Counts - Per-rule counts of hidden entries (“hiding N (sandbox, <3 msgs)”).
totalcounts each entry once even when several rules match. - Noise
Reasons - Why an entry is hidden by default. Several can apply at once.
- Preview
- Cached facts for one session.
- Preview
Cache - Query
- Refresh
Stats - What a
PreviewCache::refreshdid. - View
- Rows to render plus the sidebar/header numbers.
Enums§
- DateKey
- Deep
Event - Deep
Role - Rename
Error - Sort
- Sort orders. All descending (biggest / newest first).
- When
- The When facet.
Constants§
- DEEP_
HIT_ CAP - Hard stop: the scan ends once this many hits were delivered.
- MIN_
MESSAGES - Sessions with fewer messages than this are noise (when the count is known).
- PREVIEW_
MAX_ CHARS - Preview text cap (characters, after whitespace collapse).
Functions§
- build_
view - Filter, facet and sort. O(n) over the catalog plus the sort; cheap enough to rerun on every keystroke for thousands of entries.
- day_
groups - Split already-sorted
rowsinto day groups bykey(useSort::date_key). Rows sorted by something else just yield more, smaller groups — callers should skip headers whendate_keyisNone. - deep_
search - Scan
targets(in the given order — pass the current view order so newest sessions report first) forphrase. Hits and progress stream throughon_eventon the calling thread; setcancelfrom anywhere to stop (checked per message). A blank phrase returns immediately. Blocking — run it onspawn_blockingand forward events over a channel. - is_
session_ id YYYYMMDD-HHMMSS-<hex>(4+ hex chars) — the shapeSession::newmints.- load_
catalog - Load every past session header in
paths.sessions_dir, joined withpaths.index_path. Pure + blocking: run it onspawn_blocking. A missing dir or index is empty, not an error. - model_
key - Strip a
provider/prefix:anthropic/claude-opus-4-6→claude-opus-4-6. - model_
label - Short label:
claude-opus-4-6→opus-4-6; others unchanged. - noise_
reasons - Noise classification for one entry.
- parse_
query - Parse a query string. Total: bad tokens become free text.
- rename_
past_ session - Set (
Some) or clear (None) the name of past sessionidindir. Blocking. Idempotent: setting the current name isOkwithout a write. - tilde
$HOME→~,$HOME/x→~/x.