fix:修复无消息草稿保存

优化首次加载速度
This commit is contained in:
2026-04-26 17:23:52 +08:00
parent 31393340e7
commit a0d1cb86f0
14 changed files with 440 additions and 43 deletions

View File

@@ -2,7 +2,7 @@ import type {
CustomWorldAgentSessionSnapshot,
} from '../../../packages/shared/src/contracts/customWorldAgent';
import type { HydratedSavedGameSnapshot } from '../../persistence/runtimeSnapshotTypes';
import type { CustomWorldProfile, GameState } from '../../types';
import type { CustomWorldProfile } from '../../types';
export type SelectionStage =
| 'platform'
@@ -34,7 +34,6 @@ export type SyncedAgentDraftResult = {
export type PlatformEntryFlowShellProps = {
selectionStage: SelectionStage;
setSelectionStage: (stage: SelectionStage) => void;
gameState: GameState;
hasSavedGame: boolean;
savedSnapshot: HydratedSavedGameSnapshot | null;
handleContinueGame: (snapshot?: HydratedSavedGameSnapshot | null) => void;

View File

@@ -21,7 +21,6 @@ import type { AuthUser } from '../../services/authService';
import { ApiClientError } from '../../services/apiClient';
import {
clearRpgProfileBrowseHistory as clearProfileBrowseHistory,
deleteRpgEntryWorldProfile,
getRpgEntryWorldGalleryDetail,
getRpgProfileDashboard as getProfileDashboard,
listRpgEntryWorldGallery,
@@ -47,8 +46,10 @@ import {
listPuzzleGallery,
} from '../../services/puzzle-gallery';
import { listPuzzleWorks } from '../../services/puzzle-works';
import { getRpgEntryWorldGalleryDetailByCode } from '../../services/rpg-entry/rpgEntryLibraryClient';
import type { GameState } from '../../types';
import {
deleteRpgEntryWorldProfile,
getRpgEntryWorldGalleryDetailByCode,
} from '../../services/rpg-entry/rpgEntryLibraryClient';
import {
AuthUiContext,
type PlatformSettingsSection,
@@ -130,6 +131,7 @@ vi.mock('../../services/puzzle-gallery', () => ({
}));
vi.mock('../../services/rpg-entry/rpgEntryLibraryClient', () => ({
deleteRpgEntryWorldProfile: vi.fn(),
getRpgEntryWorldGalleryDetailByCode: vi.fn(),
}));
@@ -522,7 +524,6 @@ function TestWrapper({
<RpgEntryFlowShell
selectionStage={selectionStage}
setSelectionStage={setSelectionStage}
gameState={{} as GameState}
hasSavedGame={false}
savedSnapshot={null}
handleContinueGame={onContinueGame ?? (() => {})}
@@ -574,7 +575,7 @@ beforeEach(() => {
savedAt: '2026-04-19T12:00:00.000Z',
bottomTab: 'adventure',
currentStory: null,
gameState: {} as GameState,
gameState: {},
} as HydratedSavedGameSnapshot,
});
vi.mocked(upsertProfileBrowseHistory).mockResolvedValue([]);
@@ -1477,10 +1478,13 @@ test('published puzzle detail returns to the source platform tab', async () => {
await waitFor(() => {
expect(document.getElementById('platform-tab-panel-category')).toBeTruthy();
});
await waitFor(() => {
const categoryPanel = getPlatformTabPanel('category');
expect(
within(categoryPanel).getAllByText('星桥机关').length,
).toBeGreaterThan(0);
});
const categoryPanel = getPlatformTabPanel('category');
expect(
within(categoryPanel).getAllByText('星桥机关').length,
).toBeGreaterThan(0);
await user.click(
within(categoryPanel).getByRole('button', {
@@ -2114,7 +2118,6 @@ test('agent draft result publishes to gallery from publish panel', async () => {
<RpgEntryFlowShell
selectionStage={selectionStage}
setSelectionStage={setSelectionStage}
gameState={{} as GameState}
hasSavedGame={false}
savedSnapshot={null}
handleContinueGame={() => {}}
@@ -2189,7 +2192,6 @@ test('agent draft result test button enters current draft without publish gate',
<RpgEntryFlowShell
selectionStage={selectionStage}
setSelectionStage={setSelectionStage}
gameState={{} as GameState}
hasSavedGame={false}
savedSnapshot={null}
handleContinueGame={() => {}}
@@ -2827,7 +2829,7 @@ test('save tab can resume a selected archive directly into the game', async () =
currentStory: null,
gameState: {
worldType: 'CUSTOM',
} as GameState,
},
} as HydratedSavedGameSnapshot,
});

View File

@@ -15,7 +15,7 @@ import {
listRpgEntryWorldLibrary,
publishRpgEntryWorldProfile,
unpublishRpgEntryWorldProfile,
} from '../../services/rpg-entry';
} from '../../services/rpg-entry/rpgEntryLibraryClient';
import { ApiClientError } from '../../services/apiClient';
import type { CustomWorldProfile } from '../../types';
import {

View File

@@ -172,7 +172,6 @@ export function RpgRuntimeStageRouter({
<PlatformEntryFlowShell
selectionStage={selectionStage}
setSelectionStage={setSelectionStage}
gameState={gameState}
hasSavedGame={hasSavedGame}
savedSnapshot={savedSnapshot}
handleContinueGame={handleContinueGame}