From 8b2d1da25eb372495af2e52249b78caeb88fad5a Mon Sep 17 00:00:00 2001
From: TheWitness <1439914+TheWitness@users.noreply.github.com>
Date: Thu, 19 Nov 2026 16:08:38 +0000
Subject: [PATCH 01/10] fix: remove message hovers and set the indicator width
to 15px
Remove native and jQuery UI tooltips from message rows and recommendation indicators while retaining accessible labels and click-open details. Use form_selectable_cell with a 15px width for every indicator cell and constrain matching headers and cell padding.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
CHANGELOG.md | 1 +
README.md | 10 +++++-----
css/search.css | 5 +----
includes/functions.php | 10 +++++-----
includes/recommendations.php | 2 +-
js/functions.js | 26 +------------------------
syslog.php | 6 +++---
tests/Fixtures/compact_workspace.php | 2 +-
tests/Unit/RecommendationsTest.php | 10 ++++++----
tests/browser/compact_workspace.cjs | 29 ++++++++++++++--------------
tests/browser/threshold_messages.cjs | 2 ++
11 files changed, 40 insertions(+), 63 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 598df61b..4b913379 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
--- develop ---
+* bug: Remove message-row and lightbulb hover tooltips, keep details in the click-open flyout, and fix the recommendation column at 15 pixels
* bug: Remove recommendation callbacks on message hover, show a theme-aware lightbulb before messages with matching recommendations, and include the CSRF token in the details flyout's fallback POST
--- 5.0 ---
diff --git a/README.md b/README.md
index 7a09cb2c..f8ce9cfc 100644
--- a/README.md
+++ b/README.md
@@ -588,11 +588,11 @@ evaluates the rules, and records fired alerts in `syslog_logs`.
## Recommendations
Recommendations explain what a message means and what to do about it. A lightbulb
-in the narrow column immediately before Message marks matching messages on the
-System Logs and Alert Logs tabs, including grouped messages. Availability is
-checked in batches when the page is rendered, not through hover callbacks.
-Hovering shows the full message already present in the row's title without any
-network requests. Click the message or row to read recommendations in the flyout.
+in the fixed 15-pixel column immediately before Message marks matching messages
+on the System Logs and Alert Logs tabs, including grouped messages. Availability
+is checked in batches when the page is rendered, not through hover callbacks.
+Message rows and lightbulbs have no hover tooltips or hover-triggered requests.
+Click the message or row to read the full message and recommendations in the flyout.
Clicking a row on the System Logs or Alert Logs tab opens a **Message details**
flyout on the right. The flyout fetches the record from the server and shows
diff --git a/css/search.css b/css/search.css
index 2b45ee1b..c725563f 100644
--- a/css/search.css
+++ b/css/search.css
@@ -649,7 +649,7 @@
#syslog_workspace tr:has(.syslogMessageOpen) td:first-child { font-variant-numeric: tabular-nums; }
#syslog_workspace td.syslogMessage { width: 100%; max-width: 0; }
#syslog_workspace th:has(.syslogRecommendationHeading),
-#syslog_workspace td.syslogRecommendation { width: 1%; min-width: 20px; text-align: center; }
+#syslog_workspace tr td.syslogRecommendation { box-sizing: border-box; width: 15px; min-width: 15px; max-width: 15px; padding-left: 0; padding-right: 0; text-align: center; }
#syslog_workspace .syslogRecommendationIndicator { color: var(--search-accent, currentColor); }
.syslogMessageOpen { display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
/* Trim "All Text": the whole message wraps inside its column. */
@@ -962,9 +962,6 @@
outline-offset: -1px;
}
-/* Hover text comes from the row title; recommendation cards live in the flyout. */
-.ui-tooltip.syslogRecommendationTip { max-width: 520px; padding: 0; overflow: hidden; }
-.syslogMessageTip { padding: 8px 10px; font-size: 12px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.syslogRecSection + .syslogRecSection { margin-top: 6px; }
.syslogRecLabel { font-weight: 700; opacity: .75; text-transform: uppercase; font-size: 10px; letter-spacing: .04em; }
.syslogRecText { white-space: pre-line; overflow-wrap: anywhere; }
diff --git a/includes/functions.php b/includes/functions.php
index 2413561d..69f8a704 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -4551,18 +4551,18 @@ function syslog_priority_class($priority): string {
}
/**
- * Prints the opening row tag with the priority CSS class and message tooltip
- * for each row of the syslog table as it is displayed. It supports both the
- * legacy as well as the new approach to controlling these colors.
+ * Prints the opening row tag with the priority CSS class for each row of
+ * the syslog table as it is displayed. It supports both the legacy as well
+ * as the new approach to controlling these colors.
*
* @param mixed $priority The syslog priority level of the row.
- * @param mixed $message The syslog message for the row tooltip.
+ * @param mixed $message The syslog message (unused, kept for compatibility).
*
* @return string Always an empty string, kept for legacy row composition.
*/
function syslog_row_color($priority, $message): string {
$priority_class = syslog_priority_class($priority);
- print "
";
+ print " ";
return '';
}
diff --git a/includes/recommendations.php b/includes/recommendations.php
index 29d3a00e..113f6ddd 100644
--- a/includes/recommendations.php
+++ b/includes/recommendations.php
@@ -608,7 +608,7 @@ function syslog_recommendation_indicator(bool $available): string {
$label = __esc('Recommendation available - click the message for details', 'syslog');
- return ' ';
}
diff --git a/js/functions.js b/js/functions.js
index b866ec90..63a4f228 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -284,7 +284,6 @@ function initSyslogWorkspace() {
var row = button.closest('tr');
row.classList.add('syslogRowOpen');
var data = JSON.parse(button.dataset.message);
- row.title = data.message || '';
// Show facility and severity through badges, leaving message backgrounds neutral.
[
['facility', 'syslogFacility'],
@@ -301,7 +300,6 @@ function initSyslogWorkspace() {
});
});
function open() {
- if ($(row).tooltip('instance')) $(row).tooltip('close');
deselect();
active = button;
row.classList.add('syslogSelected');
@@ -1379,34 +1377,12 @@ function syslogRecommendationCards($parent, recommendations, labels, clipped) {
}
/**
- * Show the locally available title as text, without requesting the server.
- *
- * @returns {jQuery} The full message or indicator tooltip, never parsed as HTML.
- */
-function syslogRowTooltip() {
- return $('
').text($(this).attr('title') || '');
-}
-
-/**
- * Initialize syslog message tooltips and group expand/collapse functionality
+ * Initialize group expand/collapse and tooltips for non-message buttons.
* Call this after the syslog message table is rendered or updated
*/
function initSyslogMessagesDisplay() {
$(function() {
applySyslogTheme(document.getElementById('syslog_workspace'));
- // Initialize tooltips for syslog rows
- $('.syslogRow').tooltip({
- track: true,
- show: {
- effect: 'fade',
- duration: 250,
- delay: 125
- },
- position: { my: 'left+15 center', at: 'right center' },
- classes: { 'ui-tooltip': 'syslogRecommendationTip' },
- content: syslogRowTooltip
- });
-
// Initialize tooltips for buttons
$('button').not('.syslogRow button').tooltip({
closed: true
diff --git a/syslog.php b/syslog.php
index 413602ec..af123dee 100644
--- a/syslog.php
+++ b/syslog.php
@@ -2747,7 +2747,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . syslog_value_filter_button($hosts[$sm['host_id']] ?? __('Unknown', 'syslog'), 'host') . ' ';
print "" . syslog_value_filter_button($sm['program'], 'program') . ' ';
- print "" . syslog_recommendation_indicator($recommendations[$row]) . ' ';
+ form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $sm['seq'], '15px', 'center syslogRecommendation');
// Group summaries show the latest timestamp; use its matching sequence ID.
$rule_id = $grouping_enabled && !empty($sm['seq_list']) ? explode(',', $sm['seq_list'])[0] : $sm[$syslog_incoming_config['id']];
form_selectable_cell(syslog_message_button($sm['message'], $hosts[$sm['host_id']] ?? '', $sm['program'], $facilities[$sm['facility_id']] ?? '', $priorities[$sm['priority_id']] ?? '', $sm['logtime'], $rule_id, $sm['mtype'], $trim), $sm['seq'], '', 'left syslogMessage');
@@ -2774,7 +2774,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . html_escape($dm['logtime']) . ' ';
print "" . syslog_value_filter_button($hosts[$dm['host_id']] ?? __('Unknown', 'syslog'), 'host') . ' ';
print "" . syslog_value_filter_button($dm['program'], 'program') . ' ';
- print "" . syslog_recommendation_indicator($recommendations[$row]) . ' ';
+ form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $dm['seq'], '15px', 'center syslogRecommendation');
print "" . syslog_message_button($dm['message'], $hosts[$dm['host_id']] ?? '', $dm['program'], $facilities[$dm['facility_id']] ?? '', $priorities[$dm['priority_id']] ?? '', $dm['logtime'], $dm[$syslog_incoming_config['id']], $sm['mtype'], $trim) . ' ';
print "" . syslog_metadata_label(isset($facilities[$dm['facility_id']]) ? $facilities[$dm['facility_id']] : __('Unknown', 'syslog'), 'facility') . ' ';
print "" . syslog_value_filter_button($priorities[$dm['priority_id']] ?? __('Unknown', 'syslog'), 'priority') . ' ';
@@ -2840,7 +2840,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . syslog_value_filter_button($log['host'], 'host') . ' ';
form_selectable_cell(isset($severities[$log['severity']]) ? $severities[$log['severity']] : __('Unknown', 'syslog'), $log['seq'], '', 'left');
form_selectable_cell(filter_value($log['name'] != '' ? $log['name'] : __('Alert Removed', 'syslog'), get_request_var('rfilter'), $config['url_path'] . 'plugins/syslog/syslog.php?id=' . $log['seq'] . '&tab=current'), $log['seq'], '', 'left');
- print "" . syslog_recommendation_indicator($recommendations[$row]) . ' ';
+ form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $log['seq'], '15px', 'center syslogRecommendation');
form_selectable_cell(syslog_message_button($log['logmsg'], $log['host'], $log['program'] ?? '', $log['facility'], $log['priority'], $log['logtime'], $log['seq'], 'alert', $trim), $log['seq'], '', 'syslogMessage left');
form_selectable_cell($log['count'], $log['seq'], '', 'right');
diff --git a/tests/Fixtures/compact_workspace.php b/tests/Fixtures/compact_workspace.php
index 7114b38e..4482bdab 100644
--- a/tests/Fixtures/compact_workspace.php
+++ b/tests/Fixtures/compact_workspace.php
@@ -32,7 +32,7 @@ function read_user_setting($name, $default = false, $force = false) { return $de
$priorities = ['emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'];
$message = 'nf_conntrack: table full, dropping packet ';
$long_message = $message . ' ' . str_repeat('width preview ', 4);
-foreach(range(1,17) as $i) echo ' 2026-09-13 00:12:42 10.0.0.5 kernel '.syslog_recommendation_indicator($i === 1).' '.syslog_message_button($i === 1 ? $long_message : $message,'10.0.0.5','kernel','kern',$priorities[$i % 8],'2026-09-13 00:12:42', 100 + $i, $i === 17 ? 'removed' : 'main').' kern '.$priorities[$i % 8].' ';
+foreach(range(1,17) as $i) echo '2026-09-13 00:12:42 10.0.0.5 kernel '.syslog_recommendation_indicator($i === 1).' '.syslog_message_button($i === 1 ? $long_message : $message,'10.0.0.5','kernel','kern',$priorities[$i % 8],'2026-09-13 00:12:42', 100 + $i, $i === 17 ? 'removed' : 'main').' kern '.$priorities[$i % 8].' ';
echo '';
$start = strpos($source,"');
eval('?>'.substr($source,$start,$end-$start));
diff --git a/tests/Unit/RecommendationsTest.php b/tests/Unit/RecommendationsTest.php
index 9dba3c9a..fc334844 100644
--- a/tests/Unit/RecommendationsTest.php
+++ b/tests/Unit/RecommendationsTest.php
@@ -550,7 +550,7 @@ function recommendation_sample(array $override = []): array {
->and($flag)->toBe([SYSLOG_RECOMMENDATIONS_SEED_FLAG => '1']);
});
-it('keeps the escaped full message in the title without enabling hover lookups', function () {
+it('renders message rows without hover titles or recommendation lookups', function () {
syslog_load_plugin_source('includes/functions.php');
$queries = [];
@@ -564,8 +564,8 @@ function recommendation_sample(array $override = []): array {
syslog_row_color('3', '');
$html = ob_get_clean();
- expect($html)->not->toContain('data-recommendations')
- ->toContain("title='<script>alert("message")</script>'")
+ expect($html)->not->toContain('title=')
+ ->not->toContain('data-recommendations')
->and($queries)->toBe([]);
});
@@ -661,5 +661,7 @@ function recommendation_sample(array $override = []): array {
expect(syslog_recommendation_indicator(false))->toBe('')
->and($html)->toContain('fa-lightbulb', 'role="img"', 'aria-label="Recommendation available - click the message for details"')
- ->not->toContain('onclick', 'data-action');
+ ->not->toContain('title=')
+ ->not->toContain('onclick')
+ ->not->toContain('data-action');
});
diff --git a/tests/browser/compact_workspace.cjs b/tests/browser/compact_workspace.cjs
index 2e4e7247..b8a8ebd6 100644
--- a/tests/browser/compact_workspace.cjs
+++ b/tests/browser/compact_workspace.cjs
@@ -40,6 +40,12 @@ const fixture = execFileSync('php', [path.join(root, 'tests/Fixtures/compact_wor
await page.goto('http://fixture/'); await page.waitForTimeout(250);
assert.deepEqual(errors,[]);
const messageButton = page.locator('.syslogMessageOpen').first();
+ const indicatorColumns = page.locator('th:has(.syslogRecommendationHeading), td.syslogRecommendation');
+ async function checkIndicatorWidths() {
+ const widths = await indicatorColumns.evaluateAll(cells => cells.map(cell => cell.getBoundingClientRect().width));
+ assert(widths.length > 1 && widths.every(width => width === 15), 'The lightbulb header and cells stay exactly 15px wide');
+ }
+ await checkIndicatorWidths();
assert.equal(await messageButton.textContent(), longMessage, 'Preview retains text beyond 100 characters');
const widePreview = await messageButton.evaluate(button => {
const range = document.createRange();
@@ -98,22 +104,14 @@ const fixture = execFileSync('php', [path.join(root, 'tests/Fixtures/compact_wor
assert.equal(await page.locator('.syslogRow').first().locator('.syslogRecommendationIndicator').count(), 1, 'Matching messages advertise recommendations before a click');
assert.equal(await page.locator('.syslogRow').nth(1).locator('.syslogRecommendation').textContent(), '', 'Unmatched messages leave the indicator column blank');
assert.equal(await page.locator('.syslogRecommendationIndicator').first().evaluate(icon => icon.parentElement.nextElementSibling.classList.contains('syslogMessage')), true, 'The indicator immediately precedes the message');
+ assert.equal(await page.locator('.syslogRow[title], .syslogRow [title]').count(), 0, 'Message rows and their contents have no native hover titles');
const beforeHover = dispatched.length;
- await messageButton.hover();
- const messageTooltip = page.locator('.ui-tooltip:visible .syslogMessageTip');
- await messageTooltip.waitFor();
- assert.equal(await messageTooltip.textContent(), longMessage, 'Hover shows the full untrimmed message');
- assert.equal(await page.locator('.ui-tooltip:visible script').count(), 0, 'Hover treats message markup as literal text');
- await page.mouse.move(0, 0);
- await messageTooltip.waitFor({state: 'hidden'});
- await messageButton.hover();
- await messageTooltip.waitFor();
- assert.equal(await messageTooltip.textContent(), longMessage, 'Repeated hovers preserve the full message');
- await page.mouse.move(0, 0);
- await messageTooltip.waitFor({state: 'hidden'});
- await page.locator('.syslogRecommendationIndicator').first().hover();
- await page.locator('.ui-tooltip:visible').filter({hasText: 'Recommendation available - click the message for details'}).waitFor();
- assert.equal(dispatched.length, beforeHover, 'Neither message nor lightbulb hovers issue any requests');
+ for (const target of [messageButton, ...await page.locator('.syslogRow').first().locator('td').all(), page.locator('.syslogRecommendationIndicator').first(), messageButton]) {
+ await target.hover();
+ await page.waitForTimeout(400);
+ assert.equal(await page.locator('.ui-tooltip:visible').count(), 0, 'Hovering messages, metadata, or the lightbulb never opens a tooltip');
+ }
+ assert.equal(dispatched.length, beforeHover, 'Message-row and lightbulb hovers issue no requests');
await page.mouse.move(0, 0);
await page.waitForFunction(() => $('.ui-tooltip:visible').length === 0);
await page.locator('.syslogMessageOpen').first().click();
@@ -173,6 +171,7 @@ const fixture = execFileSync('php', [path.join(root, 'tests/Fixtures/compact_wor
await page.mouse.move(0, 0);
await page.waitForFunction(() => $('.ui-tooltip:visible').length === 0);
await page.setViewportSize({width:390,height:844});if (process.env.TEST_ARTIFACT_DIR) await page.screenshot({path:path.join(process.env.TEST_ARTIFACT_DIR, 'syslog-workspace-mobile.png'),fullPage:true});
+ await checkIndicatorWidths();
assert.equal(await messageButton.textContent(), longMessage, 'Narrow layouts retain the complete preview text');
const narrowPreview = await messageButton.evaluate(button => ({width: button.clientWidth, content: button.scrollWidth, ellipsis: getComputedStyle(button).textOverflow}));
assert(narrowPreview.content > narrowPreview.width, 'Long previews overflow their own button on narrow screens');
diff --git a/tests/browser/threshold_messages.cjs b/tests/browser/threshold_messages.cjs
index f8134db9..92613c64 100644
--- a/tests/browser/threshold_messages.cjs
+++ b/tests/browser/threshold_messages.cjs
@@ -18,6 +18,7 @@ const html = execFileSync('php', [path.join(__dirname, '../Fixtures/threshold_me
assert.equal(await rows.nth(0).locator('td').count(), 8);
assert.equal(await rows.nth(0).locator('td').nth(3).locator('.syslogRecommendationIndicator').count(), 1);
assert.equal(await rows.nth(1).locator('td').nth(3).textContent(), '');
+ assert.equal(await rows.nth(0).locator('td').nth(3).evaluate(cell => cell.style.width), '15px', 'Individual recommendation cells declare their fixed width');
const grouped = page.locator('#grouped tr');
assert.equal(await grouped.count(), 3);
assert.equal(await grouped.nth(0).locator('td').nth(7).textContent(), 'Yes');
@@ -26,6 +27,7 @@ const html = execFileSync('php', [path.join(__dirname, '../Fixtures/threshold_me
assert.equal(await grouped.nth(0).locator('td').count(), 9);
assert.equal(await grouped.nth(1).locator('td').count(), 9);
assert.equal(await grouped.locator('td:nth-child(4) .syslogRecommendationIndicator').count(), 3, 'Grouped summaries and their identical messages share the indicator');
+ assert.deepEqual(await grouped.locator('td.syslogRecommendation').evaluateAll(cells => cells.map(cell => cell.style.width)), ['15px', '15px', '15px'], 'Grouped summaries and details use the same fixed recommendation width');
console.log('Threshold message column passed: Yes/No, grouped summary, and individual details');
} finally { await browser.close(); }
})().catch(error => { console.error(error); process.exit(1); });
From e2ed218109e23233306da7d231d5b1ec7c5f0b2a Mon Sep 17 00:00:00 2001
From: TheWitness <1439914+TheWitness@users.noreply.github.com>
Date: Thu, 19 Nov 2026 16:15:04 +0000
Subject: [PATCH 02/10] fix: widen recommendation indicators to 20px
Use a fixed 20px width for recommendation headers and all message-row variants. Retain the centered header alignment and verify it alongside desktop and mobile column widths.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
CHANGELOG.md | 2 +-
README.md | 2 +-
css/search.css | 2 +-
syslog.php | 6 +++---
tests/Fixtures/compact_workspace.php | 2 +-
tests/browser/compact_workspace.cjs | 3 ++-
tests/browser/threshold_messages.cjs | 4 ++--
7 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b913379..5537f984 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
--- develop ---
-* bug: Remove message-row and lightbulb hover tooltips, keep details in the click-open flyout, and fix the recommendation column at 15 pixels
+* bug: Remove message-row and lightbulb hover tooltips, keep details in the click-open flyout, and fix the recommendation column at 20 pixels with a centered header
* bug: Remove recommendation callbacks on message hover, show a theme-aware lightbulb before messages with matching recommendations, and include the CSRF token in the details flyout's fallback POST
--- 5.0 ---
diff --git a/README.md b/README.md
index f8ce9cfc..c59fa9b7 100644
--- a/README.md
+++ b/README.md
@@ -588,7 +588,7 @@ evaluates the rules, and records fired alerts in `syslog_logs`.
## Recommendations
Recommendations explain what a message means and what to do about it. A lightbulb
-in the fixed 15-pixel column immediately before Message marks matching messages
+in the fixed 20-pixel column immediately before Message marks matching messages
on the System Logs and Alert Logs tabs, including grouped messages. Availability
is checked in batches when the page is rendered, not through hover callbacks.
Message rows and lightbulbs have no hover tooltips or hover-triggered requests.
diff --git a/css/search.css b/css/search.css
index c725563f..b9be769c 100644
--- a/css/search.css
+++ b/css/search.css
@@ -649,7 +649,7 @@
#syslog_workspace tr:has(.syslogMessageOpen) td:first-child { font-variant-numeric: tabular-nums; }
#syslog_workspace td.syslogMessage { width: 100%; max-width: 0; }
#syslog_workspace th:has(.syslogRecommendationHeading),
-#syslog_workspace tr td.syslogRecommendation { box-sizing: border-box; width: 15px; min-width: 15px; max-width: 15px; padding-left: 0; padding-right: 0; text-align: center; }
+#syslog_workspace tr td.syslogRecommendation { box-sizing: border-box; width: 20px; min-width: 20px; max-width: 20px; padding-left: 0; padding-right: 0; text-align: center; }
#syslog_workspace .syslogRecommendationIndicator { color: var(--search-accent, currentColor); }
.syslogMessageOpen { display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
/* Trim "All Text": the whole message wraps inside its column. */
diff --git a/syslog.php b/syslog.php
index af123dee..48fb1b40 100644
--- a/syslog.php
+++ b/syslog.php
@@ -2747,7 +2747,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . syslog_value_filter_button($hosts[$sm['host_id']] ?? __('Unknown', 'syslog'), 'host') . ' ';
print "" . syslog_value_filter_button($sm['program'], 'program') . ' ';
- form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $sm['seq'], '15px', 'center syslogRecommendation');
+ form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $sm['seq'], '20px', 'center syslogRecommendation');
// Group summaries show the latest timestamp; use its matching sequence ID.
$rule_id = $grouping_enabled && !empty($sm['seq_list']) ? explode(',', $sm['seq_list'])[0] : $sm[$syslog_incoming_config['id']];
form_selectable_cell(syslog_message_button($sm['message'], $hosts[$sm['host_id']] ?? '', $sm['program'], $facilities[$sm['facility_id']] ?? '', $priorities[$sm['priority_id']] ?? '', $sm['logtime'], $rule_id, $sm['mtype'], $trim), $sm['seq'], '', 'left syslogMessage');
@@ -2774,7 +2774,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . html_escape($dm['logtime']) . ' ';
print "" . syslog_value_filter_button($hosts[$dm['host_id']] ?? __('Unknown', 'syslog'), 'host') . ' ';
print "" . syslog_value_filter_button($dm['program'], 'program') . ' ';
- form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $dm['seq'], '15px', 'center syslogRecommendation');
+ form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $dm['seq'], '20px', 'center syslogRecommendation');
print "" . syslog_message_button($dm['message'], $hosts[$dm['host_id']] ?? '', $dm['program'], $facilities[$dm['facility_id']] ?? '', $priorities[$dm['priority_id']] ?? '', $dm['logtime'], $dm[$syslog_incoming_config['id']], $sm['mtype'], $trim) . ' ';
print "" . syslog_metadata_label(isset($facilities[$dm['facility_id']]) ? $facilities[$dm['facility_id']] : __('Unknown', 'syslog'), 'facility') . ' ';
print "" . syslog_value_filter_button($priorities[$dm['priority_id']] ?? __('Unknown', 'syslog'), 'priority') . ' ';
@@ -2840,7 +2840,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . syslog_value_filter_button($log['host'], 'host') . ' ';
form_selectable_cell(isset($severities[$log['severity']]) ? $severities[$log['severity']] : __('Unknown', 'syslog'), $log['seq'], '', 'left');
form_selectable_cell(filter_value($log['name'] != '' ? $log['name'] : __('Alert Removed', 'syslog'), get_request_var('rfilter'), $config['url_path'] . 'plugins/syslog/syslog.php?id=' . $log['seq'] . '&tab=current'), $log['seq'], '', 'left');
- form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $log['seq'], '15px', 'center syslogRecommendation');
+ form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $log['seq'], '20px', 'center syslogRecommendation');
form_selectable_cell(syslog_message_button($log['logmsg'], $log['host'], $log['program'] ?? '', $log['facility'], $log['priority'], $log['logtime'], $log['seq'], 'alert', $trim), $log['seq'], '', 'syslogMessage left');
form_selectable_cell($log['count'], $log['seq'], '', 'right');
diff --git a/tests/Fixtures/compact_workspace.php b/tests/Fixtures/compact_workspace.php
index 4482bdab..7b3f2eb6 100644
--- a/tests/Fixtures/compact_workspace.php
+++ b/tests/Fixtures/compact_workspace.php
@@ -32,7 +32,7 @@ function read_user_setting($name, $default = false, $force = false) { return $de
$priorities = ['emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'];
$message = 'nf_conntrack: table full, dropping packet ';
$long_message = $message . ' ' . str_repeat('width preview ', 4);
-foreach(range(1,17) as $i) echo '2026-09-13 00:12:42 10.0.0.5 kernel '.syslog_recommendation_indicator($i === 1).' '.syslog_message_button($i === 1 ? $long_message : $message,'10.0.0.5','kernel','kern',$priorities[$i % 8],'2026-09-13 00:12:42', 100 + $i, $i === 17 ? 'removed' : 'main').' kern '.$priorities[$i % 8].' ';
+foreach(range(1,17) as $i) echo '2026-09-13 00:12:42 10.0.0.5 kernel '.syslog_recommendation_indicator($i === 1).' '.syslog_message_button($i === 1 ? $long_message : $message,'10.0.0.5','kernel','kern',$priorities[$i % 8],'2026-09-13 00:12:42', 100 + $i, $i === 17 ? 'removed' : 'main').' kern '.$priorities[$i % 8].' ';
echo '';
$start = strpos($source,"');
eval('?>'.substr($source,$start,$end-$start));
diff --git a/tests/browser/compact_workspace.cjs b/tests/browser/compact_workspace.cjs
index b8a8ebd6..cfd43370 100644
--- a/tests/browser/compact_workspace.cjs
+++ b/tests/browser/compact_workspace.cjs
@@ -43,7 +43,8 @@ const fixture = execFileSync('php', [path.join(root, 'tests/Fixtures/compact_wor
const indicatorColumns = page.locator('th:has(.syslogRecommendationHeading), td.syslogRecommendation');
async function checkIndicatorWidths() {
const widths = await indicatorColumns.evaluateAll(cells => cells.map(cell => cell.getBoundingClientRect().width));
- assert(widths.length > 1 && widths.every(width => width === 15), 'The lightbulb header and cells stay exactly 15px wide');
+ assert(widths.length > 1 && widths.every(width => width === 20), 'The lightbulb header and cells stay exactly 20px wide');
+ assert.equal(await page.locator('th:has(.syslogRecommendationHeading)').evaluate(cell => getComputedStyle(cell).textAlign), 'center', 'The lightbulb header is centered');
}
await checkIndicatorWidths();
assert.equal(await messageButton.textContent(), longMessage, 'Preview retains text beyond 100 characters');
diff --git a/tests/browser/threshold_messages.cjs b/tests/browser/threshold_messages.cjs
index 92613c64..3b0e293a 100644
--- a/tests/browser/threshold_messages.cjs
+++ b/tests/browser/threshold_messages.cjs
@@ -18,7 +18,7 @@ const html = execFileSync('php', [path.join(__dirname, '../Fixtures/threshold_me
assert.equal(await rows.nth(0).locator('td').count(), 8);
assert.equal(await rows.nth(0).locator('td').nth(3).locator('.syslogRecommendationIndicator').count(), 1);
assert.equal(await rows.nth(1).locator('td').nth(3).textContent(), '');
- assert.equal(await rows.nth(0).locator('td').nth(3).evaluate(cell => cell.style.width), '15px', 'Individual recommendation cells declare their fixed width');
+ assert.equal(await rows.nth(0).locator('td').nth(3).evaluate(cell => cell.style.width), '20px', 'Individual recommendation cells declare their fixed width');
const grouped = page.locator('#grouped tr');
assert.equal(await grouped.count(), 3);
assert.equal(await grouped.nth(0).locator('td').nth(7).textContent(), 'Yes');
@@ -27,7 +27,7 @@ const html = execFileSync('php', [path.join(__dirname, '../Fixtures/threshold_me
assert.equal(await grouped.nth(0).locator('td').count(), 9);
assert.equal(await grouped.nth(1).locator('td').count(), 9);
assert.equal(await grouped.locator('td:nth-child(4) .syslogRecommendationIndicator').count(), 3, 'Grouped summaries and their identical messages share the indicator');
- assert.deepEqual(await grouped.locator('td.syslogRecommendation').evaluateAll(cells => cells.map(cell => cell.style.width)), ['15px', '15px', '15px'], 'Grouped summaries and details use the same fixed recommendation width');
+ assert.deepEqual(await grouped.locator('td.syslogRecommendation').evaluateAll(cells => cells.map(cell => cell.style.width)), ['20px', '20px', '20px'], 'Grouped summaries and details use the same fixed recommendation width');
console.log('Threshold message column passed: Yes/No, grouped summary, and individual details');
} finally { await browser.close(); }
})().catch(error => { console.error(error); process.exit(1); });
From cbe438bdf24383f2585143a52e9719a8ffd0955e Mon Sep 17 00:00:00 2001
From: TheWitness <1439914+TheWitness@users.noreply.github.com>
Date: Thu, 19 Nov 2026 16:31:58 +0000
Subject: [PATCH 03/10] fix: bound grouped message loading and preserve active
filters
Fetch group members on demand in bounded pages using the rendered search and date range. Keep relative ranges fixed during expansion, and avoid collecting every member ID or rendering hidden occurrences.
Order Cancel before Save and show the Font Awesome refresh spinner only while filter callbacks remain pending.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
CHANGELOG.md | 2 +
README.md | 6 +
css/search.css | 2 +
includes/functions.php | 168 ++++++++++++++++++++---
js/functions.js | 122 +++++++++++-----
locales/po/cacti.pot | 40 ++++--
syslog.php | 70 +++++-----
tests/Fixtures/compact_workspace.php | 2 +-
tests/Fixtures/threshold_messages.php | 23 +++-
tests/Unit/MessageDigestGroupingTest.php | 78 +++++++++--
tests/browser/compact_workspace.cjs | 32 ++++-
tests/browser/threshold_messages.cjs | 72 ++++++++--
12 files changed, 494 insertions(+), 123 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5537f984..ed2b400c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
--- develop ---
+* bug: Load grouped message details only on expansion, 50 at a time, preserving the displayed query's date range and filters instead of rendering every occurrence into hidden rows
+* bug: Place Cancel before Save in Save Search As, and show a Font Awesome refresh glyph that spins only while results callbacks are running
* bug: Remove message-row and lightbulb hover tooltips, keep details in the click-open flyout, and fix the recommendation column at 20 pixels with a centered header
* bug: Remove recommendation callbacks on message hover, show a theme-aware lightbulb before messages with matching recommendations, and include the CSRF token in the details flyout's fallback POST
diff --git a/README.md b/README.md
index c59fa9b7..3fdcd133 100644
--- a/README.md
+++ b/README.md
@@ -594,6 +594,12 @@ is checked in batches when the page is rendered, not through hover callbacks.
Message rows and lightbulbs have no hover tooltips or hover-triggered requests.
Click the message or row to read the full message and recommendations in the flyout.
+Grouped Messages initially renders summaries only. Expand a group to load 50
+matching occurrences at a time; Previous and Next replace that detail page.
+Expansion preserves the displayed search filters and date range, including the
+original bounds of relative time presets. It does not load every duplicate into
+hidden rows. Refresh the results if an older grouped view has expired.
+
Clicking a row on the System Logs or Alert Logs tab opens a **Message details**
flyout on the right. The flyout fetches the record from the server and shows
its date, device, program, facility, priority and sequence (plus the alert rule
diff --git a/css/search.css b/css/search.css
index b9be769c..2766a111 100644
--- a/css/search.css
+++ b/css/search.css
@@ -651,6 +651,8 @@
#syslog_workspace th:has(.syslogRecommendationHeading),
#syslog_workspace tr td.syslogRecommendation { box-sizing: border-box; width: 20px; min-width: 20px; max-width: 20px; padding-left: 0; padding-right: 0; text-align: center; }
#syslog_workspace .syslogRecommendationIndicator { color: var(--search-accent, currentColor); }
+#syslog_workspace .syslog-group-toggle { padding: 0; margin-right: 5px; border: 0; background: transparent; color: inherit; cursor: pointer; }
+#syslog_workspace .syslogGroupPage button { margin-left: 8px; }
.syslogMessageOpen { display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
/* Trim "All Text": the whole message wraps inside its column. */
.syslogMessageOpen.syslogMessageWrap { white-space: pre-wrap; overflow-wrap: anywhere; text-overflow: clip; }
diff --git a/includes/functions.php b/includes/functions.php
index 69f8a704..a28ca18a 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -356,13 +356,16 @@ function syslog_search_time_presets(): array {
*
* @param string $operator 'last' or 'during'.
* @param string $value A preset value of that operator.
+ * @param int|null $now Freeze relative ranges at this Unix timestamp.
*
* @return string The condition on syslog.logtime.
*
* @throws InvalidArgumentException When the preset is unknown.
*/
-function syslog_search_time_sql(string $operator, string $value): string {
+function syslog_search_time_sql(string $operator, string $value, ?int $now = null): string {
$presets = syslog_search_time_presets();
+ $clock = $now === null ? 'NOW()' : 'FROM_UNIXTIME(' . $now . ')';
+ $today = $now === null ? 'CURDATE()' : 'DATE(' . $clock . ')';
if (!isset($presets[$operator][$value])) {
throw new InvalidArgumentException('Invalid date preset.');
@@ -375,14 +378,14 @@ function syslog_search_time_sql(string $operator, string $value): string {
$interval = (int) $value . ' SECOND';
}
- return '(syslog.logtime BETWEEN DATE_SUB(NOW(), INTERVAL ' . $interval . ') AND NOW())';
+ return '(syslog.logtime BETWEEN DATE_SUB(' . $clock . ', INTERVAL ' . $interval . ') AND ' . $clock . ')';
}
// Days counted back from today to the configured first day of the week (0 = Sunday).
$first = function_exists('read_user_setting') ? (int) read_user_setting('first_weekdayid', 1) : 1;
- $week = 'DATE_SUB(CURDATE(), INTERVAL (WEEKDAY(CURDATE()) + ' . (8 - max(0, min(6, $first))) . ') % 7 DAY)';
- $month = "CAST(DATE_FORMAT(CURDATE(), '%Y-%m-01') AS DATE)";
- $year = 'MAKEDATE(YEAR(CURDATE()), 1)';
+ $week = 'DATE_SUB(' . $today . ', INTERVAL (WEEKDAY(' . $today . ') + ' . (8 - max(0, min(6, $first))) . ') % 7 DAY)';
+ $month = "CAST(DATE_FORMAT($today, '%Y-%m-01') AS DATE)";
+ $year = 'MAKEDATE(YEAR(' . $today . '), 1)';
if ($value === 'day_shift') {
$minutes = function (string $setting, string $default): int {
@@ -393,12 +396,12 @@ function syslog_search_time_sql(string $operator, string $value): string {
};
$range = [
- 'CURDATE() + INTERVAL ' . $minutes('day_shift_start', '07:00') . ' MINUTE',
- 'CURDATE() + INTERVAL ' . $minutes('day_shift_end', '18:00') . ' MINUTE'
+ $today . ' + INTERVAL ' . $minutes('day_shift_start', '07:00') . ' MINUTE',
+ $today . ' + INTERVAL ' . $minutes('day_shift_end', '18:00') . ' MINUTE'
];
} else {
[$when, $unit] = explode('_', $value);
- $start = ['day' => 'CURDATE()', 'week' => $week, 'month' => $month, 'year' => $year][$unit];
+ $start = ['day' => $today, 'week' => $week, 'month' => $month, 'year' => $year][$unit];
$step = ' INTERVAL 1 ' . strtoupper($unit);
$range = $when === 'this' ? [$start, $start . ' +' . $step] : [$start . ' -' . $step, $start];
}
@@ -555,12 +558,13 @@ function syslog_parse_logical_search(string $input): ?array {
*
* @param array|null $tree The parsed search tree.
* @param string $column The column name ('message' or 'logmsg').
+ * @param int|null $now Freeze relative ranges at this Unix timestamp.
*
* @return string The SQL WHERE clause fragment.
*
* @throws InvalidArgumentException When the tree or column is invalid.
*/
-function syslog_logical_search_sql(?array $tree, string $column): string {
+function syslog_logical_search_sql(?array $tree, string $column, ?int $now = null): string {
if (!in_array($column, ['message', 'logmsg'], true)) {
throw new InvalidArgumentException('Invalid message column.');
}
@@ -582,7 +586,7 @@ function syslog_logical_search_sql(?array $tree, string $column): string {
}
if ($operator === 'last' || $operator === 'during') {
- return syslog_search_time_sql($operator, (string) $value);
+ return syslog_search_time_sql($operator, (string) $value, $now);
}
$target = $field === 'message' ? $column : 'syslog.' . $field;
@@ -608,10 +612,10 @@ function syslog_logical_search_sql(?array $tree, string $column): string {
}
if ($tree[0] == 'NOT') {
- return '(NOT ' . syslog_logical_search_sql($tree[1], $column) . ')';
+ return '(NOT ' . syslog_logical_search_sql($tree[1], $column, $now) . ')';
}
- return '(' . syslog_logical_search_sql($tree[1], $column) . ' ' . $tree[0] . ' ' . syslog_logical_search_sql($tree[2], $column) . ')';
+ return '(' . syslog_logical_search_sql($tree[1], $column, $now) . ' ' . $tree[0] . ' ' . syslog_logical_search_sql($tree[2], $column, $now) . ')';
}
/**
@@ -8502,27 +8506,147 @@ function alert_replace_variables($alert, $results, $hostname = '') {
}
/**
- * Fetch a group's messages within the active search predicates.
+ * Preserve a bounded set of rendered group filters for subsequent detail requests.
+ *
+ * @param array $messages The displayed group summaries.
+ * @param string $sql_where The compiled search and date-range predicates.
+ * @param int $trim The displayed message trim setting.
+ * @param array $recommendations Recommendation availability keyed by summary row.
+ *
+ * @return string The opaque, session-owned filter context.
+ */
+function syslog_group_context(array $messages, string $sql_where, int $trim, array $recommendations): string {
+ $groups = [];
+
+ foreach ($messages as $key => $message) {
+ if (($message['occurrence_count'] ?? 0) > 1) {
+ $groups[$key] = [
+ 'source' => $message['mtype'],
+ 'id' => $message['latest_seq'],
+ 'logtime' => $message['logtime'],
+ 'available' => $recommendations[$key]
+ ];
+ }
+ }
+
+ $token = bin2hex(random_bytes(16));
+ $_SESSION['syslog_group_contexts'][$token] = ['where' => $sql_where, 'trim' => $trim, 'groups' => $groups];
+ $_SESSION['syslog_group_contexts'] = array_slice($_SESSION['syslog_group_contexts'], -5, null, true);
+
+ return $token;
+}
+
+/**
+ * Fetch one bounded page of a group's messages within the active search predicates.
*
* @param array $group The grouped message row.
* @param string $sql_where The compiled message search clause.
* @param string $breach_sql The compiled threshold-breach expression.
+ * @param int $offset The zero-based detail-page offset.
*
* @return array|false The matching rows, or false on a database error.
*/
-function syslog_group_detail_messages(array $group, string $sql_where, string $breach_sql): array|false {
+function syslog_group_detail_messages(array $group, string $sql_where, string $breach_sql, int $offset = 0): array|false {
global $syslogdb_default;
- $seq_array = array_map('intval', explode(',', $group['seq_list']));
- $group_where = $sql_where . ($sql_where === '' ? 'WHERE ' : ' AND ') .
- 'syslog.seq IN (' . implode(',', array_fill(0, cacti_sizeof($seq_array), '?')) . ')';
-
- return syslog_db_fetch_assoc_prepared("SELECT `syslog`.*, $breach_sql AS threshold_breached, `syslog_programs`.`program`
+ $group_where = $sql_where === '' ? 'WHERE ' : 'WHERE (' . substr($sql_where, 6) . ') AND ';
+ $digest = syslog_message_digest_ready();
+ $group_where .= 'syslog.host_id = ? AND syslog.program_id = ? AND syslog.facility_id = ? AND syslog.priority_id = ? AND ' .
+ ($digest ? "IF(syslog.message_digest = '', MD5(syslog.message), syslog.message_digest)" : 'syslog.message') . ' = ?';
+ $params = [$group['host_id'], $group['program_id'], $group['facility_id'], $group['priority_id'],
+ $digest ? md5($group['message']) : $group['message']];
+
+ return syslog_db_fetch_assoc_prepared("SELECT syslog.seq, syslog.logtime, syslog.message, $breach_sql AS threshold_breached,
+ (SELECT host FROM `$syslogdb_default`.`syslog_hosts` AS sh WHERE sh.host_id = syslog.host_id) AS host,
+ syslog_programs.program,
+ (SELECT facility FROM `$syslogdb_default`.`syslog_facilities` AS sf WHERE sf.facility_id = syslog.facility_id) AS facility,
+ (SELECT priority FROM `$syslogdb_default`.`syslog_priorities` AS sp WHERE sp.priority_id = syslog.priority_id) AS priority
FROM `$syslogdb_default`.`" . (($group['mtype'] === 'main') ? 'syslog' : 'syslog_removed') . "` AS syslog
- LEFT JOIN `$syslogdb_default`.`syslog_programs`
- ON syslog.program_id = syslog_programs.program_id
+ LEFT JOIN `$syslogdb_default`.`syslog_programs` AS syslog_programs ON syslog.program_id = syslog_programs.program_id
$group_where
- ORDER BY syslog.logtime DESC", $seq_array);
+ ORDER BY syslog.logtime DESC, syslog.seq DESC
+ LIMIT 51 OFFSET " . $offset, $params);
+}
+
+/**
+ * Resolve a detail page exclusively from its server-owned filter context.
+ *
+ * @param string $token The rendered view's context token.
+ * @param string $group The rendered summary index.
+ * @param string $offset The zero-based page offset.
+ *
+ * @return array The bounded page or an explicit error.
+ */
+function syslog_group_details_page(string $token, string $group, string $offset = '0'): array {
+ global $syslogdb_default;
+
+ $context = $_SESSION['syslog_group_contexts'][$token] ?? null;
+
+ if (!$context || !isset($context['groups'][$group]) || !ctype_digit($offset)
+ || filter_var($offset, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => PHP_INT_MAX - 51]]) === false) {
+ return ['error' => __('Grouped results are unavailable or expired. Refresh the results and try again.', 'syslog')];
+ }
+
+ $anchor = $context['groups'][$group];
+ $table = $anchor['source'] === 'main' ? 'syslog' : 'syslog_removed';
+ $where = $context['where'] === '' ? 'WHERE ' : 'WHERE (' . substr($context['where'], 6) . ') AND ';
+ $record = syslog_db_fetch_row_prepared("SELECT syslog.host_id, syslog.program_id, syslog.facility_id, syslog.priority_id, syslog.message
+ FROM `$syslogdb_default`.`$table` AS syslog
+ $where syslog.seq = ? AND syslog.logtime = ?
+ LIMIT 1", [$anchor['id'], $anchor['logtime']]);
+
+ if ($record === false) {
+ return ['error' => __('Group messages could not be loaded.', 'syslog')];
+ }
+
+ if (!$record) {
+ return ['error' => __('Grouped results are unavailable or expired. Refresh the results and try again.', 'syslog')];
+ }
+
+ $record['mtype'] = $anchor['source'];
+ $messages = syslog_group_detail_messages($record, $context['where'], syslog_message_breach_sql(), (int) $offset);
+
+ if ($messages === false) {
+ return ['error' => __('Group messages could not be loaded.', 'syslog')];
+ }
+
+ return [
+ 'rows' => array_slice($messages, 0, 50),
+ 'more' => cacti_sizeof($messages) > 50,
+ 'source' => $anchor['source'],
+ 'available' => $anchor['available'],
+ 'trim' => $context['trim']
+ ];
+}
+
+/**
+ * Render a bounded page of group members using the normal message controls.
+ *
+ * @param array $messages The detail-page records.
+ * @param string $source The stored or removed table name.
+ * @param int $trim The message trim setting.
+ * @param bool $available Whether the group has a recommendation.
+ *
+ * @return string The escaped detail row HTML.
+ */
+function syslog_group_detail_rows(array $messages, string $source, int $trim, bool $available): string {
+ ob_start();
+
+ foreach ($messages as $message) {
+ print "";
+ form_selectable_cell(html_escape($message['logtime']), $message['seq'], '', 'left');
+ print "" . syslog_value_filter_button($message['host'] ?? '', 'host') . ' ';
+ print "" . syslog_value_filter_button($message['program'] ?? '', 'program') . ' ';
+ form_selectable_cell(syslog_recommendation_indicator($available), $message['seq'], '20px', 'center syslogRecommendation');
+ form_selectable_cell(syslog_message_button($message['message'], $message['host'] ?? '', $message['program'] ?? '', $message['facility'] ?? '', $message['priority'] ?? '', $message['logtime'], $message['seq'], $source, $trim), $message['seq'], '', 'left syslogMessage');
+ form_selectable_cell(syslog_metadata_label($message['facility'] ?? '', 'facility'), $message['seq'], '', 'left');
+ print "" . syslog_value_filter_button($message['priority'] ?? '', 'priority') . ' ';
+ form_selectable_cell(!empty($message['threshold_breached']) ? __('Yes', 'syslog') : __('No', 'syslog'), $message['seq'], '1%', 'center');
+ form_selectable_cell('', $message['seq'], '', 'right');
+ print ' ';
+ }
+
+ return ob_get_clean();
}
/**
diff --git a/js/functions.js b/js/functions.js
index 63a4f228..0a31bff8 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -105,6 +105,25 @@ function initSyslogCompactSearch() {
}).filter(Boolean);
status.textContent = summaries.join(' ยท ');
$('#refresh_results').off('click').on('click', refreshResults);
+ var pending = $(document).data('syslogFilterRequests') || new Set();
+ $(document).data('syslogFilterRequests', pending);
+ function showRefreshActivity() {
+ $('#refresh_results i').toggleClass('fa-spin', pending.size > 0);
+ }
+ $(document).off('ajaxSend.syslogRefresh ajaxComplete.syslogRefresh')
+ .on('ajaxSend.syslogRefresh', function(event, xhr, settings) {
+ var url = new URL(settings.url, window.location.href);
+ var data = new URLSearchParams(typeof settings.data === 'string' ? settings.data : '');
+ var action = url.searchParams.get('action') || data.get('action');
+ if (url.origin === window.location.origin && /\/syslog\.php$/.test(url.pathname) && (!action || action === 'view')) {
+ pending.add(xhr);
+ showRefreshActivity();
+ }
+ }).on('ajaxComplete.syslogRefresh', function(event, xhr) {
+ pending.delete(xhr);
+ showRefreshActivity();
+ });
+ showRefreshActivity();
var summary = document.getElementById('syslog_search_summary');
summary.textContent = document.getElementById('rfilter').value || builder.dataset.message;
// Collapse the filter by default; only a saved 'false' preference keeps it open.
@@ -299,22 +318,17 @@ function initSyslogWorkspace() {
}
});
});
- function open() {
- deselect();
- active = button;
- row.classList.add('syslogSelected');
- button.setAttribute('aria-expanded', 'true');
- show(data);
- }
- // The message button keeps keyboard access; the rest of the row opens the pane too.
- button.addEventListener('click', function(event) {
- event.stopPropagation();
- open();
- });
- row.addEventListener('click', function(event) {
- if (event.target.closest('a, button, input, select, textarea, summary, .syslog-group-toggle')) return;
- open();
- });
+ });
+ // Delegation also covers group members loaded after the initial render.
+ $(workspace).off('click.syslogMessage').on('click.syslogMessage', 'tr.syslogRow', function(event) {
+ var button = this.querySelector('.syslogMessageOpen');
+ if (!button || event.target.closest('a, button:not(.syslogMessageOpen), input, select, textarea, summary')) return;
+ event.stopPropagation();
+ deselect();
+ active = button;
+ this.classList.add('syslogSelected');
+ button.setAttribute('aria-expanded', 'true');
+ show(JSON.parse(button.dataset.message));
});
/**
@@ -438,8 +452,9 @@ function syslogEnableColumnResize(workspace) {
});
}
-function initSyslogValueFilters() {
- document.querySelectorAll('.syslogValueFilter').forEach(function(button) {
+function initSyslogValueFilters(root) {
+ var buttons = Array.from((root || document).querySelectorAll('.syslogValueFilter'));
+ buttons.forEach(function(button) {
button.addEventListener('click', function(event) {
event.stopPropagation();
syslogAddFilterCondition(button.dataset.filterField, button.dataset.filterValue);
@@ -449,7 +464,7 @@ function initSyslogValueFilters() {
// The search builder initializes on document ready, so mark after it.
$(function() {
var builder = document.getElementById('syslog_search_builder');
- document.querySelectorAll('.syslogValueFilter').forEach(function(button) {
+ buttons.forEach(function(button) {
var active = builder && syslogFilterInScope(builder.searchRows, button.dataset.filterField, button.dataset.filterValue);
button.classList.toggle('syslogValueFilterActive', !!active);
button.setAttribute('aria-pressed', active ? 'true' : 'false');
@@ -1182,6 +1197,7 @@ function savedSearchPrompt(name, accept) {
applySyslogTheme(this);
},
buttons: [
+ {text: text.cancel, click: function() { $(this).dialog('close'); }},
{text: text.save, click: function() {
var value = input.value.trim();
if (!value) {
@@ -1190,8 +1206,7 @@ function savedSearchPrompt(name, accept) {
}
$(this).dialog('close');
accept(value, makeDefault.checked);
- }},
- {text: text.cancel, click: function() { $(this).dialog('close'); }}
+ }}
]
});
}
@@ -1396,19 +1411,60 @@ function initSyslogMessagesDisplay() {
$('.syslog-group-toggle').off('click').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
+ var toggle = this;
+ var page = $(toggle).data('syslogGroupPage');
+
+ if (!page) {
+ var parent = toggle.closest('tr');
+ var control = $(' ').insertAfter(parent);
+ var cell = $(' ').attr('colspan', parent.cells.length).appendTo(control);
+ page = {
+ control: control, rows: $(), offset: 0, loaded: false, busy: false,
+ status: $(' ').appendTo(cell),
+ previous: $(' ').text(toggle.dataset.previous).appendTo(cell),
+ next: $(' ').text(toggle.dataset.next).appendTo(cell)
+ };
+ $(toggle).data('syslogGroupPage', page);
+ page.previous.on('click', function() { load(page.offset - 50); });
+ page.next.on('click', function() { load(page.offset + 50); });
+ }
- var seq = $(this).data('seq');
- var detailRows = $('.syslog-detail-' + seq);
- var icon = $(this);
-
- if (detailRows.is(':visible')) {
- // Collapse
- detailRows.hide();
- icon.removeClass('fa-chevron-up').addClass('fa-chevron-down');
- } else {
- // Expand
- detailRows.show();
- icon.removeClass('fa-chevron-down').addClass('fa-chevron-up');
+ var expanded = toggle.getAttribute('aria-expanded') !== 'true';
+ toggle.setAttribute('aria-expanded', String(expanded));
+ $(toggle).find('i').toggleClass('fa-chevron-up', expanded).toggleClass('fa-chevron-down', !expanded);
+ page.control.toggle(expanded);
+ page.rows.toggle(expanded);
+ if (expanded && !page.loaded && !page.busy) load(0);
+
+ function load(offset) {
+ if (page.busy) return;
+ page.busy = true;
+ page.status.text(toggle.dataset.loading);
+ page.previous.prop('disabled', true);
+ page.next.prop('disabled', true);
+ $.getJSON('syslog.php', {action: 'group_details', context: toggle.dataset.context, group: toggle.dataset.group, offset: offset})
+ .done(function(result) {
+ if (!document.documentElement.contains(toggle)) return;
+ if (!result || typeof result.html !== 'string' || typeof result.more !== 'boolean') {
+ page.status.text(result && result.error || toggle.dataset.error);
+ return;
+ }
+ var body = $(' ').html(result.html);
+ initSyslogValueFilters(body[0]);
+ page.rows.remove();
+ page.rows = body.children('tr').insertAfter(page.control);
+ page.rows.toggle(toggle.getAttribute('aria-expanded') === 'true');
+ page.offset = offset;
+ page.loaded = true;
+ page.more = result.more;
+ page.status.text(page.rows.length ? (offset + 1) + ' - ' + (offset + page.rows.length) : toggle.dataset.empty);
+ }).fail(function() {
+ page.status.text(toggle.dataset.error);
+ }).always(function() {
+ page.busy = false;
+ page.previous.prop('disabled', !page.loaded || page.offset === 0);
+ page.next.prop('disabled', !page.loaded || !page.more);
+ });
}
});
});
diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot
index bd969351..3d124769 100644
--- a/locales/po/cacti.pot
+++ b/locales/po/cacti.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Cacti \n"
"Report-Msgid-Bugs-To: developers@cacti.net\n"
-"POT-Creation-Date: 2026-11-19 15:22+0000\n"
+"POT-Creation-Date: 2026-11-19 16:30+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Cacti Developers >\n"
"Language-Team: Cacti Developers \n"
@@ -495,6 +495,26 @@ msgstr ""
msgid "Report previews search the most recent %d stored messages; the report itself covers its whole time window. Testing does not send email."
msgstr ""
+#: includes/functions.php
+msgid "Grouped results are unavailable or expired. Refresh the results and try again."
+msgstr ""
+
+#: includes/functions.php syslog.php
+msgid "Group messages could not be loaded."
+msgstr ""
+
+#: includes/functions.php syslog.php syslog_alerts.php syslog_dashboards.php
+#: syslog_device_rules.php syslog_recommendations.php syslog_removal.php
+#: syslog_reports.php
+msgid "No"
+msgstr ""
+
+#: includes/functions.php syslog.php syslog_alerts.php syslog_dashboards.php
+#: syslog_device_rules.php syslog_recommendations.php syslog_removal.php
+#: syslog_reports.php
+msgid "Yes"
+msgstr ""
+
#: includes/functions.php
msgid "All Text"
msgstr ""
@@ -1737,11 +1757,11 @@ msgstr ""
msgid "Recovery requires no matching messages until the displayed time. Every match restarts the quiet period."
msgstr ""
-#: lib/syslog_thresholds.php
+#: lib/syslog_thresholds.php syslog.php
msgid "Previous"
msgstr ""
-#: lib/syslog_thresholds.php
+#: lib/syslog_thresholds.php syslog.php
msgid "Next"
msgstr ""
@@ -2495,14 +2515,16 @@ msgstr ""
msgid "Empty message"
msgstr ""
-#: syslog.php syslog_alerts.php syslog_dashboards.php syslog_device_rules.php
-#: syslog_recommendations.php syslog_removal.php syslog_reports.php
-msgid "No"
+#: syslog.php
+msgid "Toggle group messages"
msgstr ""
-#: syslog.php syslog_alerts.php syslog_dashboards.php syslog_device_rules.php
-#: syslog_recommendations.php syslog_removal.php syslog_reports.php
-msgid "Yes"
+#: syslog.php
+msgid "Loading group messages..."
+msgstr ""
+
+#: syslog.php
+msgid "No matching messages."
msgstr ""
#: syslog.php
diff --git a/syslog.php b/syslog.php
index 48fb1b40..71a28dcb 100644
--- a/syslog.php
+++ b/syslog.php
@@ -141,6 +141,23 @@
exit;
}
+if (get_request_var('action') === 'group_details') {
+ header('Content-Type: application/json; charset=UTF-8');
+ $page = syslog_group_details_page(
+ (string) get_filter_request_var('context', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-f0-9]{32}$/D']]),
+ (string) get_filter_request_var('group', FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]),
+ isset_request_var('offset') ? (string) get_filter_request_var('offset', FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) : '0'
+ );
+
+ if (!isset($page['error'])) {
+ $page['html'] = syslog_group_detail_rows($page['rows'], $page['source'], $page['trim'], $page['available']);
+ unset($page['rows'], $page['source'], $page['trim'], $page['available']);
+ }
+
+ print json_encode($page, JSON_INVALID_UTF8_SUBSTITUTE);
+ exit;
+}
+
$title = __('Syslog Viewer', 'syslog');
// set the default tab
@@ -2021,7 +2038,8 @@ function get_syslog_messages(string &$sql_where, $rows, string $tab): array {
if (get_request_var('search_mode') === 'logical') {
$predicate = !empty($GLOBALS['syslog_search_error']) ? '(1 = 0)' :
- syslog_logical_search_sql($GLOBALS['syslog_search_tree'] ?? null, $tab == 'syslog' ? 'message' : 'logmsg');
+ syslog_logical_search_sql($GLOBALS['syslog_search_tree'] ?? null, $tab == 'syslog' ? 'message' : 'logmsg',
+ $tab === 'syslog' && get_request_var('grouping') == '1' ? time() : null);
if ($predicate !== '') {
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . $predicate;
@@ -2132,13 +2150,16 @@ function get_syslog_messages(string &$sql_where, $rows, string $tab): array {
? "GROUP BY syslog.host_id, IF(syslog.message_digest = '', MD5(syslog.message), syslog.message_digest), syslog.program_id, syslog.facility_id, syslog.priority_id"
: 'GROUP BY syslog.host_id, syslog.message, syslog.program_id, syslog.facility_id, syslog.priority_id';
+ // A fixed-width timestamp/sequence pair selects the latest ID without collecting all member IDs.
+ $latest_seq_sql = "CAST(RIGHT(MAX(CONCAT(DATE_FORMAT(syslog.logtime, '%Y%m%d%H%i%s%f'), LPAD(syslog.seq, 20, '0'))), 20) AS UNSIGNED)";
+
if (get_request_var('removal') == '-1') {
$query_sql = "SELECT syslog.host_id, syslog.message, syslog.program_id,
syslog.facility_id, syslog.priority_id, syslog_programs.program,
'main' AS mtype, COUNT(*) AS occurrence_count, MIN(syslog.logtime) AS first_logtime,
MAX(syslog.logtime) AS logtime, MIN(syslog.seq) AS seq,
MAX($breach_sql) AS threshold_breached,
- GROUP_CONCAT(syslog.seq ORDER BY syslog.logtime DESC SEPARATOR ',') AS seq_list
+ $latest_seq_sql AS latest_seq
FROM `$syslogdb_default`.`syslog`
LEFT JOIN `$syslogdb_default`.`syslog_programs`
ON syslog.program_id=syslog_programs.program_id
@@ -2155,7 +2176,7 @@ function get_syslog_messages(string &$sql_where, $rows, string $tab): array {
'main' AS mtype, COUNT(*) AS occurrence_count, MIN(syslog.logtime) AS first_logtime,
MAX(syslog.logtime) AS logtime, MIN(syslog.seq) AS seq,
MAX($breach_sql) AS threshold_breached,
- GROUP_CONCAT(syslog.seq ORDER BY syslog.logtime DESC SEPARATOR ',') AS seq_list
+ $latest_seq_sql AS latest_seq
FROM `$syslogdb_default`.`syslog` AS syslog
LEFT JOIN `$syslogdb_default`.`syslog_programs`
ON syslog.program_id=syslog_programs.program_id
@@ -2167,7 +2188,7 @@ function get_syslog_messages(string &$sql_where, $rows, string $tab): array {
'remove' AS mtype, COUNT(*) AS occurrence_count, MIN(syslog.logtime) AS first_logtime,
MAX(syslog.logtime) AS logtime, MIN(syslog.seq) AS seq,
MAX($breach_sql) AS threshold_breached,
- GROUP_CONCAT(syslog.seq ORDER BY syslog.logtime DESC SEPARATOR ',') AS seq_list
+ $latest_seq_sql AS latest_seq
FROM `$syslogdb_default`.`syslog_removed` AS syslog
LEFT JOIN `$syslogdb_default`.`syslog_programs`
ON syslog.program_id=syslog_programs.program_id
@@ -2183,7 +2204,7 @@ function get_syslog_messages(string &$sql_where, $rows, string $tab): array {
'remove' AS mtype, COUNT(*) AS occurrence_count, MIN(syslog.logtime) AS first_logtime,
MAX(syslog.logtime) AS logtime, MIN(syslog.seq) AS seq,
MAX($breach_sql) AS threshold_breached,
- GROUP_CONCAT(syslog.seq ORDER BY syslog.logtime DESC SEPARATOR ',') AS seq_list
+ $latest_seq_sql AS latest_seq
FROM `$syslogdb_default`.`syslog_removed` AS syslog
LEFT JOIN `$syslogdb_default`.`syslog_programs` AS syslog_programs
ON syslog.program_id = syslog_programs.program_id
@@ -2515,7 +2536,7 @@ function syslog_filter(string $sql_where, string $tab): void {
'>
- '>
+ ' title=''>
'>
'>
@@ -2663,6 +2684,7 @@ function syslog_messages(string $tab = 'syslog'): void {
'align' => 'center',
'tip' => __('Recommendations', 'syslog')
];
+ $group_token = $grouping_enabled ? syslog_group_context($syslog_messages, $sql_where, $trim, $recommendations) : '';
if ($tab == 'syslog') {
// Check if grouping is enabled for display
@@ -2739,7 +2761,13 @@ function syslog_messages(string $tab = 'syslog'): void {
// Display grouped or individual messages
if ($grouping_enabled && isset($sm['occurrence_count']) && $sm['occurrence_count'] > 1) {
// Grouped message display with expand/collapse
- $expand_icon = " ";
+ $expand_icon = " ";
form_selectable_cell($expand_icon . $sm['logtime'], $sm['seq'], '', 'left');
} else {
form_selectable_cell($sm['logtime'], $sm['seq'], '', 'left');
@@ -2749,7 +2777,7 @@ function syslog_messages(string $tab = 'syslog'): void {
print "" . syslog_value_filter_button($sm['program'], 'program') . ' ';
form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $sm['seq'], '20px', 'center syslogRecommendation');
// Group summaries show the latest timestamp; use its matching sequence ID.
- $rule_id = $grouping_enabled && !empty($sm['seq_list']) ? explode(',', $sm['seq_list'])[0] : $sm[$syslog_incoming_config['id']];
+ $rule_id = $grouping_enabled ? $sm['latest_seq'] : $sm[$syslog_incoming_config['id']];
form_selectable_cell(syslog_message_button($sm['message'], $hosts[$sm['host_id']] ?? '', $sm['program'], $facilities[$sm['facility_id']] ?? '', $priorities[$sm['priority_id']] ?? '', $sm['logtime'], $rule_id, $sm['mtype'], $trim), $sm['seq'], '', 'left syslogMessage');
form_selectable_cell(syslog_metadata_label(isset($facilities[$sm['facility_id']]) ? $facilities[$sm['facility_id']] : __('Unknown', 'syslog'), 'facility'), $sm['seq'], '', 'left');
form_selectable_cell(syslog_value_filter_button($priorities[$sm['priority_id']] ?? __('Unknown', 'syslog'), 'priority'), $sm['seq'], '', 'left');
@@ -2763,32 +2791,6 @@ function syslog_messages(string $tab = 'syslog'): void {
form_end_row();
- // If grouping is enabled and there are multiple occurrences, add hidden detail rows
- if ($grouping_enabled && isset($sm['occurrence_count']) && $sm['occurrence_count'] > 1 && isset($sm['seq_list'])) {
- $detail_messages = syslog_group_detail_messages($sm, $sql_where, $breach_sql);
-
- if (cacti_sizeof($detail_messages)) {
- foreach ($detail_messages as $dm) {
- print "";
-
- print "" . html_escape($dm['logtime']) . ' ';
- print "" . syslog_value_filter_button($hosts[$dm['host_id']] ?? __('Unknown', 'syslog'), 'host') . ' ';
- print "" . syslog_value_filter_button($dm['program'], 'program') . ' ';
- form_selectable_cell(syslog_recommendation_indicator($recommendations[$row]), $dm['seq'], '20px', 'center syslogRecommendation');
- print "" . syslog_message_button($dm['message'], $hosts[$dm['host_id']] ?? '', $dm['program'], $facilities[$dm['facility_id']] ?? '', $priorities[$dm['priority_id']] ?? '', $dm['logtime'], $dm[$syslog_incoming_config['id']], $sm['mtype'], $trim) . ' ';
- print "" . syslog_metadata_label(isset($facilities[$dm['facility_id']]) ? $facilities[$dm['facility_id']] : __('Unknown', 'syslog'), 'facility') . ' ';
- print "" . syslog_value_filter_button($priorities[$dm['priority_id']] ?? __('Unknown', 'syslog'), 'priority') . ' ';
-
- print "" . (!empty($dm['threshold_breached']) ? __('Yes', 'syslog') : __('No', 'syslog')) . ' ';
-
- if ($grouping_enabled) {
- print " ";
- }
-
- print ' ';
- }
- }
- }
}
} else {
print "" . __('No Syslog Messages', 'syslog') . ' ';
diff --git a/tests/Fixtures/compact_workspace.php b/tests/Fixtures/compact_workspace.php
index 7b3f2eb6..9f994c4b 100644
--- a/tests/Fixtures/compact_workspace.php
+++ b/tests/Fixtures/compact_workspace.php
@@ -36,4 +36,4 @@ function read_user_setting($name, $default = false, $force = false) { return $de
echo '';
$start = strpos($source,"');
eval('?>'.substr($source,$start,$end-$start));
-echo '