feat(frontend): enhance IMChannelsOverviewPanel layout and functionality

This update improves the layout and user experience of the IMChannelsOverviewPanel component. Key changes include:

- Added tooltips for subtitles and agent names for better accessibility.
- Refactored channel and agent display logic to improve clarity and consistency.
- Adjusted styling for better visual hierarchy and responsiveness.
- Enhanced toggle functionality for IM channels to ensure state consistency during updates.

These changes aim to provide a more intuitive interface for users managing instant messaging channels.
This commit is contained in:
wizardchen
2026-05-29 14:37:07 +08:00
committed by lyingbug
parent bb202a203a
commit c07ab6988c
@@ -3,7 +3,9 @@
<div class="submenu-header"> <div class="submenu-header">
<div class="titles"> <div class="titles">
<h4 class="title">{{ $t('imOverview.pageTitle') }}</h4> <h4 class="title">{{ $t('imOverview.pageTitle') }}</h4>
<p class="subtitle">{{ $t('imOverview.subtitle') }}</p> <p class="subtitle" :title="$t('imOverview.subtitle')">
{{ $t('imOverview.subtitle') }}
</p>
</div> </div>
<t-button <t-button
variant="text" variant="text"
@@ -38,11 +40,22 @@
@keydown.enter="gotoAgentEditor(ch)" @keydown.enter="gotoAgentEditor(ch)"
@keydown.space.prevent="gotoAgentEditor(ch)" @keydown.space.prevent="gotoAgentEditor(ch)"
> >
<!-- Stacked rows: agent on top, IM channel below. Same avatar size <div class="item-main">
and typography → both read as co-equal identities of the row. --> <div class="channel-primary">
<div class="stack"> <span class="platform-avatar">
<div class="stack-row"> <img
<span class="row-avatar"> v-if="hasPlatformLogo(ch.platform)"
:src="platformLogo(ch.platform)"
:alt="platformLabel(ch.platform)"
/>
<t-icon v-else name="link" size="14px" />
</span>
<span class="channel-name" :title="channelDisplayName(ch)">
{{ channelDisplayName(ch) }}
</span>
</div>
<div class="channel-secondary">
<span class="agent-avatar-sm">
<span <span
v-if="agentMeta(ch.agent_id)?.is_builtin" v-if="agentMeta(ch.agent_id)?.is_builtin"
class="builtin-avatar" class="builtin-avatar"
@@ -50,7 +63,7 @@
> >
<t-icon <t-icon
:name="agentMeta(ch.agent_id)?.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" :name="agentMeta(ch.agent_id)?.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'"
size="12px" size="10px"
/> />
</span> </span>
<span <span
@@ -59,22 +72,12 @@
>{{ agentMeta(ch.agent_id)!.avatar }}</span> >{{ agentMeta(ch.agent_id)!.avatar }}</span>
<AgentAvatar <AgentAvatar
v-else v-else
:name="ch.agent_name || ch.agent_id" :name="agentDisplayName(ch)"
size="small" size="small"
/> />
</span> </span>
<span class="row-label" :title="ch.agent_name || agentMeta(ch.agent_id)?.name || ''"> <span class="agent-name" :title="agentDisplayName(ch)">
{{ ch.agent_name || agentMeta(ch.agent_id)?.name || $t('imOverview.builtinAgent') }} {{ agentDisplayName(ch) }}
</span>
</div>
<div class="stack-row">
<img
class="row-avatar platform-logo"
:src="platformLogo(ch.platform)"
:alt="platformLabel(ch.platform)"
/>
<span class="row-label" :title="ch.name || platformLabel(ch.platform)">
{{ ch.name || platformLabel(ch.platform) }}
</span> </span>
</div> </div>
</div> </div>
@@ -109,8 +112,6 @@ import {
} from '@/api/agent'; } from '@/api/agent';
import AgentAvatar from '@/components/AgentAvatar.vue'; import AgentAvatar from '@/components/AgentAvatar.vue';
// Platform logos sourced from iconify (simple-icons / logos / tdesign / remix icon).
// Bundled as static assets so they share the app's caching story.
import wecomLogo from '@/assets/img/im/wecom.svg'; import wecomLogo from '@/assets/img/im/wecom.svg';
import feishuLogo from '@/assets/img/im/feishu.svg'; import feishuLogo from '@/assets/img/im/feishu.svg';
import slackLogo from '@/assets/img/im/slack.svg'; import slackLogo from '@/assets/img/im/slack.svg';
@@ -147,8 +148,6 @@ const agentMap = ref<Map<string, CustomAgent>>(new Map());
const loading = ref(false); const loading = ref(false);
const togglingId = ref<string>(''); const togglingId = ref<string>('');
// Parent tells us when the submenu is active (hover/click-open). Reload only
// when transitioning into active so we don't refetch on every re-render.
watch( watch(
() => props.active, () => props.active,
(v, old) => { (v, old) => {
@@ -157,6 +156,10 @@ watch(
{ immediate: true }, { immediate: true },
); );
function hasPlatformLogo(p: string): boolean {
return Boolean(PLATFORM_LOGO[p]);
}
function platformLogo(p: string): string { function platformLogo(p: string): string {
return PLATFORM_LOGO[p] || ''; return PLATFORM_LOGO[p] || '';
} }
@@ -165,10 +168,18 @@ function platformLabel(p: string): string {
return t(`agentEditor.im.${p}`); return t(`agentEditor.im.${p}`);
} }
function channelDisplayName(ch: IMChannelOverview): string {
return ch.name || platformLabel(ch.platform);
}
function agentMeta(agentId: string): CustomAgent | undefined { function agentMeta(agentId: string): CustomAgent | undefined {
return agentMap.value.get(agentId); return agentMap.value.get(agentId);
} }
function agentDisplayName(ch: IMChannelOverview): string {
return ch.agent_name || agentMeta(ch.agent_id)?.name || t('imOverview.builtinAgent');
}
async function loadAll() { async function loadAll() {
loading.value = true; loading.value = true;
try { try {
@@ -190,18 +201,21 @@ async function loadAll() {
} }
async function handleToggle(ch: IMChannelOverview) { async function handleToggle(ch: IMChannelOverview) {
if (togglingId.value) return; if (togglingId.value === ch.id) return;
togglingId.value = ch.id; togglingId.value = ch.id;
const prev = ch.enabled;
ch.enabled = !prev;
try { try {
await toggleIMChannel(ch.id); await toggleIMChannel(ch.id);
const resp = await listAllIMChannels(); const resp = await listAllIMChannels();
channels.value = resp?.data || []; channels.value = resp?.data || [];
emit('channels-changed', channels.value); emit('channels-changed', channels.value);
} catch (err: any) { } catch (err: any) {
ch.enabled = prev;
console.error('Failed to toggle IM channel:', err); console.error('Failed to toggle IM channel:', err);
MessagePlugin.error(err?.message || t('common.operationFailed')); MessagePlugin.error(err?.message || t('common.operationFailed'));
} finally { } finally {
togglingId.value = ''; if (togglingId.value === ch.id) togglingId.value = '';
} }
} }
@@ -221,9 +235,9 @@ function gotoAgentEditor(ch: IMChannelOverview) {
width: 300px; width: 300px;
max-height: 520px; max-height: 520px;
background: var(--td-bg-color-container); background: var(--td-bg-color-container);
border-radius: 8px; border-radius: 10px;
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
border: 1px solid var(--td-component-stroke); border: 0.5px solid var(--td-component-stroke);
overflow: hidden; overflow: hidden;
} }
@@ -232,36 +246,38 @@ function gotoAgentEditor(ch: IMChannelOverview) {
align-items: flex-start; align-items: flex-start;
justify-content: space-between; justify-content: space-between;
gap: 8px; gap: 8px;
padding: 12px 14px; padding: 10px 12px 8px;
border-bottom: 1px solid var(--td-component-stroke); border-bottom: 0.5px solid var(--td-component-stroke);
.titles { .titles {
min-width: 0; min-width: 0;
} }
.title { .title {
margin: 0 0 2px; margin: 0 0 4px;
font-size: 13px; font-size: 12px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-primary); color: var(--td-text-color-secondary);
line-height: 1.3; line-height: 1.3;
} }
.subtitle { .subtitle {
margin: 0; margin: 0;
font-size: 11px; font-size: 11px;
color: var(--td-text-color-secondary); color: var(--td-text-color-placeholder);
line-height: 1.4; line-height: 1.45;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
} }
} }
.submenu-body { .submenu-body {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
padding: 6px; padding: 4px;
display: flex;
flex-direction: column;
gap: 4px;
} }
.state-placeholder { .state-placeholder {
@@ -281,116 +297,146 @@ function gotoAgentEditor(ch: IMChannelOverview) {
.channels-list { .channels-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px;
} }
.channel-item { .channel-item {
display: flex; display: flex;
align-items: center; align-items: flex-start;
gap: 8px; gap: 8px;
padding: 8px 10px; padding: 8px;
background: transparent;
border-radius: 6px; border-radius: 6px;
cursor: pointer; cursor: pointer;
outline: none; outline: none;
transition: background 0.15s; transition: background 0.15s;
&:hover, & + & {
&:focus-visible { border-top: 0.5px solid var(--td-component-stroke);
background: var(--td-bg-color-container-hover);
} }
&.is-disabled { &:hover,
opacity: 0.55; &:focus-visible {
background: var(--td-bg-color-secondarycontainer);
}
&.is-disabled .item-main {
opacity: 0.6;
} }
} }
// Stacked rows: agent on top, channel below. Both lines share identical .item-main {
// typography and avatar size so neither dominates — they read as two facets
// of the same row rather than a headline + caption.
.stack {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 3px; gap: 4px;
} }
.stack-row { .channel-primary {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
min-width: 0; min-width: 0;
} }
.row-avatar { .platform-avatar {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 20px; width: 24px;
height: 20px; height: 24px;
border-radius: 4px; border-radius: 6px;
flex-shrink: 0; flex-shrink: 0;
background: var(--td-bg-color-secondarycontainer);
&.platform-logo { img {
width: 18px;
height: 18px;
object-fit: contain; object-fit: contain;
background: transparent; }
padding: 1px;
.t-icon {
color: var(--td-text-color-placeholder);
} }
} }
.row-label { .channel-name {
font-size: 12px; font-size: 13px;
font-weight: 500;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
min-width: 0; min-width: 0;
line-height: 1.3; line-height: 1.35;
}
.channel-secondary {
display: flex;
align-items: center;
gap: 6px;
min-width: 0;
padding-left: 32px;
}
.agent-avatar-sm {
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
flex-shrink: 0;
:deep(.agent-avatar),
:deep(.agent-avatar-small) {
width: 16px;
height: 16px;
}
:deep(.agent-avatar-letter) {
font-size: 9px !important;
}
}
.agent-name {
font-size: 11px;
color: var(--td-text-color-placeholder);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
line-height: 1.35;
} }
// Switch stays right-anchored, separated from the stack by the natural row gap.
.item-actions { .item-actions {
margin-left: 8px;
flex-shrink: 0; flex-shrink: 0;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
padding-top: 2px;
} }
.builtin-avatar { .builtin-avatar {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 20px; width: 16px;
height: 20px; height: 16px;
border-radius: 4px; border-radius: 4px;
flex-shrink: 0; flex-shrink: 0;
&.agent-emoji { &.agent-emoji {
font-size: 13px; font-size: 11px;
line-height: 1; line-height: 1;
background: var(--td-bg-color-container-hover); background: var(--td-bg-color-container-hover);
} }
&.normal { &.normal {
background: linear-gradient(135deg, rgba(7, 192, 95, 0.15) 0%, rgba(7, 192, 95, 0.08) 100%); background: linear-gradient(135deg, rgba(7, 192, 95, 0.15) 0%, rgba(7, 192, 95, 0.08) 100%);
color: var(--td-brand-color-active); color: var(--td-brand-color-active);
} }
&.agent { &.agent {
background: linear-gradient(135deg, rgba(124, 77, 255, 0.15) 0%, rgba(124, 77, 255, 0.08) 100%); background: linear-gradient(135deg, rgba(124, 77, 255, 0.15) 0%, rgba(124, 77, 255, 0.08) 100%);
color: var(--td-brand-color); color: var(--td-brand-color);
} }
} }
// Size the generated AgentAvatar (hash-based gradient + letter) to match the
// builtin-avatar and platform-logo so all three rows align perfectly.
.stack-row {
:deep(.agent-avatar),
:deep(.agent-avatar-small) {
width: 20px;
height: 20px;
}
:deep(.agent-avatar-letter) {
font-size: 10px !important;
}
}
</style> </style>