From f40aa538b0e8ce0f00cff435d1dccf09509818e5 Mon Sep 17 00:00:00 2001 From: PTah Date: Tue, 14 Jul 2026 10:30:13 +1000 Subject: [PATCH] fix: keep host name in WinRM update log titles (0.5.17) Do not overwrite UI log titles with generic backend job.title when several logs are open. --- README.md | 2 +- README_en.md | 2 +- backend/app/api/v1/hosts.py | 10 ++++++---- frontend/src/components/HostActionLogModal.vue | 10 +++++++++- frontend/src/composables/useHostRemoteAction.ts | 6 +++--- frontend/src/views/HostDetailView.vue | 10 ++++++++-- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index dffac32..e6fb8bc 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ | **security-alert-center** | Сервер SAC (Ubuntu 24.04) | | [seaca](https://git.kalinamall.ru/PapaTramp/seaca) | Android-клиент | -**Версия:** `0.5.16` · **Деплой:** `sudo /opt/sac-deploy.sh` +**Версия:** `0.5.17` · **Деплой:** `sudo /opt/sac-deploy.sh` ## Возможности diff --git a/README_en.md b/README_en.md index da713f1..e993ad4 100644 --- a/README_en.md +++ b/README_en.md @@ -13,7 +13,7 @@ Self-hosted hub for security events from Linux and Windows agents: ingest, corre | **security-alert-center** | SAC server (Ubuntu 24.04) | | [seaca](https://git.kalinamall.ru/PapaTramp/seaca) | Android client | -**Version:** `0.5.16` · **Deploy:** `sudo /opt/sac-deploy.sh` +**Version:** `0.5.17` · **Deploy:** `sudo /opt/sac-deploy.sh` ## Features diff --git a/backend/app/api/v1/hosts.py b/backend/app/api/v1/hosts.py index 1cd70a7..f190a0b 100644 --- a/backend/app/api/v1/hosts.py +++ b/backend/app/api/v1/hosts.py @@ -590,7 +590,8 @@ def update_host_agent_via_ssh( detail="Linux SSH admin is not configured (host override or Settings → Linux)", ) - title = "Обновление ssh-monitor (SSH)" + host_label = (host.display_name or host.hostname or "").strip() or f"host#{host.id}" + title = f"Обновление ssh-monitor (SSH): {host_label}" try: start_host_remote_action( db, @@ -650,12 +651,13 @@ def post_agent_update_fallback( from app.services.winrm_connect import is_windows_host product = (host.product or "").strip() + host_label = (host.display_name or host.hostname or "").strip() or f"host#{host.id}" if product == PRODUCT_RDP or is_windows_host(host): - title = "Обновление через WinRM" + title = f"Обновление {host_label} через WinRM" elif product == PRODUCT_SSH or is_linux_host(host): - title = "Fallback SSH (ssh-monitor)" + title = f"Fallback SSH (ssh-monitor): {host_label}" else: - title = "Обновление агента (fallback)" + title = f"Обновление агента (fallback): {host_label}" try: start_host_remote_action( diff --git a/frontend/src/components/HostActionLogModal.vue b/frontend/src/components/HostActionLogModal.vue index 4d2cd8b..fa0009c 100644 --- a/frontend/src/components/HostActionLogModal.vue +++ b/frontend/src/components/HostActionLogModal.vue @@ -167,7 +167,15 @@ function startCountdown() { function applyFinishedJob(job: HostRemoteActionJobStatus) { isLoading.value = false; ok.value = job.ok ?? job.status === "success"; - if (job.title) localTitle.value = job.title; + // Prefer props.title (hostname) over generic backend job.title. + let title = props.title || job.title || ""; + const jobTitle = job.title || ""; + if (title && jobTitle.includes(" — готово") && !title.includes(" — готово")) { + title = `${title} — готово`; + } else if (title && jobTitle.includes(" — ошибка") && !title.includes(" — ошибка")) { + title = `${title} — ошибка`; + } + localTitle.value = title; if (job.message) localMessage.value = job.message; const out = (job.output || job.stdout || "").trim(); if (out) polledOutput.value = out; diff --git a/frontend/src/composables/useHostRemoteAction.ts b/frontend/src/composables/useHostRemoteAction.ts index f4fc1e4..d44dff1 100644 --- a/frontend/src/composables/useHostRemoteAction.ts +++ b/frontend/src/composables/useHostRemoteAction.ts @@ -86,9 +86,9 @@ function scheduleSuccessAutoClose(entryId: string) { } function applyJobToEntry(entry: HostRemoteActionLogEntry, job: HostRemoteActionJobStatus) { - if (job.title) { - entry.title = job.title; - } + // Keep the UI title set when the log opened (with hostname). Backend job titles + // are generic ("Обновление через WinRM") and overwrite would strip the host name + // when polling / when another log window opens. if (job.message) { entry.message = job.message; } diff --git a/frontend/src/views/HostDetailView.vue b/frontend/src/views/HostDetailView.vue index 0a043bb..5960001 100644 --- a/frontend/src/views/HostDetailView.vue +++ b/frontend/src/views/HostDetailView.vue @@ -713,8 +713,14 @@ async function runRequestAgentUpdate() { async function runAgentFallback() { agentControlMessage.value = ""; - const title = isWindowsHost.value ? "Обновление через WinRM" : "Fallback SSH (ssh-monitor)"; - const job = await runHostRemoteAction(hostId.value, title, "fallback", remoteActionLogPlaceholder(host.value, "fallback")); + if (!host.value) return; + const title = remoteActionTitleForHost(host.value); + const job = await runHostRemoteAction( + hostId.value, + title, + "fallback", + remoteActionLogPlaceholder(host.value, "fallback"), + ); if (job) { agentControlOk.value = job.ok ?? false; if (job.ok) {