fix: inject app version from package.json instead of hardcoded 1.0.0

- Add Vite define for __APP_VERSION__ from package.json
- Use dynamic version in gateway connect handshake and userAgent
- Show version number in sidebar footer
- Add globals.d.ts type declaration
This commit is contained in:
Nicolas Varrot
2026-02-12 09:37:28 +00:00
parent 7905f64f37
commit 3c5fcdfc73
4 changed files with 9 additions and 3 deletions

View File

@@ -137,11 +137,12 @@ export function Sidebar({ sessions, activeSession, onSwitch, open, onClose }: Pr
);
})}
</div>
{/* Footer glow dots */}
{/* Footer with version */}
<div className="px-4 py-3 border-t border-white/8 flex items-center justify-center gap-2">
<span className="h-1.5 w-1.5 rounded-full bg-violet-300/60 shadow-[0_0_10px_rgba(168,85,247,0.5)]" />
<span className="h-1.5 w-1.5 rounded-full bg-cyan-300/60 shadow-[0_0_10px_rgba(34,211,238,0.5)]" />
<span className="h-1.5 w-1.5 rounded-full bg-indigo-300/50 shadow-[0_0_10px_rgba(99,102,241,0.4)]" />
<span className="ml-1 text-[9px] text-zinc-600 select-all" title={`PinchChat v${__APP_VERSION__}`}>v{__APP_VERSION__}</span>
</div>
</aside>
</>

1
src/globals.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
declare const __APP_VERSION__: string;

View File

@@ -98,7 +98,7 @@ export class GatewayClient {
this.request(id, 'connect', {
minProtocol: 3,
maxProtocol: 3,
client: { id: 'webchat', version: '1.0.0', platform: 'web', mode: 'webchat' },
client: { id: 'webchat', version: __APP_VERSION__, platform: 'web', mode: 'webchat' },
role: 'operator',
scopes: ['operator.read', 'operator.write'],
caps: [],
@@ -106,7 +106,7 @@ export class GatewayClient {
permissions: {},
auth: { token: this.authToken },
locale: navigator.language || 'en',
userAgent: 'pinchchat/1.0.0',
userAgent: `pinchchat/${__APP_VERSION__}`,
}).then((res) => {
console.log('[GW] connected!', res);
this.connected = true;

View File

@@ -1,8 +1,12 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import pkg from './package.json' with { type: 'json' }
export default defineConfig({
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
plugins: [react(), tailwindcss()],
build: {
rollupOptions: {