From 7f85eb7d98fb540a66a2b03eb70b726f1ad1c162 Mon Sep 17 00:00:00 2001 From: Christoph Brandau Date: Mon, 13 Jul 2026 00:23:27 +0200 Subject: [PATCH] refactor(explorer): improve file history state management Adjusts the logic governing when file history views are refreshed or displayed. This ensures that selecting a file via the explorer correctly hides any active file history view, and prevents unnecessary refreshes of history data if the view is already collapsed or if the repository path is not yet set. - Added explicit function to reset file history state - Prevents automatic display of file history upon file selection - Refines conditions for refreshing file history during repo updates --- src/App.svelte | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 52174ff..bcd419a 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1612,6 +1612,15 @@ fileHistoryCollapsed = false; } + function hideAndResetFileHistory() { + fileHistoryRequestId += 1; + cancelActiveFileHistoryLoad(); + activeFileHistoryRequestId = ""; + fileHistoryLoading = false; + fileHistory = []; + fileHistoryCollapsed = true; + } + function rememberRecentRepo(path: string) { recentRepoPaths = uniqueRepoPaths([path, ...recentRepoPaths]).slice(0, 40); persistRepoLists(); @@ -1818,7 +1827,7 @@ await refreshBranchList(path); await refreshTags(path); await refreshCommitHistory(path); - if (lastFileHistoryHeadHash !== previousHeadHash) { + if (lastFileHistoryHeadHash !== previousHeadHash && !fileHistoryCollapsed) { await refreshFileHistory(path); } } @@ -3262,7 +3271,7 @@ } async function selectExplorerNode(node: ExplorerNode) { - if (!activeRepoPath || (selectedExplorerPath === node.path && selectedExplorerKind === node.kind)) return; + if (!activeRepoPath) return; selectedExplorerPath = node.path; selectedExplorerKind = node.kind; revealFileHistory(); @@ -3292,9 +3301,7 @@ selectedExplorerPath = file.path; selectedExplorerKind = "file"; expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]); - revealFileHistory(); - - void loadSelectedFileHistory(file.path); + hideAndResetFileHistory(); trackEvent("explorer_file_selected", { source: "status", status: file.unstaged ?? file.staged ?? "unknown",