File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
apps/code/src/renderer/features
packages/agent/src/adapters/claude/session Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 11import type { AvailableCommand } from "@agentclientprotocol/sdk" ;
2+ import { getSessionService } from "@features/sessions/service/service" ;
23import { ANALYTICS_EVENTS , type FeedbackType } from "@shared/types/analytics" ;
34import { track } from "@utils/analytics" ;
45import { toast } from "@utils/toast" ;
@@ -51,6 +52,18 @@ const commands: CodeCommand[] = [
5152 makeFeedbackCommand ( "good" , "good" , "Positive" ) ,
5253 makeFeedbackCommand ( "bad" , "bad" , "Negative" ) ,
5354 makeFeedbackCommand ( "feedback" , "general" , "General" ) ,
55+ {
56+ name : "clear" ,
57+ description : "Clear conversation history and start fresh" ,
58+ async execute ( _args , ctx ) {
59+ if ( ! ctx . repoPath || ! ctx . taskId ) {
60+ toast . error ( "Cannot clear: no active session" ) ;
61+ return ;
62+ }
63+ await getSessionService ( ) . resetSession ( ctx . taskId , ctx . repoPath ) ;
64+ toast . success ( "Conversation cleared" ) ;
65+ } ,
66+ } ,
5467] ;
5568
5669export const CODE_COMMANDS : AvailableCommand [ ] = commands . map ( ( cmd ) => ( {
Original file line number Diff line number Diff line change @@ -1793,11 +1793,23 @@ export class SessionService {
17931793
17941794 /**
17951795 * Start a fresh session for a task, abandoning the old conversation.
1796- * Clears the backend sessionId so the next reconnect creates a new
1797- * session instead of attempting to resume the stale one .
1796+ * Tears down the current session and creates a new task run so that
1797+ * S3 logs start clean — old messages won't reappear on restart .
17981798 */
17991799 async resetSession ( taskId : string , repoPath : string ) : Promise < void > {
1800- await this . reconnectInPlace ( taskId , repoPath , null ) ;
1800+ const session = sessionStoreSetters . getSessionByTaskId ( taskId ) ;
1801+ if ( ! session ) return ;
1802+
1803+ const { taskTitle } = session ;
1804+
1805+ await this . teardownSession ( session . taskRunId ) ;
1806+
1807+ const auth = this . getAuthCredentials ( ) ;
1808+ if ( ! auth ) {
1809+ throw new Error ( "Unable to reach server. Please check your connection." ) ;
1810+ }
1811+
1812+ await this . createNewLocalSession ( taskId , taskTitle , repoPath , auth ) ;
18011813 }
18021814
18031815 /**
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