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): show personal version in sidebar

MagicLizi2e0acb21dd17
diff --git a/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts b/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts
index 526d7c76f1..82f3c04811 100644
--- a/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts
+++ b/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts
@@ -83,8 +83,11 @@ describe('UserInfoSection — version label', () => {
/const appVersionLabel = appRegionLabel\s*\n\s*\? `\$\{appRegionLabel\} · \$\{appDisplayVersion\}`\s*\n\s*: appDisplayVersion;/,
);
expect(source).not.toContain('XD.Inc');
- expect(source).toContain('{appVersionLabel}');
- expect(source).toContain('title={appVersionLabelDetail}');
+ expect(source).toContain("import { useCindyVersions } from '@/lib/useCindyVersions';");
+ expect(source).toContain('const versions = useCindyVersions();');
+ expect(source).toContain("t('cindyMake.versions.personal')");
+ expect(source).toContain('{visibleVersionLabel}');
+ expect(source).toContain('title={visibleVersionLabelDetail}');
});
it('shows the Beta label only after the persisted channel state has loaded', () => {
diff --git a/apps/desktop/src/renderer/__tests__/userInfoSectionUpdateFlame.test.tsx b/apps/desktop/src/renderer/__tests__/userInfoSectionUpdateFlame.test.tsx
index 21d9bf62ac..3d9b593158 100644
--- a/apps/desktop/src/renderer/__tests__/userInfoSectionUpdateFlame.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/userInfoSectionUpdateFlame.test.tsx
@@ -8,6 +8,10 @@
import { cleanup, render, screen } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+const { useCindyVersionsMock } = vi.hoisted(() => ({
+ useCindyVersionsMock: vi.fn(),
+}));
+
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
@@ -41,6 +45,10 @@ vi.mock('@/hooks/useBetaChannelSettings', () => ({
}),
}));
+vi.mock('@/lib/useCindyVersions', () => ({
+ useCindyVersions: useCindyVersionsMock,
+}));
+
vi.mock('@/hooks/useLogout', () => ({
useLogout: () => ({ handleLogout: vi.fn() }),
}));
@@ -56,6 +64,7 @@ vi.mock('@/components/ui/tooltip', () => ({
import { UserInfoSection } from '@/components/sidebar/UserInfoSection';
beforeEach(() => {
+ useCindyVersionsMock.mockReturnValue({ state: undefined });
Object.defineProperty(window, 'electronAPI', {
configurable: true,
value: {
@@ -80,4 +89,17 @@ describe('UserInfoSection update flame vs rail', () => {
expect(screen.getByRole('button', { name: 'sidebar.user.reopenUpdateBanner' })).toBeTruthy();
});
+
+ it('shows the personal version label when the running app is personal', () => {
+ useCindyVersionsMock.mockReturnValue({
+ state: {
+ currentId: 'personal',
+ },
+ });
+
+ render(<UserInfoSection isCollapsed={false} />);
+
+ expect(screen.getByText('cindyMake.versions.personal')).toBeTruthy();
+ expect(screen.queryByText('1.0.0')).toBeNull();
+ });
});
diff --git a/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx b/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx
index 3237fa5df7..19548e2f4f 100644
--- a/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx
+++ b/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx
@@ -18,6 +18,7 @@ import { useOptionalConfirmDialog } from '@/components/ui/confirm-dialog-provide
import { useUpdateStatus } from '@/hooks/useUpdateStatus';
import { useUpdateBannerDismiss } from '@/hooks/useUpdateBannerDismiss';
import { useBetaChannelSettings } from '@/hooks/useBetaChannelSettings';
+import { useCindyVersions } from '@/lib/useCindyVersions';
import { Tip } from '@/components/ui/tooltip';
import { Spinner } from '@/components/ui/spinner';
import {
@@ -93,6 +94,7 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
const { status } = useUpdateStatus();
const { dismissed, restore } = useUpdateBannerDismiss();
const { state: betaChannelState } = useBetaChannelSettings();
+ const versions = useCindyVersions();
const hasPendingUpdate = status === 'ready' || status === 'superseding';
const isFlameReopen = hasPendingUpdate && dismissed;
const showBetaLabel = !betaChannelState.loading && betaChannelState.enableBeta;
@@ -145,6 +147,14 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
const appVersionLabelDetail = appRegionLabel
? `${appRegionLabel} · ${appDisplayVersionDetail}`
: appDisplayVersionDetail;
+ const isPersonalVersion =
+ versions.state?.currentId !== undefined && versions.state.currentId !== 'original';
+ const visibleVersionLabel = isPersonalVersion
+ ? t('cindyMake.versions.personal')
+ : appVersionLabel;
+ const visibleVersionLabelDetail = isPersonalVersion
+ ? t('cindyMake.versions.personal') + ' · ' + appDisplayVersionDetail
+ : appVersionLabelDetail;
const remoteAvailable = mode === 'cloud';
const openSettings = () => {
@@ -495,9 +505,9 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
{/* 2px gap 与同栏 userNameContainer 保持一致。 */}
<p
className="flex min-w-0 items-center gap-1 text-10 leading-[1.3] text-[var(--sidebar-user-card-text)]"
- title={appVersionLabelDetail}
+ title={visibleVersionLabelDetail}
>
- <span className="truncate opacity-80">{appVersionLabel}</span>
+ <span className="truncate opacity-80">{visibleVersionLabel}</span>
{showBetaLabel ? (
<span
className="shrink-0 select-none opacity-80"