fix kiro fresh auto-run state reset

This commit is contained in:
QLHazyCoder
2026-05-22 07:57:36 +08:00
parent 5610262f7d
commit 25c6b8b4a7
6 changed files with 308 additions and 5 deletions
+44 -4
View File
@@ -93,17 +93,55 @@
return String(getFirstUnfinishedWorkflowNode(freshState) || '').trim();
}
function stripRuntimeProgressFromFreshKeepState(value) {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
return value;
}
const next = {
...value,
};
delete next.currentNodeId;
delete next.nodeStatuses;
delete next.stepStatuses;
if (next.runtimeState && typeof next.runtimeState === 'object' && !Array.isArray(next.runtimeState)) {
const runtimeState = {
...next.runtimeState,
};
delete runtimeState.currentNodeId;
delete runtimeState.nodeStatuses;
if (runtimeState.sharedState && typeof runtimeState.sharedState === 'object' && !Array.isArray(runtimeState.sharedState)) {
const sharedState = {
...runtimeState.sharedState,
};
delete sharedState.tabRegistry;
delete sharedState.sourceLastUrls;
delete sharedState.flowStartTime;
runtimeState.sharedState = sharedState;
}
next.runtimeState = runtimeState;
}
return next;
}
function buildFreshAttemptNodeStatuses(state = {}) {
const knownNodeIds = getKnownNodeIdsFromState(state);
if (knownNodeIds.length) {
return Object.fromEntries(knownNodeIds.map((nodeId) => [nodeId, 'pending']));
}
return {};
}
function buildFreshAttemptKeepState(state = {}, context = {}) {
if (typeof buildFreshAutoRunKeepState === 'function') {
const helperPatch = buildFreshAutoRunKeepState(state, context);
if (helperPatch && typeof helperPatch === 'object' && !Array.isArray(helperPatch)) {
return {
return stripRuntimeProgressFromFreshKeepState({
...helperPatch,
};
});
}
}
return {
return stripRuntimeProgressFromFreshKeepState({
activeFlowId: state.activeFlowId,
flowId: state.flowId || state.activeFlowId,
targetId: state.targetId,
@@ -136,7 +174,7 @@
cloudflareDomain: state.cloudflareDomain,
cloudflareDomains: state.cloudflareDomains,
reusablePhoneActivation: state.reusablePhoneActivation,
};
});
}
function createAutoRunRoundSummary(round) {
@@ -596,6 +634,8 @@
attemptRun,
sessionId,
}),
currentNodeId: '',
nodeStatuses: buildFreshAttemptNodeStatuses(prevState),
autoRunRoundSummaries: serializeAutoRunRoundSummaries(totalRuns, roundSummaries),
autoRunSessionId: sessionId,
tabRegistry: {},