From 855e3161cfc481ce32be4f5b70f60667289fc967 Mon Sep 17 00:00:00 2001 From: jakub961241 <144362244+jakub961241@users.noreply.github.com> Date: Sun, 22 Mar 2026 02:27:47 +0100 Subject: [PATCH] fix: traffic chart spike after blur and terminal scroll speed (#12067, #11911) Two fixes: 1. Traffic data spike after page blur (#12067) When the page loses focus, polling pauses. On resume, accumulated network bytes divided by a small interval caused a massive spike. Now skips the first data point after resume (or when timeInterval > 10s), only updating counters without chart push. 2. Terminal scroll sensitivity inconsistency (#11911) scrollSensitivity had 4 different defaults across the codebase: - Store: 10, Component: 15, Preview: 15, Reset: 6 Unified all to 5 (lower = less sensitive in xterm.js). Changed || to ?? so setting 0 is respected. Fixes #12067, #11911 --- frontend/src/components/terminal/index.vue | 2 +- frontend/src/store/modules/terminal.ts | 2 +- frontend/src/views/home/index.vue | 9 +++++++++ frontend/src/views/terminal/setting/index.vue | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/terminal/index.vue b/frontend/src/components/terminal/index.vue index 804545e298fc..9a93da52386f 100644 --- a/frontend/src/components/terminal/index.vue +++ b/frontend/src/components/terminal/index.vue @@ -110,7 +110,7 @@ const newTerm = () => { cursorBlink: terminalStore.cursorBlink ? String(terminalStore.cursorBlink).toLowerCase() === 'enable' : true, cursorStyle: terminalStore.cursorStyle ? getStyle() : 'underline', scrollback: terminalStore.scrollback || 1000, - scrollSensitivity: terminalStore.scrollSensitivity || 15, + scrollSensitivity: terminalStore.scrollSensitivity ?? 5, }); }; diff --git a/frontend/src/store/modules/terminal.ts b/frontend/src/store/modules/terminal.ts index 1a41482ecd9f..35c7eeb5b95d 100644 --- a/frontend/src/store/modules/terminal.ts +++ b/frontend/src/store/modules/terminal.ts @@ -14,7 +14,7 @@ export const TerminalStore = defineStore({ cursorBlink: 'enable', cursorStyle: 'underline', scrollback: 1000, - scrollSensitivity: 10, + scrollSensitivity: 5, }), actions: { setLineHeight(lineHeight: number) { diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 48a71606706e..5af9a6a06253 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -747,6 +747,11 @@ const onLoadCurrentInfo = async () => { currentInfo.value.timeSinceUptime = res.data.timeSinceUptime; let timeInterval = Number(res.data.uptime - currentInfo.value.uptime) || 3; + if (skipNextChart.value || timeInterval > 10) { + skipNextChart.value = false; + currentInfo.value = res.data; + return; + } currentChartInfo.netBytesSent = res.data.netBytesSent - currentInfo.value.netBytesSent > 0 ? Number(((res.data.netBytesSent - currentInfo.value.netBytesSent) / 1024 / timeInterval).toFixed(2)) @@ -982,7 +987,11 @@ const loadSource = (row: any) => { ); }; +const skipNextChart = ref(false); const onFocus = () => { + if (!isActive.value) { + skipNextChart.value = true; + } isActive.value = true; }; const onBlur = () => { diff --git a/frontend/src/views/terminal/setting/index.vue b/frontend/src/views/terminal/setting/index.vue index 2fd6e62e68cc..612f840c8c46 100644 --- a/frontend/src/views/terminal/setting/index.vue +++ b/frontend/src/views/terminal/setting/index.vue @@ -363,7 +363,7 @@ const iniTerm = () => { cursorBlink: true, cursorStyle: 'block', scrollback: 1000, - scrollSensitivity: 15, + scrollSensitivity: 5, }); term.value.open(terminalElement.value); applyPreviewBackground(); @@ -415,7 +415,7 @@ const onSetDefault = () => { form.cursorBlink = 'Enable'; form.cursorStyle = 'block'; form.scrollback = 1000; - form.scrollSensitivity = 6; + form.scrollSensitivity = 5; changeItem(); };