Skip to content

fix(cli): search all rg words and send date filters in seconds - #314

Merged
AnnatarHe merged 1 commit into
mainfrom
claude/quirky-volta-wzws5j
Oct 6, 2026
Merged

AnnatarHe merged 1 commit into
mainfrom
claude/quirky-volta-wzws5j

Conversation

@AnnatarHe

Copy link
Copy Markdown
Contributor

Problem

Three bugs in shelltime rg (commands/grep.go):

  1. Only the first word was searched. searchText := c.Args().First() meant shelltime rg git sub searched for git, and sub was dropped without any warning.
  2. Date filters were in the wrong unit. --since / --until were sent as UnixMilli(), but the server's CommandFilter.time is in unix seconds (time.Unix(sec, 0)). Every date filter landed around the year 56000 and matched nothing.
  3. A lone --since or --until matched only one day. When the server gets a single time value, it reads it as "that one day", not as an open-ended range.

The main reason rg missed older commands was on the server: CLI calls were limited to the last 7 days. That is fixed in shelltime/server on the branch of the same name.

Fix

  • Every positional arg is joined into one phrase, so rg git sub and rg "git sub" give the same results. The usage error now says shelltime rg <search-text>.
  • Time filters are always sent as a [start, end] pair in seconds. A missing side is filled in: epoch for start, now for end.

Tests

  • TestBuildGrepFilter_SinceAndUntilTimeWindow now expects seconds. It previously asserted the millisecond bug.
  • New TestBuildGrepFilter_SinceOnlyRunsUntilNow and TestBuildGrepFilter_UntilOnlyStartsAtEpoch.
  • New TestCommandGrep_UnquotedWordsFormOnePhrase: runs rg git sub against an httptest GraphQL server and checks that the request's filter.command is "git sub".

go vet ./commands/ and go test ./commands/ pass locally, after mockery.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EcWEjASeNtz3QVVtf1wLXp


Generated by Claude Code

- `shelltime rg git sub` searched only "git" because just the first arg
  was used; join every arg into one search phrase.
- --since/--until were sent as unix milliseconds while the server reads
  seconds, so any date filter matched nothing.
- A lone --since or --until sent a single value, which the server reads
  as "that one day"; always send a [start, end] range instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcWEjASeNtz3QVVtf1wLXp
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@claude

claude Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 85.49% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
commands/grep.go 97.91% <100.00%> (+0.01%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AnnatarHe
AnnatarHe merged commit c8dd39c into main Oct 6, 2026
4 checks passed
@AnnatarHe
AnnatarHe deleted the claude/quirky-volta-wzws5j branch October 6, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants