Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(universal-input): schedule a time with no day at its next occurrence (#9376)

Peter Chinman2db07e63ea86
diff --git a/crates/universal_input/src/domain/temporal/resolve.rs b/crates/universal_input/src/domain/temporal/resolve.rs
index 0306eeff5f..14b1b8856a 100644
--- a/crates/universal_input/src/domain/temporal/resolve.rs
+++ b/crates/universal_input/src/domain/temporal/resolve.rs
@@ -163,7 +163,6 @@ fn start(
expression: &StartExpression,
input: &ExtractInputRequest,
reference: DateTime<Tz>,
- date_only: bool,
) -> Result<ResolvedStart, InputError> {
match expression {
StartExpression::Relative { span, minutes } => {
@@ -205,13 +204,23 @@ fn start(
.ok_or(InputError::Extraction)?,
);
}
+ // A clock without a date is its next occurrence: today, or tomorrow
+ // once that clock has passed.
+ if let (None, Some((t, _))) = (day, time) {
+ let today = reference.date_naive();
+ day = Some(if t < reference.time() {
+ today
+ .checked_add_days(Days::new(1))
+ .ok_or(InputError::Extraction)?
+ } else {
+ today
+ });
+ }
let value = match (day, time) {
(Some(d), Some((t, _))) => Some(instant(d, t, reference.timezone())?),
_ => None,
};
- if (date_only && day.is_none())
- || (expression_date.is_none() && expression_clock.is_none())
- {
+ if expression_date.is_none() && expression_clock.is_none() {
return Err(InputError::Extraction);
}
let assumption = expression_clock
@@ -251,7 +260,7 @@ pub(super) fn apply(
(InputSuggestions::Task(fields), TemporalExpressions::Task(expressions)) => {
fields.due_date = None;
if let Some(expression) = expressions.due {
- let resolved = start(&expression, input, reference, true)?;
+ let resolved = start(&expression, input, reference)?;
fields.due_date = resolved
.instant
.map(|d| d.format("%Y-%m-%dT%H:%M").to_string())
@@ -278,7 +287,7 @@ pub(super) fn apply(
let resolved = expressions
.start
.as_ref()
- .map(|e| start(e, input, reference, false))
+ .map(|e| start(e, input, reference))
.transpose()?;
let starts_at = resolved.as_ref().and_then(|r| r.instant);
fields.start = starts_at.map(|d| d.format("%Y-%m-%dT%H:%M").to_string());
diff --git a/crates/universal_input/src/domain/temporal/resolve/test.rs b/crates/universal_input/src/domain/temporal/resolve/test.rs
index 81614c2161..c26fbd5084 100644
--- a/crates/universal_input/src/domain/temporal/resolve/test.rs
+++ b/crates/universal_input/src/domain/temporal/resolve/test.rs
@@ -306,7 +306,6 @@ fn upcoming_today_with_a_past_clock_moves_one_week_but_this_week_does_not() {
},
&request,
reference,
- false,
)
.unwrap();
assert_eq!(
@@ -320,6 +319,78 @@ fn upcoming_today_with_a_past_clock_moves_one_week_but_this_week_does_not() {
}
}
+#[test]
+fn a_clock_without_a_date_is_its_next_occurrence() {
+ // The reference is 14:00 in New York: 3pm is still ahead today, 9am has passed.
+ for (text, span, hour, meridiem, expected) in [
+ (
+ "Team sync at 3pm",
+ "3pm",
+ 3,
+ Meridiem::Pm,
+ "2026-10-23T15:00",
+ ),
+ (
+ "Team sync at 9am",
+ "9am",
+ 9,
+ Meridiem::Am,
+ "2026-10-24T09:00",
+ ),
+ ] {
+ let request = input(text);
+ let mut fields = InputSuggestions::Calendar(CalendarSuggestions::default());
+ apply(
+ &mut fields,
+ TemporalExpressions::Calendar(CalendarTemporalExpressions {
+ start: Some(StartExpression::Local {
+ date: None,
+ clock: Some(ClockExpression {
+ span: span.into(),
+ hour,
+ minute: 0,
+ meridiem: Some(meridiem),
+ daypart: None,
+ }),
+ }),
+ end: None,
+ recurrence: None,
+ }),
+ &request,
+ )
+ .unwrap();
+ let InputSuggestions::Calendar(fields) = fields else {
+ panic!("wrong intent");
+ };
+ assert_eq!(fields.start.as_deref(), Some(expected));
+ }
+
+ let mut request = input("Send the deck by 3pm");
+ request.intent = InputIntent::Task;
+ let mut fields = InputSuggestions::Task(TaskSuggestions::default());
+ apply(
+ &mut fields,
+ TemporalExpressions::Task(TaskTemporalExpressions {
+ due: Some(StartExpression::Local {
+ date: None,
+ clock: Some(ClockExpression {
+ span: "3pm".into(),
+ hour: 3,
+ minute: 0,
+ meridiem: Some(Meridiem::Pm),
+ daypart: None,
+ }),
+ }),
+ }),
+ &request,
+ )
+ .unwrap();
+ let InputSuggestions::Task(fields) = fields else {
+ panic!("wrong intent");
+ };
+ assert_eq!(fields.due_date.as_deref(), Some("2026-10-23T15:00"));
+}
+
#[test]
fn a_repeat_cutoff_cannot_precede_the_first_occurrence() {
let request = input("Meet tomorrow at noon repeat daily until today");
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index 9848fe0c3d..c36a162f50 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -796,7 +796,9 @@ shows the absolute date, time, timezone, calendar, and invitees. For example,
“Call John at 3pm tomorrow” becomes a one-hour event at 3 PM tomorrow with no
invitation; inviting John requires an explicit invitation request or guest edit.
Bare hours use a reasonable default (1–7 PM, 8–11 AM, 12 noon). For example,
-“call with Julia tomorrow at 7” becomes 7 PM tomorrow for one hour. An assumption
+“call with Julia tomorrow at 7” becomes 7 PM tomorrow for one hour. A time with
+no day is its next occurrence: “sync at 3pm” is 3 PM today, or tomorrow once 3 PM
+has passed, and a task deadline “by 3pm” resolves the same way. An assumption
cue beneath the date/time range draws attention to the inferred AM/PM; editing the start
time removes that cue. The temporal model identifies clock facts, explicit AM/PM and day parts;
Rust resolves them, marks assumed AM/PM, validates timestamps and supplies