diff --git a/README.md b/README.md index 195729d..44d662a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The installer creates: - Service: `synapsis.service` - Mandatory update timer: `synapsis-update.timer` -Every node checks `origin/main` about once per minute. When a new commit is available, Synapsis fast-forwards the checkout, replaces the single `backups/latest` database snapshot, installs dependencies, runs migrations, builds, and restarts automatically. The currently deployed commit is shown in the Network Info card and exposed by `/api/version`. +Every node checks `origin/main` about once per minute. When a new commit is available, Synapsis fast-forwards the checkout, replaces the single `backups/latest` database snapshot, installs dependencies, runs migrations, builds, and restarts automatically. The repository commit count is shown in the Network Info card; `/api/version` exposes both that number and the full deployed commit hash. For a node installed before automatic updates existed, bootstrap the timer once with: diff --git a/next.config.ts b/next.config.ts index 95f8d79..7eb05d7 100644 --- a/next.config.ts +++ b/next.config.ts @@ -14,9 +14,23 @@ function getBuildCommit(): string { } } +function getBuildCommitCount(): string { + if (process.env.APP_COMMIT_COUNT) return process.env.APP_COMMIT_COUNT; + + try { + return execFileSync('git', ['rev-list', '--count', 'HEAD'], { + cwd: process.cwd(), + encoding: 'utf8', + }).trim(); + } catch { + return 'unknown'; + } +} + const nextConfig: NextConfig = { env: { APP_COMMIT: getBuildCommit(), + APP_COMMIT_COUNT: getBuildCommitCount(), APP_BUILD_DATE: process.env.APP_BUILD_DATE || new Date().toISOString(), }, diff --git a/src/components/RightSidebar.tsx b/src/components/RightSidebar.tsx index b6299ff..1d797fe 100644 --- a/src/components/RightSidebar.tsx +++ b/src/components/RightSidebar.tsx @@ -32,6 +32,7 @@ export function RightSidebar() { const [version, setVersion] = useState<{ version: string; commit: string | null; + commitCount: number | null; buildDate: string | null; } | null>(null); @@ -80,7 +81,7 @@ export function RightSidebar() { fetch('/api/version') .then(res => res.json()) .then(data => setVersion(data)) - .catch(() => setVersion({ version: 'unknown', commit: null, buildDate: null })); + .catch(() => setVersion({ version: 'unknown', commit: null, commitCount: null, buildDate: null })); return () => window.removeEventListener('synapsis:node-updated', handleNodeUpdated); }, []); @@ -154,8 +155,8 @@ export function RightSidebar() {
Running{' '}
Synapsis
- {version?.commit
- ? ` ${version.commit.slice(0, 7)}`
+ {version?.commitCount !== null && version?.commitCount !== undefined
+ ? ` ${version.commitCount}`
: version?.version
? ` ${version.version}`
: ''}
diff --git a/src/lib/swarm/discovery.ts b/src/lib/swarm/discovery.ts
index 9146edc..14a2d33 100644
--- a/src/lib/swarm/discovery.ts
+++ b/src/lib/swarm/discovery.ts
@@ -63,7 +63,9 @@ export async function buildAnnouncement(): Promise