Skip to content

Handle one-sided date ranges and date-only end dates consistently - #249

Merged
mattt merged 4 commits into
mainfrom
mattt/date-range-handling
Sep 26, 2026
Merged

mattt merged 4 commits into
mainfrom
mattt/date-range-handling

Conversation

@mattt

@mattt mattt commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

messages_fetch applied a date range only when both start and end were given, so a call with start alone ignored it and returned messages from years earlier. This PR applies each bound on its own. The open end uses a date that fits the Int64 nanoseconds chat.db uses, an end before the start matches nothing instead of trapping, and a start or end that is not an ISO 8601 string is rejected instead of dropped.

reminders_fetch had the same gap: without completed, it ignored start and end and returned every reminder. With a date range, it now returns incomplete reminders by due date and completed ones by completion date, as the two explicit modes do.

A date-only end already includes that whole day in messages_fetch, events_fetch, and reminders_fetch, but the descriptions said it uses local midnight or said nothing. The descriptions now say that a date-only value includes that whole day. phone_calls_fetch used a date-only end as midnight, which left that day out, so it now normalizes date-only start and end values like the other tools.

messages_fetch applied a date range only when both start and end were
given, so start alone was ignored. Each bound now applies on its own,
and an end before the start matches nothing instead of trapping.

A date-only end already includes that whole day in messages_fetch,
events_fetch, and reminders_fetch, but the descriptions said it uses
local midnight. The descriptions now say so, and phone_calls_fetch
normalizes date-only start and end values the same way.

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

Invalid message date inputs can be silently ignored instead of rejected.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates date-range handling and date-only documentation across message, phone, calendar, and reminder fetch services.

Changes:

  • Supports one-sided message date ranges.
  • Normalizes phone date-only bounds.
  • Clarifies date-only end-date behavior.
  • Messages still need explicit validation for invalid date inputs.
File Changes
App/​Services/​Reminders.swift Updated end-date documentation.
App/​Services/​Phone.swift Normalized date-only bounds.
App/​Services/​Messages.swift Added independent date bounds and open-range handling.
App/​Services/​Calendar.swift Updated end-date documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread App/Services/Messages.swift Outdated
An unparseable start or end was dropped silently, which widened the
range instead of reporting the mistake.

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

Non-string date bounds can be treated as omitted, bypassing message filtering.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread App/Services/Messages.swift Outdated

Copilot AI left a comment

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.

Copilot review overview

🔵 Needs a closer look

The default reminders query ignores the documented date range when completed is omitted.

Review effort: Lite
Findings: None

Resolved since last review (1)

When completed was omitted, reminders_fetch fetched every reminder in
the lists and ignored start and end. With a date range, it now fetches
incomplete reminders by due date and completed ones by completion date,
as the two explicit modes do.

Copilot AI left a comment

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.

Copilot review overview

🔵 Needs a closer look

Adjust the Messages.swift upper sentinel to support all valid Int64 nanosecond dates.

Review effort: Lite
Findings: None

@mattt
mattt merged commit 3ce1424 into main Sep 26, 2026
2 checks passed
@mattt
mattt deleted the mattt/date-range-handling branch September 26, 2026 11:40
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