Skip to content

Commit 27004e1

Browse files
remove explicit prefetching
1 parent e188aa8 commit 27004e1

File tree

8 files changed

+1
-148
lines changed

8 files changed

+1
-148
lines changed

packages/web/src/app/[domain]/browse/[...path]/components/pureTreePreviewPanel.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { FileTreeItemComponent } from "@/features/fileTree/components/fileTreeIt
66
import { useBrowseNavigation } from "../../hooks/useBrowseNavigation";
77
import { ScrollArea } from "@/components/ui/scroll-area";
88
import { useBrowseParams } from "../../hooks/useBrowseParams";
9-
import { usePrefetchFileSource } from "@/hooks/usePrefetchFileSource";
10-
import { usePrefetchFolderContents } from "@/hooks/usePrefetchFolderContents";
119

1210
interface PureTreePreviewPanelProps {
1311
items: FileTreeItem[];
@@ -16,8 +14,6 @@ interface PureTreePreviewPanelProps {
1614
export const PureTreePreviewPanel = ({ items }: PureTreePreviewPanelProps) => {
1715
const { repoName, revisionName } = useBrowseParams();
1816
const { navigateToPath } = useBrowseNavigation();
19-
const { prefetchFileSource } = usePrefetchFileSource();
20-
const { prefetchFolderContents } = usePrefetchFolderContents();
2117
const scrollAreaRef = useRef<HTMLDivElement>(null);
2218

2319
const onNodeClicked = useCallback((node: FileTreeItem) => {
@@ -29,14 +25,6 @@ export const PureTreePreviewPanel = ({ items }: PureTreePreviewPanelProps) => {
2925
});
3026
}, [navigateToPath, repoName, revisionName]);
3127

32-
const onNodeMouseEnter = useCallback((node: FileTreeItem) => {
33-
if (node.type === 'blob') {
34-
prefetchFileSource(repoName, revisionName ?? 'HEAD', node.path);
35-
} else if (node.type === 'tree') {
36-
prefetchFolderContents(repoName, revisionName ?? 'HEAD', node.path);
37-
}
38-
}, [prefetchFileSource, prefetchFolderContents, repoName, revisionName]);
39-
4028
return (
4129
<ScrollArea
4230
className="flex flex-col p-0.5"
@@ -50,7 +38,6 @@ export const PureTreePreviewPanel = ({ items }: PureTreePreviewPanelProps) => {
5038
depth={0}
5139
isCollapseChevronVisible={false}
5240
onClick={() => onNodeClicked(item)}
53-
onMouseEnter={() => onNodeMouseEnter(item)}
5441
parentRef={scrollAreaRef}
5542
/>
5643
))}

packages/web/src/app/[domain]/browse/components/fileSearchCommandDialog.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { useDomain } from "@/hooks/useDomain";
1010
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
1111
import { useBrowseNavigation } from "../hooks/useBrowseNavigation";
1212
import { useBrowseState } from "../hooks/useBrowseState";
13-
import { usePrefetchFileSource } from "@/hooks/usePrefetchFileSource";
1413
import { useBrowseParams } from "../hooks/useBrowseParams";
1514
import { FileTreeItemIcon } from "@/features/fileTree/components/fileTreeItemIcon";
1615
import { useLocalStorage } from "usehooks-ts";
@@ -36,7 +35,6 @@ export const FileSearchCommandDialog = () => {
3635
const inputRef = useRef<HTMLInputElement>(null);
3736
const [searchQuery, setSearchQuery] = useState('');
3837
const { navigateToPath } = useBrowseNavigation();
39-
const { prefetchFileSource } = usePrefetchFileSource();
4038

4139
const [recentlyOpened, setRecentlyOpened] = useLocalStorage<FileTreeItem[]>(`recentlyOpenedFiles-${repoName}`, []);
4240

@@ -122,14 +120,6 @@ export const FileSearchCommandDialog = () => {
122120
});
123121
}, [navigateToPath, repoName, revisionName, setRecentlyOpened, updateBrowseState]);
124122

125-
const onMouseEnter = useCallback((file: FileTreeItem) => {
126-
prefetchFileSource(
127-
repoName,
128-
revisionName ?? 'HEAD',
129-
file.path
130-
);
131-
}, [prefetchFileSource, repoName, revisionName]);
132-
133123
// @note: We were hitting issues when the user types into the input field while the files are still
134124
// loading. The workaround was to set `disabled` when loading and then focus the input field when
135125
// the files are loaded, hence the `useEffect` below.
@@ -181,7 +171,6 @@ export const FileSearchCommandDialog = () => {
181171
key={file.path}
182172
file={file}
183173
onSelect={() => onSelect(file)}
184-
onMouseEnter={() => onMouseEnter(file)}
185174
/>
186175
);
187176
})}
@@ -196,7 +185,6 @@ export const FileSearchCommandDialog = () => {
196185
file={file}
197186
match={match}
198187
onSelect={() => onSelect(file)}
199-
onMouseEnter={() => onMouseEnter(file)}
200188
/>
201189
);
202190
})}
@@ -223,20 +211,17 @@ interface SearchResultComponentProps {
223211
to: number;
224212
};
225213
onSelect: () => void;
226-
onMouseEnter: () => void;
227214
}
228215

