@@ -3,6 +3,7 @@ import type {
33 TaskDecomposeRequest ,
44 TaskDecomposeResult ,
55} from "./task-decompose.types" ;
6+ import { normalizeTaskTimezone } from "./task-timezone" ;
67import type {
78 CalendarCreatedEvent ,
89 CalendarSyncResult ,
@@ -51,6 +52,23 @@ function buildEventSummary(
5152 return `[${ index + 1 } /${ totalCount } ] ${ normalizedSubtask } | ${ normalizedOverall } ` ;
5253}
5354
55+ function toOverallTaskName (
56+ requestTask : string ,
57+ breakdown : TaskDecomposeResult ,
58+ ) : string {
59+ const summary = toSingleLine ( breakdown . summary ?? "" ) ;
60+ if ( summary . length > 0 ) {
61+ return summary ;
62+ }
63+
64+ const goal = toSingleLine ( breakdown . goal ?? "" ) ;
65+ if ( goal . length > 0 ) {
66+ return goal ;
67+ }
68+
69+ return toSingleLine ( requestTask ) ;
70+ }
71+
5472function safeDate ( value : string , fallback : Date ) : Date {
5573 const parsed = new Date ( value ) ;
5674 if ( Number . isNaN ( parsed . getTime ( ) ) ) {
@@ -279,8 +297,12 @@ export async function createCalendarEvents(
279297 input : CreateCalendarEventsInput ,
280298) : Promise < CalendarSyncResult > {
281299 const accessToken = await getGoogleAccessToken ( env , input . userId ) ;
282- const timezone = input . request . timezone ?? "UTC" ;
300+ const timezone = normalizeTaskTimezone ( input . request . timezone ) ;
283301 const calendarId = PRIMARY_CALENDAR_ID ;
302+ const overallTaskName = toOverallTaskName (
303+ input . request . task ,
304+ input . breakdown ,
305+ ) ;
284306
285307 const createdEvents : CalendarCreatedEvent [ ] = [ ] ;
286308 const totalCount = Math . max ( input . breakdown . subtasks . length , 1 ) ;
@@ -296,7 +318,7 @@ export async function createCalendarEvents(
296318 const eventId = await createStableEventId ( input . workflowId , index ) ;
297319 const summary = buildEventSummary (
298320 subtask . title ,
299- input . request . task ,
321+ overallTaskName ,
300322 index ,
301323 totalCount ,
302324 ) ;
0 commit comments