fix: debugger lagging from too many logs
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
ElementRef,
|
ElementRef,
|
||||||
effect,
|
effect,
|
||||||
input,
|
input,
|
||||||
|
output,
|
||||||
signal,
|
signal,
|
||||||
viewChild
|
viewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@@ -30,6 +31,7 @@ import { type DebugLogEntry, type DebugLogLevel } from '../../../../core/service
|
|||||||
export class DebugConsoleEntryListComponent {
|
export class DebugConsoleEntryListComponent {
|
||||||
readonly entries = input.required<DebugLogEntry[]>();
|
readonly entries = input.required<DebugLogEntry[]>();
|
||||||
readonly autoScroll = input.required<boolean>();
|
readonly autoScroll = input.required<boolean>();
|
||||||
|
readonly entryExpanded = output<void>();
|
||||||
readonly expandedEntryIds = signal<number[]>([]);
|
readonly expandedEntryIds = signal<number[]>([]);
|
||||||
|
|
||||||
private readonly viewportRef = viewChild<ElementRef<HTMLDivElement>>('viewport');
|
private readonly viewportRef = viewChild<ElementRef<HTMLDivElement>>('viewport');
|
||||||
@@ -52,6 +54,7 @@ export class DebugConsoleEntryListComponent {
|
|||||||
nextExpandedIds.delete(entryId);
|
nextExpandedIds.delete(entryId);
|
||||||
} else {
|
} else {
|
||||||
nextExpandedIds.add(entryId);
|
nextExpandedIds.add(entryId);
|
||||||
|
this.entryExpanded.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.expandedEntryIds.set(Array.from(nextExpandedIds));
|
this.expandedEntryIds.set(Array.from(nextExpandedIds));
|
||||||
|
|||||||
@@ -173,10 +173,25 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
@if (activeTab() === 'logs') {
|
@if (activeTab() === 'logs') {
|
||||||
|
@if (isTruncated()) {
|
||||||
|
<div class="flex items-center justify-between border-b border-border bg-muted/50 px-4 py-1.5">
|
||||||
|
<span class="text-xs text-muted-foreground">
|
||||||
|
Showing latest 500 of {{ filteredEntries().length }} entries
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="text-xs font-medium text-primary hover:underline"
|
||||||
|
(click)="toggleShowAllEntries()"
|
||||||
|
>
|
||||||
|
Show all
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<app-debug-console-entry-list
|
<app-debug-console-entry-list
|
||||||
class="min-h-0 flex-1 overflow-hidden"
|
class="min-h-0 flex-1 overflow-hidden"
|
||||||
[entries]="filteredEntries()"
|
[entries]="visibleEntries()"
|
||||||
[autoScroll]="autoScroll()"
|
[autoScroll]="autoScroll()"
|
||||||
|
(entryExpanded)="disableAutoScroll()"
|
||||||
/>
|
/>
|
||||||
} @else {
|
} @else {
|
||||||
<app-debug-console-network-map
|
<app-debug-console-network-map
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export class DebugConsoleComponent {
|
|||||||
readonly searchTerm = signal('');
|
readonly searchTerm = signal('');
|
||||||
readonly selectedSource = signal('all');
|
readonly selectedSource = signal('all');
|
||||||
readonly autoScroll = signal(true);
|
readonly autoScroll = signal(true);
|
||||||
|
readonly showAllEntries = signal(false);
|
||||||
readonly panelHeight = this.resizeService.panelHeight;
|
readonly panelHeight = this.resizeService.panelHeight;
|
||||||
readonly panelWidth = this.resizeService.panelWidth;
|
readonly panelWidth = this.resizeService.panelWidth;
|
||||||
readonly panelLeft = this.resizeService.panelLeft;
|
readonly panelLeft = this.resizeService.panelLeft;
|
||||||
@@ -77,6 +78,8 @@ export class DebugConsoleComponent {
|
|||||||
readonly sourceOptions = computed(() => {
|
readonly sourceOptions = computed(() => {
|
||||||
return Array.from(new Set(this.entries().map((entry) => entry.source))).sort();
|
return Array.from(new Set(this.entries().map((entry) => entry.source))).sort();
|
||||||
});
|
});
|
||||||
|
private static readonly VISIBLE_ENTRY_LIMIT = 500;
|
||||||
|
|
||||||
readonly filteredEntries = computed(() => {
|
readonly filteredEntries = computed(() => {
|
||||||
const searchTerm = this.searchTerm().trim()
|
const searchTerm = this.searchTerm().trim()
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
@@ -103,6 +106,17 @@ export class DebugConsoleComponent {
|
|||||||
].some((value) => value.toLowerCase().includes(searchTerm));
|
].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<Record<DebugLogLevel, number>>(() => {
|
readonly levelCounts = computed<Record<DebugLogLevel, number>>(() => {
|
||||||
const counts: Record<DebugLogLevel, number> = {
|
const counts: Record<DebugLogLevel, number> = {
|
||||||
event: 0,
|
event: 0,
|
||||||
@@ -119,7 +133,7 @@ export class DebugConsoleComponent {
|
|||||||
return counts;
|
return counts;
|
||||||
});
|
});
|
||||||
readonly visibleCount = computed(() => {
|
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(() => {
|
readonly badgeCount = computed(() => {
|
||||||
const counts = this.levelCounts();
|
const counts = this.levelCounts();
|
||||||
@@ -221,8 +235,17 @@ export class DebugConsoleComponent {
|
|||||||
this.autoScroll.update((enabled) => !enabled);
|
this.autoScroll.update((enabled) => !enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableAutoScroll(): void {
|
||||||
|
this.autoScroll.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
clearLogs(): void {
|
clearLogs(): void {
|
||||||
this.debugging.clear();
|
this.debugging.clear();
|
||||||
|
this.showAllEntries.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleShowAllEntries(): void {
|
||||||
|
this.showAllEntries.update((v) => !v);
|
||||||
}
|
}
|
||||||
|
|
||||||
startTopResize(event: MouseEvent): void {
|
startTopResize(event: MouseEvent): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user