Skip to content

Commit 71f3677

Browse files
authored
Merge pull request #168 from opentiny/optimize-playground-tool-call
fix(playground): pin tool call options to tools tab bottom with independent scroll
2 parents 2113db3 + 4721da4 commit 71f3677

4 files changed

Lines changed: 107 additions & 41 deletions

File tree

sites/playground/web/src/components/PlaygroundSidebar.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ const updateCustomExamples = (list) => {
162162
</button>
163163
</div>
164164
165-
<tiny-tabs class="playground-sidebar__tabs" v-model="activeName" v-show="expanded">
165+
<tiny-tabs
166+
class="playground-sidebar__tabs"
167+
:class="{ 'playground-sidebar__tabs--tools': activeName === 'tools' }"
168+
v-model="activeName"
169+
v-show="expanded"
170+
>
166171
<tiny-tab-item title="模型配置" name="model">
167172
<ModelConfig @createNewTemplate="handleCreateNewTemplate" @update-custom-examples="updateCustomExamples"/>
168173
</tiny-tab-item>
@@ -274,6 +279,8 @@ const updateCustomExamples = (list) => {
274279
flex: 1;
275280
min-height: 0;
276281
overflow: hidden;
282+
display: flex;
283+
flex-direction: column;
277284
278285
.config-title {
279286
font-size: 14px;
@@ -284,13 +291,28 @@ const updateCustomExamples = (list) => {
284291
285292
:deep(.tiny-tabs__header.is-top) {
286293
padding: 0 24px;
294+
flex-shrink: 0;
287295
}
288296
289297
:deep(.tiny-tabs__content) {
290-
height: 100%;
298+
flex: 1;
299+
min-height: 0;
291300
overflow: auto;
292301
padding: 0 24px 90px;
293302
}
303+
304+
&--tools :deep(.tiny-tabs__content) {
305+
overflow: hidden;
306+
padding: 0;
307+
display: flex;
308+
flex-direction: column;
309+
310+
> .tiny-tab-pane {
311+
flex: 1;
312+
min-height: 0;
313+
overflow: hidden;
314+
}
315+
}
294316
}
295317
296318
.svg-icon {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup>
2+
import { inject } from 'vue';
3+
import { TinyCheckbox } from '@opentiny/vue';
4+
5+
const playgroundContext = inject('playgroundContext');
6+
const { chatConfig } = playgroundContext;
7+
8+
const updateAddToolCallContext = (value) => {
9+
chatConfig.addToolCallContext = value;
10+
};
11+
12+
const updateShowThinkingResult = (value) => {
13+
chatConfig.showThinkingResult = value;
14+
};
15+
</script>
16+
17+
<template>
18+
<div class="tool-call-config">
19+
<tiny-checkbox :model-value="chatConfig.addToolCallContext" @update:model-value="updateAddToolCallContext">
20+
调用结果添加到上下文
21+
</tiny-checkbox>
22+
</div>
23+
<div class="tool-call-config">
24+
<tiny-checkbox :model-value="chatConfig.showThinkingResult" @update:model-value="updateShowThinkingResult">
25+
调用结果展示在界面中
26+
</tiny-checkbox>
27+
</div>
28+
</template>
29+
30+
<style scoped lang="less">
31+
.tool-call-config {
32+
display: flex;
33+
align-items: center;
34+
font-size: 14px;
35+
color: #595959;
36+
37+
& + & {
38+
margin-top: 12px;
39+
}
40+
}
41+
</style>

sites/playground/web/src/components/tab-components/mcpTools.vue

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,53 @@
22
import { ref } from 'vue';
33
import { TinyCollapse } from '@opentiny/vue';
44
import { AgentPanel, McpServerPanel, SkillPanel } from './tool-panels';
5+
import ToolCallConfig from './ToolCallConfig.vue';
56
67
const activePanels = ref(['mcp', 'agent', 'skills']);
78
</script>
89

910
<template>
10-
<div>
11-
<tiny-collapse class="playground-tools" v-model="activePanels">
12-
<McpServerPanel />
13-
<AgentPanel />
14-
<SkillPanel />
15-
</tiny-collapse>
11+
<div class="mcp-tools">
12+
<div class="mcp-tools__scroll">
13+
<div class="mcp-tools__scroll-inner">
14+
<tiny-collapse class="playground-tools" v-model="activePanels">
15+
<McpServerPanel />
16+
<AgentPanel />
17+
<SkillPanel />
18+
</tiny-collapse>
19+
</div>
20+
</div>
21+
<div class="mcp-tools__footer">
22+
<ToolCallConfig />
23+
</div>
1624
</div>
1725
</template>
1826

1927
<style scoped lang="less">
28+
.mcp-tools {
29+
display: flex;
30+
flex-direction: column;
31+
height: 100%;
32+
min-height: 0;
33+
}
34+
35+
.mcp-tools__scroll {
36+
flex: 1;
37+
min-height: 0;
38+
overflow-y: auto;
39+
overflow-x: hidden;
40+
}
41+
42+
.mcp-tools__scroll-inner {
43+
padding: 0 24px;
44+
}
45+
46+
.mcp-tools__footer {
47+
flex-shrink: 0;
48+
padding: 12px 24px 16px;
49+
background: var(--ti-base-color-bg, #fff);
50+
}
51+
2052
:deep(.tiny-collapse) {
2153
border-bottom: none;
2254
@@ -34,6 +66,9 @@ const activePanels = ref(['mcp', 'agent', 'skills']);
3466
.tiny-collapse-item__header {
3567
padding: 0;
3668
border-bottom: none;
69+
position: sticky;
70+
top: 0;
71+
z-index: 2;
3772
}
3873
3974
.tiny-collapse-item__content {

sites/playground/web/src/components/tab-components/tool-panels/McpServerPanel.vue

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
TinyButton,
55
TinySwitch,
66
TinyPopover,
7-
TinyCheckbox,
87
TinyCollapseItem,
98
TinyDialogBox,
109
TinyForm,
@@ -15,7 +14,7 @@ import {
1514
import { iconDel, iconEdit, iconPlus, iconEllipsis } from '@opentiny/vue-icon';
1615
1716
const playgroundContext = inject('playgroundContext');
18-
const { llmConfig, chatConfig } = playgroundContext;
17+
const { llmConfig } = playgroundContext;
1918
2019
const IconPlus = iconPlus();
2120
const IconDel = iconDel();
@@ -91,14 +90,6 @@ const updateServerEnabled = (server, enabled) => {
9190
llmConfig.mcpServers = mcpServers.map((s) => (s.name === server.name ? { ...s, enabled } : s));
9291
};
9392
94-
const updateAddToolCallContext = (value) => {
95-
chatConfig.addToolCallContext = value;
96-
};
97-
98-
const updateShowThinkingResult = (value) => {
99-
chatConfig.showThinkingResult = value;
100-
};
101-
10293
const confirmMCPServer = async () => {
10394
addToolLoading.value = true;
10495
try {
@@ -204,16 +195,6 @@ const confirmMCPServer = async () => {
204195
</div>
205196
</div>
206197
</div>
207-
<div class="mcp-server-tool-call-context">
208-
<tiny-checkbox :model-value="chatConfig.addToolCallContext" @update:model-value="updateAddToolCallContext">
209-
调用结果添加到上下文
210-
</tiny-checkbox>
211-
</div>
212-
<div class="mcp-server-tool-call-context" style="margin-top: 12px">
213-
<tiny-checkbox :model-value="chatConfig.showThinkingResult" @update:model-value="updateShowThinkingResult">
214-
调用结果展示在界面中
215-
</tiny-checkbox>
216-
</div>
217198
<tiny-dialog-box
218199
v-model:visible="showToolFormDialog"
219200
:title="mcpServerData.index > -1 ? '编辑 MCP 服务' : '添加 MCP 服务'"
@@ -317,19 +298,6 @@ const confirmMCPServer = async () => {
317298
color: #595959;
318299
}
319300
320-
.mcp-server-tool-call-context {
321-
margin-top: 12px;
322-
display: flex;
323-
align-items: center;
324-
justify-content: space-between;
325-
font-size: 14px;
326-
color: #595959;
327-
328-
&:last-child {
329-
margin-bottom: 16px;
330-
}
331-
}
332-
333301
:deep(.mcp-server-item-actions-popover) {
334302
padding: 0;
335303
border: none;

0 commit comments

Comments
 (0)