Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@ vi.mock("../../../hooks/useLocale", () => ({

// Mock Tauri invoke for get_available_languages
vi.mock("@tauri-apps/api/core", () => ({
invoke: vi.fn().mockResolvedValue([
{ value: "english", display: "English" },
{ value: "chinese", display: "中文" },
{ value: "chinesetraditional", display: "繁體中文" },
{ value: "japanese", display: "日本語" },
{ value: "korean", display: "한국어" },
{ value: "spanish", display: "Español" },
{ value: "russian", display: "Русский" },
{ value: "turkish", display: "Türkçe" },
]),
invoke: vi.fn(async (command: string) => {
if (command === "get_app_info") {
return {
name: "CodexBar",
version: "0.60.3",
buildNumber: "42",
updateChannel: "stable",
tagline: "usage",
};
}
return [
{ value: "english", display: "English" },
{ value: "chinese", display: "中文" },
{ value: "chinesetraditional", display: "繁體中文" },
{ value: "japanese", display: "日本語" },
{ value: "korean", display: "한국어" },
{ value: "spanish", display: "Español" },
{ value: "russian", display: "Русский" },
{ value: "turkish", display: "Türkçe" },
];
}),
}));

vi.mock("@tauri-apps/plugin-dialog", () => ({
Expand Down Expand Up @@ -96,6 +107,14 @@ const settings: SettingsSnapshot = {
showResetWhenExhausted: false,
};

describe("GeneralTab running version", () => {
it("shows the running app version on the general tab", async () => {
render(<GeneralTab settings={settings} set={vi.fn()} saving={false} />);

expect(await screen.findByText("0.60.3 (42)")).toBeInTheDocument();
});
});

describe("GeneralTab language picker", () => {
it("renders all supported language options", () => {
render(<GeneralTab settings={settings} set={vi.fn()} saving={false} />);
Expand Down
26 changes: 25 additions & 1 deletion apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useCallback, useEffect, useState } from "react";
import { useLocale } from "../../../hooks/useLocale";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import { playNotificationSound, quitApp } from "../../../lib/tauri";
import { getAppInfo, playNotificationSound, quitApp } from "../../../lib/tauri";
import type { AppInfoBridge } from "../../../types/bridge";
import { Field, NumberInput, Select, Toggle } from "../../../components/FormControls";
import type {
Language,
Expand Down Expand Up @@ -199,6 +200,14 @@ export default function GeneralTab({
.catch(() => {}); // graceful fallback to static default
}, []);

const [appVersion, setAppVersion] = useState<AppInfoBridge | null>(null);

useEffect(() => {
getAppInfo()
.then(setAppVersion)
.catch(() => {}); // version row degrades to absent, never blocks the tab
}, []);

const handleTestSound = useCallback((event: NotificationSoundEvent) => {
setSoundError(null);
setPlayingSound(event);
Expand Down Expand Up @@ -576,6 +585,21 @@ export default function GeneralTab({
</div>
</div>
</section>}

{/* ── Running version (upstream 0.64.0 #3806) ─────────────── */}
{mode === "general" && appVersion && (
<section className="settings-section">
<h3 className="settings-section__title">{t("Version")}</h3>
<div className="settings-section__group">
<Field label={appVersion.name}>
<span className="about-version">
{appVersion.version}
{appVersion.buildNumber !== "dev" && ` (${appVersion.buildNumber})`}
</span>
</Field>
</div>
</section>
)}
</>
);
}