Skip to content

fix: timezone awareness during atuin search - #3762

Open
Dilyxs wants to merge 5 commits into
atuinsh:mainfrom
Dilyxs:test/timezone_filter
Open

fix: timezone awareness during atuin search#3762
Dilyxs wants to merge 5 commits into
atuinsh:mainfrom
Dilyxs:test/timezone_filter

Conversation

@Dilyxs

@Dilyxs Dilyxs commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #2808
Fixes #2607

problem

when we filter through it always pass UTC as fallback when library can't figure out which timezone we are in causing the wrong window to be selected

solution

pass on the timezone from settings so that is the fallback.

Timezone support in filtering:

  • Added a timezone field of from settings when library cannot figure out what timezone the requested filter is in.

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR propagates the configured timezone into non-interactive history filtering.

  • Adds a timezone field to database search filters.
  • Uses it as the fallback when parsing before/after values.
  • Adds UTC defaults and fixed-offset parsing tests.

Confidence Score: 3/5

This should be fixed before merging because timezone-less filters still select the wrong one-hour window when the requested date has a different DST offset.

The new path applies the current local UTC offset to every parsed date, but a fixed offset cannot represent the date-dependent DST rules needed for historical and future boundaries.

Files Needing Attention: crates/atuin-client/src/database.rs, crates/atuin-common/src/time/utc_offset.rs

Important Files Changed

Filename Overview
crates/atuin-client/src/database.rs Applies the configured fixed offset to date filters, but historical dates can receive the wrong DST offset.
crates/atuin-common/src/time/utc_offset.rs Adds a UTC default while the existing local resolution remains a fixed offset without timezone rules.
crates/atuin/src/command/client/search.rs Correctly propagates settings.timezone into the non-interactive search filter.

Reviews (1): Last reviewed commit: "removed redudant test, not exactly sure ..." | Re-trigger Greptile

})?;
let parsed = interim::parse_date_string(
before,
OffsetDateTime::now_utc().to_offset(filter_options.timezone.0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Historical dates use current offset

When a timezone-less filter targets a date whose DST offset differs from the offset resolved at startup, parsing applies the current fixed offset instead, shifting the search boundary by an hour and returning the wrong history window.

Knowledge Base Used: Client Core (atuin-client)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woudn't full DST support require adding a new dependency like jiff to get a named timezone no? wouldn't this PR still resolve bare strings defaulting to UTC instead of local time, the common case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right on both counts. Full DST-aware parsing would need a named timezone (e.g., America/New_York) so the library can look up the correct historical offset — that's a separate dependency and a larger change.

This PR does fix the primary regression: bare strings like "yesterday" or "last week" were always resolved against UTC, which is wrong for anyone not in UTC. Using the configured timezone offset is a clear improvement for the common case, even if a fixed offset won't handle DST boundaries perfectly.

My concern is a narrow edge case (searches crossing a DST transition), not a blocker. The PR is a net improvement.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Full DST-correct parsing requires a named IANA timezone (e.g. America/New_York) so the library can look up the historically correct offset for the parsed date — a fixed UtcOffset can't do that. That would need something like jiff or chrono-tz, which is a separate, more invasive change.

This PR does fix the primary bug: bare date strings like "yesterday" or "last week" were anchored to UTC instead of local time, which is the common case and the root cause of #2808 and #2607. The DST edge case is a much narrower failure mode.

My comment was valid but shouldn't block this — it's an incremental improvement over the current behavior. Sorry for the noise.

Shall I remember this as a rule: "Accept timezone-related fixes that improve the common case (local time vs UTC), even if they don't handle DST edge cases, unless the repo has an existing named-timezone dependency available"?

@Dilyxs
Dilyxs force-pushed the test/timezone_filter branch from 8f0134f to 57d6548 Compare July 27, 2026 21:59
@Dilyxs
Dilyxs force-pushed the test/timezone_filter branch from 57d6548 to 209f0f2 Compare July 27, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant