fix: stabilize rpg publish and launch
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import type { RpgCreationResultView } from '../../../packages/shared/src/contracts/rpgCreationResultView';
|
||||
import type { CustomWorldAgentSessionSnapshot } from '../../../packages/shared/src/contracts/customWorldAgent';
|
||||
import type { CustomWorldRuntimeLaunchOptions } from '../platform-entry/platformEntryTypes';
|
||||
import { rpgCreationPreviewAdapter } from '../../services/rpg-creation/rpgCreationPreviewAdapter';
|
||||
import type { CustomWorldProfile } from '../../types';
|
||||
@@ -8,6 +9,7 @@ import type { CustomWorldProfile } from '../../types';
|
||||
type UseRpgCreationEnterWorldParams = {
|
||||
isAgentDraftResultView: boolean;
|
||||
activeAgentSessionId: string | null;
|
||||
currentAgentSessionStage?: CustomWorldAgentSessionSnapshot['stage'] | null;
|
||||
generatedCustomWorldProfile: CustomWorldProfile | null;
|
||||
handleCustomWorldSelect: (
|
||||
customWorldProfile: CustomWorldProfile,
|
||||
@@ -33,6 +35,7 @@ export function useRpgCreationEnterWorld(
|
||||
const {
|
||||
isAgentDraftResultView,
|
||||
activeAgentSessionId,
|
||||
currentAgentSessionStage,
|
||||
generatedCustomWorldProfile,
|
||||
handleCustomWorldSelect,
|
||||
syncAgentDraftResultProfile,
|
||||
@@ -77,6 +80,17 @@ export function useRpgCreationEnterWorld(
|
||||
return generatedCustomWorldProfile;
|
||||
}
|
||||
|
||||
if (currentAgentSessionStage === 'published') {
|
||||
const latestView = await syncAgentCreationResultView(activeAgentSessionId);
|
||||
const publishedProfile =
|
||||
rpgCreationPreviewAdapter.buildPreviewFromResultView(latestView) ??
|
||||
generatedCustomWorldProfile;
|
||||
// 中文注释:已发布会话的“进入世界”只读取后端结果页真相,
|
||||
// 不能再同步草稿或重复发送 publish_world,否则会被发布阶段门槛拒绝。
|
||||
setGeneratedCustomWorldProfile(publishedProfile);
|
||||
return publishedProfile;
|
||||
}
|
||||
|
||||
const syncedResult = await syncAgentDraftResultProfile(
|
||||
generatedCustomWorldProfile,
|
||||
);
|
||||
@@ -112,6 +126,7 @@ export function useRpgCreationEnterWorld(
|
||||
return publishedProfile;
|
||||
}, [
|
||||
activeAgentSessionId,
|
||||
currentAgentSessionStage,
|
||||
executePublishWorld,
|
||||
generatedCustomWorldProfile,
|
||||
isAgentDraftResultView,
|
||||
|
||||
Reference in New Issue
Block a user