Fix file selection being reset when clicking entry file in tree

The useEffect that syncs selectedFile was resetting to an existing file
whenever the selected path wasn't in the bundle's on-disk file list.
This prevented selecting the entry file (e.g. AGENTS.md) when it didn't
yet exist on disk, even though it was visible in the file tree.

Allow selecting the currentEntryFile even when it has no on-disk file.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta
2026-03-18 14:32:04 -05:00
parent cfc53bf96b
commit 6ba5758d30

View File

@@ -1636,7 +1636,7 @@ function PromptsTab({
if (selectedFile !== bundle.entryFile) setSelectedFile(bundle.entryFile);
return;
}
if (!availablePaths.includes(selectedFile)) {
if (!availablePaths.includes(selectedFile) && selectedFile !== currentEntryFile) {
setSelectedFile(availablePaths.includes(bundle.entryFile) ? bundle.entryFile : availablePaths[0]!);
}
}, [bundle, bundleMatchesDraft, currentEntryFile, selectedFile]);