fix(tui): restore prompt after undo (#35987)

This commit is contained in:
Aiden Cline
2026-07-08 19:54:29 -05:00
committed by GitHub
parent 0590819090
commit 7eea97184a
+22 -17
View File
@@ -430,29 +430,34 @@ export function Session() {
category: "Session", category: "Session",
slash: { name: "undo" }, slash: { name: "undo" },
run: () => { run: () => {
void (async () => {
const boundary = session()?.revert?.messageID const boundary = session()?.revert?.messageID
const list = messages() const message = messages().findLast(
let target: string | undefined (message): message is SessionMessageUser =>
for (let i = list.length - 1; i >= 0; i--) { message.type === "user" && !!message.text.trim() && (!boundary || message.id < boundary),
const message = list[i] )
if (message.type !== "user" || !message.text.trim()) continue if (!message) {
if (boundary && message.id >= boundary) continue
target = message.id
break
}
if (!target) {
toast.show({ message: "Nothing to undo", variant: "error", duration: 3000 }) toast.show({ message: "Nothing to undo", variant: "error", duration: 3000 })
dialog.clear() dialog.clear()
return return
} }
const error = await sdk.api.session.revert.stage({ sessionID: route.sessionID, messageID: target }).then( void sdk.api.session.revert
() => undefined, .stage({ sessionID: route.sessionID, messageID: message.id })
(error) => error, .catch((error) => toast.show({ message: errorMessage(error), variant: "error", duration: 5000 }))
) prompt?.set({
if (error) toast.show({ message: errorMessage(error), variant: "error", duration: 5000 }) text: message.text,
files: message.files?.map((file) => ({
uri: file.source.type === "uri" ? file.source.uri : `data:${file.mime};base64,${file.data}`,
name: file.name,
description: file.description,
mention: file.mention ? { ...file.mention } : undefined,
})),
agents: message.agents?.map((agent) => ({
name: agent.name,
mention: agent.mention ? { ...agent.mention } : undefined,
})),
pasted: [],
})
dialog.clear() dialog.clear()
})()
}, },
}, },
{ {