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
19 changes: 19 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pengine",
"private": true,
"version": "0.1.0",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pengine"
version = "0.1.0"
version = "1.0.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
Expand Down
68 changes: 67 additions & 1 deletion src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,69 @@
fn main() {
tauri_build::build()
let manifest_dir = std::path::PathBuf::from(
std::env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"),
);

let app_version = package_json_version(&manifest_dir);
println!("cargo:rustc-env=PENGINE_APP_VERSION={app_version}");

let commit = git_head_commit(&manifest_dir);
println!("cargo:rustc-env=PENGINE_GIT_COMMIT={commit}");

let package_json = manifest_dir.join("../package.json");
if let Ok(canonical) = package_json.canonicalize() {
println!("cargo:rerun-if-changed={}", canonical.display());
}

let git_head = manifest_dir.join("../.git/HEAD");
if let Ok(canonical) = git_head.canonicalize() {
println!("cargo:rerun-if-changed={}", canonical.display());
}

tauri_build::build();
}

/// User-facing release version: root `package.json` `"version"` (same as Vite/npm).
fn package_json_version(manifest_dir: &std::path::Path) -> String {
let path = manifest_dir
.parent()
.unwrap_or(manifest_dir)
.join("package.json");
let raw = match std::fs::read_to_string(&path) {
Ok(s) => s,
Err(_) => return std::env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "0.0.0".into()),
};
for line in raw.lines() {
let t = line.trim_start();
if let Some(rest) = t.strip_prefix("\"version\"") {
let rest = rest.trim_start();
let rest = match rest.strip_prefix(':') {
Some(r) => r.trim_start(),
None => continue,
};
let rest = match rest.strip_prefix('"') {
Some(r) => r,
None => continue,
};
if let Some(end) = rest.find('"') {
let v = rest[..end].trim();
if !v.is_empty() {
return v.to_string();
}
}
}
}
std::env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "0.0.0".into())
}

/// Resolved `HEAD` at build time (tip of the checked-out branch).
fn git_head_commit(manifest_dir: &std::path::Path) -> String {
let repo_root = manifest_dir.parent().unwrap_or(manifest_dir);
let output = std::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.current_dir(repo_root)
.output();
match output {
Ok(o) if o.status.success() => String::from_utf8_lossy(&o.stdout).trim().to_string(),
_ => "unknown".to_string(),
}
}
4 changes: 4 additions & 0 deletions src-tauri/src/build_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Compile-time app version (root `package.json`, set in `build.rs`) and git commit.

pub const APP_VERSION: &str = env!("PENGINE_APP_VERSION");
pub const GIT_COMMIT: &str = env!("PENGINE_GIT_COMMIT");
7 changes: 7 additions & 0 deletions src-tauri/src/infrastructure/http_server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::build_info;
use crate::infrastructure::bot_lifecycle;
use crate::modules::bot::{agent as bot_agent, repository, service as bot_service};
use crate::modules::cron::{
Expand Down Expand Up @@ -53,6 +54,10 @@ pub struct HealthResponse {
pub bot_connected: bool,
pub bot_username: Option<String>,
pub bot_id: Option<String>,
/// Release version (root `package.json`, baked in at build).
pub app_version: String,
/// Git commit at build time (`HEAD`), or `"unknown"`.
pub git_commit: String,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -348,6 +353,8 @@ async fn handle_health(State(state): State<AppState>) -> Json<HealthResponse> {
bot_connected: conn.is_some(),
bot_username: conn.as_ref().map(|c| c.bot_username.clone()),
bot_id: conn.as_ref().map(|c| c.bot_id.clone()),
app_version: build_info::APP_VERSION.to_string(),
git_commit: build_info::GIT_COMMIT.to_string(),
})
}

Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod app;
mod build_info;
mod infrastructure;
pub mod modules;
mod shared;
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "pengine",
"version": "0.1.0",
"version": "1.0.0",
"identifier": "com.maximedogawa.pengine",
"build": {
"beforeDevCommand": "bun run dev",
Expand Down
2 changes: 2 additions & 0 deletions src/modules/bot/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ export type PengineHealth = {
bot_connected: boolean;
bot_username?: string;
bot_id?: string | null;
app_version?: string;
git_commit?: string;
};
20 changes: 20 additions & 0 deletions src/pages/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ export function DashboardPage() {
{ name: "Ollama", status: "checking", detail: "Checking…" },
]);
const [disconnectError, setDisconnectError] = useState<string | null>(null);
const [appVersion, setAppVersion] = useState<string | null>(null);
const [gitCommit, setGitCommit] = useState<string | null>(null);
const refreshStatus = useCallback(async () => {
let botUser = botUsername ?? "unknown";
const health = await getPengineHealth(3000);
const pengineUp = !!health;
const botConnected = health?.bot_connected ?? false;
if (health?.bot_username) botUser = health.bot_username;
if (health) {
setAppVersion(health.app_version ?? null);
setGitCommit(health.git_commit ?? null);
} else {
setAppVersion(null);
setGitCommit(null);
}

const ollama = await fetchOllamaModels(2500);
const ollamaUp = ollama.reachable;
Expand Down Expand Up @@ -204,6 +213,17 @@ export function DashboardPage() {
)}
{modelError && <p className="mt-2 font-mono text-xs text-rose-300">{modelError}</p>}

{appVersion && gitCommit && (
<p
className="mt-2 font-mono text-[10px] tracking-wide text-white/35 sm:text-[11px]"
title={`${gitCommit}`}
data-testid="app-build-info"
>
Pengine v{appVersion}
{gitCommit !== "unknown" ? ` · ${gitCommit.slice(0, 7)}` : ""}
</p>
)}

{/* ── Terminal (full width) ────────────────────────────── */}
<section className="mt-4 sm:mt-6">
<TerminalPreview />
Expand Down