fix(design): connect video preparation and playable history
This commit is contained in:
@@ -98,6 +98,7 @@ type ImageWorkspaceState = {
|
||||
operations: DesignUserFieldOperation[],
|
||||
clearDraftPaths?: string[],
|
||||
) => Promise<DesignWorkspace>;
|
||||
prepareGeneration: (operations?: DesignUserFieldOperation[]) => Promise<DesignWorkspace>;
|
||||
sendChat: () => Promise<DesignWorkspace>;
|
||||
resolveDecisionPrompt: (
|
||||
promptId: string,
|
||||
@@ -177,6 +178,10 @@ function isQuoteBlocked(error: unknown): boolean {
|
||||
&& error.code.toLowerCase() === 'design_quote_blocked';
|
||||
}
|
||||
|
||||
function isPrepareGenerationCommand(command: DesignCommandInput): boolean {
|
||||
return command.kind === 'apply_input' && command.input.kind === 'prepare_generation';
|
||||
}
|
||||
|
||||
function isDefinitiveCommandFailure(error: unknown): error is ImageWorkspaceApiError {
|
||||
return error instanceof ImageWorkspaceApiError
|
||||
&& error.commandOutcome === 'definitive_failure';
|
||||
@@ -562,7 +567,10 @@ export const useImageWorkspaceStore = create<ImageWorkspaceState>((set, get) =>
|
||||
pendingOperations: { ...state.pendingOperations, [operation.id]: operation },
|
||||
assistantActivities,
|
||||
error: null,
|
||||
quoteBlockers: command.kind === 'request_quote' ? [] : state.quoteBlockers,
|
||||
quoteBlockers: command.kind === 'request_quote'
|
||||
|| (command.kind === 'apply_input' && command.input.kind === 'prepare_generation')
|
||||
? []
|
||||
: state.quoteBlockers,
|
||||
};
|
||||
});
|
||||
try {
|
||||
@@ -666,9 +674,15 @@ export const useImageWorkspaceStore = create<ImageWorkspaceState>((set, get) =>
|
||||
set((state) => {
|
||||
const pendingOperations = { ...state.pendingOperations };
|
||||
delete pendingOperations[operation.id];
|
||||
const preparationFailedWithoutBlockers = isPrepareGenerationCommand(command)
|
||||
&& state.quoteBlockers.length === 0;
|
||||
return {
|
||||
pendingOperations,
|
||||
error: isCurrentOperationSelection(state, operation) ? null : state.error,
|
||||
error: isCurrentOperationSelection(state, operation)
|
||||
? preparationFailedWithoutBlockers
|
||||
? '方案还没整理好,请稍后重试'
|
||||
: null
|
||||
: state.error,
|
||||
};
|
||||
});
|
||||
} else if (isDefinitiveCommandFailure(error)) {
|
||||
@@ -1149,6 +1163,20 @@ export const useImageWorkspaceStore = create<ImageWorkspaceState>((set, get) =>
|
||||
});
|
||||
},
|
||||
|
||||
prepareGeneration: async (operations = []) => {
|
||||
const workspace = get().workspace;
|
||||
if (!workspace) throw new Error('请先选择一个设计项目');
|
||||
const command: DesignCommandInput = {
|
||||
kind: 'apply_input',
|
||||
workspaceId: workspace.workspace.workspaceId,
|
||||
sessionId: workspace.workspace.sessionId,
|
||||
expectedDirectionRevision: workspace.form.directionRevision,
|
||||
clientOperationId: createImageWorkspaceOperationId(),
|
||||
input: { kind: 'prepare_generation', operations },
|
||||
};
|
||||
return executeCommand(command, { label: '整理制作方案' });
|
||||
},
|
||||
|
||||
sendChat: async () => {
|
||||
const workspace = get().workspace;
|
||||
const message = get().chatDraft.trim();
|
||||
@@ -1185,8 +1213,10 @@ export const useImageWorkspaceStore = create<ImageWorkspaceState>((set, get) =>
|
||||
},
|
||||
|
||||
requestQuote: async () => {
|
||||
const workspace = get().workspace;
|
||||
if (!workspace) throw new Error('请先选择一个设计项目');
|
||||
const preparedWorkspace = await get().prepareGeneration();
|
||||
const workspace = get().workspace?.workspace.workspaceId === preparedWorkspace.workspace.workspaceId
|
||||
? get().workspace ?? preparedWorkspace
|
||||
: preparedWorkspace;
|
||||
const command: DesignCommandInput = {
|
||||
kind: 'request_quote',
|
||||
workspaceId: workspace.workspace.workspaceId,
|
||||
|
||||
Reference in New Issue
Block a user