feat(about): show the desktop version and the web build's commit and date (#276)
CI / Build & Quality Checks (pull_request) Successful in 1m46s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 13s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m27s
CI / Build & Quality Checks (pull_request) Successful in 1m46s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 13s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m27s
Settings → About only showed cinny's package version, the same on web and desktop and unchanged across many deploys a day. vite.config.js now stamps the short commit (git, or LOTUS_BUILD_COMMIT; "unknown" without git) and build time into the bundle, and About shows "Web build <commit> · built <date>", linking the commit. On desktop it also shows "Desktop <version>" from Tauri's built-in plugin:app|version (allowed by core:default). Fixes #276 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e1168f47bb
commit
72277399f0
@@ -8,6 +8,7 @@ import { getOriginBaseUrl, withOriginBaseUrl } from '../../../pages/pathUtils';
|
|||||||
import pkg from '../../../../../package.json';
|
import pkg from '../../../../../package.json';
|
||||||
import { clearCacheAndReload } from '../../../../client/initMatrix';
|
import { clearCacheAndReload } from '../../../../client/initMatrix';
|
||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
|
import { tauriInvoke } from '../../../hooks/useTauri';
|
||||||
|
|
||||||
const LotusLogo = withOriginBaseUrl(getOriginBaseUrl(), '/public/res/lotus-logo.png');
|
const LotusLogo = withOriginBaseUrl(getOriginBaseUrl(), '/public/res/lotus-logo.png');
|
||||||
|
|
||||||
@@ -78,6 +79,51 @@ function useServerSupport(): { support: MSC1929Support | null; loading: boolean
|
|||||||
type AboutProps = {
|
type AboutProps = {
|
||||||
requestClose: () => void;
|
requestClose: () => void;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* [Gitea #276] Which build someone is on: the web deploy's commit and build
|
||||||
|
* date (stamped in by vite.config.js), plus the desktop app's own version from
|
||||||
|
* Tauri, the number a desktop or updater bug report needs.
|
||||||
|
*/
|
||||||
|
function BuildInfo() {
|
||||||
|
const [desktopVersion, setDesktopVersion] = useState<string>();
|
||||||
|
useEffect(() => {
|
||||||
|
tauriInvoke()?.('plugin:app|version')
|
||||||
|
.then((v) => {
|
||||||
|
if (typeof v === 'string') setDesktopVersion(v);
|
||||||
|
})
|
||||||
|
.catch(() => undefined);
|
||||||
|
}, []);
|
||||||
|
const commit = __LOTUS_BUILD_COMMIT__;
|
||||||
|
const built = new Date(__LOTUS_BUILD_DATE__);
|
||||||
|
const builtText = Number.isNaN(built.getTime())
|
||||||
|
? undefined
|
||||||
|
: built.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });
|
||||||
|
return (
|
||||||
|
<Box direction="Column" gap="0">
|
||||||
|
{desktopVersion && (
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
Desktop {desktopVersion}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
Web build{' '}
|
||||||
|
{commit !== 'unknown' ? (
|
||||||
|
<a
|
||||||
|
href={`https://code.lotusguild.org/LotusGuild/cinny/commit/${commit}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer noopener"
|
||||||
|
>
|
||||||
|
{commit}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
commit
|
||||||
|
)}
|
||||||
|
{builtText && ` · built ${builtText}`}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function About({ requestClose }: AboutProps) {
|
export function About({ requestClose }: AboutProps) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
const { support: serverSupport, loading: supportLoading } = useServerSupport();
|
const { support: serverSupport, loading: supportLoading } = useServerSupport();
|
||||||
@@ -117,6 +163,7 @@ export function About({ requestClose }: AboutProps) {
|
|||||||
<Text size="T200">v{pkg.version}</Text>
|
<Text size="T200">v{pkg.version}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<Text>A Matrix client for Lotus Guild.</Text>
|
<Text>A Matrix client for Lotus Guild.</Text>
|
||||||
|
<BuildInfo />
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box gap="200" wrap="Wrap">
|
<Box gap="200" wrap="Wrap">
|
||||||
|
|||||||
Vendored
+4
@@ -1,5 +1,9 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
// [Gitea #276] Set by vite.config.js `define`.
|
||||||
|
declare const __LOTUS_BUILD_COMMIT__: string;
|
||||||
|
declare const __LOTUS_BUILD_DATE__: string;
|
||||||
|
|
||||||
declare module 'browser-encrypt-attachment' {
|
declare module 'browser-encrypt-attachment' {
|
||||||
export interface EncryptedAttachmentInfo {
|
export interface EncryptedAttachmentInfo {
|
||||||
v: string;
|
v: string;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|||||||
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
||||||
import { VitePWA } from 'vite-plugin-pwa';
|
import { VitePWA } from 'vite-plugin-pwa';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import buildConfig from './build.config';
|
import buildConfig from './build.config';
|
||||||
|
|
||||||
@@ -272,8 +273,26 @@ const vendorChunks = (id) => {
|
|||||||
if (id.includes('node_modules/chroma-js')) return 'chroma';
|
if (id.includes('node_modules/chroma-js')) return 'chroma';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// [Gitea #276] Which build is this? The short commit and build time are shown
|
||||||
|
// in Settings → About (web deploys change many times a day while the package
|
||||||
|
// version stays the same). LOTUS_BUILD_COMMIT overrides; no git → "unknown".
|
||||||
|
const buildCommit = (() => {
|
||||||
|
if (process.env.LOTUS_BUILD_COMMIT) return process.env.LOTUS_BUILD_COMMIT.slice(0, 12);
|
||||||
|
try {
|
||||||
|
return execSync('git rev-parse --short=8 HEAD', { stdio: ['ignore', 'pipe', 'ignore'] })
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
} catch {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
appType: 'spa',
|
appType: 'spa',
|
||||||
|
define: {
|
||||||
|
__LOTUS_BUILD_COMMIT__: JSON.stringify(buildCommit),
|
||||||
|
__LOTUS_BUILD_DATE__: JSON.stringify(new Date().toISOString()),
|
||||||
|
},
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
base: buildConfig.base,
|
base: buildConfig.base,
|
||||||
server: {
|
server: {
|
||||||
|
|||||||
Reference in New Issue
Block a user