Skip to main content

Module slice

Module slice 

Source
Expand description

Timeline slicing — parsers + application for --after / --before duration filters, --after-step / --before-step / --range index filters, and the :@<duration> TUI jump command.

Duration grammar (permissive, case-insensitive):

  • 30s / 30sec → 30 seconds
  • 5m / 5min → 5 minutes
  • 2h / 2hr → 2 hours
  • 1d / 1day → 1 day
  • 1h30m / 90m30s → concatenated components, summed
  • Bare integer → seconds (e.g. 300 = 5m)

Range grammar: start..end (exclusive end, mirrors Rust’s Range<usize>). Open-ended forms: ..500, 100.., or just .. (no-op). 1-based step numbers internally convert to 0-based so --range 1..11 = the first 10 steps regardless of format.

Time semantics: --after 2h / --before 10m are relative to the session’s first step, not to wall-clock now. This is unambiguous for archived sessions where “now” is meaningless, and matches the intuitive read of “give me what happened in the first 10 minutes of this session”. Sessions with no timestamps get a stderr warning and pass through unfiltered.

Structs§

StepRange
Inclusive start, exclusive end, both 0-based.

Functions§

parse_duration_ms
Parse a duration string like 1h30m, 45s, 2h, 90m30s, or a bare integer (seconds). Returns milliseconds.
parse_step_range
Parse start..end, ..end, start.., or .. into a StepRange. End is always exclusive — 1..11 means the first ten steps. The CLI surface accepts 1-based numbers; the conversion to 0-based indices happens at the slice site.
slice_steps
Slice the steps by index range and optional time bounds. Time bounds are offsets in milliseconds from the session’s first step’s timestamp. When no step carries a timestamp, time filters are silently skipped (and the caller gets a stderr warning from warn_if_time_filter_ignored — kept out here so this function stays pure).
step_range_from_bounds
Build a StepRange from top-level --after-step / --before-step scalars. Either may be None for an open bound.
warn_if_time_filter_ignored
Print a one-line stderr warning when the user asked for a time filter but the session has no usable timestamps. Keeps slice_steps itself pure.