fix(cli): handle session.error in run command to prevent infinite wait
When session.error occurs with incomplete todos, the run command now: - Captures the error via handleSessionError() - Exits with code 1 instead of waiting indefinitely - Shows clear error message to user Previously, run command ignored session.error events, causing infinite 'Waiting: N todos remaining' loop when agent errors occurred. 🤖 Generated with assistance of OhMyOpenCode https://github.com/code-yeongyu/oh-my-opencode
This commit is contained in:
@@ -87,6 +87,16 @@ export async function run(options: RunOptions): Promise<number> {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if session errored - exit with failure if so
|
||||
if (eventState.mainSessionError) {
|
||||
console.error(pc.red(`\n\nSession ended with error: ${eventState.lastError}`))
|
||||
console.error(pc.yellow("Check if todos were completed before the error."))
|
||||
abortController.abort()
|
||||
await eventProcessor.catch(() => {})
|
||||
cleanup()
|
||||
return 1
|
||||
}
|
||||
|
||||
const shouldExit = await checkCompletionConditions(ctx)
|
||||
if (shouldExit) {
|
||||
console.log(pc.green("\n\nAll tasks completed."))
|
||||
|
||||
Reference in New Issue
Block a user