From 30257a6079fa8e1a5a87985510819f01e384d8cf Mon Sep 17 00:00:00 2001 From: HotelSync Date: Fri, 27 Mar 2026 20:54:39 +0300 Subject: [PATCH] fix: send sync message with workstation name after hello Co-Authored-By: Claude Sonnet 4.6 --- backend/src/agent-ws.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/agent-ws.ts b/backend/src/agent-ws.ts index c923ba5..8e6a7aa 100644 --- a/backend/src/agent-ws.ts +++ b/backend/src/agent-ws.ts @@ -145,9 +145,14 @@ export const setupAgentWsRoute: FastifyPluginAsync = async (fastify) => { if (msg.type === 'hello') { console.log(`[agent-ws] Hello from ${msg.agent_id} (${wsId})`) db.query( - 'UPDATE workstations SET agent_version = $1, hostname = COALESCE($2, hostname) WHERE id = $3', + 'UPDATE workstations SET agent_version = $1, hostname = COALESCE($2, hostname) WHERE id = $3 RETURNING name', [msg.version ?? null, msg.hostname ?? null, wsId], - ).catch(() => {}) + ).then(({ rows }) => { + // Отправляем агенту актуальное имя рабочего места + if (rows[0]?.name) { + socket.send(JSON.stringify({ type: 'sync', workstation_name: rows[0].name })) + } + }).catch(() => {}) } } catch {} })