Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): limit teammate sidebar preview with show-all controls

zqchris0968eeea951a
diff --git a/apps/desktop/scripts/fixtures/teammates-section/teammates-fixture.tsx b/apps/desktop/scripts/fixtures/teammates-section/teammates-fixture.tsx
new file mode 100644
index 0000000000..8033a6c79a
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/teammates-section/teammates-fixture.tsx
@@ -0,0 +1,10 @@
+import { Route, Routes } from 'react-router-dom';
+import { AppFrame, mountPage } from '../../ui-page/harness';
+import { TeammatesSection } from '../../../src/renderer/features/bots/TeammatesSection';
+
+mountPage({
+ route: '/bots/mate-6',
+ render: () => <Routes><Route path="/bots/:botId" element={
+ <AppFrame header={false} sidebar={<TeammatesSection />} />
+ } /></Routes>,
+});
diff --git a/apps/desktop/scripts/fixtures/teammates-section/ui-page.mjs b/apps/desktop/scripts/fixtures/teammates-section/ui-page.mjs
new file mode 100644
index 0000000000..80cc6f3a0a
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/teammates-section/ui-page.mjs
@@ -0,0 +1,50 @@
+import assert from 'node:assert/strict';
+
+const data = 'window.__uiPage.ctx.data';
+const profiles = ['Cindy', 'Writer', 'Researcher', 'Designer', 'Translator', 'Reviewer'].map((name, index) => ({
+ id: `mate-${index + 1}`, name, avatar: '', avatarColor: 'violet', channel: 'local',
+ status: 'active', enabled: true, skills: [], capabilities: {}, createdAt: 0,
+ lastMessageAt: 600 - index, lastMessagePreview: 'Ready',
+ sessions: [{ id: `chat-${index}`, kind: 'chat', role: 'canonical' }],
+}));
+
+export default {
+ name: 'teammates-section',
+ entry: './teammates-fixture.tsx',
+ viewport: { width: 800, height: 600 },
+ real: 'TeammatesSection rows, current-chat preview, show-all/show-less controls, avatar strip, theme and translations',
+ notCovered: 'Roster loading, cloud/device connections, create/delete menus and message delivery',
+ stubs: {
+ 'src/renderer/contexts/AuthContext': { partial: 'export const useAuth=()=>({dataOwnerId:"ui-fixture"});' },
+ 'src/renderer/features/bots/botStore': { partial: `export const useBotProfiles=()=>${data}.profiles; export const useBotUnreadCounts=()=>({});` },
+ 'src/renderer/features/bots/useRemoteBots': 'export const useRemoteBots=()=>[];',
+ 'src/renderer/features/bots/companionCloudStore': { partial: 'const snapshot={enabled:false,actors:[],demotedBotIds:[]}; export const useCompanionCloud=()=>snapshot;' },
+ 'src/renderer/features/bots/botGroupStore': { partial: 'export const useBotGroupList=()=>({groups:[],loaded:true});' },
+ 'src/renderer/features/device-link/useDeviceLinkDeviceList': 'export const useDeviceLinkDeviceList=()=>[];',
+ 'src/renderer/state/agentIslandActivity': { partial: 'const activity=new Map(); export const useAgentIslandActivityMap=()=>activity;' },
+ 'src/renderer/features/bots/BotCreateMenu': 'export const BotCreateMenu=()=>null;',
+ 'src/renderer/features/bots/BotDeleteDialog': 'export const BotDeleteDialog=()=>null;',
+ },
+ cases: { default: { about: 'Six chats with the sixth selected; five-row preview, expand, shrink and avatar strip', data: { profiles } } },
+ async check(page, ui) {
+ const rows = page.getByText('Ready', { exact: true });
+ assert.equal(await rows.count(), 5);
+ assert.equal(await page.getByText('Translator', { exact: true }).count(), 0);
+ await page.getByText('Reviewer', { exact: true }).waitFor();
+ const showAllLabel = await ui.t('ccAgent.sidebar.showAllSessions', { count: 6 });
+ const showAll = () => page.getByRole('button', { name: showAllLabel, exact: true });
+ await showAll().click();
+ assert.equal(await rows.count(), 6);
+ await ui.capture('all');
+ await page.getByRole('button', { name: await ui.t('bots.list.showLess'), exact: true }).click();
+ assert.equal(await rows.count(), 5);
+ await ui.capture('preview');
+ await showAll().click();
+ const header = page.getByRole('button', { name: await ui.t('bots.title'), exact: true });
+ await header.click();
+ await rows.first().waitFor({ state: 'hidden' });
+ await ui.capture('avatars');
+ await header.click();
+ assert.equal(await rows.count(), 5, 'reopening the section restores its compact preview');
+ },
+};
diff --git a/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx b/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx
index c2e98318db..a56296e1dd 100644
--- a/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx
+++ b/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx
@@ -92,6 +92,7 @@ const HEADER_ICON_BUTTON_CLASS =
/** 收起态头像行:28px 头像 + 8px 间距。 */
const AVATAR_SLOT_PX = 36;
+const CHAT_PREVIEW_LIMIT = 5;
/**
* 收起态只占一行:按内容宽度算出能放几个头像(含末尾「+N」),伙伴再多也不换行。
@@ -127,14 +128,17 @@ export function TeammatesSection() {
// The registered sidebar slot can sit outside the group's route context.
const selectedGroupId = matchPath('/bots/groups/:groupId', pathname)?.params.groupId;
const [collapsed, setCollapsed] = useState(() => readTeammatesSectionCollapsed(dataOwnerId));
+ const [showAllChats, setShowAllChats] = useState(false);
const avatarRowRef = useRef<HTMLDivElement>(null);
const avatarCapacity = useAvatarRowCapacity(avatarRowRef, collapsed);
useEffect(() => {
setCollapsed(readTeammatesSectionCollapsed(dataOwnerId));
+ setShowAllChats(false);
}, [dataOwnerId]);
const toggleCollapsed = () => {
const next = !collapsed;
setCollapsed(next);
+ setShowAllChats(false);
writeTeammatesSectionCollapsed(dataOwnerId, next);
};
const cloud = useCompanionCloud();
@@ -326,6 +330,17 @@ export function TeammatesSection() {
activityAt: Math.max(...cindyOptions.map(option => 'activityAt' in option.bot ? option.bot.activityAt : option.bot.lastMessageAt ?? option.bot.createdAt)) }] : []),
].sort((a, b) => Number(b.pinned) - Number(a.pinned) || b.activityAt - a.activityAt);
+ // Keep the open chat in the five-row preview without growing the section.
+ const selectedChat = visibleChats.find(entry => entry.kind === 'group'
+ ? entry.group.id === selectedGroupId
+ : entry.kind === 'cindy' ? Boolean(routeCindy)
+ : entry.bot.id === botId && ('deviceId' in entry.bot ? entry.bot.deviceId === deviceId : !deviceId));
+ const previewChats = visibleChats.slice(0, CHAT_PREVIEW_LIMIT);
+ if (selectedChat && !previewChats.includes(selectedChat)) {
+ previewChats[CHAT_PREVIEW_LIMIT - 1] = selectedChat;
+ }
+ const displayedChats = showAllChats ? visibleChats : previewChats;
+
useEffect(() => {
if (roster.visible.length + remoteBots.length + groups.length === 0) return;
const timer = setInterval(() => setNow(Date.now()), 30_000);
@@ -550,7 +565,7 @@ export function TeammatesSection() {
<Tip text={t('bots.list.sectionExpand')} side="bottom">
<button
type="button"
- onClick={toggleCollapsed}
+ onClick={() => { toggleCollapsed(); setShowAllChats(true); }}
aria-label={`${t('bots.list.sectionExpand')} · +${hidden.length}`}
className="relative flex h-7 min-w-7 shrink-0 items-center justify-center rounded-full bg-[var(--surface-chip)] px-1.5 text-11 font-medium tabular-nums text-[var(--sidebar-nav-text)] outline-none hover:bg-sidebar-item-hover focus-visible:ring-2 focus-visible:ring-ring"
>
@@ -579,7 +594,7 @@ export function TeammatesSection() {
</div>
) : (
<div className="flex flex-col gap-1">
- {visibleChats.map(entry => {
+ {displayedChats.map(entry => {
if (entry.kind === 'group') return renderGroupRow(entry.group);
if (entry.kind === 'cindy') {
if (!currentCindy) return null;
@@ -762,6 +777,20 @@ export function TeammatesSection() {
</div>
);
})}
+ {visibleChats.length > CHAT_PREVIEW_LIMIT ? (
+ <button
+ type="button"
+ aria-expanded={showAllChats}
+ onClick={() => setShowAllChats(value => !value)}
+ className={cn(
+ 'flex h-6 w-full items-center justify-center rounded-full px-2 text-xs font-normal',
+ 'text-[var(--cmd-palette-item-meta)] transition-colors hover:bg-sidebar-item-hover hover:text-foreground',
+ 'focus:outline-none focus-visible:ring-1 focus-visible:ring-[var(--focus-ring)]',
+ )}
+ >
+ {showAllChats ? t('bots.list.showLess') : t('ccAgent.sidebar.showAllSessions', { count: visibleChats.length })}
+ </button>
+ ) : null}
{roster.showHiddenSection ? (
<div className="mt-3 border-t border-[var(--border-default)] pt-3">
<button
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 1fbc094d02..b6ada39dd7 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -9013,6 +9013,7 @@
"duplicate": "Duplicate teammate",
"moreActions": "More actions for {{name}}",
"sectionExpand": "Expand teammates",
+ "showLess": "Show less",
"sectionCollapse": "Collapse teammates",
"noResults": "No matching teammates or groups"
},
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index d207dea2c1..a225a8c75d 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -8974,6 +8974,7 @@
"duplicate": "仲間を複製",
"moreActions": "{{name}} のその他の操作",
"sectionExpand": "仲間を展開",
+ "showLess": "折りたたむ",
"sectionCollapse": "仲間を折りたたむ",
"noResults": "一致するパートナーやグループはありません"
},
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index ac78aa0502..9d72d691a2 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -8974,6 +8974,7 @@
"duplicate": "동료 복제",
"moreActions": "{{name}} 추가 작업",
"sectionExpand": "동료 펼치기",
+ "showLess": "접기",
"sectionCollapse": "동료 접기",
"noResults": "검색과 일치하는 파트너나 그룹이 없어요"
},
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 20e1a4429b..d45e8c1346 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -8974,6 +8974,7 @@
"duplicate": "复制伙伴",
"moreActions": "{{name}} 的更多操作",
"sectionExpand": "展开伙伴",
+ "showLess": "收起",
"sectionCollapse": "收起伙伴",
"noResults": "没有匹配的伙伴或群聊"
},
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 9c7a51ad51..db0a9a6eee 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -8974,6 +8974,7 @@
"duplicate": "複製夥伴",
"moreActions": "{{name}} 的更多操作",
"sectionExpand": "展開夥伴",
+ "showLess": "收起",
"sectionCollapse": "收起夥伴",
"noResults": "找不到符合的夥伴或群組"
},
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index c1773d34d5..d7520b154d 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -658,6 +658,10 @@ download happens in the normal startup Splash, not in the row.
- Centered-card layouts (login, empty states) follow the Surface + Card two-layer rule in §2.
- Reading-width content (settings forms, document previews) is centered with a comfortable max width; full-bleed content (chat stream, file tree) fills its region.
+### Desktop teammate sidebar
+
+The expanded teammate section previews five chats (local teammates, remote teammates, groups and the merged Cindy device row share this limit). Keep the current chat visible within those five rows. Use the task list’s “Show all N” footer style, with “Show less” after expansion. Collapsing the section to its existing avatar strip resets the preview; the strip’s +N button opens the full list. This limit applies to the Desktop sidebar, not the Mobile teammate home list.
+
### Mobile iOS navigation chrome / iPhone Duo
- Home modes are ordered tabs: Tasks on the left, Teammates on the right (owner decision, 2026-10-13); the slide below is iOS-only, Android switches in place because its bar lives inside each pane. All mode-selection entry points, including drawer tabs and title scope menus, use the same horizontal slide via HomeModePanes / HomeModeTransition. Switching to Teammates moves content left; switching back moves it right. One shared progress owned by `ResidentHomeListProvider` drives the panes and the wide resident task list over the same slide distance; it moves on the critically damped spring registered in §14.4. Retain both visited lists and their positions, retarget interrupted slides from the current position, and snap for reduced/unknown motion preference or initial preference restoration. The resident list follows without remounting; inactive pages cannot intercept touches or accessibility focus. This is a selection transition, not a new horizontal gesture that competes with list controls.