Commit 01267e8a6c60b506221b020f76f503be72c42979

Authored by yibo
1 parent 19b037f7

feat(agent-chat): Agent 侧栏加宽并支持搜索跳转

侧栏 170px 太窄看不全 agent 名字,改成 260px 并把名字从省略号截断
改成允许换行;顶部加搜索框按 name/id 过滤列表,点击过滤结果复用
已有的 switchAgent() 跳转逻辑,不用额外写定位/滚动代码。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Showing 1 changed file with 17 additions and 2 deletions
web/src/views/AgentChat.vue
@@ -6,12 +6,19 @@ @@ -6,12 +6,19 @@
6 <!-- 第1列: Agent 列表 (始终可见) --> 6 <!-- 第1列: Agent 列表 (始终可见) -->
7 <aside class="agent-sidebar"> 7 <aside class="agent-sidebar">
8 <div class="col-header">{{ $route.params.id ? '🏢 Agents' : '💻 System Agents' }}</div> 8 <div class="col-header">{{ $route.params.id ? '🏢 Agents' : '💻 System Agents' }}</div>
  9 + <input
  10 + v-model="agentSearchQuery"
  11 + class="agent-search-input"
  12 + type="text"
  13 + placeholder="🔍 搜索 Agent..."
  14 + />
9 <div class="agent-list"> 15 <div class="agent-list">
10 <template v-for="(agents, compId) in groupedAgents" :key="compId"> 16 <template v-for="(agents, compId) in groupedAgents" :key="compId">
11 <div class="agent-group-title" v-if="$route.params.id">{{ compId === 'system' ? '💻 系统 Agent' : `🏢 ${compId}` }}</div> 17 <div class="agent-group-title" v-if="$route.params.id">{{ compId === 'system' ? '💻 系统 Agent' : `🏢 ${compId}` }}</div>
12 <div 18 <div
13 v-for="a in agents" :key="a.id" 19 v-for="a in agents" :key="a.id"
14 class="agent-card" :class="{ active: agentId === a.id }" 20 class="agent-card" :class="{ active: agentId === a.id }"
  21 + :title="a.name"
15 @click="agentId = a.id; switchAgent()" 22 @click="agentId = a.id; switchAgent()"
16 > 23 >
17 <span class="agent-card-emoji">{{ a.emoji || '🤖' }}</span> 24 <span class="agent-card-emoji">{{ a.emoji || '🤖' }}</span>
@@ -329,8 +336,10 @@ const route = useRoute() @@ -329,8 +336,10 @@ const route = useRoute()
329 const router = useRouter() 336 const router = useRouter()
330 const agentId = ref(route.params.agentId || '') 337 const agentId = ref(route.params.agentId || '')
331 const agentList = ref([]) 338 const agentList = ref([])
  339 +const agentSearchQuery = ref('')
332 340
333 const groupedAgents = computed(() => { 341 const groupedAgents = computed(() => {
  342 + const q = agentSearchQuery.value.trim().toLowerCase()
334 const groups = {} 343 const groups = {}
335 agentList.value.forEach(a => { 344 agentList.value.forEach(a => {
336 const comp = a.companyId || 'system' 345 const comp = a.companyId || 'system'
@@ -341,6 +350,7 @@ const groupedAgents = computed(() =&gt; { @@ -341,6 +350,7 @@ const groupedAgents = computed(() =&gt; {
341 // If we are in the System Agents context, ONLY show system agents 350 // If we are in the System Agents context, ONLY show system agents
342 if (comp !== 'system') return 351 if (comp !== 'system') return
343 } 352 }
  353 + if (q && !(a.name || '').toLowerCase().includes(q) && !(a.id || '').toLowerCase().includes(q)) return
344 354
345 if (!groups[comp]) groups[comp] = [] 355 if (!groups[comp]) groups[comp] = []
346 groups[comp].push(a) 356 groups[comp].push(a)
@@ -1005,9 +1015,14 @@ onMounted(async () =&gt; { @@ -1005,9 +1015,14 @@ onMounted(async () =&gt; {
1005 1015
1006 /* ═══ 第1列: Agent 列表 ═══ */ 1016 /* ═══ 第1列: Agent 列表 ═══ */
1007 .agent-sidebar { 1017 .agent-sidebar {
1008 - width: 170px; min-width: 150px; border-right: 1px solid var(--border-primary); 1018 + width: 260px; min-width: 220px; border-right: 1px solid var(--border-primary);
1009 background: var(--bg-overlay); display: flex; flex-direction: column; 1019 background: var(--bg-overlay); display: flex; flex-direction: column;
1010 } 1020 }
  1021 +.agent-search-input {
  1022 + margin: 0 6px 6px; padding: 5px 8px; border-radius: 6px;
  1023 + border: 1px solid var(--border-primary); background: var(--bg-input);
  1024 + color: var(--text-primary); font-size: 11px; box-sizing: border-box;
  1025 +}
1011 .agent-list { flex: 1; overflow-y: auto; padding: 6px; } 1026 .agent-list { flex: 1; overflow-y: auto; padding: 6px; }
1012 .agent-group-title { font-size: 10px; font-weight: 700; color: var(--text-tertiary); padding: 8px 6px 4px; text-transform: uppercase; } 1027 .agent-group-title { font-size: 10px; font-weight: 700; color: var(--text-tertiary); padding: 8px 6px 4px; text-transform: uppercase; }
1013 .agent-card { 1028 .agent-card {
@@ -1019,7 +1034,7 @@ onMounted(async () =&gt; { @@ -1019,7 +1034,7 @@ onMounted(async () =&gt; {
1019 .agent-card.active { background: var(--bg-surface-active); border-color: var(--border-active); } 1034 .agent-card.active { background: var(--bg-surface-active); border-color: var(--border-active); }
1020 .agent-card-emoji { font-size: 18px; flex-shrink: 0; } 1035 .agent-card-emoji { font-size: 18px; flex-shrink: 0; }
1021 .agent-card-info { min-width: 0; } 1036 .agent-card-info { min-width: 0; }
1022 -.agent-card-name { font-size: 11px; font-weight: 600; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } 1037 +.agent-card-name { font-size: 11px; font-weight: 600; color: var(--text-secondary); white-space: normal; word-break: break-word; }
1023 .agent-card-type { font-size: 9px; color: var(--text-faint); } 1038 .agent-card-type { font-size: 9px; color: var(--text-faint); }
1024 .agent-card-time { font-size: 9px; color: var(--text-faint); white-space: nowrap; margin-left: 6px; } 1039 .agent-card-time { font-size: 9px; color: var(--text-faint); white-space: nowrap; margin-left: 6px; }
1025 .agent-card-msg { font-size: 10px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; } 1040 .agent-card-msg { font-size: 10px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }