Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): make all login accounts reachable (#3323)
weikl666-xd280d2771698e
diff --git a/apps/desktop/src/renderer/components/login/LoginPage.tsx b/apps/desktop/src/renderer/components/login/LoginPage.tsxindex a0bc61b09c..2211cfb1a7 100644--- a/apps/desktop/src/renderer/components/login/LoginPage.tsx+++ b/apps/desktop/src/renderer/components/login/LoginPage.tsx@@ -24,6 +24,7 @@ import { captchaRequiredActionForVerificationKind, isValidEmail } from '@cindy/aimport { cn } from '@/lib/utils';import { createLogger } from '@/lib/logger';import { setLoginEmailCaptchaGate } from '@/lib/loginCaptchaGate';+import { flashScrollbar } from '@/lib/scrollbarAutoHide';import { WindowControls } from '@/components/title-bar/WindowControls';import { ChromeIconButton } from '@/components/title-bar/ChromeIconButton';import { useLogin } from '@/hooks/useLogin';@@ -65,11 +66,14 @@ import { shouldLabelRegion } from '../../../shared/regionCode';import { LEGAL_LINKS } from '../../../shared/legalLinks';import { resolveIdentifierMethod } from '../../../shared/loginIdentifierMethod';import {+ ACCOUNT_LIST,DRAG_BAR_HEIGHT,LOADING_RING,LOGIN_COLORS,LOGIN_DELETION_BUBBLE,LOGIN_LOCAL_MODE,+ METHOD_ROW,+ PANEL,SSO_ORG_HINT,} from './loginDesignTokens';import { PANEL_FIXED_SCALE } from './loginScale';@@ -146,8 +150,15 @@ export function LoginPage({const handoff = useLoginHandoff();const isAddAccount = intent === 'add-account';const accountSwitcherTriggerRef = useRef<HTMLButtonElement>(null);+ const accountListRef = useRef<HTMLDivElement>(null);const [accountSwitcherOpen, setAccountSwitcherOpen] = useState(false);const [hasSavedAccounts, setHasSavedAccounts] = useState(false);+ const accountCount = loginState?.step === 'account-selection' ? loginState.accounts.length : 0;++ useEffect(() => {+ if (accountCount <= 3 || !accountListRef.current) return;+ flashScrollbar(accountListRef.current);+ }, [accountCount]);useEffect(() => {if (isAddAccount || !listAccounts) {@@ -1055,6 +1066,14 @@ export function LoginPage({/* ── account-selection(行样式复用方式行) ── */const renderAccountSelection = () => {if (loginState?.step !== 'account-selection') return null;+ const viewportHeight = PANEL.height - ACCOUNT_LIST.top - ACCOUNT_LIST.bottom;+ const contentHeight = Math.max(+ viewportHeight,+ ACCOUNT_LIST.rowTop ++ (loginState.accounts.length - 1) * ACCOUNT_LIST.rowStep ++ METHOD_ROW.height ++ ACCOUNT_LIST.bottomPadding,+ );return (<LoginPanel testId="login-panel-account-selection"><LoginBackButton disabled={isLoading} label={t('login.back')} onClick={reset} />@@ -1062,23 +1081,37 @@ export function LoginPage({title={t('login.chooseAccount')}subtitle={t('login.chooseAccountSubtitle')}/>- {/* demo accountPanel 呈现仲裁:行 148/268(step 120),左 icon 统一企业默认形- (demo 两行均未传 icon 变体);副行 = 企业 meta / 个人身份 */}- {loginState.accounts.map((account, index) => (- <LoginMethodRow- key={account.id}- top={148 + index * 120}- disabled={isLoading}- title={account.displayName}- subtitle={- account.kind === 'org'- ? account.orgName || account.email || ''- : t('login.personalAccount')- }- logoUrl={account.kind === 'org' ? (account.orgLogoUrl ?? null) : null}- onClick={() => void dispatch({ type: 'select-account', accountId: account.id })}- />- ))}+ {/* 标题区固定;身份卡片独立滚动。1–3 个身份保持原构图,更多身份不再+ 被面板的 overflow-hidden 裁掉。 */}+ <div+ ref={accountListRef}+ data-testid="login-account-list"+ className="absolute left-0 overflow-x-hidden overscroll-contain"+ style={{+ top: ACCOUNT_LIST.top,+ width: PANEL.width,+ height: viewportHeight,+ overflowY: loginState.accounts.length > 3 ? 'auto' : 'hidden',+ }}+ >+ <div className="relative" style={{ height: contentHeight }}>+ {loginState.accounts.map((account, index) => (+ <LoginMethodRow+ key={account.id}+ top={ACCOUNT_LIST.rowTop + index * ACCOUNT_LIST.rowStep}+ disabled={isLoading}+ title={account.displayName}+ subtitle={+ account.kind === 'org'+ ? account.orgName || account.email || ''+ : t('login.personalAccount')+ }+ logoUrl={account.kind === 'org' ? (account.orgLogoUrl ?? null) : null}+ onClick={() => void dispatch({ type: 'select-account', accountId: account.id })}+ />+ ))}+ </div>+ </div></LoginPanel>);};diff --git a/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx b/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsxindex 57709b0e69..25740ba787 100644--- a/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx+++ b/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx@@ -33,6 +33,7 @@ const loginHook = vi.hoisted(() => ({clearError: vi.fn(),},}));+const flashScrollbar = vi.hoisted(() => vi.fn());vi.mock('react-i18next', () => ({useTranslation: () => ({@@ -51,6 +52,7 @@ vi.mock('../../../../shared/brandRegion', () => ({}));vi.mock('@/hooks/useLogin', () => ({ useLogin: () => loginHook.value }));vi.mock('@/components/title-bar/WindowControls', () => ({ WindowControls: () => null }));+vi.mock('@/lib/scrollbarAutoHide', () => ({ flashScrollbar }));import { LoginPage } from '../LoginPage';@@ -286,17 +288,67 @@ describe('verification-code', () => {/* ── account-selection / binding / browser-redirect / error / completed ── */describe('account-selection', () => {- it('outcome select_account → 双身份行 148/268(demo 行样式,左 icon 企业默认形)', async () => {+ it('outcome select_account → 双身份行保持面板坐标 148/268', async () => {mount(await outcomeState('outcome:select-account'));expect(screen.getByTestId('login-panel-account-selection')).toBeTruthy();+ const list = screen.getByTestId('login-account-list');const rows = screen.getAllByTestId('login-method-row');expect(rows.length).toBe(2);- expect(rows[0].style.top).toBe('148px');- expect(rows[1].style.top).toBe('268px');+ expect(Number.parseInt(list.style.top) + Number.parseInt(rows[0].style.top)).toBe(148);+ expect(Number.parseInt(list.style.top) + Number.parseInt(rows[1].style.top)).toBe(268);+ expect(list.style.overflowY).toBe('hidden');expect(rows[0].textContent).toContain('Scenario User');expect(rows[0].textContent).toContain('login.personalAccount');expect(rows[1].textContent).toContain('Scenario Org User');expect(rows[1].textContent).toContain('Example Org');+ expect(flashScrollbar).not.toHaveBeenCalled();+ });++ it('五个身份都能通过面板内滚动区域访问并选择第四个企业', async () => {+ const dispatch = vi.fn(async () => true);+ mount(+ {+ step: 'account-selection',+ accounts: [+ {+ id: 'personal',+ kind: 'personal',+ role: 'owner',+ displayName: 'weikailing',+ email: '[email protected]',+ orgId: null,+ orgName: null,+ },+ ...['心动网络', '平台测试企业', 'XDS', '22'].map((orgName, index) => ({+ id: `org-${index + 1}`,+ kind: 'org' as const,+ role: 'admin' as const,+ displayName: 'weikailing',+ email: '[email protected]',+ orgId: `org-${index + 1}`,+ orgName,+ })),+ ],+ },+ { dispatch },+ );++ const list = screen.getByTestId('login-account-list');+ const rows = screen.getAllByTestId('login-method-row');+ const content = list.firstElementChild as HTMLElement;+ expect(rows).toHaveLength(5);+ expect(list.style.overflowY).toBe('auto');+ expect(Number.parseInt(content.style.height)).toBeGreaterThan(+ Number.parseInt(list.style.height),+ );+ expect(Number.parseInt(list.style.top) + Number.parseInt(rows[2].style.top)).toBe(388);+ expect(rows[3].textContent).toContain('XDS');+ await vi.waitFor(() => expect(flashScrollbar).toHaveBeenCalledWith(list));++ await act(async () => {+ fireEvent.click(rows[3]);+ });+ expect(dispatch).toHaveBeenCalledWith({ type: 'select-account', accountId: 'org-3' });});});diff --git a/apps/desktop/src/renderer/components/login/loginDesignTokens.ts b/apps/desktop/src/renderer/components/login/loginDesignTokens.tsindex 0fea61d796..a4b0ef7b2d 100644--- a/apps/desktop/src/renderer/components/login/loginDesignTokens.ts+++ b/apps/desktop/src/renderer/components/login/loginDesignTokens.ts@@ -92,6 +92,18 @@ export const LOGIN_LOCAL_MODE = {* 500,见 SPLASH_PANEL.height。*/export const PANEL = { width: 680, height: 500, radius: 36 } as const;++/**+ * 身份选择列表视口。标题区固定不动,身份超过三项时只滚动卡片区;首行的+ * 面板坐标仍为 y=148,避免修复可达性时改变既有登录构图。+ */+export const ACCOUNT_LIST = {+ top: 136,+ bottom: 12,+ rowTop: 12,+ rowStep: 120,+ bottomPadding: 12,+} as const;export const TITLE = { y: 31, height: 38, fontSize: 32 } as const;/** 副标题:540@70 ≤2 行顶对齐,槽高 = 行高 × 最大行数(DESIGN.md §16.2,2026-07-24 拍板)。 */export const SUBTITLE = { x: 70, y: 75, width: 540, fontSize: 20, lineHeight: 23, maxLines: 2 } as const;diff --git a/docs/design-previews/login-account-scroll/README.md b/docs/design-previews/login-account-scroll/README.mdnew file mode 100644index 0000000000..0798fe5ca6--- /dev/null+++ b/docs/design-previews/login-account-scroll/README.md@@ -0,0 +1,10 @@+# Desktop 登录身份列表滚动证据++PR #3323 的 macOS Electron 实际渲染截图,用于证明登录身份超过 3 项时仍可访问后续身份。++- [滚动前:前三项保持原构图](./evidence/macos-five-accounts-before-scroll.png)+- [滚动后:第 4 项 XDS 与第 5 项 22 完整可见](./evidence/macos-five-accounts-after-scroll.png)++验证环境:2026-08-28,macOS,CN Desktop dev,1280 × 800,devicePixelRatio 2,独立 userData 沙箱。认证响应来自开发专用离线场景,只用于验证 Desktop 的布局、滚动与身份选择动作,不代表真实企业账号的完整端到端登录。++可复核数据:列表视口 352 CSS px,内容高度 604 CSS px,滚动到底部时 `scrollTop=252`;`平台测试企业`、`XDS`、`22` 均完整位于列表视口内。diff --git a/docs/design-previews/login-account-scroll/evidence/macos-five-accounts-after-scroll.png b/docs/design-previews/login-account-scroll/evidence/macos-five-accounts-after-scroll.pngnew file mode 100644index 0000000000..168a4dfbefBinary files /dev/null and b/docs/design-previews/login-account-scroll/evidence/macos-five-accounts-after-scroll.png differdiff --git a/docs/design-previews/login-account-scroll/evidence/macos-five-accounts-before-scroll.png b/docs/design-previews/login-account-scroll/evidence/macos-five-accounts-before-scroll.pngnew file mode 100644index 0000000000..dffcd25dfbBinary files /dev/null and b/docs/design-previews/login-account-scroll/evidence/macos-five-accounts-before-scroll.png differ