add Loading Spinner when file History is loading

Make Renamed instad of Del and untracked
This commit is contained in:
Christoph Brandau
2026-07-02 12:17:57 +02:00
parent 310a0fb09a
commit e18f8f1040
5 changed files with 328 additions and 17 deletions
+27 -7
View File
@@ -117,6 +117,8 @@
let expandedExplorerPaths = new Set<string>();
let expandedCommitHashes = new Set<string>();
let fileHistory: GitCommit[] = [];
let fileHistoryLoading = false;
let fileHistoryRequestId = 0;
let commitMessage = "";
let errorMessage = "";
let operation = "";
@@ -537,7 +539,9 @@
}
async function refreshFileHistory(path = activeRepoPath, file = selectedExplorerPath) {
fileHistory = file ? await listFileHistory(path, file, 100) : [];
const requestId = ++fileHistoryRequestId;
const history = file ? await listFileHistory(path, file, 100) : [];
if (requestId === fileHistoryRequestId) fileHistory = history;
}
// ── Repository operations ──────────────────────────────────────────────────
@@ -1112,13 +1116,30 @@
return folders;
}
// Loads history for a selected explorer node without blocking the rest of the UI
// (isBusy/runOperation would disable every button in the app while this awaits).
// A request id guards against a slower, stale request overwriting a newer selection.
async function loadSelectedFileHistory(path: string, repo = activeRepoPath) {
const requestId = ++fileHistoryRequestId;
fileHistoryLoading = true;
try {
const history = await listFileHistory(repo, path, 100);
if (requestId === fileHistoryRequestId) fileHistory = history;
} catch (error) {
if (requestId === fileHistoryRequestId) {
fileHistory = [];
errorMessage = errorToMessage(error);
}
} finally {
if (requestId === fileHistoryRequestId) fileHistoryLoading = false;
}
}
async function selectExplorerNode(node: ExplorerNode) {
if (!activeRepoPath || (selectedExplorerPath === node.path && selectedExplorerKind === node.kind)) return;
selectedExplorerPath = node.path;
selectedExplorerKind = node.kind;
await runOperation(`Loading ${node.path} history`, async () => {
await refreshFileHistory(activeRepoPath, node.path);
});
await loadSelectedFileHistory(node.path);
}
async function selectFileFromSearch(file: GitRepositoryFile) {
@@ -1127,9 +1148,7 @@
selectedExplorerKind = "file";
expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]);
await runOperation(`Loading ${file.path} history`, async () => {
await refreshFileHistory(activeRepoPath, file.path);
});
await loadSelectedFileHistory(file.path);
}
async function restoreSelectedFileFromCommit(target: GitCommit) {
@@ -1642,6 +1661,7 @@
selectedExplorerLabel={selectedExplorerPath ? `${selectedExplorerKind === "folder" ? "Folder" : "File"} history` : "File history"}
{hasRepository}
{isBusy}
isLoading={fileHistoryLoading}
onDiff={diffSelectedFileFromCommit}
onRestore={restoreSelectedFileFromCommit}
/>