feat: /sessions timeline command for chronological session bucketing (F4.4) #34
Notifications
Due Date
No due date set.
Depends on
#26 feat: redact api keys/secrets/JWTs during session import (Privacy)
terraphim/agent-tasks
Reference: terraphim/agent-tasks#34
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
The
terraphim-agent-session-search-spec.md(section F4.4 "Session Commands" and the "Interactive Mode" UX preview) mandates a/sessions timelinecommand for chronological grouping and trend analysis of imported coding-assistant sessions:The Phase 3 success criterion claims
[x] Timeline and export, yet a repository-wide grep forTimeline/timelineincrates/terraphim_sessions/,crates/terraphim_agent/, andcrates/terraphim-session-analyzer/returns zero hits. Users cannot ask "how many Claude sessions did I have last week" or "show me my coding-assistant activity over the past 30 days" without writing custom queries against the cache. This blocks the dashboards described in the spec's "Reporting & Publishing" section and the historical-trend roadmap item.Acceptance Criteria
SessionsSubcommand::Timelineaccepts:--group-by day|week|month|hour(defaultday)--last <duration>accepting7d,30d,12w,6m,1y(default30d)--source <name>(optional filter, repeatable)--since <iso8601>/--until <iso8601>for explicit range bounds (overrides--last)SessionService::timeline(query: TimelineQuery) -> Result<Timeline>that bins sessions by(group_key, source)usingcreated_atpub struct Timeline { buckets: Vec<TimelineBucket>, summary: TimelineSummary }pub struct TimelineBucket { period_start: DateTime<Utc>, period_end: DateTime<Utc>, sessions_by_source: HashMap<String, usize>, total_sessions: usize, total_messages: usize, top_concepts: Vec<String> }(top concepts populated only whenenrichmentfeature is enabled)RobotResponse<Timeline>with full bucket array;--max-bucketsflag caps payload sizeERROR_NOT_FOUND)cargo test -p terraphim_sessions timelinepassescargo test -p terraphim_agent --features repl-full,repl-sessions sessions_timelinepassescargo clippy -p terraphim_sessions -p terraphim_agent --features repl-full,repl-sessions -- -D warningspassesProposed Approach
Affected crates:
crates/terraphim_sessions/-- addpub mod timelinewithTimelineQuery,Timeline,TimelineBucket, and the service method. Bucket assignment useschrono::DateTime::date_naive()truncation per group-by mode.crates/terraphim_agent/src/repl/commands.rs-- extendSessionsSubcommandwithTimeline(TimelineArgs)clap variant; reuses an existingparse_durationhelper or adds a small one.crates/terraphim_agent/src/repl/handler.rs-- newhandle_sessions_timelinebranch that renders the ASCII chart via existingcomfy-tablestyling.Top-concepts aggregation runs only when the
enrichmentfeature is on, and it reusesSessionConceptsalready attached to enriched sessions -- no new KG calls.Dependencies
None. The session cache and
SessionService::listare sufficient to enumerate sessions for bucketing.Verification
Smoke test (after build):
Scope
Single PR, approximately 320 LOC: ~150 LOC bucketing logic + types, ~80 LOC clap variant + ASCII renderer, ~90 LOC tests + fixtures. Trend forecasting, the historical-trends dashboard (Extensibility Roadmap item), and HTML/SVG renderers are out of scope.