fix custom world agent draft profile identity

This commit is contained in:
2026-04-23 13:54:38 +08:00
parent 1e200ec5ba
commit da7c1ff0c5
8 changed files with 356 additions and 6 deletions

View File

@@ -1763,10 +1763,16 @@ test('agent draft result auto-save persists the latest profile rebuilt from sync
const latestSavedProfile = vi
.mocked(upsertRpgWorldProfile)
.mock.calls.at(-1)?.[0];
const latestSaveRequest = vi
.mocked(upsertRpgWorldProfile)
.mock.calls.at(-1)?.[1];
expect(latestSavedProfile?.name).toBe('潮雾列岛·session最新版');
expect(latestSavedProfile?.summary).toBe(
'作品库应该保存这份同步后的最新快照。',
);
expect(latestSaveRequest).toEqual({
sourceAgentSessionId: 'custom-world-agent-session-1',
});
});
test('agent draft result can open from server result preview without embedded legacyResultProfile', async () => {

View File

@@ -126,7 +126,15 @@ export function useRpgCreationResultAutosave(
try {
const mutation =
await upsertRpgWorldProfile(normalizedProfile);
await upsertRpgWorldProfile(
normalizedProfile,
{
sourceAgentSessionId:
isAgentDraftResultView && activeAgentSessionId
? activeAgentSessionId
: null,
},
);
if (latestAutoSaveRequestIdRef.current !== requestId) {
return mutation;
}
@@ -159,7 +167,9 @@ export function useRpgCreationResultAutosave(
}
},
[
activeAgentSessionId,
generatedCustomWorldProfile,
isAgentDraftResultView,
refreshCustomWorldWorks,
setSavedCustomWorldEntries,
setSelectedDetailEntry,

View File

@@ -28,6 +28,9 @@ export async function listRpgWorldLibrary(
export async function upsertRpgWorldProfile(
profile: CustomWorldProfile,
request: {
sourceAgentSessionId?: string | null;
} = {},
options: RpgCreationRuntimeRequestOptions = {},
) {
const response = await requestRpgCreationRuntimeJson<
@@ -39,6 +42,7 @@ export async function upsertRpgWorldProfile(
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
profile,
sourceAgentSessionId: request.sourceAgentSessionId ?? null,
}),
},
'保存自定义世界失败',