Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: cascade user message deletion to include assistant reply (#6720)

Nilayb56d24ea3e71
diff --git a/studio/frontend/src/features/chat/utils/delete-thread-message.ts b/studio/frontend/src/features/chat/utils/delete-thread-message.ts
index 3b439eb7795..bea5a63ea78 100644
--- a/studio/frontend/src/features/chat/utils/delete-thread-message.ts
+++ b/studio/frontend/src/features/chat/utils/delete-thread-message.ts
@@ -112,7 +112,26 @@ export async function deleteThreadMessage(args: {
const exported = thread.export();
const repo = new MessageRepository();
repo.import(exported);
+
+ const target = exported.messages.find(
+ ({ message }) => message.id === messageId,
+ );
+ const assistantReplyIds =
+ target?.message.role === "user"
+ ? exported.messages
+ .filter(
+ ({ parentId, message }) =>
+ parentId === messageId && message.role === "assistant",
+ )
+ .map(({ message }) => message.id)
+ : [];
+
+ // Delete the prompt first; that relinks its replies up to the prompt's parent
repo.deleteMessage(messageId);
+ for (const replyId of assistantReplyIds) {
+ repo.deleteMessage(replyId);
+ }
+
const next = repo.export();
if (remoteId) {
await syncExportedRepositoryToBackend(remoteId, next, {