perf: a Files tab that is not on screen still draws its whole file list (#35090)

A Files tab drew every row of its file list even while it sat hidden behind another tab or in a collapsed side panel. Every switch into a folder or chat that has a Files tab open rebuilds that tab, so the switch kept the page busy drawing rows nobody could see. A Files tab now draws its list the first time it is shown, and everything else about it (its folder, open file, unsaved edits) loads as before.

<table>
<tr><th>Switch from a chat outside a folder into one of its chats, Files tab of 201 entries hidden behind it, 4x CPU slowdown, median of 5</th><th>Before</th><th>After</th></tr>
<tr><td>Main thread blocked</td><td>1.31 s</td><td>0.85 s</td></tr>
<tr><td>File rows drawn</td><td>201</td><td>0</td></tr>
</table>

Fixes #35088
This commit is contained in:
Classic298 authored and GitHub committed 2026-12-01 01:25:25 +04:00
1 parent 00f73217c7
commit 786f618fd5
1 file changed
+4 -1
+4 -1
View File
@@ -144,6 +144,9 @@
export let initialFile: { path: string; page?: number | null } | null = null;
export let initialDirectory: string | null = null;
export let onSelectDirectory: ((path: string) => void) | null = null;
// Rows are costly to draw.
let seen = false;
$: if (active) seen = true;
let showCloneRepository = false;
let gitAvailable = false;
let cloneSupportVersion = 0;
@@ -3087,7 +3090,7 @@
{/if}
{#if !isSearching && !loading && !error && !uploading && !(effectiveMachineId && $machines === null)}
{#if visibleEntries.length > 0 || creatingFolder || creatingFile}
{#if seen && (visibleEntries.length > 0 || creatingFolder || creatingFile)}
<ul
data-file-list
class={viewMode === 'grid'