File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
apps/code/src/renderer/features
packages/agent/src/adapters/claude/session Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ const commands: CodeCommand[] = [
5151 makeFeedbackCommand ( "good" , "good" , "Positive" ) ,
5252 makeFeedbackCommand ( "bad" , "bad" , "Negative" ) ,
5353 makeFeedbackCommand ( "feedback" , "general" , "General" ) ,
54+ {
55+ name : "clear" ,
56+ description : "Clear conversation history and start fresh" ,
57+ async execute ( _args , ctx ) {
58+ if ( ! ctx . repoPath || ! ctx . taskId ) {
59+ toast . error ( "Cannot clear: no active session" ) ;
60+ return ;
61+ }
62+ const { getSessionService } = await import (
63+ "@features/sessions/service/service"
64+ ) ;
65+ await getSessionService ( ) . resetSession ( ctx . taskId , ctx . repoPath ) ;
66+ toast . success ( "Conversation cleared" ) ;
67+ } ,
68+ } ,
5469] ;
5570
5671export const CODE_COMMANDS : AvailableCommand [ ] = commands . map ( ( cmd ) => ( {
Original file line number Diff line number Diff line change @@ -1751,7 +1751,7 @@ export class SessionService {
17511751 * session instead of attempting to resume the stale one.
17521752 */
17531753 async resetSession ( taskId : string , repoPath : string ) : Promise < void > {
1754- await this . reconnectInPlace ( taskId , repoPath , null ) ;
1754+ await this . reconnectInPlace ( taskId , repoPath , null , true ) ;
17551755 }
17561756
17571757 /**
@@ -1768,6 +1768,7 @@ export class SessionService {
17681768 taskId : string ,
17691769 repoPath : string ,
17701770 overrideSessionId ?: string | null ,
1771+ clearHistory = false ,
17711772 ) : Promise < void > {
17721773 const session = sessionStoreSetters . getSessionByTaskId ( taskId ) ;
17731774 if ( ! session ) return ;
@@ -1788,7 +1789,13 @@ export class SessionService {
17881789 throw new Error ( "Unable to reach server. Please check your connection." ) ;
17891790 }
17901791
1791- const prefetchedLogs = await this . fetchSessionLogs ( logUrl , taskRunId ) ;
1792+ const prefetchedLogs = clearHistory
1793+ ? {
1794+ rawEntries : [ ] as StoredLogEntry [ ] ,
1795+ sessionId : undefined ,
1796+ adapter : undefined as Adapter | undefined ,
1797+ }
1798+ : await this . fetchSessionLogs ( logUrl , taskRunId ) ;
17921799
17931800 // Determine sessionId: undefined = use from logs, null = strip (fresh), string = use as-is
17941801 const sessionId =
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { AvailableCommand } from "@agentclientprotocol/sdk";
22import type { SlashCommand } from "@anthropic-ai/claude-agent-sdk" ;
33
44const UNSUPPORTED_COMMANDS = [
5+ "clear" ,
56 "context" ,
67 "cost" ,
78 "keybindings-help" ,
You can’t perform that action at this time.
0 commit comments