Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions src/node/services/agentSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ export class AgentSession {
}

if (options?.editMessageId) {
// Interrupt an existing stream or compaction, if active
if (this.aiService.isStreaming(this.workspaceId)) {
// MUST use abandonPartial=true to prevent handleAbort from performing partial compaction
// with mismatched history (since we're about to truncate it)
const stopResult = await this.interruptStream(/* abandonPartial */ true);
if (!stopResult.success) {
return Err(createUnknownSendMessageError(stopResult.error));
}
}
const truncateResult = await this.historyService.truncateAfterMessage(
this.workspaceId,
options.editMessageId
Expand Down Expand Up @@ -367,6 +376,14 @@ export class AgentSession {
return Err(stopResult.error);
}

// Delete partial when abandoning to prevent commitToHistory from reintroducing it
if (abandonPartial) {
const deleteResult = await this.partialService.deletePartial(this.workspaceId);
if (!deleteResult.success) {
return Err(deleteResult.error);
}
}

return Ok(undefined);
}

Expand Down
6 changes: 0 additions & 6 deletions src/node/services/ipcMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,12 +1104,6 @@ export class IpcMain {
return { success: false, error: stopResult.error };
}

// If abandonPartial is true, delete the partial instead of committing it
if (options?.abandonPartial) {
log.debug("Abandoning partial for workspace:", workspaceId);
await this.partialService.deletePartial(workspaceId);
}

return { success: true, data: undefined };
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
Expand Down