This commit is contained in:
2026-04-25 22:38:03 +08:00
29 changed files with 1988 additions and 121 deletions

View File

@@ -81,6 +81,15 @@ type PlatformCreationAgentFlowControllerOptions<
session: TSession;
setSession: (session: TSession) => void;
}) => Promise<void> | void;
beforeExecuteAction?: (params: {
payload: TActionPayload;
session: TSession;
}) => void;
onActionError?: (params: {
payload: TActionPayload;
error: unknown;
errorMessage: string;
}) => void;
};
function buildOptimisticMessage<TMessagePayload extends CreationAgentMessageLike>(
@@ -235,6 +244,7 @@ export function usePlatformCreationAgentFlowController<
setError(null);
try {
options.beforeExecuteAction?.({ payload, session });
const response = await options.client.executeAction(
session.sessionId,
payload,
@@ -249,9 +259,16 @@ export function usePlatformCreationAgentFlowController<
options.setSelectionStage(options.resultStage);
}
} catch (caughtError) {
setError(
options.resolveErrorMessage(caughtError, options.errorMessages.execute),
const errorMessage = options.resolveErrorMessage(
caughtError,
options.errorMessages.execute,
);
setError(errorMessage);
options.onActionError?.({
payload,
error: caughtError,
errorMessage,
});
} finally {
setIsBusy(false);
}