Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Commit 5e91bba

Browse files
committed
FEAT-133: Fix PR review feedback on diagnostics logging
- Reset lastMessage on clear() so first post-clear log is not dropped - Pass copy (not mutable ref) from clear() onChange callback - Remove unused LOG_LEVEL_COLORS constant - Escape e.tag in log row innerHTML to prevent XSS - Only auto-scroll to bottom if user was already at bottom
1 parent 4d73745 commit 5e91bba

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

apps/desktop/src/main/gateway-logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export class GatewayLogger {
5959

6060
clear(): void {
6161
this.buffer.length = 0;
62-
this.onChange?.(this.buffer);
62+
this.lastMessage = "";
63+
this.onChange?.([]);
6364
}
6465

6566
private log(level: LogLevel, tag: string, message: string): void {

apps/desktop/src/renderer/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,6 @@ <h3 class="settings-group-title">Always-Allow Rules</h3>
28222822

28232823
// --- Logs tab ---
28242824
const logsList = document.getElementById("logsList");
2825-
const LOG_LEVEL_COLORS = { info: "var(--muted)", warn: "#d97706", error: "#dc2626" };
28262825

28272826
let logsAutoRefreshTimer = null;
28282827

@@ -2839,6 +2838,7 @@ <h3 class="settings-group-title">Always-Allow Rules</h3>
28392838
}
28402839

28412840
async function renderLogs() {
2841+
const wasAtBottom = logsList.scrollTop + logsList.clientHeight >= logsList.scrollHeight - 20;
28422842
const entries = await api.getLogs();
28432843
if (!entries || !entries.length) {
28442844
logsList.innerHTML = '<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;padding:40px 20px;color:var(--muted);text-align:center;gap:6px"><div style="font-size:13px">No log entries yet</div><div style="font-size:11px;opacity:0.7">Turn on Verbose to capture detailed diagnostics.</div></div>';
@@ -2849,10 +2849,12 @@ <h3 class="settings-group-title">Always-Allow Rules</h3>
28492849
const isWarn = e.level === "warn";
28502850
const rowClass = isError ? "log-row log-error" : isWarn ? "log-row log-warn" : "log-row";
28512851
const ts = e.timestamp.slice(11, 23);
2852-
return `<div class="${rowClass}"><span class="log-ts">${ts}</span><span class="log-tag">${e.tag}</span><span class="log-msg">${escapeHtml(e.message)}</span></div>`;
2852+
return `<div class="${rowClass}"><span class="log-ts">${ts}</span><span class="log-tag">${escapeHtml(e.tag)}</span><span class="log-msg">${escapeHtml(e.message)}</span></div>`;
28532853
}).join("");
28542854
logsList.innerHTML = html;
2855-
logsList.scrollTop = logsList.scrollHeight;
2855+
if (wasAtBottom) {
2856+
logsList.scrollTop = logsList.scrollHeight;
2857+
}
28562858
}
28572859

28582860
function escapeHtml(s) {

0 commit comments

Comments
 (0)