fix: send sync message with workstation name after hello

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-27 20:54:39 +03:00
parent ccd366a5ad
commit 30257a6079

View File

@@ -145,9 +145,14 @@ export const setupAgentWsRoute: FastifyPluginAsync = async (fastify) => {
if (msg.type === 'hello') { if (msg.type === 'hello') {
console.log(`[agent-ws] Hello from ${msg.agent_id} (${wsId})`) console.log(`[agent-ws] Hello from ${msg.agent_id} (${wsId})`)
db.query( 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], [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 {} } catch {}
}) })