From 4a41de79d688f6a7d828d1ad974d443444414c0a Mon Sep 17 00:00:00 2001 From: Myx Date: Sat, 4 Apr 2026 04:55:13 +0200 Subject: [PATCH] fix: debugger lagging from too many logs --- .../debug-console-entry-list.component.ts | 3 +++ .../debug-console.component.html | 17 ++++++++++++- .../debug-console/debug-console.component.ts | 25 ++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/toju-app/src/app/shared/components/debug-console/debug-console-entry-list/debug-console-entry-list.component.ts b/toju-app/src/app/shared/components/debug-console/debug-console-entry-list/debug-console-entry-list.component.ts index f0ca0b0..10d35af 100644 --- a/toju-app/src/app/shared/components/debug-console/debug-console-entry-list/debug-console-entry-list.component.ts +++ b/toju-app/src/app/shared/components/debug-console/debug-console-entry-list/debug-console-entry-list.component.ts @@ -3,6 +3,7 @@ import { ElementRef, effect, input, + output, signal, viewChild } from '@angular/core'; @@ -30,6 +31,7 @@ import { type DebugLogEntry, type DebugLogLevel } from '../../../../core/service export class DebugConsoleEntryListComponent { readonly entries = input.required(); readonly autoScroll = input.required(); + readonly entryExpanded = output(); readonly expandedEntryIds = signal([]); private readonly viewportRef = viewChild>('viewport'); @@ -52,6 +54,7 @@ export class DebugConsoleEntryListComponent { nextExpandedIds.delete(entryId); } else { nextExpandedIds.add(entryId); + this.entryExpanded.emit(); } this.expandedEntryIds.set(Array.from(nextExpandedIds)); diff --git a/toju-app/src/app/shared/components/debug-console/debug-console.component.html b/toju-app/src/app/shared/components/debug-console/debug-console.component.html index 8ff7347..8132b7a 100644 --- a/toju-app/src/app/shared/components/debug-console/debug-console.component.html +++ b/toju-app/src/app/shared/components/debug-console/debug-console.component.html @@ -173,10 +173,25 @@ /> @if (activeTab() === 'logs') { + @if (isTruncated()) { +
+ + Showing latest 500 of {{ filteredEntries().length }} entries + + +
+ } } @else { { return Array.from(new Set(this.entries().map((entry) => entry.source))).sort(); }); + private static readonly VISIBLE_ENTRY_LIMIT = 500; + readonly filteredEntries = computed(() => { const searchTerm = this.searchTerm().trim() .toLowerCase(); @@ -103,6 +106,17 @@ export class DebugConsoleComponent { ].some((value) => value.toLowerCase().includes(searchTerm)); }); }); + readonly visibleEntries = computed(() => { + const all = this.filteredEntries(); + + if (this.showAllEntries() || all.length <= DebugConsoleComponent.VISIBLE_ENTRY_LIMIT) + return all; + + return all.slice(-DebugConsoleComponent.VISIBLE_ENTRY_LIMIT); + }); + readonly isTruncated = computed(() => { + return !this.showAllEntries() && this.filteredEntries().length > DebugConsoleComponent.VISIBLE_ENTRY_LIMIT; + }); readonly levelCounts = computed>(() => { const counts: Record = { event: 0, @@ -119,7 +133,7 @@ export class DebugConsoleComponent { return counts; }); readonly visibleCount = computed(() => { - return this.filteredEntries().reduce((sum, entry) => sum + entry.count, 0); + return this.visibleEntries().reduce((sum, entry) => sum + entry.count, 0); }); readonly badgeCount = computed(() => { const counts = this.levelCounts(); @@ -221,8 +235,17 @@ export class DebugConsoleComponent { this.autoScroll.update((enabled) => !enabled); } + disableAutoScroll(): void { + this.autoScroll.set(false); + } + clearLogs(): void { this.debugging.clear(); + this.showAllEntries.set(false); + } + + toggleShowAllEntries(): void { + this.showAllEntries.update((v) => !v); } startTopResize(event: MouseEvent): void {