From 259fe51cb7a5d1bf4eae1320d9ab56de54a0ead3 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 5 Dec 2026 04:56:00 +0100 Subject: [PATCH] perf: typing lags while many folder chat tabs are open (#35689) Typing in a folder chat gets sluggish once a dozen chats are open as tabs. Every key press searched the whole page for an open dialog before checking whether the key was a tab shortcut at all, and that search gets slower with every open tab. Now only the tab shortcut keys trigger the search, so normal typing skips it and the shortcuts behave as before. The table shows typing 40 characters with 12 folder chat tabs open, as the median of 8 interleaved runs per side (Chromium with 6x CPU slowdown, WebKit unthrottled).
actionbrowserbeforeafter
time the page is blocked while typingChromium1012 ms79 ms
time the page is blocked while typingWebKit2870 ms864 ms
delay from key press to screen updateChromium58 ms43 ms
delay from key press to screen updateWebKit63 ms35 ms
Fixes #35688 --- src/lib/components/chat/Tabs.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Tabs.svelte b/src/lib/components/chat/Tabs.svelte index 297c23e866..4d3b29f68e 100644 --- a/src/lib/components/chat/Tabs.svelte +++ b/src/lib/components/chat/Tabs.svelte @@ -1759,17 +1759,18 @@ }; const handleWorkspaceShortcut = (event: KeyboardEvent) => { + const shortcut = matchKeybinding(event); if ( event.defaultPrevented || event.repeat || $settings?.keyboardShortcuts === false || + !shortcut || document.querySelector('.modal, [role="alertdialog"]') || (event.target instanceof Element && event.target.closest('[role="dialog"], [role="menu"], [role="listbox"]')) ) return; - const shortcut = matchKeybinding(event); let action: (() => void) | undefined; switch (shortcut) { case Shortcut.VOICE_NOTE: