@@ -162,10 +162,11 @@ func eventDate(_ text: String?, _ field: String, allDay: Bool) throws -> Date {
162162func runAppCommand ( _ command : AppCommand ) throws -> [ String : Any ] {
163163 switch command . name {
164164 case " list_reminder_lists " :
165- let lists = try remindersStore ( ) . calendars ( for : . reminder ) . prefix ( 200 ) . map { list -> [ String : Any ] in
165+ let allLists = try remindersStore ( ) . calendars ( for : . reminder )
166+ let lists = allLists . prefix ( 200 ) . map { list -> [ String : Any ] in
166167 [ " id " : list . calendarIdentifier , " title " : String ( list . title . prefix ( 1024 ) ) , " allowsModifications " : list . allowsContentModifications ]
167168 }
168- return [ " kind " : " command " , " command " : command . name , " items " : lists ]
169+ return [ " kind " : " command " , " command " : command . name , " items " : lists , " truncated " : allLists . count > 200 ]
169170 case " create_reminder " :
170171 let title = ( command . title ?? " " ) . trimmingCharacters ( in : . whitespacesAndNewlines )
171172 guard ! title . isEmpty , title . count <= 1024 else { throw ComputerError ( " invalid_arguments " , " A reminder needs a title of at most 1024 characters. " , dispatchState : " not_started " ) }
@@ -192,10 +193,11 @@ func runAppCommand(_ command: AppCommand) throws -> [String: Any] {
192193 try store . save ( reminder , commit : true )
193194 return [ " kind " : " command " , " command " : command . name , " created " : [ " id " : reminder . calendarItemIdentifier , " title " : title , " list " : list . title ] ]
194195 case " list_calendars " :
195- let calendars = try calendarStore ( ) . calendars ( for : . event ) . prefix ( 200 ) . map { calendar -> [ String : Any ] in
196+ let allCalendars = try calendarStore ( ) . calendars ( for : . event )
197+ let calendars = allCalendars . prefix ( 200 ) . map { calendar -> [ String : Any ] in
196198 [ " id " : calendar . calendarIdentifier , " title " : String ( calendar . title . prefix ( 1024 ) ) , " allowsModifications " : calendar . allowsContentModifications ]
197199 }
198- return [ " kind " : " command " , " command " : command . name , " items " : calendars ]
200+ return [ " kind " : " command " , " command " : command . name , " items " : calendars , " truncated " : allCalendars . count > 200 ]
199201 case " create_event " :
200202 let title = try commandText ( command . title , " Title " )
201203 let allDay = command . allDay ?? false
@@ -230,10 +232,11 @@ func runAppCommand(_ command: AppCommand) throws -> [String: Any] {
230232 try store . save ( event , span : . thisEvent , commit : true )
231233 return [ " kind " : " command " , " command " : command . name , " created " : [ " id " : event . eventIdentifier ?? event . calendarItemIdentifier , " title " : title , " list " : calendar . title ] ]
232234 case " list_contact_groups " :
233- let groups = try contactStore ( ) . groups ( matching : nil ) . prefix ( 200 ) . map { group -> [ String : Any ] in
235+ let allGroups = try contactStore ( ) . groups ( matching : nil )
236+ let groups = allGroups . prefix ( 200 ) . map { group -> [ String : Any ] in
234237 [ " id " : group . identifier , " title " : String ( group . name . prefix ( 1024 ) ) , " allowsModifications " : true ]
235238 }
236- return [ " kind " : " command " , " command " : command . name , " items " : groups ]
239+ return [ " kind " : " command " , " command " : command . name , " items " : groups , " truncated " : allGroups . count > 200 ]
237240 case " create_contact_group " :
238241 let name = try commandText ( command . title , " Group name " )
239242 let store = try contactStore ( )
0 commit comments