From 3bf7f70ec51a6ab52069f92383cf611f49348b14 Mon Sep 17 00:00:00 2001 From: Pierre DE SOYRES Date: Thu, 28 May 2026 16:46:03 +0200 Subject: [PATCH 1/6] test(logs-stream): remove duplicated "should set completed state" test --- test/logs/logs-stream.test.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/test/logs/logs-stream.test.js b/test/logs/logs-stream.test.js index 31ac3f555..1e1436b24 100644 --- a/test/logs/logs-stream.test.js +++ b/test/logs/logs-stream.test.js @@ -327,22 +327,6 @@ describe('logs-stream', () => { overflowing: false, }); }); - - it('should set completed state', async () => { - const logsStream = new FakeLogsStream(); - logsStream.openLogsStream({ since: new Date().toISOString(), until: new Date().toISOString() }); - await fakeLogsReceived(logsStream); - logsStream.resetSpies(); - - await logsStream.sseFakeApi.end(); - - expect(logsStream.spies.updateStreamState.callCount).to.eql(1); - expect(logsStream.spies.updateStreamState.firstCall.args[0]).to.eql({ - type: 'completed', - progress: { value: 1, percent: 100 }, - overflowing: false, - }); - }); }); describe('pause() method', () => { From dcca11f70aaabfeb5bc6441233f669bcc3dabfe2 Mon Sep 17 00:00:00 2001 From: Pierre DE SOYRES Date: Thu, 28 May 2026 16:47:54 +0200 Subject: [PATCH 2/6] feat(logs): track visible-log count separately for overflow detection Preparing the upcoming "clear logs" UI: clearing the view should restart the overflow watermark check without affecting the underlying total fetched. Introduces a dedicated `_visibleValue` counter and a `resetVisible()` method on `LogsProgress` (forwarded by `LogsStream`) so the clear action can reset the overflow signal independently. --- src/lib/logs/logs-progress.js | 10 ++++++++-- src/lib/logs/logs-stream.js | 4 ++++ test/logs/logs-progress.test.js | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/lib/logs/logs-progress.js b/src/lib/logs/logs-progress.js index bd34ccc13..f4c9b0563 100644 --- a/src/lib/logs/logs-progress.js +++ b/src/lib/logs/logs-progress.js @@ -20,12 +20,17 @@ export class LogsProgress { reset() { this._value = 0; + this._visibleValue = 0; this._percent = null; this._isLive = false; this._lastLogDate = null; this._overflowWasNotified = false; } + resetVisible() { + this._visibleValue = 0; + } + /** * @param {DateRange} dateRange */ @@ -48,6 +53,7 @@ export class LogsProgress { } this._value = this._value + logs.length; + this._visibleValue = this._visibleValue + logs.length; this._lastLogDate = logs[logs.length - 1].date; if (!this._isLive) { @@ -55,7 +61,7 @@ export class LogsProgress { this._percent = (100 * timeProgress) / this._dateRangeDuration; } - if (!this._overflowWasNotified && this._value >= this._overflowWatermark) { + if (!this._overflowWasNotified && this.isOverflowing()) { this._overflowWasNotified = true; return true; } @@ -85,7 +91,7 @@ export class LogsProgress { } isOverflowing() { - return this._value >= this._overflowWatermark; + return this._visibleValue >= this._overflowWatermark; } getLastLogDate() { diff --git a/src/lib/logs/logs-stream.js b/src/lib/logs/logs-stream.js index ae2d9d8a7..c3a938f8f 100644 --- a/src/lib/logs/logs-stream.js +++ b/src/lib/logs/logs-stream.js @@ -180,6 +180,10 @@ export class LogsStream { }); } + resetVisible() { + this.#progress.resetVisible(); + } + /** * @return {Date|null} The date of the last received log. Or `null` if no logs have been received. */ diff --git a/test/logs/logs-progress.test.js b/test/logs/logs-progress.test.js index 1991ec9ad..4077a316c 100644 --- a/test/logs/logs-progress.test.js +++ b/test/logs/logs-progress.test.js @@ -43,6 +43,17 @@ describe('logs-progress', () => { expect(logsProgress.isOverflowing()).to.eq(false); }); + it('should return false when progress lower than the overflowWatermark after reset visible', () => { + const logsProgress = new LogsProgress(10); + logsProgress.start({ since: new Date().toISOString() }); + logsProgress.progress(generateLogs(15)); + logsProgress.resetVisible(); + + logsProgress.progress(generateLogs(9)); + + expect(logsProgress.isOverflowing()).to.eq(false); + }); + it('should return true when progress equals the overflowWatermark', () => { const logsProgress = new LogsProgress(10); logsProgress.start({ since: new Date().toISOString() }); @@ -103,6 +114,17 @@ describe('logs-progress', () => { expect(watermarkReached).to.eq(false); }); + it('should return false when watermark not reached after reset visible', () => { + const logsProgress = new LogsProgress(10); + logsProgress.start({ since: new Date().toISOString() }); + logsProgress.progress(generateLogs(9)); + logsProgress.resetVisible(); + + const watermarkReached = logsProgress.progress(generateLogs(5)); + + expect(watermarkReached).to.eq(false); + }); + it('should return true when watermark is reached', () => { const logsProgress = new LogsProgress(10); logsProgress.start({ since: new Date().toISOString() }); From 740ef7d4eb76f8329b442f6e365da1e8cf8aa8c0 Mon Sep 17 00:00:00 2001 From: Pierre DE SOYRES Date: Thu, 28 May 2026 16:52:09 +0200 Subject: [PATCH 3/6] feat(cc-logs-control): add button to request log clearing Users accumulating long log sessions had no way to clear the view and focus on fresh output. Add a clear button in the control header that dispatches a new CcLogsClearEvent, leaving the actual clearing logic to the consumer. The smart wiring that handles the event lives in a separate commit so the component change stays independently reviewable. --- .../cc-logs-control/cc-logs-control.events.js | 12 ++++++++++++ src/components/cc-logs-control/cc-logs-control.js | 14 +++++++++++++- src/lib/events-map.types.d.ts | 3 ++- src/translations/translations.en.js | 1 + src/translations/translations.fr.js | 1 + 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/cc-logs-control/cc-logs-control.events.js b/src/components/cc-logs-control/cc-logs-control.events.js index 36719c023..0e20aae8c 100644 --- a/src/components/cc-logs-control/cc-logs-control.events.js +++ b/src/components/cc-logs-control/cc-logs-control.events.js @@ -18,3 +18,15 @@ export class CcLogsOptionsChangeEvent extends CcEvent { super(CcLogsOptionsChangeEvent.TYPE, detail); } } + +/** + * Dispatched when clearing of the logs is requested. + * @extends {CcEvent} + */ +export class CcLogsClearEvent extends CcEvent { + static TYPE = 'cc-logs-clear'; + + constructor() { + super(CcLogsClearEvent.TYPE); + } +} diff --git a/src/components/cc-logs-control/cc-logs-control.js b/src/components/cc-logs-control/cc-logs-control.js index 954579a07..d741a6706 100644 --- a/src/components/cc-logs-control/cc-logs-control.js +++ b/src/components/cc-logs-control/cc-logs-control.js @@ -1,6 +1,7 @@ import { css, html, LitElement } from 'lit'; import { createRef, ref } from 'lit/directives/ref.js'; import { + iconRemixEraserLine as clearIcon, iconRemixCalendarScheduleLine as dateIcon, iconRemixPaletteLine as displayIcon, iconRemixPantoneLine as metadataIcon, @@ -22,7 +23,7 @@ import { DATE_DISPLAYS, TIMEZONES } from '../cc-logs/date-displayer.js'; import '../cc-popover/cc-popover.js'; import '../cc-select/cc-select.js'; import '../cc-toggle/cc-toggle.js'; -import { CcLogsOptionsChangeEvent } from './cc-logs-control.events.js'; +import { CcLogsClearEvent, CcLogsOptionsChangeEvent } from './cc-logs-control.events.js'; /** * @type {{[key in LogsControlPalette]: string}} @@ -248,6 +249,10 @@ export class CcLogsControl extends LitElement { this._logsRef.value?.scrollToBottom(); } + _onClearButtonClick() { + this.dispatchEvent(new CcLogsClearEvent()); + } + /** * @param {CcSelectEvent} event */ @@ -328,6 +333,13 @@ export class CcLogsControl extends LitElement { @cc-click=${this._onScrollToBottomButtonClick} > + + Date: Thu, 28 May 2026 16:55:44 +0200 Subject: [PATCH 4/6] feat(cc-logs-app-runtime): handle cc-logs-clear event to clear displayed logs Wires the clear button (added in e04781b4) to the app-runtime smart controller so users can drop the currently displayed logs without interrupting the live stream. Resets the visible log tracking alongside the component clear so overflow detection stays accurate. --- .../cc-logs-app-runtime/cc-logs-app-runtime.smart.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/cc-logs-app-runtime/cc-logs-app-runtime.smart.js b/src/components/cc-logs-app-runtime/cc-logs-app-runtime.smart.js index 23761b090..df54880d6 100644 --- a/src/components/cc-logs-app-runtime/cc-logs-app-runtime.smart.js +++ b/src/components/cc-logs-app-runtime/cc-logs-app-runtime.smart.js @@ -62,6 +62,10 @@ defineSmartComponent({ controller.setNewInstanceSelection(instances); }); + onEvent('cc-logs-clear', () => { + controller.clearVisibleLogs(); + }); + onEvent('cc-logs-loading-pause', () => { controller.pause(); }); @@ -218,6 +222,11 @@ class SmartController extends LogsStream { this._updateState({ type: 'loadingInstances' }); } + clearVisibleLogs() { + this.resetVisible(); + this._component.clear(); + } + /** * @param {DateRange} dateRange * @param {Array} selection From ef3b11c56053d5bcc025f8d1791dfef9893b81e6 Mon Sep 17 00:00:00 2001 From: Pierre DE SOYRES Date: Thu, 28 May 2026 16:57:54 +0200 Subject: [PATCH 5/6] feat(cc-logs-app-access): handle cc-logs-clear event to clear displayed logs --- .../cc-logs-app-access/cc-logs-app-access.smart.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/cc-logs-app-access/cc-logs-app-access.smart.js b/src/components/cc-logs-app-access/cc-logs-app-access.smart.js index d1b9a6e54..68ed4e69a 100644 --- a/src/components/cc-logs-app-access/cc-logs-app-access.smart.js +++ b/src/components/cc-logs-app-access/cc-logs-app-access.smart.js @@ -47,6 +47,10 @@ defineSmartComponent({ controller.setNewDateRange(range); }); + onEvent('cc-logs-clear', () => { + controller.clearVisibleLogs(); + }); + onEvent('cc-logs-loading-pause', () => { controller.pause(); }); @@ -149,6 +153,11 @@ class SmartController extends LogsStream { this._component.appendLogs(logs); } + clearVisibleLogs() { + this.resetVisible(); + this._component.clear(); + } + /** * @param {DateRange} dateRange */ From 7ca4cc95d3b0929f7bd976657fb65a3c4445dced Mon Sep 17 00:00:00 2001 From: Pierre DE SOYRES Date: Thu, 28 May 2026 16:58:44 +0200 Subject: [PATCH 6/6] feat(cc-logs-addon-runtime): handle cc-logs-clear event to clear displayed logs --- .../cc-logs-addon-runtime/cc-logs-addon-runtime.smart.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/cc-logs-addon-runtime/cc-logs-addon-runtime.smart.js b/src/components/cc-logs-addon-runtime/cc-logs-addon-runtime.smart.js index 52ee9020a..d0546cf8a 100644 --- a/src/components/cc-logs-addon-runtime/cc-logs-addon-runtime.smart.js +++ b/src/components/cc-logs-addon-runtime/cc-logs-addon-runtime.smart.js @@ -47,6 +47,10 @@ defineSmartComponent({ controller.setNewDateRange(range); }); + onEvent('cc-logs-clear', () => { + controller.clearVisibleLogs(); + }); + onEvent('cc-logs-loading-pause', () => { controller.pause(); }); @@ -159,6 +163,11 @@ class SmartController extends LogsStream { this._component.appendLogs(logs); } + clearVisibleLogs() { + this.resetVisible(); + this._component.clear(); + } + init() { this.openLogsStream(this._dateRange); }