chore: persist activity feed history and improve build versioning

This commit is contained in:
Riz Ashraf committed 2026-09-20 06:41:12 +01:00
1 parent e72af4f877
commit cb8447224f
2 files changed
+44 -10

No files matched your search

+14 -10
View File
@@ -1,25 +1,29 @@
use std::process::Command; use std::process::Command;
fn main() { fn main() {
let git_hash = Command::new("git") let mut git_hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"]) .args(["rev-parse", "--short", "HEAD"])
.output() .output()
.ok() .ok()
.and_then(|out| String::from_utf8(out.stdout).ok()) .and_then(|out| String::from_utf8(out.stdout).ok())
.unwrap_or_else(|| "unknown".to_string()); .unwrap_or_else(|| "unknown".to_string());
git_hash = git_hash.trim().to_string();
let git_date = Command::new("git") let is_dirty = Command::new("git")
.args(["log", "-1", "--format=%cd", "--date=format:%y.%m.%d.%H%M%S"]) .args(["status", "--porcelain"])
.output() .output()
.ok() .ok()
.and_then(|out| String::from_utf8(out.stdout).ok()) .map(|out| !out.stdout.is_empty())
.unwrap_or_else(|| "unknown".to_string()); .unwrap_or(false);
let version = format!( if is_dirty {
"{} ({})", git_hash.push_str("-dirty");
git_date.trim(), }
git_hash.trim()
); let build_date = chrono::Local::now().format("%y.%m.%d.%H%M%S").to_string();
let version = format!("{} ({})", build_date, git_hash);
println!("cargo:rustc-env=APP_VERSION={}", version); println!("cargo:rustc-env=APP_VERSION={}", version);
if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" { if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" {
+30
View File
@@ -893,6 +893,33 @@
} }
// --- WebSocket Activity Feed --- // --- WebSocket Activity Feed ---
const MAX_ACTIVITY_HISTORY = 100;
function saveActivityHistory(time, htmlData) {
try {
let history = JSON.parse(localStorage.getItem('activityHistory') || '[]');
history.push({ time, data: htmlData });
if (history.length > MAX_ACTIVITY_HISTORY) history = history.slice(-MAX_ACTIVITY_HISTORY);
localStorage.setItem('activityHistory', JSON.stringify(history));
} catch(e) {}
}
function loadActivityHistory() {
try {
const feed = document.getElementById('activity-feed');
let history = JSON.parse(localStorage.getItem('activityHistory') || '[]');
history.forEach(item => {
const div = document.createElement('div');
div.className = 'feed-entry';
div.innerHTML = `<span class="time">[${item.time}]</span> ${item.data}`;
feed.appendChild(div);
});
if (history.length > 0) {
feed.scrollTop = feed.scrollHeight;
}
} catch(e) {}
}
function setupWS() { function setupWS() {
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = new WebSocket(`${protocol}//${location.host}/ws?client=ui`); const ws = new WebSocket(`${protocol}//${location.host}/ws?client=ui`);
@@ -908,6 +935,8 @@
div.innerHTML = `<span class="time">[${time}]</span> ${data.data}`; div.innerHTML = `<span class="time">[${time}]</span> ${data.data}`;
feed.appendChild(div); feed.appendChild(div);
saveActivityHistory(time, data.data);
// Auto-scroll logic // Auto-scroll logic
const isScrolledToBottom = feed.scrollHeight - feed.clientHeight <= feed.scrollTop + 20; const isScrolledToBottom = feed.scrollHeight - feed.clientHeight <= feed.scrollTop + 20;
if (isScrolledToBottom) { if (isScrolledToBottom) {
@@ -967,6 +996,7 @@
loadGraph(); loadGraph();
loadTasks(); loadTasks();
loadStickyNotes(); loadStickyNotes();
loadActivityHistory();
setupWS(); setupWS();
// Listen to theme toggle changes to update graph font colors // Listen to theme toggle changes to update graph font colors