Skip to content

Commit 6144e95

Browse files
committed
feat(agents): support click prompt text to copy in codex quick use
1 parent fd2f761 commit 6144e95

2 files changed

Lines changed: 61 additions & 31 deletions

File tree

‎app/web/pages/agents/detail/AgentDetailContent.tsx‎

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -348,38 +348,60 @@ const AgentDetailContent: React.FC<AgentDetailContentProps> = ({ name, history }
348348
<div className="agent-prompts agent-prompts-compact">
349349
{introBlocks.openingQuestions.length > 0 ? (
350350
introBlocks.openingQuestions.map(
351-
(item: any, index: number) => (
352-
<Card
353-
key={`${item.title}-${index}`}
354-
size="small"
355-
className="agent-intro-panel agent-question-card"
356-
>
357-
<div className="agent-question-card-body">
358-
<div className="agent-intro-icon-wrap is-question">
359-
<QuestionCircleOutlined />
351+
(item: any, index: number) => {
352+
const promptText =
353+
typeof item === 'string'
354+
? item
355+
: item?.prompt || item?.title || '';
356+
return (
357+
<Card
358+
key={`${
359+
item.title || index
360+
}-${index}`}
361+
size="small"
362+
className="agent-intro-panel agent-question-card"
363+
>
364+
<div className="agent-question-card-body">
365+
<div className="agent-intro-icon-wrap is-question">
366+
<QuestionCircleOutlined />
367+
</div>
368+
<Tooltip title="点击复制">
369+
<div
370+
className="agent-question-copy"
371+
onClick={(event) => {
372+
event.stopPropagation();
373+
// 点击提示词文本区域直接复制到剪贴板
374+
if (promptText) {
375+
copyToClipboard(
376+
promptText,
377+
'复制成功'
378+
);
379+
}
380+
}}
381+
>
382+
<Paragraph>
383+
{promptText}
384+
</Paragraph>
385+
</div>
386+
</Tooltip>
387+
<Button
388+
size="small"
389+
className="agent-question-quick-use"
390+
icon={
391+
<span className="agent-question-quick-use-icon">
392+
<CodeOutlined />
393+
</span>
394+
}
395+
onClick={() =>
396+
openCodexInstall(item)
397+
}
398+
>
399+
快捷使用
400+
</Button>
360401
</div>
361-
<div className="agent-question-copy">
362-
<Paragraph>
363-
{item.prompt}
364-
</Paragraph>
365-
</div>
366-
<Button
367-
size="small"
368-
className="agent-question-quick-use"
369-
icon={
370-
<span className="agent-question-quick-use-icon">
371-
<CodeOutlined />
372-
</span>
373-
}
374-
onClick={() =>
375-
openCodexInstall(item)
376-
}
377-
>
378-
快捷使用
379-
</Button>
380-
</div>
381-
</Card>
382-
)
402+
</Card>
403+
);
404+
}
383405
)
384406
) : (
385407
<Empty

‎app/web/pages/agents/detail/style.scss‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,14 @@
455455
display: flex;
456456
flex-direction: column;
457457
align-items: flex-start;
458+
padding: 4px 8px;
459+
margin: -4px -8px;
460+
border-radius: 6px;
461+
cursor: pointer;
462+
transition: background-color 0.2s ease;
463+
.ant-typography {
464+
transition: color 0.2s ease;
465+
}
458466
.ant-typography:first-child {
459467
display: block;
460468
margin-bottom: 4px;

0 commit comments

Comments
 (0)