fix(web): refresh open file with the file tree (#7490)

This commit is contained in:
Wout Stiens authored and GitHub committed 2026-08-19 14:23:20 -04:00
1 parent 68d569138b
commit 4347f14b89
2 files changed
+8 -1

No files matched your search

@@ -31,6 +31,7 @@ interface FileBrowserPanelProps {
/** Bumped when the same path should be revealed again (e.g. re-opened from search). */
selectedPathRevealId: number;
onOpenFile: (relativePath: string) => void;
onRefreshSelectedFile?: () => void;
}
const TREE_UNSAFE_CSS = `
@@ -105,6 +106,7 @@ export default function FileBrowserPanel({
selectedPath,
selectedPathRevealId,
onOpenFile,
onRefreshSelectedFile,
}: FileBrowserPanelProps) {
const { resolvedTheme } = useTheme();
const composerRef = useComposerHandleContext();
@@ -254,6 +256,10 @@ export default function FileBrowserPanel({
}
search.setValue(value);
};
const handleRefresh = () => {
entriesQuery.refresh();
onRefreshSelectedFile?.();
};
useEffect(() => {
if (previousTreePathsRef.current === treePaths) return;
@@ -354,7 +360,7 @@ export default function FileBrowserPanel({
className="flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-3 in-data-[preview-panel-mode=inline]:h-7 in-data-[preview-panel-mode=inline]:min-h-7 in-data-[preview-panel-mode=inline]:border-b-transparent"
data-surface-subheader
>
<RefreshFilesButton isPending={entriesQuery.isPending} onRefresh={entriesQuery.refresh} />
<RefreshFilesButton isPending={entriesQuery.isPending} onRefresh={handleRefresh} />
<FileSearchField
name="project-files-search"
ariaLabel={`Search ${projectName} files`}
@@ -1080,6 +1080,7 @@ export default function FilePreviewPanel({
selectedPath={relativePath}
selectedPathRevealId={revealRequestId}
onOpenFile={onOpenFile}
{...(relativePath && !isImage ? { onRefreshSelectedFile: file.refresh } : {})}
/>
</aside>
) : null}