Skip to content

Commit 769c4e0

Browse files
fix(web): Fix error when clicking on file with more than 1 branch match (#797)
1 parent c396b2d commit 769c4e0

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Changed
1616
- Added commit graph generation to improve performance for commit traversal operations. [#791](https://github.com/sourcebot-dev/sourcebot/pull/791)
1717

18+
### Fixed
19+
- Fixed issue where a file would fail to load when opening it from the /search view and it matched multiple branches. [#797](https://github.com/sourcebot-dev/sourcebot/pull/797)
20+
1821
## [4.10.17] - 2026-01-23
1922

2023
### Fixed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
5353
displayName: repoInfoResponse.displayName,
5454
webUrl: repoInfoResponse.webUrl,
5555
}}
56-
branchDisplayName={revisionName}
56+
revisionName={revisionName}
5757
/>
5858

5959
{fileWebUrl && (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const TreePreviewPanel = async ({ path, repoName, revisionName }: TreePre
3939
}}
4040
pathType="tree"
4141
isFileIconVisible={false}
42-
branchDisplayName={revisionName}
42+
revisionName={revisionName}
4343
/>
4444
</div>
4545
<Separator />

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface FileHeaderProps {
3333
},
3434
isBranchDisplayNameVisible?: boolean;
3535
branchDisplayName?: string;
36+
revisionName?: string;
3637
branchDisplayTitle?: string;
3738
isCodeHostIconVisible?: boolean;
3839
isFileIconVisible?: boolean;
@@ -53,7 +54,8 @@ export const PathHeader = ({
5354
repo,
5455
path,
5556
pathHighlightRange,
56-
branchDisplayName,
57+
revisionName,
58+
branchDisplayName = revisionName,
5759
isBranchDisplayNameVisible = !!branchDisplayName,
5860
branchDisplayTitle,
5961
pathType = 'blob',
@@ -220,7 +222,7 @@ export const PathHeader = ({
220222
repoName: repo.name,
221223
path: '/',
222224
pathType: 'tree',
223-
revisionName: branchDisplayName,
225+
revisionName,
224226
domain,
225227
})}
226228
>
@@ -259,7 +261,7 @@ export const PathHeader = ({
259261
repoName: repo.name,
260262
path: segment.fullPath,
261263
pathType: segment.isLastSegment ? pathType : 'tree',
262-
revisionName: branchDisplayName,
264+
revisionName,
263265
domain,
264266
})}
265267
className="font-mono text-sm hover:cursor cursor-pointer"
@@ -288,7 +290,7 @@ export const PathHeader = ({
288290
repoName: repo.name,
289291
path: segment.fullPath,
290292
pathType: segment.isLastSegment ? pathType : 'tree',
291-
revisionName: branchDisplayName,
293+
revisionName,
292294
domain,
293295
})}
294296
>

packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatchContainer.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ export const FileMatchContainer = ({
6969
return file.branches;
7070
}, [file.branches]);
7171

72-
const branchDisplayName = useMemo(() => {
73-
if (branches.length === 0) {
74-
return undefined;
75-
}
76-
77-
return `${branches[0]}${branches.length > 1 ? ` +${branches.length - 1}` : ''}`;
72+
const revisionName = useMemo(() => {
73+
return branches.length > 0 ? branches[0] : undefined;
7874
}, [branches]);
7975

76+
const branchDisplayName = useMemo(() => {
77+
return revisionName ? `${revisionName}${branches.length > 1 ? ` +${branches.length - 1}` : ''}` : undefined;
78+
}, [branches.length, revisionName]);
79+
8080
const repo = useMemo(() => {
8181
return repoInfo[file.repositoryId];
8282
}, [repoInfo, file.repositoryId]);
@@ -99,8 +99,9 @@ export const FileMatchContainer = ({
9999
}}
100100
path={file.fileName.text}
101101
pathHighlightRange={fileNameRange}
102-
isBranchDisplayNameVisible={isBranchFilteringEnabled}
102+
revisionName={revisionName}
103103
branchDisplayName={branchDisplayName}
104+
isBranchDisplayNameVisible={isBranchFilteringEnabled}
104105
branchDisplayTitle={branches.join(", ")}
105106
/>
106107
<Button

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const ReferenceList = ({
9898
webUrl: repoInfo.webUrl,
9999
}}
100100
path={file.fileName}
101-
branchDisplayName={revisionName === "HEAD" ? undefined : revisionName}
101+
revisionName={revisionName === "HEAD" ? undefined : revisionName}
102102
/>
103103
</div>
104104
<div className="divide-y">

packages/web/src/features/chat/components/chatThread/referencedFileSourceListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const ReferencedFileSourceListItem = ({
231231
displayName: repoDisplayName,
232232
webUrl: repoWebUrl,
233233
}}
234-
branchDisplayName={revision === 'HEAD' ? undefined : revision}
234+
revisionName={revision === 'HEAD' ? undefined : revision}
235235
repoNameClassName="font-normal text-muted-foreground text-sm"
236236
/>
237237
</div>

0 commit comments

Comments
 (0)