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。

feat(desktop): show Pi version in About settings

Lizif920d3e2d2fe
diff --git a/apps/desktop/src/renderer/components/settings/AboutSection.tsx b/apps/desktop/src/renderer/components/settings/AboutSection.tsx
index d1095faf80..40a4c6e12c 100644
--- a/apps/desktop/src/renderer/components/settings/AboutSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/AboutSection.tsx
@@ -3,8 +3,7 @@
*
* 版本号:
* - 应用版本号:仅国内版显示,值由 window.electronAPI.appDisplayVersion 同步注入
- * - Claude Code 版本号: spawn 当前应用使用的 binary `--version`
- * - Codex 版本号: 同上
+ * - Claude Code / Codex / Pi 版本号: spawn 当前应用使用的 binary `--version`
*
* 卡片样式与 NotificationSection / FeishuBotSection 同级 (rounded-xl / Board border)。
*/
@@ -55,7 +54,7 @@ const DESKTOP_SOCIAL_LINKS = [
},
] as const;
-function useAgentBinaryVersion(kind: 'claude-code' | 'codex'): AgentVersionState {
+function useAgentBinaryVersion(kind: 'claude-code' | 'codex' | 'pi'): AgentVersionState {
const [state, setState] = useState<AgentVersionState>(INITIAL);
useEffect(() => {
@@ -92,10 +91,38 @@ function renderVersion(state: AgentVersionState, t: (key: string) => string): st
return t('settings.about.version.unknown');
}
-export function AboutSection() {
+export function AgentVersionsRows() {
const { t } = useTranslation();
const claudeCode = useAgentBinaryVersion('claude-code');
const codex = useAgentBinaryVersion('codex');
+ const pi = useAgentBinaryVersion('pi');
+
+ return (
+ <>
+ <InfoRow
+ label={t('settings.about.claudeCodeVersionLabel')}
+ value={renderVersion(claudeCode, t)}
+ dim={!claudeCode.version}
+ />
+ <Divider />
+ <InfoRow
+ label={t('settings.about.codexVersionLabel')}
+ value={renderVersion(codex, t)}
+ dim={!codex.version}
+ />
+ <Divider />
+ <InfoRow
+ label={t('settings.about.piVersionLabel')}
+ value={renderVersion(pi, t)}
+ dim={!pi.version}
+ />
+ <Divider />
+ </>
+ );
+}
+
+export function AboutSection() {
+ const { t } = useTranslation();
return (
<div className="flex flex-col gap-3">
@@ -130,18 +157,7 @@ export function AboutSection() {
<Divider />
<AnalyticsToggleRow />
<Divider />
- <InfoRow
- label={t('settings.about.claudeCodeVersionLabel')}
- value={renderVersion(claudeCode, t)}
- dim={!claudeCode.version}
- />
- <Divider />
- <InfoRow
- label={t('settings.about.codexVersionLabel')}
- value={renderVersion(codex, t)}
- dim={!codex.version}
- />
- <Divider />
+ <AgentVersionsRows />
<DebugLogToggleRow />
<Divider />
<OpenLogsRow />
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/AboutSection.binaryVersions.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/AboutSection.binaryVersions.test.tsx
new file mode 100644
index 0000000000..4a00b37829
--- /dev/null
+++ b/apps/desktop/src/renderer/components/settings/__tests__/AboutSection.binaryVersions.test.tsx
@@ -0,0 +1,74 @@
+// @vitest-environment jsdom
+
+import { cleanup, render, screen, waitFor } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (key: string) => key,
+ }),
+}));
+
+import { AgentVersionsRows } from '../AboutSection';
+
+const getBinaryVersion = vi.fn();
+
+describe('AboutSection agent binary versions', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ (window as unknown as { electronAPI: unknown }).electronAPI = {
+ maker: {
+ agent: {
+ getBinaryVersion,
+ },
+ },
+ };
+ });
+
+ afterEach(() => {
+ cleanup();
+ Reflect.deleteProperty(window, 'electronAPI');
+ });
+
+ it('requests and renders Claude Code, Codex, and Pi versions', async () => {
+ getBinaryVersion.mockImplementation((kind: string) =>
+ Promise.resolve({
+ kind,
+ binaryPath: `/${kind}`,
+ version:
+ kind === 'claude-code'
+ ? '2.1.258 (Claude Code)'
+ : kind === 'codex'
+ ? 'codex-cli 0.145.0'
+ : 'pi 0.84.4',
+ }),
+ );
+
+ render(<AgentVersionsRows />);
+
+ await waitFor(() => expect(getBinaryVersion).toHaveBeenCalledTimes(3));
+ expect(getBinaryVersion).toHaveBeenCalledWith('claude-code');
+ expect(getBinaryVersion).toHaveBeenCalledWith('codex');
+ expect(getBinaryVersion).toHaveBeenCalledWith('pi');
+ await waitFor(() => {
+ expect(screen.getByText('settings.about.claudeCodeVersionLabel')).toBeTruthy();
+ expect(screen.getByText('settings.about.codexVersionLabel')).toBeTruthy();
+ expect(screen.getByText('settings.about.piVersionLabel')).toBeTruthy();
+ expect(screen.getByText('0.84.4')).toBeTruthy();
+ });
+ });
+
+ it('shows the existing not-ready state when Pi is unavailable', async () => {
+ getBinaryVersion.mockImplementation((kind: string) =>
+ Promise.resolve(
+ kind === 'pi'
+ ? { kind, binaryPath: null, version: null, error: 'binary_not_ready' }
+ : { kind, binaryPath: `/${kind}`, version: '1.0.0' },
+ ),
+ );
+
+ render(<AgentVersionsRows />);
+
+ await waitFor(() => expect(screen.getByText('settings.about.version.notReady')).toBeTruthy());
+ });
+});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 90d9678536..c1f98ffd71 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -787,6 +787,7 @@
"appVersionLabel": "App version",
"claudeCodeVersionLabel": "Claude Code version",
"codexVersionLabel": "Codex version",
+ "piVersionLabel": "Pi version",
"logsDirLabel": "Logs directory",
"openLogsDir": "Open",
"openLogsDirTooltip": "Open the logs directory in the system file manager",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index d410a9c8db..da76e8051c 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -787,6 +787,7 @@
"appVersionLabel": "アプリのバージョン",
"claudeCodeVersionLabel": "Claude Code バージョン",
"codexVersionLabel": "Codex バージョン",
+ "piVersionLabel": "Pi バージョン",
"logsDirLabel": "ログディレクトリ",
"openLogsDir": "開く",
"openLogsDirTooltip": "システムのファイルマネージャーでログディレクトリを開く",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index af2be80296..471e60100b 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -787,6 +787,7 @@
"appVersionLabel": "앱 버전",
"claudeCodeVersionLabel": "Claude Code 버전",
"codexVersionLabel": "Codex 버전",
+ "piVersionLabel": "Pi 버전",
"logsDirLabel": "로그 디렉터리",
"openLogsDir": "열기",
"openLogsDirTooltip": "시스템 파일 관리자에서 로그 디렉터리 열기",
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 e1d060e7bc..5564f32d71 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -787,6 +787,7 @@
"appVersionLabel": "应用版本号",
"claudeCodeVersionLabel": "Claude Code 版本号",
"codexVersionLabel": "Codex 版本号",
+ "piVersionLabel": "Pi 版本号",
"logsDirLabel": "日志目录",
"openLogsDir": "打开",
"openLogsDirTooltip": "在系统文件管理器中打开日志目录",
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 0d845e3df8..0ed4eab8c6 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -787,6 +787,7 @@
"appVersionLabel": "應用版本號",
"claudeCodeVersionLabel": "Claude Code 版本號",
"codexVersionLabel": "Codex 版本號",
+ "piVersionLabel": "Pi 版本號",
"logsDirLabel": "日誌目錄",
"openLogsDir": "開啟",
"openLogsDirTooltip": "在系統檔案管理器中開啟日誌目錄",