Files
Genarrative/apps/ai-game-creator-shell/src/view/project-development/ResourceDocumentPreviewDialog.tsx
T
suzmii 5cd02aa8b0
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Failing after 2m44s
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Failing after 2m45s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Failing after 2m46s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Failing after 2m49s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m53s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 3m18s
Project CI / Frontend tests (pull_request) Failing after 4m6s
Project CI / Native shell tests (pull_request) Successful in 6m12s
Project CI / Repository checks (pull_request) Failing after 3m48s
Project CI / Backend tests (pull_request) Successful in 7m8s
Project CI / AI game creator shell web tests (pull_request) Failing after 3m59s
统一智能体对话层级并完善素材导出与文档预览
当前Agent与策划Agent共用正文和过程表现组件,统一思考及工具调用的小字号浅色样式
素材工具栏按实际动作分组,导出紧邻删除并修复空分组重复分隔线
文档与代码使用共享Markdown预览和代码高亮,复用按需读取与缓存
移除未调用的活跃回合查询命令,保留正式快照恢复链路
补充回归用例并同步技术方案和团队约定
2026-09-16 03:59:27 +08:00

88 lines
2.8 KiB
TypeScript

import { X } from 'lucide-react';
import { useEffect, useMemo } from 'react';
import { PlatformActionButton } from '../../../../../packages/shared/src/components/PlatformActionButton';
import { PlatformIconButton } from '../../../../../packages/shared/src/components/PlatformIconButton';
import { ChatMarkdownMessage } from '../../components/ChatMarkdownMessage';
import { ThemedModal } from '../../components/modal/ThemedModal';
import { resourceDocumentPreviewMarkdown } from '../../features/resource-canvas/resourceDocumentPreviewModel';
import type { ProjectResourceCardPreviewState } from './resourceCardPreviewModel';
import type { ProjectResource } from './resourceProjectionModel';
export function ResourceDocumentPreviewDialog({
resource,
identity,
preview,
onRequestPreview,
onClose,
}: {
resource: ProjectResource;
identity: string;
preview: ProjectResourceCardPreviewState;
onRequestPreview: (
resource: ProjectResource,
identity: string,
reason: 'detail',
) => void;
onClose: () => void;
}) {
useEffect(() => {
onRequestPreview(resource, identity, 'detail');
}, [resource, identity, onRequestPreview]);
const content =
preview.status === 'loaded' ? preview.preview.content : undefined;
const markdown = useMemo(
() =>
content === undefined
? ''
: resourceDocumentPreviewMarkdown(resource, content),
[resource, content],
);
return (
<ThemedModal
open
ariaLabel="文档预览"
onClose={onClose}
panelClassName="game-resource-document-preview"
>
<header className="game-resource-document-preview__header">
<strong title={resource.label}>{resource.label}</strong>
<PlatformIconButton
label="关闭文档预览"
title="关闭"
icon={<X size={18} aria-hidden="true" />}
onClick={onClose}
/>
</header>
<div className="game-resource-document-preview__body">
{preview.status === 'idle' || preview.status === 'loading' ? (
<p role="status">正在加载文档…</p>
) : preview.status === 'failed' ? (
<>
<p role="alert">{preview.error}</p>
{preview.retryable ? (
<PlatformActionButton
tone="secondary"
onClick={() => onRequestPreview(resource, identity, 'detail')}
>
重试
</PlatformActionButton>
) : null}
</>
) : content === undefined ? (
<p role="alert">没有可预览的文本内容</p>
) : content === '' ? (
<p role="status">文档为空</p>
) : (
<ChatMarkdownMessage
role="assistant"
text={markdown}
preserveBlankLines
/>
)}
</div>
</ThemedModal>
);
}