把回合执行过程渲染的两层三目抽成 renderTurnProcess
- apps/ai-game-creator-shell/src/view/project-development/chat/components/DirectProjectConversation/DirectProjectTurn.tsx 新增 renderTurnProcess,负责空过程、运行中平铺与结束后折叠三种分支 - 组件主体不再嵌套三目,渲染结果与 data-testid="turn-process" 等 DOM 结构保持不变
This commit is contained in:
+16
-16
@@ -32,22 +32,7 @@ export function DirectProjectTurn({ turn }: { turn: DirectChatTurn }) {
|
||||
{turn.users.map((block) =>
|
||||
renderBlock(turn, block, 'body', streamingKey),
|
||||
)}
|
||||
{turn.process.length > 0 ? (
|
||||
turn.active ? (
|
||||
turn.process.map((block) =>
|
||||
renderBlock(turn, block, 'process', streamingKey),
|
||||
)
|
||||
) : (
|
||||
<details className="message-turn-process" data-testid="turn-process">
|
||||
<summary>执行过程</summary>
|
||||
<div className="message-turn-process-body">
|
||||
{turn.process.map((block) =>
|
||||
renderBlock(turn, block, 'process', streamingKey),
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
)
|
||||
) : null}
|
||||
{renderTurnProcess(turn, streamingKey)}
|
||||
{turn.finals.map((block) =>
|
||||
renderBlock(turn, block, 'body', streamingKey),
|
||||
)}
|
||||
@@ -56,6 +41,21 @@ export function DirectProjectTurn({ turn }: { turn: DirectChatTurn }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** 运行中的回合把执行过程平铺,已结束的回合折叠进「执行过程」。 */
|
||||
function renderTurnProcess(turn: DirectChatTurn, streamingKey: string | null) {
|
||||
if (turn.process.length === 0) return null;
|
||||
const blocks = turn.process.map((block) =>
|
||||
renderBlock(turn, block, 'process', streamingKey),
|
||||
);
|
||||
if (turn.active) return blocks;
|
||||
return (
|
||||
<details className="message-turn-process" data-testid="turn-process">
|
||||
<summary>执行过程</summary>
|
||||
<div className="message-turn-process-body">{blocks}</div>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
|
||||
function DirectProjectTurnUsage({ turn }: { turn: DirectChatTurn }) {
|
||||
if (turn.active || !turn.startedAt) return null;
|
||||
const endedAt = Math.max(turn.endedAt, turn.startedAt);
|
||||
|
||||
Reference in New Issue
Block a user