@@ -915,6 +915,12 @@ export class ClineProvider implements vscode.WebviewViewProvider {
915915 await this . postMessageToWebview ( { type : "didUpdateSettings" } )
916916 break
917917 }
918+ case "clearAllTaskHistory" : {
919+ await this . deleteAllTaskHistory ( )
920+ await this . postStateToWebview ( )
921+ this . postMessageToWebview ( { type : "relinquishControl" } )
922+ break
923+ }
918924 // Add more switch case statements here as more webview message commands
919925 // are created within the webview context (i.e. inside media/main.js)
920926 }
@@ -1751,6 +1757,28 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
17511757 await downloadTask ( historyItem . ts , apiConversationHistory )
17521758 }
17531759
1760+ async deleteAllTaskHistory ( ) {
1761+ await this . clearTask ( )
1762+ await this . updateGlobalState ( "taskHistory" , undefined )
1763+ try {
1764+ // Remove all contents of tasks directory
1765+ const taskDirPath = path . join ( this . context . globalStorageUri . fsPath , "tasks" )
1766+ if ( await fileExistsAtPath ( taskDirPath ) ) {
1767+ await fs . rm ( taskDirPath , { recursive : true , force : true } )
1768+ }
1769+ // Remove checkpoints directory contents
1770+ const checkpointsDirPath = path . join ( this . context . globalStorageUri . fsPath , "checkpoints" )
1771+ if ( await fileExistsAtPath ( checkpointsDirPath ) ) {
1772+ await fs . rm ( checkpointsDirPath , { recursive : true , force : true } )
1773+ }
1774+ } catch ( error ) {
1775+ vscode . window . showErrorMessage (
1776+ `Encountered error while deleting task history, there may be some files left behind. Error: ${ error instanceof Error ? error . message : String ( error ) } ` ,
1777+ )
1778+ }
1779+ // await this.postStateToWebview()
1780+ }
1781+
17541782 async deleteTaskWithId ( id : string ) {
17551783 console . info ( "deleteTaskWithId: " , id )
17561784
@@ -1831,7 +1859,10 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
18311859 currentTaskItem : this . cline ?. taskId ? ( taskHistory || [ ] ) . find ( ( item ) => item . id === this . cline ?. taskId ) : undefined ,
18321860 checkpointTrackerErrorMessage : this . cline ?. checkpointTrackerErrorMessage ,
18331861 clineMessages : this . cline ?. clineMessages || [ ] ,
1834- taskHistory : ( taskHistory || [ ] ) . filter ( ( item ) => item . ts && item . task ) . sort ( ( a , b ) => b . ts - a . ts ) ,
1862+ taskHistory : ( taskHistory || [ ] )
1863+ . filter ( ( item ) => item . ts && item . task )
1864+ . sort ( ( a , b ) => b . ts - a . ts )
1865+ . slice ( 0 , 100 ) , // for now we're only getting the latest 100 tasks, but a better solution here is to only pass in 3 for recent task history, and then get the full task history on demand when going to the task history view (maybe with pagination?)
18351866 shouldShowAnnouncement : lastShownAnnouncementId !== this . latestAnnouncementId ,
18361867 platform : process . platform as Platform ,
18371868 autoApprovalSettings,
0 commit comments