Skip to content

Commit 8e2579c

Browse files
Merge pull request #213 from scszcoder/gui-v2-merge-from-dev
Gui v2 merge from dev
2 parents f39e5a8 + a5b838f commit 8e2579c

8 files changed

Lines changed: 62 additions & 91 deletions

File tree

gui_v2/src/pages/Prompts/PromptsDetail.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@
188188
border-color: rgba(148, 163, 184, 0.12) !important;
189189
}
190190

191+
/* ========== Scroll Container ========== */
192+
.scrollContainer {
193+
flex: 1;
194+
min-height: 0;
195+
overflow: auto;
196+
overflow-y: scroll;
197+
}
198+
191199
/* ========== Scrollbar ========== */
192200
.scrollContainer::-webkit-scrollbar {
193201
width: 8px;

gui_v2/src/pages/Prompts/PromptsDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ const PromptsDetail: React.FC<PromptsDetailProps> = ({ prompt, onChange, initial
859859
</Button>
860860
</Space>
861861
</div>
862-
<div className={styles.scrollContainer} style={{ flex: 1, minHeight: 150, overflow: 'auto', overflowY: 'scroll', padding: '16px 20px', paddingBottom: '40px' }}>
862+
<div className={styles.scrollContainer} style={{ flex: 1, minHeight: 150 }}>
863863
{/* Top editable area */}
864864
<SectionContainer
865865
title={t('pages.prompts.fields.title', { defaultValue: 'Title' })}
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
/* Fix Tabs content area scrolling */
2-
.promptsTabs :global(.ant-tabs-content) {
2+
.promptsTabs {
33
height: 100%;
4-
overflow: hidden;
4+
display: flex;
5+
flex-direction: column;
56
}
67

7-
.promptsTabs :global(.ant-tabs-content-holder) {
8-
height: 100%;
9-
overflow: hidden;
8+
.promptsTabs :global(.ant-tabs-content) {
9+
flex: 1;
10+
min-height: 0;
1011
}
1112

12-
.promptsTabs :global(.ant-tabs-tabpane) {
13+
.promptsTabs :global(.ant-tabs-content-holder) {
1314
height: 100%;
14-
overflow: hidden;
15+
overflow: auto;
1516
}
1617

17-
/* Ensure tab content can scroll */
18-
.promptsTabs :global(.ant-tabs-tabpane-active) {
19-
height: 100%;
20-
display: flex;
21-
flex-direction: column;
18+
.promptsTabs :global(.ant-tabs-tabpane) {
19+
padding: 16px 20px 40px 20px;
2220
}

gui_v2/src/pages/Prompts/PromptsEnhanced.tsx

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useMemo, useState } from 'react';
22
import { useSearchParams } from 'react-router-dom';
3-
import { Tabs, Button, Space, Tooltip } from 'antd';
3+
import { Tabs, Space } from 'antd';
44
import {
55
EditOutlined,
66
BulbOutlined,
@@ -207,35 +207,6 @@ const PromptsEnhanced: React.FC = () => {
207207
return selected ? selected.title : t('pages.prompts.details');
208208
}, [activeTab, selected, t]);
209209

210-
const detailsExtra = useMemo(() => {
211-
if (activeTab !== 'editor') return null;
212-
213-
return (
214-
<Space size={8}>
215-
<Tooltip title={t('pages.prompts.tabs.guide', { defaultValue: '设计指南' })}>
216-
<Button
217-
type="text"
218-
size="small"
219-
icon={<BulbOutlined />}
220-
onClick={() => setActiveTab('guide')}
221-
>
222-
{t('pages.prompts.viewGuide', { defaultValue: '查看指南' })}
223-
</Button>
224-
</Tooltip>
225-
<Tooltip title={t('pages.prompts.tabs.templates', { defaultValue: '模板库' })}>
226-
<Button
227-
type="text"
228-
size="small"
229-
icon={<ThunderboltOutlined />}
230-
onClick={() => setActiveTab('templates')}
231-
>
232-
{t('pages.prompts.useTemplate', { defaultValue: '使用模板' })}
233-
</Button>
234-
</Tooltip>
235-
</Space>
236-
);
237-
}, [activeTab, t]);
238-
239210
return (
240211
<DetailLayout
241212
listTitle={null}
@@ -257,14 +228,12 @@ const PromptsEnhanced: React.FC = () => {
257228
/>
258229
}
259230
detailsContent={
260-
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
231+
<div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
261232
<Tabs
262233
activeKey={activeTab}
263234
onChange={setActiveTab}
264-
items={tabItems}
265-
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
266-
tabBarStyle={{ marginBottom: 0, paddingLeft: 20, paddingRight: 20, background: '#0f172a', flex: '0 0 auto' }}
267235
className={styles.promptsTabs}
236+
items={tabItems}
268237
/>
269238
</div>
270239
}

gui_v2/src/pages/Prompts/components/PromptExamples.tsx

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useMemo } from 'react';
22
import { Card, Typography, Space, Tag, Divider, Collapse, Tabs, Spin, Alert } from 'antd';
33
import {
44
CheckCircleOutlined,
@@ -14,6 +14,28 @@ import ReactMarkdown from 'react-markdown';
1414

1515
const { Title, Text, Paragraph } = Typography;
1616

17+
// Style constants to prevent recreation on every render
18+
const CONTAINER_STYLE = {
19+
height: '100%',
20+
display: 'flex' as const,
21+
flexDirection: 'column' as const,
22+
background: '#0f172a'
23+
};
24+
25+
const TABS_STYLE = {
26+
flex: 1,
27+
display: 'flex' as const,
28+
flexDirection: 'column' as const
29+
};
30+
31+
const TAB_BAR_STYLE = {
32+
margin: '0 20px',
33+
paddingTop: '16px',
34+
marginBottom: 16,
35+
borderBottom: '1px solid rgba(148,163,184,0.14)',
36+
flexShrink: 0
37+
};
38+
1739
interface Example {
1840
id: string;
1941
category: string;
@@ -32,6 +54,7 @@ const PromptExamples: React.FC = () => {
3254
const [loading, setLoading] = useState(false);
3355
const [error, setError] = useState<string | null>(null);
3456

57+
// Load markdown only once on mount
3558
useEffect(() => {
3659
const loadMarkdown = async () => {
3760
setLoading(true);
@@ -331,7 +354,8 @@ class User(BaseModel):
331354
return acc;
332355
}, {} as Record<string, Example[]>);
333356

334-
const tabItems = [
357+
// Memoize tabItems to prevent recreation on every render
358+
const tabItems = useMemo(() => [
335359
{
336360
key: 'builtin',
337361
label: (
@@ -341,8 +365,7 @@ class User(BaseModel):
341365
</Space>
342366
),
343367
children: (
344-
<div style={{ height: '100%', overflow: 'auto', overflowY: 'scroll', paddingBottom: '40px' }}>
345-
<Space direction="vertical" size="large" style={{ width: '100%' }}>
368+
<Space direction="vertical" size="large" style={{ width: '100%' }}>
346369
<Card
347370
size="small"
348371
style={{ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', border: 'none' }}
@@ -464,8 +487,7 @@ class User(BaseModel):
464487
</Space>
465488
</div>
466489
))}
467-
</Space>
468-
</div>
490+
</Space>
469491
),
470492
},
471493
{
@@ -477,7 +499,7 @@ class User(BaseModel):
477499
</Space>
478500
),
479501
children: (
480-
<div style={{ width: '100%', height: '100%', overflow: 'auto', overflowY: 'scroll', paddingBottom: '40px' }}>
502+
<>
481503
{loading && (
482504
<div style={{ textAlign: 'center', padding: '40px' }}>
483505
<Spin size="large" />
@@ -635,31 +657,21 @@ class User(BaseModel):
635657
</div>
636658
</Card>
637659
)}
638-
</div>
660+
</>
639661
),
640662
},
641-
];
663+
], [t, loading, error, markdownContent, groupedExamples, getLevelColor, getLevelText]);
642664

643665
return (
644-
<div style={{
645-
height: '100%',
646-
overflow: 'auto',
647-
overflowY: 'scroll',
648-
padding: '16px 20px',
649-
paddingBottom: '40px',
650-
background: '#0f172a'
651-
}}>
666+
<div style={CONTAINER_STYLE}>
652667
<Tabs
653668
defaultActiveKey="builtin"
654669
items={tabItems}
655-
style={{ height: '100%' }}
656-
tabBarStyle={{
657-
marginBottom: 16,
658-
borderBottom: '1px solid rgba(148,163,184,0.14)',
659-
}}
670+
style={TABS_STYLE}
671+
tabBarStyle={TAB_BAR_STYLE}
660672
/>
661673
</div>
662674
);
663675
};
664676

665-
export default PromptExamples;
677+
export default React.memo(PromptExamples);

gui_v2/src/pages/Prompts/components/PromptGuide.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,7 @@ const PromptGuide: React.FC<PromptGuideProps> = ({ visible = true }) => {
159159
];
160160

161161
return (
162-
<div style={{
163-
height: '100%',
164-
overflow: 'auto',
165-
padding: '16px 20px',
166-
background: '#0f172a',
167-
overflowY: 'scroll'
168-
}}>
169-
<Space direction="vertical" size="large" style={{ width: '100%', paddingBottom: '40px' }}>
162+
<Space direction="vertical" size="large" style={{ width: '100%' }}>
170163
{/* Quick Action Banner */}
171164
<Card
172165
size="small"
@@ -332,8 +325,7 @@ const PromptGuide: React.FC<PromptGuideProps> = ({ visible = true }) => {
332325
</Space>
333326
</Card>
334327
</Space>
335-
</div>
336328
);
337329
};
338330

339-
export default PromptGuide;
331+
export default React.memo(PromptGuide);

gui_v2/src/pages/Prompts/components/PromptTemplates.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,7 @@ Output Format:
419419
};
420420

421421
return (
422-
<div style={{
423-
height: '100%',
424-
overflow: 'auto',
425-
padding: '16px 20px',
426-
background: '#0f172a',
427-
overflowY: 'scroll'
428-
}}>
429-
<Space direction="vertical" size="large" style={{ width: '100%', paddingBottom: '40px' }}>
422+
<Space direction="vertical" size="large" style={{ width: '100%' }}>
430423
{/* Quick Action Banner */}
431424
<Card
432425
size="small"
@@ -589,8 +582,7 @@ Output Format:
589582
</Card>
590583
))}
591584
</Space>
592-
</div>
593585
);
594586
};
595587

596-
export default PromptTemplates;
588+
export default React.memo(PromptTemplates);

requirements-base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ aioconsole==0.7.1
128128
aiohappyeyeballs==2.6.1
129129
aiolimiter==1.2.1
130130
aiosignal==1.4.0
131-
anyio==4.9.0
131+
anyio==4.12.1 # Required by browser-use 0.12.0, compatible with all other packages
132132
nest_asyncio==1.6.0
133133
asgiref==3.8.1
134134
gevent==25.9.1

0 commit comments

Comments
 (0)