Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

feat(frontend): display running app version in sidebar for release/branch awareness (#73)

Gustavo Henrique Rodrigues Guterresea792f6ba2e4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 465e73ea..6114d727 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -90,5 +90,7 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+ build-args: |
+ VITE_APP_VERSION=${{ github.event.release.tag_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
diff --git a/docker-compose.yml b/docker-compose.yml
index bce49f72..6b45e40b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -28,7 +28,7 @@ services:
redis:
image: redis:7-alpine
healthcheck:
- test: [ "CMD", "redis-cli", "ping" ]
+ test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 3s
retries: 5
@@ -42,30 +42,34 @@ services:
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
- test: [ "CMD-SHELL", "pg_isready -U postgres" ]
+ test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 5s
timeout: 3s
retries: 5
backend:
<<: *backend-base
- command: sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
+ command:
+ sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port
+ 8000 --reload"
ports:
- - "8000:8000"
+ - '8000:8000'
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.dev
ports:
- - "3000:5173"
+ - '3000:5173'
environment:
BACKEND_URL: http://backend:8000
FRONTEND_URL: http://localhost:3000
+ APP_VERSION_ROOT: /workspace
depends_on:
- backend
volumes:
- ./frontend:/app
+ - ./:/workspace:ro
- /app/node_modules
restart: unless-stopped
diff --git a/frontend/Dockerfile b/frontend/Dockerfile
index 7ca40c3d..e1f0c442 100644
--- a/frontend/Dockerfile
+++ b/frontend/Dockerfile
@@ -2,6 +2,9 @@ FROM node:22-slim AS build
WORKDIR /app
+ARG VITE_APP_VERSION
+ENV VITE_APP_VERSION=$VITE_APP_VERSION
+
COPY package.json package-lock.json ./
RUN npm ci
diff --git a/frontend/Dockerfile.dev b/frontend/Dockerfile.dev
index 12d8bd42..a196f845 100644
--- a/frontend/Dockerfile.dev
+++ b/frontend/Dockerfile.dev
@@ -2,6 +2,9 @@ FROM node:22-slim
WORKDIR /app
+RUN apt-get update && apt-get install -y --no-install-recommends git \
+ && rm -rf /var/lib/apt/lists/*
+
COPY package.json package-lock.json ./
RUN npm ci
diff --git a/frontend/build/version.ts b/frontend/build/version.ts
new file mode 100644
index 00000000..404c5992
--- /dev/null
+++ b/frontend/build/version.ts
@@ -0,0 +1,249 @@
+import { execSync, execFileSync } from 'node:child_process'
+const officialReleaseRepo = 'https://github.com/securo-finance/securo.git'
+const officialLatestReleaseApi =
+ 'https://api.github.com/repos/securo-finance/securo/releases/latest'
+const semverPattern =
+ /^v?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/
+
+type ParsedSemverTag = {
+ major: number
+ minor: number
+ patch: number
+ prerelease: string[]
+}
+
+function runLocalGit(projectRoot: string, command: string) {
+ const args = ['-c', `safe.directory=${projectRoot}`, ...command.split(' ')]
+ return execFileSync('git', args, {
+ cwd: projectRoot,
+ stdio: ['ignore', 'pipe', 'ignore'],
+ })
+ .toString()
+ .trim()
+}
+
+function normalizeVersionLabel(value?: string | null) {
+ const trimmed = value?.trim()
+ if (!trimmed) return null
+
+ if (semverPattern.test(trimmed)) {
+ return trimmed.startsWith('v') ? trimmed : `v${trimmed}`
+ }
+
+ return trimmed
+}
+
+function parseSemverTag(value: string): ParsedSemverTag | null {
+ const match = value.match(
+ /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/,
+ )
+ if (!match) return null
+
+ return {
+ major: Number.parseInt(match[1], 10),
+ minor: Number.parseInt(match[2], 10),
+ patch: Number.parseInt(match[3], 10),
+ prerelease: match[4]?.split('.').filter(Boolean) ?? [],
+ }
+}
+
+function comparePrereleaseIdentifiers(left: string, right: string) {
+ const leftIsNumber = /^\d+$/.test(left)
+ const rightIsNumber = /^\d+$/.test(right)
+
+ if (leftIsNumber && rightIsNumber) {
+ return Number.parseInt(left, 10) - Number.parseInt(right, 10)
+ }
+
+ if (leftIsNumber) return -1
+ if (rightIsNumber) return 1
+
+ return left.localeCompare(right)
+}
+
+function compareSemverTags(left: ParsedSemverTag, right: ParsedSemverTag) {
+ if (left.major !== right.major) return left.major - right.major
+ if (left.minor !== right.minor) return left.minor - right.minor
+ if (left.patch !== right.patch) return left.patch - right.patch
+
+ const leftStable = left.prerelease.length === 0
+ const rightStable = right.prerelease.length === 0
+ if (leftStable && rightStable) return 0
+ if (leftStable) return 1
+ if (rightStable) return -1
+
+ const maxLength = Math.max(left.prerelease.length, right.prerelease.length)
+ for (let index = 0; index < maxLength; index += 1) {
+ const leftId = left.prerelease[index]
+ const rightId = right.prerelease[index]
+
+ if (leftId === undefined) return -1
+ if (rightId === undefined) return 1
+
+ const difference = comparePrereleaseIdentifiers(leftId, rightId)
+ if (difference !== 0) return difference
+ }
+
+ return 0
+}
+
+function getCurrentGitTag(projectRoot: string) {
+ try {
+ const tag = runLocalGit(projectRoot, 'describe --tags --exact-match')
+
+ if (!parseSemverTag(tag)) return null
+ return normalizeVersionLabel(tag)
+ } catch {
+ return null
+ }
+}
+
+function getHeadShortSha(projectRoot: string) {
+ try {
+ const shortSha = runLocalGit(projectRoot, 'rev-parse --short HEAD')
+
+ if (!shortSha) return null
+
+ return shortSha
+ } catch {
+ return null
+ }
+}
+
+function getOfficialMainSha(projectRoot: string) {
+ try {
+ const output = execSync(
+ `git ls-remote ${officialReleaseRepo} refs/heads/main`,
+ {
+ cwd: projectRoot,
+ stdio: ['ignore', 'pipe', 'ignore'],
+ timeout: 3000,
+ },
+ )
+ .toString()
+ .trim()
+
+ const [sha] = output.split(/\s+/)
+ return sha || null
+ } catch {
+ return null
+ }
+}
+
+function getHeadSha(projectRoot: string) {
+ try {
+ const sha = runLocalGit(projectRoot, 'rev-parse HEAD')
+
+ return sha || null
+ } catch {
+ return null
+ }
+}
+
+function getLatestOfficialReleaseTagFromGit(projectRoot: string) {
+ try {
+ const output = execSync(
+ `git ls-remote --refs --tags ${officialReleaseRepo} 'v*'`,
+ {
+ cwd: projectRoot,
+ stdio: ['ignore', 'pipe', 'ignore'],
+ timeout: 3000,
+ },
+ ).toString()
+
+ const semverTags = output
+ .split('\n')
+ .map((line) => line.split('refs/tags/')[1]?.trim())
+ .filter((tag): tag is string => Boolean(tag))
+ .map((tag) => {
+ const normalizedTag = normalizeVersionLabel(tag)
+ const parsedTag = normalizedTag ? parseSemverTag(normalizedTag) : null
+
+ if (!normalizedTag || !parsedTag) return null
+
+ return {
+ normalizedTag,
+ parsedTag,
+ }
+ })
+ .filter(
+ (
+ entry,
+ ): entry is { normalizedTag: string; parsedTag: ParsedSemverTag } =>
+ Boolean(entry),
+ )
+
+ if (semverTags.length === 0) return null
+
+ const stableTags = semverTags.filter(
+ (entry) => entry.parsedTag.prerelease.length === 0,
+ )
+ const candidateTags = stableTags.length > 0 ? stableTags : semverTags
+ candidateTags.sort((left, right) =>
+ compareSemverTags(left.parsedTag, right.parsedTag),
+ )
+
+ return candidateTags.at(-1)?.normalizedTag ?? null
+ } catch {
+ return null
+ }
+}
+
+async function getLatestOfficialReleaseTagFromApi() {
+ try {
+ const response = await fetch(officialLatestReleaseApi, {
+ headers: {
+ Accept: 'application/vnd.github+json',
+ 'User-Agent': 'securo-frontend-build',
+ },
+ signal: AbortSignal.timeout(3000),
+ })
+
+ if (!response.ok) return null
+
+ const payload = (await response.json()) as { tag_name?: string }
+ return normalizeVersionLabel(payload.tag_name)
+ } catch {
+ return null
+ }
+}
+
+async function getLatestOfficialReleaseTag(projectRoot: string) {
+ return (
+ getLatestOfficialReleaseTagFromGit(projectRoot) ??
+ (await getLatestOfficialReleaseTagFromApi())
+ )
+}
+
+export async function resolveAppVersion(
+ projectRoot: string,
+ explicitVersion?: string,
+) {
+ const resolvedExplicitVersion = normalizeVersionLabel(explicitVersion)
+ if (resolvedExplicitVersion) return resolvedExplicitVersion
+
+ const currentGitTag = getCurrentGitTag(projectRoot)
+ if (currentGitTag) return currentGitTag
+
+ const latestOfficialReleaseTag =
+ await getLatestOfficialReleaseTag(projectRoot)
+ const headSha = getHeadSha(projectRoot)
+ const officialMainSha = getOfficialMainSha(projectRoot)
+ const headShortSha = getHeadShortSha(projectRoot)
+
+ if (latestOfficialReleaseTag) {
+ if (headSha && officialMainSha && headSha === officialMainSha) {
+ return latestOfficialReleaseTag
+ }
+
+ if (headShortSha) {
+ return `${latestOfficialReleaseTag}+${headShortSha}`
+ }
+
+ return latestOfficialReleaseTag
+ }
+
+ if (headShortSha) return headShortSha
+
+ return 'dev'
+}
diff --git a/frontend/src/components/app-layout.tsx b/frontend/src/components/app-layout.tsx
index 9266573c..a93c574b 100644
--- a/frontend/src/components/app-layout.tsx
+++ b/frontend/src/components/app-layout.tsx
@@ -24,7 +24,10 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { cn } from '@/lib/utils'
+import { APP_VERSION } from '@/lib/build-info'
import { ShellLogo } from '@/components/shell-logo'
+import { UpdateAvailableBanner } from '@/components/update-available-banner'
+import { UpdateAvailableDialog } from '@/components/update-available-dialog'
import {
LayoutDashboard,
ArrowLeftRight,
@@ -51,6 +54,7 @@ import {
HardDriveDownload,
Shield,
ShieldCheck,
+ Download,
} from 'lucide-react'
import { usePrivacyMode } from '@/hooks/use-privacy-mode'
import { ChangePasswordDialog } from '@/components/change-password-dialog'
@@ -64,25 +68,32 @@ type NavItem =
| { type: 'separator'; labelKey: string }
const navItems: NavItem[] = [
- { type: 'link', key: 'dashboard', path: '/', icon: LayoutDashboard },
- { type: 'link', key: 'transactions', path: '/transactions', icon: ArrowLeftRight },
+ { type: 'link', key: 'dashboard', path: '/', icon: LayoutDashboard },
+ {
+ type: 'link',
+ key: 'transactions',
+ path: '/transactions',
+ icon: ArrowLeftRight,
+ },
{ type: 'separator', labelKey: 'nav.groupAccounts' },
- { type: 'link', key: 'accounts', path: '/accounts', icon: Building2 },
- { type: 'link', key: 'import', path: '/import', icon: Upload },
+ { type: 'link', key: 'accounts', path: '/accounts', icon: Building2 },
+ { type: 'link', key: 'import', path: '/import', icon: Upload },
{ type: 'separator', labelKey: 'nav.groupAnalysis' },
- { type: 'link', key: 'reports', path: '/reports', icon: BarChart3 },
- { type: 'link', key: 'assets', path: '/assets', icon: Landmark },
+ { type: 'link', key: 'reports', path: '/reports', icon: BarChart3 },
+ { type: 'link', key: 'assets', path: '/assets', icon: Landmark },
{ type: 'separator', labelKey: 'nav.groupSetup' },
- { type: 'link', key: 'budgets', path: '/budgets', icon: PiggyBank },
- { type: 'link', key: 'goals', path: '/goals', icon: Target },
- { type: 'link', key: 'recurring', path: '/recurring', icon: Repeat },
- { type: 'link', key: 'categories', path: '/categories', icon: Tag },
- { type: 'link', key: 'payees', path: '/payees', icon: Users },
- { type: 'link', key: 'rules', path: '/rules', icon: SlidersHorizontal },
+ { type: 'link', key: 'budgets', path: '/budgets', icon: PiggyBank },
+ { type: 'link', key: 'goals', path: '/goals', icon: Target },
+ { type: 'link', key: 'recurring', path: '/recurring', icon: Repeat },
+ { type: 'link', key: 'categories', path: '/categories', icon: Tag },
+ { type: 'link', key: 'payees', path: '/payees', icon: Users },
+ { type: 'link', key: 'rules', path: '/rules', icon: SlidersHorizontal },
]
function formatCurrency(value: number, currency = 'USD', locale = 'en-US') {
- return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value)
+ return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(
+ value,
+ )
}
export function AppLayout() {
@@ -101,15 +112,24 @@ export function AppLayout() {
const [twoFactorOpen, setTwoFactorOpen] = useState(false)
const [backingUp, setBackingUp] = useState(false)
const [paletteOpen, setPaletteOpen] = useState(false)
+ const [updateDialogOpen, setUpdateDialogOpen] = useState(false)
useCommandPaletteHotkey(setPaletteOpen)
- const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.platform)
+ const isMac =
+ typeof navigator !== 'undefined' &&
+ /Mac|iPhone|iPad|iPod/.test(navigator.platform)
- const showTour = user && !user.preferences?.onboarding_completed && !localStorage.getItem('onboarding_completed')
+ const showTour =
+ user &&
+ !user.preferences?.onboarding_completed &&
+ !localStorage.getItem('onboarding_completed')
const handleTourComplete = useCallback(async () => {
localStorage.setItem('onboarding_completed', 'true')
try {
- const prefs = { ...(user?.preferences || {}), onboarding_completed: true }
+ const prefs = {
+ ...(user?.preferences || {}),
+ onboarding_completed: true,
+ }
const updated = await authApi.updateMe({ preferences: prefs })
updateUser(updated)
} catch {
@@ -135,6 +155,7 @@ export function AppLayout() {
const totalBalance = allAccounts.reduce((sum, a) => {
return sum + Number(a.balance_primary ?? a.current_balance)
}, 0)
+ const versionA11yLabel = t('app.versionAriaLabel', { version: APP_VERSION })
return (
<div className="min-h-screen bg-background">
@@ -149,7 +170,9 @@ export function AppLayout() {
</button>
<div className="flex items-center gap-2">
<ShellLogo size={22} className="text-primary shrink-0" />
- <span className="font-bold text-sidebar-foreground">{t('app.name')}</span>
+ <span className="font-bold text-sidebar-foreground">
+ {t('app.name')}
+ </span>
</div>
<div className="ml-auto flex items-center gap-2">
<button
@@ -171,21 +194,32 @@ export function AppLayout() {
onClick={toggleTheme}
className="text-sidebar-muted hover:text-sidebar-foreground transition-colors p-1"
title={isDark ? t('settings.themeLight') : t('settings.themeDark')}
- aria-label={isDark ? t('settings.themeLight') : t('settings.themeDark')}
+ aria-label={
+ isDark ? t('settings.themeLight') : t('settings.themeDark')
+ }
>
{isDark ? <Sun size={18} /> : <Moon size={18} />}
</button>
- <UserMenu userInitial={userInitial} logout={logout} onChangePassword={() => setChangePasswordOpen(true)} onTwoFactor={() => setTwoFactorOpen(true)} backingUp={backingUp} onBackup={async () => {
- setBackingUp(true)
- try {
- await backupApi.download()
- toast.success(t('backup.success'))
- } catch {
- toast.error(t('backup.error'))
- } finally {
- setBackingUp(false)
- }
- }} dark isAdmin={user?.is_superuser} />
+ <UserMenu
+ userInitial={userInitial}
+ logout={logout}
+ onChangePassword={() => setChangePasswordOpen(true)}
+ onTwoFactor={() => setTwoFactorOpen(true)}
+ backingUp={backingUp}
+ onBackup={async () => {
+ setBackingUp(true)
+ try {
+ await backupApi.download()
+ toast.success(t('backup.success'))
+ } catch {
+ toast.error(t('backup.error'))
+ } finally {
+ setBackingUp(false)
+ }
+ }}
+ dark
+ isAdmin={user?.is_superuser}
+ />
</div>
</header>
@@ -201,15 +235,17 @@ export function AppLayout() {
{/* Sidebar */}
<aside
className={cn(
- 'fixed inset-y-0 left-0 z-50 w-60 bg-sidebar border-r border-sidebar-border flex flex-col transform transition-transform lg:translate-x-0 shrink-0 overflow-y-auto',
- sidebarOpen ? 'translate-x-0' : '-translate-x-full'
+ 'fixed inset-y-0 left-0 z-50 w-60 bg-sidebar border-r border-sidebar-border flex flex-col transform transition-transform lg:translate-x-0 shrink-0',
+ sidebarOpen ? 'translate-x-0' : '-translate-x-full',
)}
>
{/* Logo */}
<div className="flex h-16 min-h-16 items-center justify-between px-5 border-b border-sidebar-border shrink-0">
<div className="flex items-center gap-2.5">
<ShellLogo size={24} className="text-primary shrink-0" />
- <span className="font-bold text-lg text-sidebar-foreground tracking-tight">{t('app.name')}</span>
+ <span className="font-bold text-lg text-sidebar-foreground tracking-tight">
+ {t('app.name')}
+ </span>
</div>
<div className="flex items-center gap-0.5">
<button
@@ -223,8 +259,12 @@ export function AppLayout() {
<button
onClick={toggleTheme}
className="text-sidebar-muted hover:text-sidebar-foreground transition-colors p-1 rounded-md hover:bg-sidebar-accent"
- title={isDark ? t('settings.themeLight') : t('settings.themeDark')}
- aria-label={isDark ? t('settings.themeLight') : t('settings.themeDark')}
+ title={
+ isDark ? t('settings.themeLight') : t('settings.themeDark')
+ }
+ aria-label={
+ isDark ? t('settings.themeLight') : t('settings.themeDark')
+ }
>
{isDark ? <Sun size={16} /> : <Moon size={16} />}
</button>
@@ -239,7 +279,7 @@ export function AppLayout() {
className={cn(
'group flex w-full items-center gap-2 rounded-lg border border-sidebar-border/80 bg-sidebar-accent/40 px-3 py-2',
'text-[12.5px] text-sidebar-muted transition-all',
- 'hover:bg-sidebar-accent hover:text-sidebar-foreground hover:border-sidebar-border'
+ 'hover:bg-sidebar-accent hover:text-sidebar-foreground hover:border-sidebar-border',
)}
aria-label={t('cmdk.triggerAria')}
>
@@ -251,6 +291,7 @@ export function AppLayout() {
</button>
</div>
+ <div className="flex-1 min-h-0 overflow-y-auto">
{/* Nav */}
<nav className="flex flex-col gap-0.5 p-3" data-tour="sidebar">
{navItems.map((item, idx) => {
@@ -264,9 +305,10 @@ export function AppLayout() {
)
}
- const isActive = item.path === '/'
- ? location.pathname === '/'
- : location.pathname.startsWith(item.path)
+ const isActive =
+ item.path === '/'
+ ? location.pathname === '/'
+ : location.pathname.startsWith(item.path)
const Icon = item.icon
return (
<Link
@@ -278,12 +320,15 @@ export function AppLayout() {
'flex items-center gap-3 text-[13px] font-medium transition-all rounded-lg px-3 py-2',
isActive
? 'bg-primary/[0.08] text-primary border-l-[3px] border-primary pl-[9px]'
- : 'text-sidebar-muted hover:bg-sidebar-accent hover:text-sidebar-foreground'
+ : 'text-sidebar-muted hover:bg-sidebar-accent hover:text-sidebar-foreground',
)}
>
<Icon
size={17}
- className={cn('shrink-0', isActive ? 'text-primary' : 'text-sidebar-muted')}
+ className={cn(
+ 'shrink-0',
+ isActive ? 'text-primary' : 'text-sidebar-muted',
+ )}
/>
<span>{t(`nav.${item.key}`)}</span>
</Link>
@@ -298,14 +343,21 @@ export function AppLayout() {
onClick={() => setAccountsExpanded(!accountsExpanded)}
className="flex items-center justify-between w-full px-3 py-2 hover:text-sidebar-foreground transition-colors"
>
- <span className="text-[11px] uppercase tracking-[0.12em] font-semibold text-sidebar-muted">{t('accounts.title')}</span>
+ <span className="text-[11px] uppercase tracking-[0.12em] font-semibold text-sidebar-muted">
+ {t('accounts.title')}
+ </span>
<div className="flex items-center gap-2">
- <span className={`tabular-nums font-medium text-xs ${totalBalance < 0 ? 'text-rose-400' : 'text-sidebar-muted'}`}>
+ <span
+ className={`tabular-nums font-medium text-xs ${totalBalance < 0 ? 'text-rose-400' : 'text-sidebar-muted'}`}
+ >
{mask(formatCurrency(totalBalance, userCurrency, locale))}
</span>
<ChevronRight
size={12}
- className={cn('text-sidebar-muted transition-transform', accountsExpanded && 'rotate-90')}
+ className={cn(
+ 'text-sidebar-muted transition-transform',
+ accountsExpanded && 'rotate-90',
+ )}
/>
</div>
</button>
@@ -352,18 +404,22 @@ export function AppLayout() {
>
{accountsShowAll
? t('common.showLess', { defaultValue: 'Show less' })
- : t('common.showMore', { count: allAccounts.length - 3, defaultValue: `+${allAccounts.length - 3} more` })}
+ : t('common.showMore', {
+ count: allAccounts.length - 3,
+ defaultValue: `+${allAccounts.length - 3} more`,
+ })}
</button>
)}
</div>
)}
</div>
)}
+ </div>
- <div className="flex-1" />
+ <UpdateAvailableBanner onOpen={() => setUpdateDialogOpen(true)} />
{/* User section */}
- <div className="p-3">
+ <div className="px-3 pt-1">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button className="flex items-center gap-3 w-full rounded-lg px-3 py-2.5 text-sm hover:bg-sidebar-accent transition-colors text-left">
@@ -372,7 +428,9 @@ export function AppLayout() {
{userInitial}
</AvatarFallback>
</Avatar>
- <span className="text-xs text-sidebar-muted truncate flex-1">{user?.email}</span>
+ <span className="text-xs text-sidebar-muted truncate flex-1">
+ {user?.email}
+ </span>
</button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48" side="top">
@@ -420,6 +478,13 @@ export function AppLayout() {
<HardDriveDownload size={14} />
{backingUp ? t('backup.downloading') : t('backup.button')}
</DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => setUpdateDialogOpen(true)}
+ className="flex items-center gap-2"
+ >
+ <Download size={14} />
+ {t('update.menuItem')}
+ </DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger className="flex items-center gap-2">
<Languages size={14} />
@@ -465,6 +530,18 @@ export function AppLayout() {
</DropdownMenuContent>
</DropdownMenu>
</div>
+
+ <div className="px-3 pb-3 pt-1">
+ <div
+ className="text-[11px] leading-4 text-sidebar-muted/70 text-center"
+ role="note"
+ >
+ <span className="sr-only">{versionA11yLabel}</span>
+ <span aria-hidden="true" className="block break-all line-clamp-2">
+ {t('app.versionLabel', { version: APP_VERSION })}
+ </span>
+ </div>
+ </div>
</aside>
{/* Main content */}
@@ -476,14 +553,42 @@ export function AppLayout() {
</div>
{showTour && <OnboardingTour onComplete={handleTourComplete} />}
- <ChangePasswordDialog open={changePasswordOpen} onClose={() => setChangePasswordOpen(false)} />
- <TwoFactorSetup open={twoFactorOpen} onClose={() => setTwoFactorOpen(false)} />
+ <ChangePasswordDialog
+ open={changePasswordOpen}
+ onClose={() => setChangePasswordOpen(false)}
+ />
+ <TwoFactorSetup
+ open={twoFactorOpen}
+ onClose={() => setTwoFactorOpen(false)}
+ />
<CommandPalette open={paletteOpen} onOpenChange={setPaletteOpen} />
+ <UpdateAvailableDialog
+ open={updateDialogOpen}
+ onClose={() => setUpdateDialogOpen(false)}
+ />
</div>
)
}
-function UserMenu({ userInitial, logout, onChangePassword, onTwoFactor, onBackup, backingUp, dark, isAdmin }: { userInitial: string; logout: () => void; onChangePassword: () => void; onTwoFactor: () => void; onBackup: () => void; backingUp: boolean; dark?: boolean; isAdmin?: boolean }) {
+function UserMenu({
+ userInitial,
+ logout,
+ onChangePassword,
+ onTwoFactor,
+ onBackup,
+ backingUp,
+ dark,
+ isAdmin,
+}: {
+ userInitial: string
+ logout: () => void
+ onChangePassword: () => void
+ onTwoFactor: () => void
+ onBackup: () => void
+ backingUp: boolean
+ dark?: boolean
+ isAdmin?: boolean
+}) {
const { t, i18n } = useTranslation()
const nav = useNavigate()
const currentLang = i18n.language
@@ -492,7 +597,13 @@ function UserMenu({ userInitial, logout, onChangePassword, onTwoFactor, onBackup
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="relative h-8 w-8 rounded-full p-0">
<Avatar className="h-8 w-8">
- <AvatarFallback className={dark ? 'bg-primary/20 text-primary text-xs font-semibold' : 'bg-primary/10 text-primary text-xs font-semibold'}>
+ <AvatarFallback
+ className={
+ dark
+ ? 'bg-primary/20 text-primary text-xs font-semibold'
+ : 'bg-primary/10 text-primary text-xs font-semibold'
+ }
+ >
{userInitial}
</AvatarFallback>
</Avatar>
@@ -501,22 +612,35 @@ function UserMenu({ userInitial, logout, onChangePassword, onTwoFactor, onBackup
<DropdownMenuContent align="end">
{isAdmin && (
<>
- <DropdownMenuItem onClick={() => nav('/admin')} className="flex items-center gap-2">
+ <DropdownMenuItem
+ onClick={() => nav('/admin')}
+ className="flex items-center gap-2"
+ >
<Shield size={14} />
{t('nav.groupAdmin')}
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
)}
- <DropdownMenuItem onClick={onChangePassword} className="flex items-center gap-2">
+ <DropdownMenuItem
+ onClick={onChangePassword}
+ className="flex items-center gap-2"
+ >
<KeyRound size={14} />
{t('auth.changePassword')}
</DropdownMenuItem>
- <DropdownMenuItem onClick={onTwoFactor} className="flex items-center gap-2">
+ <DropdownMenuItem
+ onClick={onTwoFactor}
+ className="flex items-center gap-2"
+ >
<ShieldCheck size={14} />
{t('auth.twoFactorTitle')}
</DropdownMenuItem>
- <DropdownMenuItem disabled={backingUp} onClick={onBackup} className="flex items-center gap-2">
+ <DropdownMenuItem
+ disabled={backingUp}
+ onClick={onBackup}
+ className="flex items-center gap-2"
+ >
<HardDriveDownload size={14} />
{backingUp ? t('backup.downloading') : t('backup.button')}
</DropdownMenuItem>
@@ -555,7 +679,10 @@ function UserMenu({ userInitial, logout, onChangePassword, onTwoFactor, onBackup
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuSeparator />
- <DropdownMenuItem onClick={logout} className="text-rose-600 focus:text-rose-600">
+ <DropdownMenuItem
+ onClick={logout}
+ className="text-rose-600 focus:text-rose-600"
+ >
{t('auth.logout')}
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/frontend/src/components/ui/switch.tsx b/frontend/src/components/ui/switch.tsx
new file mode 100644
index 00000000..b3c08a58
--- /dev/null
+++ b/frontend/src/components/ui/switch.tsx
@@ -0,0 +1,46 @@
+import { cn } from '@/lib/utils'
+
+interface SwitchProps {
+ checked: boolean
+ onCheckedChange: (checked: boolean) => void
+ disabled?: boolean
+ id?: string
+ 'aria-labelledby'?: string
+ className?: string
+}
+
+export function Switch({
+ checked,
+ onCheckedChange,
+ disabled,
+ id,
+ className,
+ ...rest
+}: SwitchProps) {
+ return (
+ <button
+ type="button"
+ role="switch"
+ id={id}
+ aria-checked={checked}
+ aria-labelledby={rest['aria-labelledby']}
+ disabled={disabled}
+ onClick={() => onCheckedChange(!checked)}
+ className={cn(
+ 'relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
+ 'disabled:cursor-not-allowed disabled:opacity-50',
+ checked ? 'bg-primary' : 'bg-input',
+ className,
+ )}
+ >
+ <span
+ aria-hidden="true"
+ className={cn(
+ 'pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform',
+ checked ? 'translate-x-[18px]' : 'translate-x-0.5',
+ )}
+ />
+ </button>
+ )
+}
diff --git a/frontend/src/components/update-available-banner.tsx b/frontend/src/components/update-available-banner.tsx
new file mode 100644
index 00000000..a68efe2b
--- /dev/null
+++ b/frontend/src/components/update-available-banner.tsx
@@ -0,0 +1,38 @@
+import { useTranslation } from 'react-i18next'
+import { Download } from 'lucide-react'
+import { APP_VERSION } from '@/lib/build-info'
+import { useLatestRelease } from '@/hooks/use-latest-release'
+import { useAutoUpdateCheck } from '@/hooks/use-auto-update-check'
+import { isUpdateAvailable } from '@/lib/semver'
+
+interface UpdateAvailableBannerProps {
+ onOpen: () => void
+}
+
+export function UpdateAvailableBanner({ onOpen }: UpdateAvailableBannerProps) {
+ const { t } = useTranslation()
+ const { enabled } = useAutoUpdateCheck()
+ const { data } = useLatestRelease()
+
+ if (!enabled) return null
+ if (!data) return null
+ if (!isUpdateAvailable(APP_VERSION, data.tagName)) return null
+
+ return (
+ <div className="px-3 pb-1">
+ <button
+ type="button"
+ onClick={onOpen}
+ title={t('app.updateAvailableHint', { version: data.tagName })}
+ className="flex items-center gap-2 w-full rounded-lg border border-sidebar-border px-3 py-2 text-xs font-medium text-sidebar-foreground hover:bg-sidebar-accent transition-colors text-left"
+ >
+ <Download size={14} className="shrink-0 text-sidebar-muted" />
+ <span className="flex-1 truncate">{t('app.updateAvailable')}</span>
+ <span
+ aria-hidden="true"
+ className="h-2 w-2 shrink-0 rounded-full bg-emerald-500"
+ />
+ </button>
+ </div>
+ )
+}
diff --git a/frontend/src/components/update-available-dialog.tsx b/frontend/src/components/update-available-dialog.tsx
new file mode 100644
index 00000000..064b06c6
--- /dev/null
+++ b/frontend/src/components/update-available-dialog.tsx
@@ -0,0 +1,189 @@
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { toast } from 'sonner'
+import {
+ Check,
+ Copy,
+ Download,
+ Info,
+ Sparkles,
+ Bug,
+ Server,
+ CheckCircle2,
+ BellOff,
+} from 'lucide-react'
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogFooter,
+} from '@/components/ui/dialog'
+import { Button } from '@/components/ui/button'
+import { Switch } from '@/components/ui/switch'
+import { APP_VERSION } from '@/lib/build-info'
+import { useAutoUpdateCheck } from '@/hooks/use-auto-update-check'
+import { useLatestRelease } from '@/hooks/use-latest-release'
+import { isUpdateAvailable } from '@/lib/semver'
+
+const UPGRADE_COMMAND = 'git pull && docker compose up -d --build'
+
+interface UpdateAvailableDialogProps {
+ open: boolean
+ onClose: () => void
+}
+
+export function UpdateAvailableDialog({
+ open,
+ onClose,
+}: UpdateAvailableDialogProps) {
+ const { t } = useTranslation()
+ const { enabled, setEnabled } = useAutoUpdateCheck()
+ const { data, isFetching } = useLatestRelease()
+ const [copied, setCopied] = useState(false)
+
+ const hasUpdate = data ? isUpdateAvailable(APP_VERSION, data.tagName) : false
+
+ const handleCopy = async () => {
+ try {
+ await navigator.clipboard.writeText(UPGRADE_COMMAND)
+ setCopied(true)
+ toast.success(t('update.copied'))
+ setTimeout(() => setCopied(false), 2000)
+ } catch {
+ toast.error(t('update.copyFailed'))
+ }
+ }
+
+ return (
+ <Dialog open={open} onOpenChange={(v) => !v && onClose()}>
+ <DialogContent className="sm:max-w-lg">
+ <DialogHeader>
+ <div className="flex items-center justify-between gap-3 pr-6">
+ <DialogTitle>{t('update.title')}</DialogTitle>
+ <span className="inline-flex items-center gap-1.5 rounded-full border bg-muted/60 px-2.5 py-1 text-[11px] font-medium text-muted-foreground">
+ <Server size={12} />
+ <span className="tabular-nums font-semibold text-foreground">
+ {APP_VERSION}
+ </span>
+ <span className="h-1 w-1 rounded-full bg-muted-foreground/40" />
+ <span>{t('update.runningLabel')}</span>
+ </span>
+ </div>
+ </DialogHeader>
+
+ <div className="space-y-5">
+ {!enabled && (
+ <div className="flex items-start gap-2.5 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3.5 py-3 text-sm text-amber-700 dark:text-amber-400">
+ <BellOff size={16} className="shrink-0 mt-0.5" />
+ <p className="leading-relaxed">{t('update.autoCheckDisabled')}</p>
+ </div>
+ )}
+
+ {enabled && isFetching && !data && (
+ <div className="rounded-lg border bg-muted/40 px-3.5 py-3 text-sm text-muted-foreground">
+ {t('update.checking')}
+ </div>
+ )}
+
+ {enabled && data && !hasUpdate && (
+ <div className="flex items-center gap-2.5 rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-3.5 py-3 text-sm font-medium text-emerald-700 dark:text-emerald-400">
+ <CheckCircle2 size={18} className="shrink-0" />
+ <span className="flex-1">
+ {t('update.upToDate')}{' '}
+ <span className="tabular-nums font-bold">{data.tagName}</span>
+ </span>
+ </div>
+ )}
+
+ {enabled && hasUpdate && data && (
+ <>
+ <div className="flex items-center gap-2.5 rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-3.5 py-3 text-sm font-semibold text-emerald-700 dark:text-emerald-400">
+ <Download size={18} className="shrink-0" />
+ <span className="flex-1">
+ {t('update.newVersionAvailable')}{' '}
+ <span className="font-bold tabular-nums">
+ {data.tagName}
+ </span>
+ </span>
+ </div>
+
+ <div className="space-y-3">
+ <p className="text-sm text-foreground/80">
+ {t('update.description')}
+ </p>
+ <ul className="space-y-2 text-sm text-foreground/80">
+ <li className="flex items-start gap-2.5">
+ <Sparkles
+ size={15}
+ className="text-primary shrink-0 mt-0.5"
+ />
+ <span>{t('update.reasonFeatures')}</span>
+ </li>
+ <li className="flex items-start gap-2.5">
+ <Bug size={15} className="text-primary shrink-0 mt-0.5" />
+ <span>{t('update.reasonBugs')}</span>
+ </li>
+ </ul>
+ </div>
+
+ <div className="flex items-start gap-2.5 rounded-lg border border-blue-500/20 bg-blue-500/10 px-3.5 py-3 text-sm text-blue-700 dark:text-blue-300">
+ <Info size={16} className="shrink-0 mt-0.5" />
+ <p className="leading-relaxed">
+ {t('update.releaseNotesHintBefore')}{' '}
+ <a
+ href={data.htmlUrl}
+ target="_blank"
+ rel="noreferrer noopener"
+ className="font-medium underline underline-offset-2 hover:opacity-80"
+ >
+ {t('update.releaseNotesLink')}
+ </a>{' '}
+ {t('update.releaseNotesHintAfter')}
+ </p>
+ </div>
+
+ <div className="space-y-2">
+ <div className="text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
+ {t('update.commandLabel')}
+ </div>
+ <code className="block rounded-md border bg-muted/50 px-3 py-2.5 font-mono text-xs text-foreground break-all">
+ <span className="select-none text-muted-foreground mr-2">
+ $
+ </span>
+ {UPGRADE_COMMAND}
+ </code>
+ </div>
+ </>
+ )}
+
+ <div className="flex items-center justify-between gap-3 rounded-lg border bg-muted/30 px-3.5 py-2.5">
+ <label
+ htmlFor="auto-update-check"
+ className="text-sm font-medium cursor-pointer select-none"
+ >
+ {t('update.autoCheckToggle')}
+ </label>
+ <Switch
+ id="auto-update-check"
+ checked={enabled}
+ onCheckedChange={setEnabled}
+ />
+ </div>
+ </div>
+
+ <DialogFooter>
+ <Button type="button" variant="outline" onClick={onClose}>
+ {hasUpdate ? t('common.cancel') : t('common.close')}
+ </Button>
+ {hasUpdate && (
+ <Button type="button" onClick={handleCopy}>
+ {copied ? <Check size={14} /> : <Copy size={14} />}
+ {copied ? t('update.copied') : t('update.copyCommand')}
+ </Button>
+ )}
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/frontend/src/hooks/use-auto-update-check.ts b/frontend/src/hooks/use-auto-update-check.ts
new file mode 100644
index 00000000..f872b89a
--- /dev/null
+++ b/frontend/src/hooks/use-auto-update-check.ts
@@ -0,0 +1,30 @@
+import { useSyncExternalStore, useCallback } from 'react'
+
+const STORAGE_KEY = 'updateCheckEnabled'
+
+const listeners = new Set<() => void>()
+
+function getSnapshot(): boolean {
+ const raw = localStorage.getItem(STORAGE_KEY)
+ return raw === null ? true : raw === 'true'
+}
+
+function subscribe(cb: () => void) {
+ listeners.add(cb)
+ return () => listeners.delete(cb)
+}
+
+function notify() {
+ listeners.forEach((cb) => cb())
+}
+
+export function useAutoUpdateCheck() {
+ const enabled = useSyncExternalStore(subscribe, getSnapshot, () => true)
+
+ const setEnabled = useCallback((next: boolean) => {
+ localStorage.setItem(STORAGE_KEY, String(next))
+ notify()
+ }, [])
+
+ return { enabled, setEnabled } as const
+}
diff --git a/frontend/src/hooks/use-latest-release.ts b/frontend/src/hooks/use-latest-release.ts
new file mode 100644
index 00000000..9bf93b9f
--- /dev/null
+++ b/frontend/src/hooks/use-latest-release.ts
@@ -0,0 +1,39 @@
+import { useQuery } from '@tanstack/react-query'
+import { useAutoUpdateCheck } from '@/hooks/use-auto-update-check'
+
+const LATEST_RELEASE_URL =
+ 'https://api.github.com/repos/securo-finance/securo/releases/latest'
+
+const SIX_HOURS = 1000 * 60 * 60 * 6
+
+export type LatestRelease = {
+ tagName: string
+ htmlUrl: string
+}
+
+async function fetchLatestRelease(): Promise<LatestRelease | null> {
+ const response = await fetch(LATEST_RELEASE_URL, {
+ headers: { Accept: 'application/vnd.github+json' },
+ })
+ if (!response.ok) return null
+ const payload = (await response.json()) as {
+ tag_name?: string
+ html_url?: string
+ }
+ if (!payload.tag_name || !payload.html_url) return null
+ return { tagName: payload.tag_name, htmlUrl: payload.html_url }
+}
+
+export function useLatestRelease() {
+ const { enabled } = useAutoUpdateCheck()
+ return useQuery<LatestRelease | null>({
+ queryKey: ['latest-release', 'securo-finance/securo'],
+ queryFn: fetchLatestRelease,
+ enabled,
+ staleTime: SIX_HOURS,
+ gcTime: SIX_HOURS,
+ retry: 1,
+ refetchOnWindowFocus: false,
+ refetchOnReconnect: false,
+ })
+}
diff --git a/frontend/src/lib/build-info.ts b/frontend/src/lib/build-info.ts
new file mode 100644
index 00000000..53a7feec
--- /dev/null
+++ b/frontend/src/lib/build-info.ts
@@ -0,0 +1 @@
+export const APP_VERSION = __APP_VERSION__
diff --git a/frontend/src/lib/semver.ts b/frontend/src/lib/semver.ts
new file mode 100644
index 00000000..b5f69cf1
--- /dev/null
+++ b/frontend/src/lib/semver.ts
@@ -0,0 +1,65 @@
+export type ParsedSemver = {
+ major: number
+ minor: number
+ patch: number
+ prerelease: string[]
+}
+
+const SEMVER_RE =
+ /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/
+
+export function parseSemver(value: string | null | undefined): ParsedSemver | null {
+ if (!value) return null
+ const match = value.trim().match(SEMVER_RE)
+ if (!match) return null
+ return {
+ major: Number.parseInt(match[1], 10),
+ minor: Number.parseInt(match[2], 10),
+ patch: Number.parseInt(match[3], 10),
+ prerelease: match[4]?.split('.').filter(Boolean) ?? [],
+ }
+}
+
+function comparePrereleaseIds(left: string, right: string): number {
+ const leftNum = /^\d+$/.test(left)
+ const rightNum = /^\d+$/.test(right)
+ if (leftNum && rightNum) {
+ return Number.parseInt(left, 10) - Number.parseInt(right, 10)
+ }
+ if (leftNum) return -1
+ if (rightNum) return 1
+ return left.localeCompare(right)
+}
+
+export function compareSemver(a: ParsedSemver, b: ParsedSemver): number {
+ if (a.major !== b.major) return a.major - b.major
+ if (a.minor !== b.minor) return a.minor - b.minor
+ if (a.patch !== b.patch) return a.patch - b.patch
+
+ const aStable = a.prerelease.length === 0
+ const bStable = b.prerelease.length === 0
+ if (aStable && bStable) return 0
+ if (aStable) return 1
+ if (bStable) return -1
+
+ const max = Math.max(a.prerelease.length, b.prerelease.length)
+ for (let i = 0; i < max; i += 1) {
+ const ai = a.prerelease[i]
+ const bi = b.prerelease[i]
+ if (ai === undefined) return -1
+ if (bi === undefined) return 1
+ const diff = comparePrereleaseIds(ai, bi)
+ if (diff !== 0) return diff
+ }
+ return 0
+}
+
+export function isUpdateAvailable(
+ current: string | null | undefined,
+ latest: string | null | undefined,
+): boolean {
+ const c = parseSemver(current)
+ const l = parseSemver(latest)
+ if (!c || !l) return false
+ return compareSemver(l, c) > 0
+}
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json
index 7a9b656d..0b904f35 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/en.json
@@ -1,6 +1,10 @@
{
"app": {
- "name": "Securo"
+ "name": "Securo",
+ "versionAriaLabel": "Running version {{version}}",
+ "versionLabel": "Version {{version}}",
+ "updateAvailable": "Update Available",
+ "updateAvailableHint": "A newer release ({{version}}) is available on GitHub"
},
"cmdk": {
"title": "Command palette",
@@ -781,6 +785,7 @@
"common": {
"save": "Save",
"cancel": "Cancel",
+ "close": "Close",
"delete": "Delete",
"edit": "Edit",
"loading": "Loading...",
@@ -816,6 +821,26 @@
"success": "Backup downloaded successfully",
"error": "Failed to download backup"
},
+ "update": {
+ "title": "Server update",
+ "runningLabel": "running",
+ "newVersionAvailable": "New version available:",
+ "description": "A new version of Securo is available. Consider updating if you:",
+ "reasonFeatures": "Want to access the latest features and improvements",
+ "reasonBugs": "Are experiencing issues that may be resolved in the new version",
+ "releaseNotesHintBefore": "We recommend reviewing the",
+ "releaseNotesLink": "release notes",
+ "releaseNotesHintAfter": "for any breaking changes before updating.",
+ "commandLabel": "Upgrade command",
+ "copyCommand": "Copy command",
+ "copied": "Copied",
+ "copyFailed": "Failed to copy to clipboard",
+ "autoCheckToggle": "Automatically check for new updates",
+ "autoCheckDisabled": "Automatic update checks are turned off. Turn them on to know when a new version is available.",
+ "checking": "Checking for updates…",
+ "upToDate": "You're on the latest version —",
+ "menuItem": "Check for updates"
+ },
"admin": {
"users": {
"title": "User Management",
@@ -875,4 +900,4 @@
"back": "Back",
"finish": "Get Started"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/pt-BR.json b/frontend/src/locales/pt-BR.json
index d2993af5..d1f31723 100644
--- a/frontend/src/locales/pt-BR.json
+++ b/frontend/src/locales/pt-BR.json
@@ -1,6 +1,10 @@
{
"app": {
- "name": "Securo"
+ "name": "Securo",
+ "versionAriaLabel": "Versão em execução {{version}}",
+ "versionLabel": "Versão {{version}}",
+ "updateAvailable": "Atualização disponível",
+ "updateAvailableHint": "Uma nova versão ({{version}}) está disponível no GitHub"
},
"cmdk": {
"title": "Paleta de comandos",
@@ -781,6 +785,7 @@
"common": {
"save": "Salvar",
"cancel": "Cancelar",
+ "close": "Fechar",
"delete": "Excluir",
"edit": "Editar",
"loading": "Carregando...",
@@ -816,6 +821,26 @@
"success": "Backup baixado com sucesso",
"error": "Erro ao baixar backup"
},
+ "update": {
+ "title": "Atualização do servidor",
+ "runningLabel": "em execução",
+ "newVersionAvailable": "Nova versão disponível:",
+ "description": "Uma nova versão do Securo está disponível. Considere atualizar se você:",
+ "reasonFeatures": "Quer acessar os recursos e melhorias mais recentes",
+ "reasonBugs": "Está enfrentando problemas que podem ter sido resolvidos na nova versão",
+ "releaseNotesHintBefore": "Recomendamos ler as",
+ "releaseNotesLink": "notas da versão",
+ "releaseNotesHintAfter": "para verificar mudanças incompatíveis antes de atualizar.",
+ "commandLabel": "Comando de atualização",
+ "copyCommand": "Copiar comando",
+ "copied": "Copiado",
+ "copyFailed": "Erro ao copiar para a área de transferência",
+ "autoCheckToggle": "Verificar novas atualizações automaticamente",
+ "autoCheckDisabled": "A verificação automática de atualizações está desligada. Ative-a para saber quando uma nova versão estiver disponível.",
+ "checking": "Verificando atualizações…",
+ "upToDate": "Você está na versão mais recente —",
+ "menuItem": "Verificar atualizações"
+ },
"admin": {
"users": {
"title": "Gerenciamento de Usuários",
@@ -875,4 +900,4 @@
"back": "Voltar",
"finish": "Começar"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts
new file mode 100644
index 00000000..54eaa072
--- /dev/null
+++ b/frontend/src/vite-env.d.ts
@@ -0,0 +1,3 @@
+/// <reference types="vite/client" />
+
+declare const __APP_VERSION__: string
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 9657832a..096ed917 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -1,34 +1,48 @@
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
-import path from 'path'
-import { defineConfig } from 'vite'
+import path from 'node:path'
+import { defineConfig, loadEnv } from 'vite'
+import { resolveAppVersion } from './build/version'
-const frontendHost = (() => {
- const url = process.env.FRONTEND_URL
- if (!url) return []
- const withoutProto = url.replace(/^https?:\/\//, '')
+function getFrontendHost(frontendUrl?: string) {
+ if (!frontendUrl) return []
+ const withoutProto = frontendUrl.replace(/^https?:\/\//, '')
return [withoutProto.split(/[:/]/)[0]]
-})()
+}
-export default defineConfig({
- plugins: [react(), tailwindcss()],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src'),
+export default defineConfig(async ({ mode }) => {
+ const env = loadEnv(mode, __dirname, '')
+ const frontendUrl = env.FRONTEND_URL || process.env.FRONTEND_URL
+ const backendUrl = env.BACKEND_URL || process.env.BACKEND_URL
+ const appVersionRoot = env.APP_VERSION_ROOT || process.env.APP_VERSION_ROOT
+ const appVersion = await resolveAppVersion(
+ appVersionRoot || __dirname,
+ env.VITE_APP_VERSION || process.env.VITE_APP_VERSION,
+ )
+
+ return {
+ define: {
+ __APP_VERSION__: JSON.stringify(appVersion),
},
- },
- server: {
- port: 5173,
- host: '0.0.0.0',
- allowedHosts: frontendHost,
- proxy: {
- '/api': {
- target: process.env.BACKEND_URL ?? 'http://localhost:8000',
- changeOrigin: true,
+ plugins: [react(), tailwindcss()],
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src'),
},
},
- watch: {
- usePolling: true,
+ server: {
+ port: 5173,
+ host: '0.0.0.0',
+ allowedHosts: getFrontendHost(frontendUrl),
+ proxy: {
+ '/api': {
+ target: backendUrl ?? 'http://localhost:8000',
+ changeOrigin: true,
+ },
+ },
+ watch: {
+ usePolling: true,
+ },
},
- },
+ }
})