feat(admin): AI 预检卡片交互与消息组件完善

- 预检卡支持列映射、导入策略确认与生成导入向导
- 消息组件/API 契约配套更新,含集成测试
This commit is contained in:
2026-08-06 11:59:36 +08:00
parent 6a18fd264d
commit d0ab8da01b
7 changed files with 588 additions and 23 deletions

View File

@@ -19,6 +19,7 @@ import { DynamicReview } from './DynamicReview';
import { ImportPreflightCard } from './ImportPreflightCard';
import { LiteCodeHighlighter } from './LiteCodeHighlighter';
import { LiteMermaid } from './LiteMermaid';
import type { ResolveImportPreflightInput } from './api';
import type {
AiAttachment,
AiChatMessage,
@@ -189,6 +190,11 @@ export interface AiMessageContentProps {
type: AiReviewSectionType,
) => AiReviewSchema | Promise<AiReviewSchema> | void;
onOpenImportWizard?: (runId: string) => void;
onResolveImportPreflight?: (
messageId: number | undefined,
preflight: AiImportPreflight,
input: ResolveImportPreflightInput,
) => Promise<void> | void;
}
export const AiMessageContent: React.FC<AiMessageContentProps> = ({
@@ -202,6 +208,7 @@ export const AiMessageContent: React.FC<AiMessageContentProps> = ({
onConfirmReviewStep,
onConfirmReviewGroup,
onOpenImportWizard,
onResolveImportPreflight,
}) => {
const streaming = status === 'loading' || status === 'updating';
const formSubmission = message.metadata?.a2uiSubmit;
@@ -317,7 +324,22 @@ export const AiMessageContent: React.FC<AiMessageContentProps> = ({
{(() => {
const preflight = message.metadata?.a2uiImportPreflight;
if (!preflight || typeof preflight !== 'object' || Array.isArray(preflight)) return null;
return <ImportPreflightCard preflight={preflight as AiImportPreflight} />;
const typedPreflight = preflight as AiImportPreflight;
return (
<ImportPreflightCard
preflight={typedPreflight}
onResolve={
onResolveImportPreflight
? (input) =>
onResolveImportPreflight(
typeof message.id === 'number' ? message.id : undefined,
typedPreflight,
input,
)
: undefined
}
/>
);
})()}
{(() => {
const wizard = message.metadata?.a2uiImportWizard as AiImportWizard | undefined;