fix: skip opencode undo when message has zero output
Prevents error when undoing messages that produced no output. Checks for reply, partialOutput, or done status before sending /undo command to opencode.
This commit is contained in:
@@ -17334,6 +17334,10 @@ async function handleUndoMessage(req, res, sessionId, messageId, userId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Check if message had any output - if not, skip the opencode undo
|
||||||
|
const hasOutput = !!(message.reply || message.partialOutput) || message.status === 'done';
|
||||||
|
|
||||||
|
if (hasOutput) {
|
||||||
log('Sending undo command to opencode', { sessionId, messageId, opencodeSessionId: session.opencodeSessionId });
|
log('Sending undo command to opencode', { sessionId, messageId, opencodeSessionId: session.opencodeSessionId });
|
||||||
|
|
||||||
const cliCommand = resolveCliCommand('opencode');
|
const cliCommand = resolveCliCommand('opencode');
|
||||||
@@ -17348,6 +17352,9 @@ async function handleUndoMessage(req, res, sessionId, messageId, userId) {
|
|||||||
cwd: session.workspaceDir || REPO_ROOT,
|
cwd: session.workspaceDir || REPO_ROOT,
|
||||||
timeout: 30000
|
timeout: 30000
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
log('Skipping undo command - message had zero output', { sessionId, messageId });
|
||||||
|
}
|
||||||
|
|
||||||
// Clear todos from the message when undone
|
// Clear todos from the message when undone
|
||||||
if (message.todos) {
|
if (message.todos) {
|
||||||
|
|||||||
Reference in New Issue
Block a user