feat(log): add search command and date shortcuts#9
Merged
Conversation
Sessions showed 0:00 duration because: 1. WriteIndex was defined but never called - no index files were created 2. Fallback to reading v3 cast files failed (v3 uses relative timestamps that must be summed, not absolute timestamps) Changes: - Call WriteIndex in recording_wrapper.go when sessions end, capturing wall-clock startedAt/finishedAt times - Simplify readFromCastFile to use mtime as fallback finish time (accurate for completed sessions, avoids parsing entire file) - Remove broken readFinalTimestamp that didn't work for v3 format - Add one-time migration script (scripts/migrate-indexes.sh) to backfill indexes for existing cast files For new sessions: Index file written with accurate wall-clock duration For old sessions: Migration script parses cast files and generates indexes Amp-Thread-ID: https://ampcode.com/threads/T-019bab65-8279-746f-9c0d-5480177d9aae Co-authored-by: Amp <amp@ampcode.com>
- Add 'nssh log search <pattern>' to grep through session recordings - Searches .txt exports if available, otherwise parses .cast files - Supports --select, --last, --case-sensitive, --context flags - Highlights matches in output - Add date shortcuts to --select flag on list, delete, search commands: - today, yesterday, this-week, last-week, this-month, last-month - Date filtering now matches on either StartedAt OR mtime, so sessions that started yesterday but were active today match both dates
5066cb9 to
baf275c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds new features to the
nssh logcommands:New
nssh log searchcommandSearch through session recordings for keywords or patterns:
.txtexports if available (faster), otherwise parses.castfiles directly with ANSI strippingDate shortcuts for
--selectflagAdds convenient shortcuts to
--select/-son list, delete, and search commands:today,yesterdaythis-week,last-weekthis-month,last-monthExamples:
nssh log list -s today nssh log list -s yesterday nssh log search -s this-week "error" nssh log delete -s last-month --dry-runImproved date filtering
Date filtering now matches on either
StartedAtORmtime(last updated), so sessions that started yesterday but were active today will match bothyesterdayandtoday.