From 786f618fd55c9351bcd50962e6a38116a9f50458 Mon Sep 17 00:00:00 2001
From: Classic298 <27028174+Classic298@users.noreply.github.com>
Date: Mon, 30 Nov 2026 22:25:25 +0100
Subject: [PATCH] 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.
| 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 | Before | After |
| Main thread blocked | 1.31 s | 0.85 s |
| File rows drawn | 201 | 0 |
Fixes #35088
---
src/lib/components/chat/FileNav.svelte | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/lib/components/chat/FileNav.svelte b/src/lib/components/chat/FileNav.svelte
index 1c725ca860..60eaa67a06 100644
--- a/src/lib/components/chat/FileNav.svelte
+++ b/src/lib/components/chat/FileNav.svelte
@@ -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)}