229216
const SearchResultComponent = ({
230217
file,
231218
match,
232219
onSelect,
233-
onMouseEnter,
234220
}: SearchResultComponentProps) => {
235221
return (
236222
<CommandItem
237223
key={file.path}
238224
onSelect={onSelect}
239-
onMouseEnter={onMouseEnter}
240225
>
241226
<div className="flex flex-row gap-2 w-full cursor-pointer relative">
242227
<FileTreeItemIcon item={file} className="mt-1" />

packages/web/src/app/[domain]/components/pathHeader.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { useBrowseNavigation } from "../browse/hooks/useBrowseNavigation";
88
import { Copy, CheckCircle2, ChevronRight, MoreHorizontal } from "lucide-react";
99
import { useCallback, useState, useMemo, useRef, useEffect } from "react";
1010
import { useToast } from "@/components/hooks/use-toast";
11-
import { usePrefetchFolderContents } from "@/hooks/usePrefetchFolderContents";
12-
import { usePrefetchFileSource } from "@/hooks/usePrefetchFileSource";
1311
import {
1412
DropdownMenu,
1513
DropdownMenuContent,
@@ -62,8 +60,6 @@ export const PathHeader = ({
6260
const { navigateToPath } = useBrowseNavigation();
6361
const { toast } = useToast();
6462
const [copied, setCopied] = useState(false);
65-
const { prefetchFolderContents } = usePrefetchFolderContents();
66-
const { prefetchFileSource } = usePrefetchFileSource();
6763

6864
const containerRef = useRef<HTMLDivElement>(null);
6965
const breadcrumbsRef = useRef<HTMLDivElement>(null);
@@ -188,19 +184,6 @@ export const PathHeader = ({
188184
});
189185
}, [repo.name, branchDisplayName, navigateToPath, pathType]);
190186

191-
const onBreadcrumbMouseEnter = useCallback((segment: BreadcrumbSegment) => {
192-
if (segment.isLastSegment && pathType === 'blob') {
193-
prefetchFileSource(repo.name, branchDisplayName ?? 'HEAD', segment.fullPath);
194-
} else {
195-
prefetchFolderContents(repo.name, branchDisplayName ?? 'HEAD', segment.fullPath);
196-
}
197-
}, [
198-
repo.name,
199-
branchDisplayName,
200-
prefetchFolderContents,
201-
pathType,
202-
prefetchFileSource,
203-
]);
204187

205188
const renderSegmentWithHighlight = (segment: BreadcrumbSegment) => {
206189
if (!segment.highlightRange) {
@@ -274,7 +257,6 @@ export const PathHeader = ({
274257
<DropdownMenuItem
275258
key={segment.fullPath}
276259
onClick={() => onBreadcrumbClick(segment)}
277-
onMouseEnter={() => onBreadcrumbMouseEnter(segment)}
278260
className="font-mono text-sm cursor-pointer"
279261
>
280262
{renderSegmentWithHighlight(segment)}
@@ -292,7 +274,6 @@ export const PathHeader = ({
292274
"font-mono text-sm truncate cursor-pointer hover:underline",
293275
)}
294276
onClick={() => onBreadcrumbClick(segment)}
295-
onMouseEnter={() => onBreadcrumbMouseEnter(segment)}
296277
>
297278
{renderSegmentWithHighlight(segment)}
298279
</span>

packages/web/src/ee/features/codeNav/components/exploreMenu/referenceList.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { RepositoryInfo, SourceRange } from "@/features/search/types";
88
import { useMemo, useRef } from "react";
99
import useCaptureEvent from "@/hooks/useCaptureEvent";
1010
import { useVirtualizer } from "@tanstack/react-virtual";
11-
import { usePrefetchFileSource } from "@/hooks/usePrefetchFileSource";
1211

1312
interface ReferenceListProps {
1413
data: FindRelatedSymbolsResponse;
@@ -31,7 +30,6 @@ export const ReferenceList = ({
3130

3231
const { navigateToPath } = useBrowseNavigation();
3332
const captureEvent = useCaptureEvent();
34-
const { prefetchFileSource } = usePrefetchFileSource();
3533

3634
// Virtualization setup
3735
const parentRef = useRef<HTMLDivElement>(null);
@@ -120,13 +118,6 @@ export const ReferenceList = ({
120118
highlightRange: match.range,
121119
})
122120
}}
123-
// @note: We prefetch the file source when the user hovers over a file.
124-
// This is to try and mitigate having a loading spinner appear when
125-
// the user clicks on a file to open it.
126-
// @see: /browse/[...path]/page.tsx
127-
onMouseEnter={() => {
128-
prefetchFileSource(file.repository, revisionName, file.fileName);
129-
}}
130121
/>
131122
))}
132123
</div>
@@ -144,23 +135,20 @@ interface ReferenceListItemProps {
144135
range: SourceRange;
145136
language: string;
146137
onClick: () => void;
147-
onMouseEnter: () => void;
148138
}
149139

150140
const ReferenceListItem = ({
151141
lineContent,
152142
range,
153143
language,
154144
onClick,
155-
onMouseEnter,
156145
}: ReferenceListItemProps) => {
157146
const highlightRanges = useMemo(() => [range], [range]);
158147

159148
return (
160149
<div
161150
className="w-full hover:bg-accent py-1 cursor-pointer"
162151
onClick={onClick}
163-
onMouseEnter={onMouseEnter}
164152
>
165153
<LightweightCodeHighlighter
166154
language={language}

packages/web/src/features/fileTree/components/fileTreeItemComponent.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const FileTreeItemComponent = ({
1414
isCollapsed = false,
1515
isCollapseChevronVisible = true,
1616
onClick,
17-
onMouseEnter,
1817
parentRef,
1918
}: {
2019
node: FileTreeItem,
@@ -23,7 +22,6 @@ export const FileTreeItemComponent = ({
2322
isCollapsed?: boolean,
2423
isCollapseChevronVisible?: boolean,
2524
onClick: () => void,
26-
onMouseEnter: () => void,
2725
parentRef: React.RefObject<HTMLDivElement>,
2826
}) => {
2927
const ref = useRef<HTMLDivElement>(null);
@@ -67,7 +65,6 @@ export const FileTreeItemComponent = ({
6765
}
6866
}}
6967
onClick={onClick}
70-
onMouseEnter={onMouseEnter}
7168
>
7269
<div
7370
className="flex flex-row gap-1 cursor-pointer w-4 h-4 flex-shrink-0"

packages/web/src/features/fileTree/components/pureFileTreePanel.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import React, { useCallback, useMemo, useState, useEffect, useRef } from "react"
66
import { FileTreeItemComponent } from "./fileTreeItemComponent";
77
import { useBrowseNavigation } from "@/app/[domain]/browse/hooks/useBrowseNavigation";
88
import { useBrowseParams } from "@/app/[domain]/browse/hooks/useBrowseParams";
9-
import { usePrefetchFileSource } from "@/hooks/usePrefetchFileSource";
109

1110

1211
export type FileTreeNode = Omit<RawFileTreeNode, 'children'> & {
@@ -44,7 +43,6 @@ export const PureFileTreePanel = ({ tree: _tree, path }: PureFileTreePanelProps)
4443
const scrollAreaRef = useRef<HTMLDivElement>(null);
4544
const { navigateToPath } = useBrowseNavigation();
4645
const { repoName, revisionName } = useBrowseParams();
47-
const { prefetchFileSource } = usePrefetchFileSource();
4846

4947
// @note: When `_tree` changes, it indicates that a new tree has been loaded.
5048
// In that case, we need to rebuild the collapsable tree.
@@ -89,18 +87,6 @@ export const PureFileTreePanel = ({ tree: _tree, path }: PureFileTreePanelProps)
8987
}
9088
}, [setIsCollapsed, navigateToPath, repoName, revisionName]);
9189

92-
// @note: We prefetch the file source when the user hovers over a file.
93-
// This is to try and mitigate having a loading spinner appear when
94-
// the user clicks on a file to open it.
95-
// @see: /browse/[...path]/page.tsx
96-
const onNodeMouseEnter = useCallback((node: FileTreeNode) => {
97-
if (node.type !== 'blob') {
98-
return;
99-
}
100-
101-
prefetchFileSource(repoName, revisionName ?? 'HEAD', node.path);
102-
}, [prefetchFileSource, repoName, revisionName]);
103-
10490
const renderTree = useCallback((nodes: FileTreeNode, depth = 0): React.ReactNode => {
10591
return (
10692
<>
@@ -115,7 +101,6 @@ export const PureFileTreePanel = ({ tree: _tree, path }: PureFileTreePanelProps)
115101
isCollapsed={node.isCollapsed}
116102
isCollapseChevronVisible={node.type === 'tree'}
117103
onClick={() => onNodeClicked(node)}
118-
onMouseEnter={() => onNodeMouseEnter(node)}
119104
parentRef={scrollAreaRef}
120105
/>
121106
{node.children.length > 0 && !node.isCollapsed && renderTree(node, depth + 1)}
@@ -124,7 +109,7 @@ export const PureFileTreePanel = ({ tree: _tree, path }: PureFileTreePanelProps)
124109
})}
125110
</>
126111
);
127-
}, [path, onNodeClicked, onNodeMouseEnter]);
112+
}, [path, onNodeClicked]);
128113

129114
const renderedTree = useMemo(() => renderTree(tree), [tree, renderTree]);
130115

packages/web/src/hooks/usePrefetchFileSource.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/web/src/hooks/usePrefetchFolderContents.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)