wip: undo properly remove messages from UI

This commit is contained in:
Dax Raad
2025-07-28 22:58:12 -04:00
parent c24fbb4292
commit 9c9cbb3e81
25 changed files with 699 additions and 472 deletions

View File

@@ -540,8 +540,6 @@ export namespace Session {
for (const part of userParts) {
await updatePart(part)
}
// mark session as updated since a message has been added to it
await update(input.sessionID, (_draft) => {})
if (isLocked(input.sessionID)) {
return new Promise((resolve) => {
@@ -566,6 +564,7 @@ export namespace Session {
const [preserve, remove] = splitWhen(msgs, (x) => x.info.id === messageID)
msgs = preserve
for (const msg of remove) {
if (msg.info.id === userMsg.id) continue
await Storage.remove(`session/message/${input.sessionID}/${msg.info.id}`)
await Bus.publish(MessageV2.Event.Removed, { sessionID: input.sessionID, messageID: msg.info.id })
}
@@ -577,11 +576,15 @@ export namespace Session {
for (const part of removeParts) {
await Storage.remove(`session/part/${input.sessionID}/${last.info.id}/${part.id}`)
await Bus.publish(MessageV2.Event.PartRemoved, {
sessionID: input.sessionID,
messageID: last.info.id,
partID: part.id,
})
}
}
await update(input.sessionID, (draft) => {
draft.revert = undefined
})
}
const previous = msgs.filter((x) => x.info.role === "assistant").at(-1)?.info as MessageV2.Assistant

View File

@@ -284,6 +284,7 @@ export namespace MessageV2 {
PartRemoved: Bus.event(
"message.part.removed",
z.object({
sessionID: z.string(),
messageID: z.string(),
partID: z.string(),
}),