Skip to content

Commit fbe1073

Browse files
fix(web): Fix loading issues with references / definitions list (#617)
1 parent 341836a commit fbe1073

File tree

30 files changed

+277
-130
lines changed

30 files changed

+277
-130
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fixed spurious infinite loads with explore panel, file tree, and file search command. [#617](https://github.com/sourcebot-dev/sourcebot/pull/617)
12+
1013
## [4.9.2] - 2025-11-13
1114

1215
### Changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { getRepoInfoByName } from "@/actions";
22
import { PathHeader } from "@/app/[domain]/components/pathHeader";
33
import { Separator } from "@/components/ui/separator";
4-
import { getFileSource } from "@/features/search/fileSourceApi";
54
import { cn, getCodeHostInfoForRepo, isServiceError } from "@/lib/utils";
65
import Image from "next/image";
76
import { PureCodePreviewPanel } from "./pureCodePreviewPanel";
7+
import { getFileSource } from "@/features/search/fileSourceApi";
88

99
interface CodePreviewPanelProps {
1010
path: string;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use client';
22

33
import { useRef } from "react";
4-
import { FileTreeItem } from "@/features/fileTree/actions";
54
import { FileTreeItemComponent } from "@/features/fileTree/components/fileTreeItemComponent";
65
import { getBrowsePath } from "../../hooks/utils";
76
import { ScrollArea } from "@/components/ui/scroll-area";
87
import { useBrowseParams } from "../../hooks/useBrowseParams";
98
import { useDomain } from "@/hooks/useDomain";
9+
import { FileTreeItem } from "@/features/fileTree/types";
1010

1111
interface PureTreePreviewPanelProps {
1212
items: FileTreeItem[];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Separator } from "@/components/ui/separator";
33
import { getRepoInfoByName } from "@/actions";
44
import { PathHeader } from "@/app/[domain]/components/pathHeader";
5-
import { getFolderContents } from "@/features/fileTree/actions";
5+
import { getFolderContents } from "@/features/fileTree/api";
66
import { isServiceError } from "@/lib/utils";
77
import { PureTreePreviewPanel } from "./pureTreePreviewPanel";
88

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import { useState, useRef, useMemo, useEffect, useCallback } from "react";
55
import { useHotkeys } from "react-hotkeys-hook";
66
import { useQuery } from "@tanstack/react-query";
77
import { unwrapServiceError } from "@/lib/utils";
8-
import { FileTreeItem, getFiles } from "@/features/fileTree/actions";
98
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
109
import { useBrowseNavigation } from "../hooks/useBrowseNavigation";
1110
import { useBrowseState } from "../hooks/useBrowseState";
1211
import { useBrowseParams } from "../hooks/useBrowseParams";
1312
import { FileTreeItemIcon } from "@/features/fileTree/components/fileTreeItemIcon";
1413
import { useLocalStorage } from "usehooks-ts";
1514
import { Skeleton } from "@/components/ui/skeleton";
15+
import { FileTreeItem } from "@/features/fileTree/types";
16+
import { getFiles } from "@/app/api/(client)/client";
1617

1718
const MAX_RESULTS = 100;
1819

packages/web/src/app/[domain]/components/searchBar/useSuggestionsData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const useSuggestionsData = ({
5555
query: `file:${suggestionQuery}`,
5656
matches: 15,
5757
contextLines: 1,
58-
}, domain),
58+
}),
5959
select: (data): Suggestion[] => {
6060
if (isServiceError(data)) {
6161
return [];
@@ -75,7 +75,7 @@ export const useSuggestionsData = ({
7575
query: `sym:${suggestionQuery.length > 0 ? suggestionQuery : ".*"}`,
7676
matches: 15,
7777
contextLines: 1,
78-
}, domain),
78+
}),
7979
select: (data): Suggestion[] => {
8080
if (isServiceError(data)) {
8181
return [];

packages/web/src/app/[domain]/search/components/codePreviewPanel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { CodePreview } from "./codePreview";
55
import { SearchResultFile } from "@/features/search/types";
66
import { SymbolIcon } from "@radix-ui/react-icons";
77
import { SetStateAction, Dispatch, useMemo } from "react";
8-
import { getFileSource } from "@/features/search/fileSourceApi";
98
import { unwrapServiceError } from "@/lib/utils";
9+
import { getFileSource } from "@/app/api/(client)/client";
1010

1111
interface CodePreviewPanelProps {
1212
previewedFile: SearchResultFile;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const SearchResultsPage = ({
6666
matches: maxMatchCount,
6767
contextLines: 3,
6868
whole: false,
69-
}, domain)), "client.search"),
69+
})), "client.search"),
7070
select: ({ data, durationMs }) => ({
7171
...data,
7272
totalClientSearchDurationMs: durationMs,

packages/web/src/app/api/(client)/client.ts

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@ import {
99
SearchRequest,
1010
SearchResponse,
1111
} from "@/features/search/types";
12+
import {
13+
FindRelatedSymbolsRequest,
14+
FindRelatedSymbolsResponse,
15+
} from "@/features/codeNav/types";
16+
import {
17+
GetFilesRequest,
18+
GetFilesResponse,
19+
GetTreeRequest,
20+
GetTreeResponse,
21+
} from "@/features/fileTree/types";
1222

13-
export const search = async (body: SearchRequest, domain: string): Promise<SearchResponse | ServiceError> => {
23+
export const search = async (body: SearchRequest): Promise<SearchResponse | ServiceError> => {
1424
const result = await fetch("/api/search", {
1525
method: "POST",
1626
headers: {
1727
"Content-Type": "application/json",
18-
"X-Org-Domain": domain,
1928
},
2029
body: JSON.stringify(body),
2130
}).then(response => response.json());
@@ -27,12 +36,11 @@ export const search = async (body: SearchRequest, domain: string): Promise<Searc
2736
return result as SearchResponse | ServiceError;
2837
}
2938

30-
export const fetchFileSource = async (body: FileSourceRequest, domain: string): Promise<FileSourceResponse | ServiceError> => {
39+
export const getFileSource = async (body: FileSourceRequest): Promise<FileSourceResponse | ServiceError> => {
3140
const result = await fetch("/api/source", {
3241
method: "POST",
3342
headers: {
3443
"Content-Type": "application/json",
35-
"X-Org-Domain": domain,
3644
},
3745
body: JSON.stringify(body),
3846
}).then(response => response.json());
@@ -60,3 +68,35 @@ export const getVersion = async (): Promise<GetVersionResponse> => {
6068
}).then(response => response.json());
6169
return result as GetVersionResponse;
6270
}
71+
72+
export const findSearchBasedSymbolReferences = async (body: FindRelatedSymbolsRequest): Promise<FindRelatedSymbolsResponse | ServiceError> => {
73+
const result = await fetch("/api/find_references", {
74+
method: "POST",
75+
body: JSON.stringify(body),
76+
}).then(response => response.json());
77+
return result as FindRelatedSymbolsResponse | ServiceError;
78+
}
79+
80+
export const findSearchBasedSymbolDefinitions = async (body: FindRelatedSymbolsRequest): Promise<FindRelatedSymbolsResponse | ServiceError> => {
81+
const result = await fetch("/api/find_definitions", {
82+
method: "POST",
83+
body: JSON.stringify(body),
84+
}).then(response => response.json());
85+
return result as FindRelatedSymbolsResponse | ServiceError;
86+
}
87+
88+
export const getTree = async (body: GetTreeRequest): Promise<GetTreeResponse | ServiceError> => {
89+
const result = await fetch("/api/tree", {
90+
method: "POST",
91+
body: JSON.stringify(body),
92+
}).then(response => response.json());
93+
return result as GetTreeResponse | ServiceError;
94+
}
95+
96+
export const getFiles = async (body: GetFilesRequest): Promise<GetFilesResponse | ServiceError> => {
97+
const result = await fetch("/api/files", {
98+
method: "POST",
99+
body: JSON.stringify(body),
100+
}).then(response => response.json());
101+
return result as GetFilesResponse | ServiceError;
102+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use server';
2+
3+
import { getFiles } from "@/features/fileTree/api";
4+
import { getFilesRequestSchema } from "@/features/fileTree/types";
5+
import { schemaValidationError, serviceErrorResponse } from "@/lib/serviceError";
6+
import { isServiceError } from "@/lib/utils";
7+
import { NextRequest } from "next/server";
8+
9+
export const POST = async (request: NextRequest) => {
10+
const body = await request.json();
11+
const parsed = await getFilesRequestSchema.safeParseAsync(body);
12+
if (!parsed.success) {
13+
return serviceErrorResponse(schemaValidationError(parsed.error));
14+
}
15+
16+
const response = await getFiles(parsed.data);
17+
if (isServiceError(response)) {
18+
return serviceErrorResponse(response);
19+
}
20+
21+
return Response.json(response);
22+
}
23+

0 commit comments

Comments
 (0)