Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions apps/code/src/renderer/features/message-editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ 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;
}
const { getSessionService } = await import(
"@features/sessions/service/service"
);
Comment thread
jonathanlab marked this conversation as resolved.
Outdated
await getSessionService().resetSession(ctx.taskId, ctx.repoPath);
toast.success("Conversation cleared");
},
},
];

export const CODE_COMMANDS: AvailableCommand[] = commands.map((cmd) => ({
Expand Down
11 changes: 9 additions & 2 deletions apps/code/src/renderer/features/sessions/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ export class SessionService {
* session instead of attempting to resume the stale one.
*/
async resetSession(taskId: string, repoPath: string): Promise<void> {
await this.reconnectInPlace(taskId, repoPath, null);
await this.reconnectInPlace(taskId, repoPath, null, true);
}

/**
Expand All @@ -1768,6 +1768,7 @@ export class SessionService {
taskId: string,
repoPath: string,
overrideSessionId?: string | null,
clearHistory = false,
): Promise<void> {
const session = sessionStoreSetters.getSessionByTaskId(taskId);
if (!session) return;
Expand All @@ -1788,7 +1789,13 @@ export class SessionService {
throw new Error("Unable to reach server. Please check your connection.");
}

const prefetchedLogs = await this.fetchSessionLogs(logUrl, taskRunId);
const prefetchedLogs = clearHistory
? {
rawEntries: [] as StoredLogEntry[],
sessionId: undefined,
adapter: undefined as Adapter | undefined,
}
: await this.fetchSessionLogs(logUrl, taskRunId);

// Determine sessionId: undefined = use from logs, null = strip (fresh), string = use as-is
const sessionId =
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