Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/code/src/renderer/features/message-editor/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AvailableCommand } from "@agentclientprotocol/sdk";
import { getSessionService } from "@features/sessions/service/service";
import { ANALYTICS_EVENTS, type FeedbackType } from "@shared/types/analytics";
import { track } from "@utils/analytics";
import { toast } from "@utils/toast";
Expand Down Expand Up @@ -51,6 +52,18 @@ const commands: CodeCommand[] = [
makeFeedbackCommand("good", "good", "Positive"),
makeFeedbackCommand("bad", "bad", "Negative"),
makeFeedbackCommand("feedback", "general", "General"),
{
name: "clear",
description: "Clear conversation history and start fresh",
async execute(_args, ctx) {
if (!ctx.repoPath || !ctx.taskId) {
toast.error("Cannot clear: no active session");
return;
}
await getSessionService().resetSession(ctx.taskId, ctx.repoPath);
toast.success("Conversation cleared");
},
},
];

export const CODE_COMMANDS: AvailableCommand[] = commands.map((cmd) => ({
Expand Down
18 changes: 15 additions & 3 deletions apps/code/src/renderer/features/sessions/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1747,11 +1747,23 @@ export class SessionService {

/**
* Start a fresh session for a task, abandoning the old conversation.
* Clears the backend sessionId so the next reconnect creates a new
* session instead of attempting to resume the stale one.
* Tears down the current session and creates a new task run so that
* S3 logs start clean — old messages won't reappear on restart.
*/
async resetSession(taskId: string, repoPath: string): Promise<void> {
await this.reconnectInPlace(taskId, repoPath, null);
const session = sessionStoreSetters.getSessionByTaskId(taskId);
if (!session) return;

const { taskTitle } = session;

await this.teardownSession(session.taskRunId);

const auth = this.getAuthCredentials();
if (!auth) {
throw new Error("Unable to reach server. Please check your connection.");
}

await this.createNewLocalSession(taskId, taskTitle, repoPath, auth);
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/agent/src/adapters/claude/session/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { AvailableCommand } from "@agentclientprotocol/sdk";
import type { SlashCommand } from "@anthropic-ai/claude-agent-sdk";

const UNSUPPORTED_COMMANDS = [
"clear",
"context",
"cost",
"keybindings-help",
Expand Down