From 188f6f8f10014a672a89e13e93114d0dd32e46cf Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Wed, 17 Jun 2026 17:19:56 +0000 Subject: [PATCH] fix: persist agent version on every heartbeat update_agent_seen() now updates version column when agents include it in their heartbeat payload. Previously version was only stored on registration, leaving the Workers tab showing NULL for agents that hadn't re-registered since v3.1. Co-Authored-By: Claude Sonnet 4.6 --- api/endpoints/agent.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/api/endpoints/agent.php b/api/endpoints/agent.php index f7ee21b..f768250 100644 --- a/api/endpoints/agent.php +++ b/api/endpoints/agent.php @@ -37,11 +37,18 @@ function get_agent_by_key(string $key): ?array { return $rows[0] ?? null; } -function update_agent_seen(string $agentId, string $status = 'online'): void { - JarvisDB::query( - 'UPDATE registered_agents SET last_seen = NOW(), status = ? WHERE agent_id = ?', - [$status, $agentId] - ); +function update_agent_seen(string $agentId, string $status = 'online', ?string $version = null): void { + if ($version !== null) { + JarvisDB::query( + 'UPDATE registered_agents SET last_seen = NOW(), status = ?, version = ? WHERE agent_id = ?', + [$status, $version, $agentId] + ); + } else { + JarvisDB::query( + 'UPDATE registered_agents SET last_seen = NOW(), status = ? WHERE agent_id = ?', + [$status, $agentId] + ); + } } // ── Auth (all actions except register) ─────────────────────────────────────── @@ -104,7 +111,7 @@ switch ($agentAction) { // ── HEARTBEAT ──────────────────────────────────────────────────────────── case 'heartbeat': - update_agent_seen($agent['agent_id']); + update_agent_seen($agent['agent_id'], 'online', trim($data['version'] ?? '') ?: null); // Return any pending commands for this agent $commands = JarvisDB::query(