From bf9bcccde2b58563cb9c3f276c2908281df090f6 Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Fri, 10 Jul 2026 11:05:27 -0400 Subject: [PATCH] Fix MachineResponse: expose last_seen_at/created_at, clean status string The status field was being decorated with "(last seen ...)" suffix which broke frontend statusVariant() matching and prevented the LastSeen column from showing the separate timestamp. Changes: - machineToResp() now returns clean status ("online"/"offline") - MachineResponse includes last_seen_at and created_at as separate fields - Fix whitespace typo in WakeCheckIntervalSeconds field --- Makefile | 2 +- cmd/server/main.go | 2 +- internal/api/dto.go | 2 ++ internal/api/handlers_machines.go | 15 ++++++++------- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 1b6a603..7f13bfb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BINARY=syncserver -VERSION?=1.0.41 +VERSION?=1.0.42 GO?=go LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) BUILD_FLAGS=CGO_ENABLED=0 diff --git a/cmd/server/main.go b/cmd/server/main.go index e08edd8..e48074a 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -20,7 +20,7 @@ import ( "github.com/syncserver/internal/syncengine" ) -var version = "1.0.41" +var version = "1.0.42" func main() { cfgPath := flag.String("config", "", "Path to config.yaml") diff --git a/internal/api/dto.go b/internal/api/dto.go index 678b737..383742c 100644 --- a/internal/api/dto.go +++ b/internal/api/dto.go @@ -28,6 +28,8 @@ type MachineResponse struct { FingerprintConfirmed bool `json:"fingerprint_confirmed"` HostKeyFingerprint *string `json:"host_key_fingerprint"` Status string `json:"status"` + LastSeenAt *string `json:"last_seen_at"` + CreatedAt string `json:"created_at"` } type TestConnectionResponse struct { diff --git a/internal/api/handlers_machines.go b/internal/api/handlers_machines.go index 77f7f92..3c40c93 100644 --- a/internal/api/handlers_machines.go +++ b/internal/api/handlers_machines.go @@ -444,11 +444,10 @@ func (h *MachineHandler) Delete(w http.ResponseWriter, r *http.Request) { } func machineToResp(m models.Machine) MachineResponse { - var status string + var lastSeen *string if m.LastSeenAt != nil { - status = m.Status + " (last seen " + m.LastSeenAt.Format(time.RFC3339) + ")" - } else { - status = m.Status + s := m.LastSeenAt.Format(time.RFC3339) + lastSeen = &s } return MachineResponse{ ID: m.ID, @@ -461,10 +460,12 @@ func machineToResp(m models.Machine) MachineResponse { WoLEnabled: m.WoLEnabled, BroadcastAddr: m.BroadcastAddr, WakeTimeoutSeconds: m.WakeTimeoutSeconds, - WakeCheckIntervalSeconds: m.WakeCheckIntervalSeconds, + WakeCheckIntervalSeconds: m.WakeCheckIntervalSeconds, FingerprintConfirmed: m.FingerprintConfirmed, - HostKeyFingerprint: m.HostKeyFingerprint, - Status: status, + HostKeyFingerprint: m.HostKeyFingerprint, + Status: m.Status, + LastSeenAt: lastSeen, + CreatedAt: m.CreatedAt.Format(time.RFC3339), } }