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(bots): 修复伙伴设备选择器的夜间模式显示 (#5066)

Dash0b5d104a2cd0
diff --git a/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx b/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx
index 94206fcf3f..170ea8f3ea 100644
--- a/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx
+++ b/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx
@@ -90,10 +90,11 @@ export function CindyDeviceRow({
current={current}
onSelect={onSelect}
className={cn(
- 'pointer-events-auto col-span-2 -mx-2 border-0 bg-transparent text-12 text-inherit focus-visible:ring-inset',
- 'enabled:hover:bg-sidebar-item-hover enabled:active:bg-sidebar-item-hover',
+ 'pointer-events-auto col-span-2 -mx-2 text-12 text-inherit focus-visible:ring-inset',
+ '[--button-face-bg:transparent] [--button-face-border:transparent] [--button-face-outset:0px]',
+ 'enabled:[&:not([aria-disabled=true])]:hover:[--button-face-bg:var(--sidebar-item-hover)] enabled:[&:not([aria-disabled=true])]:active:[--button-face-bg:var(--sidebar-item-hover)]',
selected &&
- 'enabled:hover:bg-[color-mix(in_srgb,currentColor_10%,transparent)] enabled:active:bg-[color-mix(in_srgb,currentColor_16%,transparent)]',
+ 'enabled:[&:not([aria-disabled=true])]:hover:[--button-face-bg:color-mix(in_srgb,currentColor_10%,transparent)] enabled:[&:not([aria-disabled=true])]:active:[--button-face-bg:color-mix(in_srgb,currentColor_16%,transparent)]',
)}
/>
<span
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/CindyDevicePicker.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/CindyDevicePicker.test.tsx
index c9ddd97be6..72081e7611 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/CindyDevicePicker.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/CindyDevicePicker.test.tsx
@@ -17,15 +17,86 @@ vi.mock('@/features/device-link/useDeviceLinkDeviceList', () => ({
}));
import { CindyDevicePicker } from '../CindyDevicePicker';
+import { CindyDeviceRow } from '../CindyDeviceRow';
import { cindyDeviceOptions } from '../cindyDeviceRoster';
import type { BotProfile } from '../botStore';
const originalScrollIntoView = HTMLElement.prototype.scrollIntoView;
-beforeAll(() => { HTMLElement.prototype.scrollIntoView = vi.fn(); });
-afterAll(() => { HTMLElement.prototype.scrollIntoView = originalScrollIntoView; });
+beforeAll(() => {
+ HTMLElement.prototype.scrollIntoView = vi.fn();
+});
+afterAll(() => {
+ HTMLElement.prototype.scrollIntoView = originalScrollIntoView;
+});
afterEach(cleanup);
+it.each([true, false])(
+ 'keeps the sidebar device picker on its row surface (selected=%s)',
+ async (selected) => {
+ const i18n = createInstance();
+ await i18n.init({ lng: 'en', resources: { en: { translation: en } } });
+ const options = cindyDeviceOptions(
+ [{ id: 'cindy-default', name: 'Cindy', status: 'active' } as BotProfile],
+ [
+ {
+ id: 'cindy-default',
+ deviceId: 'remote',
+ deviceName: 'Mac mini',
+ name: 'Cindy',
+ avatar: '',
+ avatarColor: '',
+ description: '',
+ preview: '',
+ activityAt: 0,
+ sessionId: 'remote-chat',
+ online: false,
+ lastReplyAt: 20,
+ readAt: 10,
+ },
+ ],
+ [],
+ {},
+ 'This Device',
+ );
+ expect(options).toHaveLength(2);
+ const onSelect = vi.fn();
+ render(
+ <I18nextProvider i18n={i18n}>
+ <CindyDeviceRow
+ current={options[0]}
+ options={options}
+ selected={selected}
+ subtitle="Ready"
+ timestamp="12:00"
+ onOpen={vi.fn()}
+ onSelect={onSelect}
+ />
+ </I18nextProvider>,
+ );
+ expect(screen.getByTestId('cindy-device-row').className).toContain(
+ selected ? 'bg-sidebar-item-active' : 'text-[var(--sidebar-nav-text)]',
+ );
+ const trigger = screen.getByRole('combobox');
+ expect(trigger.className).toContain('text-inherit');
+ expect(trigger.className).toContain('[--button-face-bg:transparent]');
+ expect(trigger.className).toContain('[--button-face-border:transparent]');
+ expect(trigger.className).not.toContain('[--button-face-bg:var(--surface-elevated)]');
+ expect(trigger.className).not.toContain('text-[var(--text-primary)]');
+ expect(trigger.className).not.toContain(
+ 'hover:[--button-face-bg:var(--button-secondary-hover)]',
+ );
+ expect(trigger.className).toContain(
+ selected
+ ? 'hover:[--button-face-bg:color-mix(in_srgb,currentColor_10%,transparent)]'
+ : 'hover:[--button-face-bg:var(--sidebar-item-hover)]',
+ );
+ fireEvent.keyDown(trigger, { key: 'ArrowDown' });
+ fireEvent.click(await screen.findByRole('option', { name: /Mac mini/ }));
+ expect(onSelect).toHaveBeenCalledWith(options[1]);
+ },
+);
+
describe('Cindy device menu with real translations', () => {
it.each([
['zh-CN', zhCN, '本机'],