diff --git a/backend/src/agent-ws.ts b/backend/src/agent-ws.ts index 322d5f5..c923ba5 100644 --- a/backend/src/agent-ws.ts +++ b/backend/src/agent-ws.ts @@ -144,9 +144,10 @@ export const setupAgentWsRoute: FastifyPluginAsync = async (fastify) => { } if (msg.type === 'hello') { console.log(`[agent-ws] Hello from ${msg.agent_id} (${wsId})`) - if (msg.version) { - db.query('UPDATE workstations SET agent_version = $1 WHERE id = $2', [msg.version, wsId]).catch(() => {}) - } + db.query( + 'UPDATE workstations SET agent_version = $1, hostname = COALESCE($2, hostname) WHERE id = $3', + [msg.version ?? null, msg.hostname ?? null, wsId], + ).catch(() => {}) } } catch {} }) diff --git a/src/pages/EquipmentPage.tsx b/src/pages/EquipmentPage.tsx index c9e40aa..532a471 100644 --- a/src/pages/EquipmentPage.tsx +++ b/src/pages/EquipmentPage.tsx @@ -562,6 +562,11 @@ function WorkstationCard({ const [editing, setEditing] = useState(false) const [name, setName] = useState(ws.name) const [showPairModal, setShowPairModal] = useState(false) + + // Sync local name state when ws.name prop changes (after onRefresh) + useEffect(() => { + if (!editing) setName(ws.name) + }, [ws.name, editing]) const [showAddDevice, setShowAddDevice] = useState(false) const [editDeviceId, setEditDeviceId] = useState(null) const [updating, setUpdating] = useState(false)