Merge remote-tracking branch 'origin/master' into codex/tiaoyitiao

This commit is contained in:
kdletters
2026-06-05 23:45:17 +08:00
11 changed files with 605 additions and 43 deletions

View File

@@ -70,6 +70,7 @@ import type {
PuzzleAgentSessionSnapshot,
SendPuzzleAgentMessageRequest,
} from '../../../packages/shared/src/contracts/puzzleAgentSession';
import { isPuzzleCompileActionReady } from './puzzleDraftGenerationState';
import type { PuzzleCreativeTemplateSelection } from '../../../packages/shared/src/contracts/puzzleCreativeTemplate';
import type {
PuzzleRunSnapshot,
@@ -6279,7 +6280,7 @@ export function PlatformEntryFlowShellImpl({
sessionController.setCreationTypeError(errorMessage);
setPuzzleCreationError(errorMessage);
},
onActionComplete: async ({ payload, response, setSession }) => {
onActionComplete: async ({ payload, response, session, setSession }) => {
setPuzzleOperation(response.operation);
setSession(response.session);
const formPayload = buildPuzzleFormPayloadFromAction(payload);
@@ -6303,6 +6304,47 @@ export function PlatformEntryFlowShellImpl({
if (payload.action === 'compile_puzzle_draft') {
const openResult = selectionStageRef.current === 'puzzle-generating';
if (!isPuzzleCompileActionReady(response.session)) {
const nextPayload =
formPayload ?? buildPuzzleFormPayloadFromSession(response.session);
const fallbackGenerationState = createPuzzleDraftGenerationStateFromPayload(
nextPayload,
response.session,
);
const nextGenerationState = mergePuzzleSessionProgressIntoGenerationState(
puzzleGenerationState ?? fallbackGenerationState,
response.session,
);
activePuzzleGenerationSessionIdRef.current = response.session.sessionId;
setSelectionStage('puzzle-generating');
markDraftGenerating('puzzle', [
response.session.sessionId,
buildPuzzleResultWorkId(response.session.sessionId),
response.session.publishedProfileId,
buildPuzzleResultProfileId(response.session.sessionId),
]);
markPendingDraftGenerating(
'puzzle',
response.session.sessionId,
buildPendingPuzzleDraftMetadata(nextPayload),
);
setPuzzleGenerationState(nextGenerationState);
setPuzzleBackgroundCompileTasks((current) => {
const next = { ...current };
if (session.sessionId !== response.session.sessionId) {
delete next[session.sessionId];
}
next[response.session.sessionId] = {
session: response.session,
payload: nextPayload,
generationState: nextGenerationState,
error: null,
};
return next;
});
void refreshPuzzleShelf();
return { openResult: false };
}
setPuzzleGenerationState((current) =>
current
? resolveFinishedMiniGameDraftGenerationState(current, 'ready', {
@@ -7197,6 +7239,22 @@ export function PlatformEntryFlowShellImpl({
return;
}
if (hasRecoverableGeneratedPuzzleDraft(latestSession)) {
const payload =
puzzleGenerationViewPayload ??
buildPuzzleFormPayloadFromSession(latestSession);
const generationState =
puzzleGenerationViewState ??
createPuzzleDraftGenerationStateFromPayload(payload, latestSession);
await recoverCompletedPuzzleDraftGeneration({
sessionId: latestSession.sessionId,
payload,
generationState,
setSession: setPuzzleSession,
});
return;
}
setPuzzleSession(latestSession);
setPuzzleBackgroundCompileTasks((current) => {
const task = current[activePuzzleGenerationSessionId];
@@ -7240,6 +7298,9 @@ export function PlatformEntryFlowShellImpl({
};
}, [
activePuzzleGenerationSessionId,
puzzleGenerationViewPayload,
puzzleGenerationViewState,
recoverCompletedPuzzleDraftGeneration,
shouldPollPuzzleGenerationSession,
setPuzzleSession,
]);
@@ -9479,20 +9540,26 @@ export function PlatformEntryFlowShellImpl({
const executeSquareHoleAction = squareHoleFlow.executeAction;
const retryMatch3DDraftGeneration = useCallback(() => {
if (match3dFormDraftPayload && !match3dSession?.draft?.profileId) {
void createMatch3DDraftFromForm(match3dFormDraftPayload);
if (match3dSession?.sessionId) {
const retryPayload =
match3dFormDraftPayload ??
buildMatch3DFormPayloadFromSession(match3dSession);
void executeMatch3DAction({
action: 'match3d_compile_draft',
generateClickSound: retryPayload.generateClickSound,
});
return;
}
void executeMatch3DAction({
action: 'match3d_compile_draft',
generateClickSound: match3dFormDraftPayload?.generateClickSound,
});
if (match3dFormDraftPayload) {
void createMatch3DDraftFromForm(match3dFormDraftPayload);
return;
}
}, [
createMatch3DDraftFromForm,
executeMatch3DAction,
match3dFormDraftPayload,
match3dSession?.draft?.profileId,
match3dSession,
]);
const retrySquareHoleAssetGeneration = useCallback(() => {
@@ -10405,15 +10472,25 @@ export function PlatformEntryFlowShellImpl({
);
const retryPuzzleDraftGeneration = useCallback(() => {
if (puzzleFormDraftPayload) {
void createPuzzleDraftFromForm(puzzleFormDraftPayload);
if (puzzleSession?.sessionId) {
const retryPayload =
puzzleFormDraftPayload ??
buildPuzzleFormPayloadFromSession(puzzleSession);
void executePuzzleAction(
buildPuzzleCompileActionFromFormPayload(retryPayload),
);
return;
}
void executePuzzleAction(
buildPuzzleCompileActionFromFormPayload(puzzleFormDraftPayload),
);
}, [createPuzzleDraftFromForm, executePuzzleAction, puzzleFormDraftPayload]);
if (puzzleFormDraftPayload) {
void createPuzzleDraftFromForm(puzzleFormDraftPayload);
}
}, [
createPuzzleDraftFromForm,
executePuzzleAction,
puzzleFormDraftPayload,
puzzleSession,
]);
const retryVisualNovelDraftGeneration = useCallback(() => {
if (!visualNovelFormDraftPayload) {