@@ -1195,6 +1195,15 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
11951195 // get the task directory full path
11961196 const { taskDirPath } = await this . getTaskWithId ( id )
11971197
1198+ // kilocode_change start
1199+ // Check if task is favorited
1200+ const history = this . getGlobalState ( "taskHistory" ) ?? [ ]
1201+ const task = history . find ( ( item ) => item . id === id )
1202+ if ( task ?. isFavorited ) {
1203+ throw new Error ( "Cannot delete a favorited task. Please unfavorite it first." )
1204+ }
1205+ // kilocode_change end
1206+
11981207 // remove task from stack if it's the current task
11991208 if ( id === this . getCurrentCline ( ) ?. taskId ) {
12001209 // if we found the taskid to delete - call finish to abort this task and allow a new task to be started,
@@ -1844,4 +1853,38 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
18441853 }
18451854 }
18461855 // end kilocode_change
1856+
1857+ // kilocode_change start
1858+ // Add new methods for favorite functionality
1859+ async toggleTaskFavorite ( id : string ) {
1860+ const history = this . getGlobalState ( "taskHistory" ) ?? [ ]
1861+ const updatedHistory = history . map ( ( item ) => {
1862+ if ( item . id === id ) {
1863+ return { ...item , isFavorited : ! item . isFavorited }
1864+ }
1865+ return item
1866+ } )
1867+ await this . updateGlobalState ( "taskHistory" , updatedHistory )
1868+ await this . postStateToWebview ( )
1869+ }
1870+
1871+ async getFavoriteTasks ( ) : Promise < HistoryItem [ ] > {
1872+ const history = this . getGlobalState ( "taskHistory" ) ?? [ ]
1873+ return history . filter ( ( item ) => item . isFavorited )
1874+ }
1875+
1876+ // Modify batch delete to respect favorites
1877+ async deleteMultipleTasks ( taskIds : string [ ] ) {
1878+ const history = this . getGlobalState ( "taskHistory" ) ?? [ ]
1879+ const favoritedTaskIds = taskIds . filter ( ( id ) => history . find ( ( item ) => item . id === id ) ?. isFavorited )
1880+
1881+ if ( favoritedTaskIds . length > 0 ) {
1882+ throw new Error ( "Cannot delete favorited tasks. Please unfavorite them first." )
1883+ }
1884+
1885+ for ( const id of taskIds ) {
1886+ await this . deleteTaskWithId ( id )
1887+ }
1888+ }
1889+ // kilocode_change end
18471890}
0 commit comments