fix: execute all-complete reaction and guard workspace postCreate

- summary.all_complete reactions now execute in pollAll() after emission
- workspace.postCreate errors trigger workspace cleanup to prevent leaks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Prateek 2026-02-13 18:13:58 +05:30
parent 2ecb011982
commit 4a804503b6
2 changed files with 20 additions and 2 deletions

View File

@ -446,6 +446,15 @@ export function createLifecycleManager(deps: LifecycleManagerDeps): LifecycleMan
});
eventBus.emit(event);
emitToHandlers(event);
// Execute all-complete reaction if configured
const reactionKey = eventToReactionKey("summary.all_complete");
if (reactionKey) {
const reactionConfig = config.reactions[reactionKey];
if (reactionConfig && reactionConfig.auto !== false && reactionConfig.action) {
await executeReaction(event, reactionKey, reactionConfig as ReactionConfig);
}
}
}
} catch {
// Poll cycle failed — will retry next interval

View File

@ -184,9 +184,18 @@ export function createSessionManager(deps: SessionManagerDeps): SessionManager {
});
workspacePath = wsInfo.path;
// Run post-create hooks
// Run post-create hooks — clean up workspace on failure
if (plugins.workspace.postCreate) {
await plugins.workspace.postCreate(wsInfo, project);
try {
await plugins.workspace.postCreate(wsInfo, project);
} catch (err) {
try {
await plugins.workspace.destroy(workspacePath);
} catch {
/* best effort */
}
throw err;
}
}
}