Skip to content

Commit f1dd16b

Browse files
fix(web): Ask sourcebot perf improvements (#632)
1 parent cc2837b commit f1dd16b

File tree

27 files changed

+527
-528
lines changed

27 files changed

+527
-528
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Fixed
1414
- Fixed issue where single quotes could not be used in search queries. [#629](https://github.com/sourcebot-dev/sourcebot/pull/629)
1515
- Fixed issue where files with special characters would fail to load. [#636](https://github.com/sourcebot-dev/sourcebot/issues/636)
16+
- Fixed Ask performance issues. [#632](https://github.com/sourcebot-dev/sourcebot/pull/632)
1617

1718
## [4.10.0] - 2025-11-24
1819

packages/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"embla-carousel-auto-scroll": "^8.3.0",
138138
"embla-carousel-react": "^8.3.0",
139139
"escape-string-regexp": "^5.0.0",
140+
"fast-deep-equal": "^3.1.3",
140141
"fuse.js": "^7.0.0",
141142
"google-auth-library": "^10.1.0",
142143
"graphql": "^16.9.0",

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { useBrowseState } from "../../hooks/useBrowseState";
1919
import { rangeHighlightingExtension } from "./rangeHighlightingExtension";
2020
import useCaptureEvent from "@/hooks/useCaptureEvent";
2121
import { createAuditAction } from "@/ee/features/audit/actions";
22-
import { useDomain } from "@/hooks/useDomain";
2322

2423
interface PureCodePreviewPanelProps {
2524
path: string;
@@ -43,7 +42,6 @@ export const PureCodePreviewPanel = ({
4342
const hasCodeNavEntitlement = useHasEntitlement("code-nav");
4443
const { updateBrowseState } = useBrowseState();
4544
const { navigateToPath } = useBrowseNavigation();
46-
const domain = useDomain();
4745
const captureEvent = useCaptureEvent();
4846

4947
const highlightRangeQuery = useNonEmptyQueryParam(HIGHLIGHT_RANGE_QUERY_PARAM);
@@ -145,7 +143,7 @@ export const PureCodePreviewPanel = ({
145143
metadata: {
146144
message: symbolName,
147145
},
148-
}, domain)
146+
})
149147

150148
updateBrowseState({
151149
selectedSymbolInfo: {
@@ -157,7 +155,7 @@ export const PureCodePreviewPanel = ({
157155
isBottomPanelCollapsed: false,
158156
activeExploreMenuTab: "references",
159157
})
160-
}, [captureEvent, updateBrowseState, repoName, revisionName, language, domain]);
158+
}, [captureEvent, updateBrowseState, repoName, revisionName, language]);
161159

162160

163161
// If we resolve multiple matches, instead of navigating to the first match, we should
@@ -171,7 +169,7 @@ export const PureCodePreviewPanel = ({
171169
metadata: {
172170
message: symbolName,
173171
},
174-
}, domain)
172+
})
175173

176174
if (symbolDefinitions.length === 0) {
177175
return;
@@ -200,7 +198,7 @@ export const PureCodePreviewPanel = ({
200198
isBottomPanelCollapsed: false,
201199
})
202200
}
203-
}, [captureEvent, navigateToPath, revisionName, updateBrowseState, repoName, language, domain]);
201+
}, [captureEvent, navigateToPath, revisionName, updateBrowseState, repoName, language]);
204202

205203
const theme = useCodeMirrorTheme();
206204

packages/web/src/app/[domain]/chat/[id]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export default async function Page(props: PageProps) {
2424
const languageModels = await getConfiguredLanguageModelsInfo();
2525
const repos = await getRepos();
2626
const searchContexts = await getSearchContexts(params.domain);
27-
const chatInfo = await getChatInfo({ chatId: params.id }, params.domain);
27+
const chatInfo = await getChatInfo({ chatId: params.id });
2828
const session = await auth();
29-
const chatHistory = session ? await getUserChatHistory(params.domain) : [];
29+
const chatHistory = session ? await getUserChatHistory() : [];
3030

3131
if (isServiceError(chatHistory)) {
3232
throw new ServiceErrorException(chatHistory);

packages/web/src/app/[domain]/chat/components/chatName.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useToast } from "@/components/hooks/use-toast";
44
import { Badge } from "@/components/ui/badge";
55
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
66
import { updateChatName } from "@/features/chat/actions";
7-
import { useDomain } from "@/hooks/useDomain";
87
import { isServiceError } from "@/lib/utils";
98
import { GlobeIcon } from "@radix-ui/react-icons";
109
import { ChatVisibility } from "@sourcebot/db";
@@ -23,15 +22,14 @@ interface ChatNameProps {
2322
export const ChatName = ({ name, visibility, id, isReadonly }: ChatNameProps) => {
2423
const [isRenameDialogOpen, setIsRenameDialogOpen] = useState(false);
2524
const { toast } = useToast();
26-
const domain = useDomain();
2725
const router = useRouter();
2826

2927
const onRenameChat = useCallback(async (name: string) => {
3028

3129
const response = await updateChatName({
3230
chatId: id,
3331
name: name,
34-
}, domain);
32+
});
3533

3634
if (isServiceError(response)) {
3735
toast({
@@ -43,7 +41,7 @@ export const ChatName = ({ name, visibility, id, isReadonly }: ChatNameProps) =>
4341
});
4442
router.refresh();
4543
}
46-
}, [id, domain, toast, router]);
44+
}, [id, toast, router]);
4745

4846
return (
4947
<>

packages/web/src/app/[domain]/chat/components/chatSidePanel.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ScrollArea } from "@/components/ui/scroll-area";
99
import { Separator } from "@/components/ui/separator";
1010
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
1111
import { deleteChat, updateChatName } from "@/features/chat/actions";
12-
import { useDomain } from "@/hooks/useDomain";
1312
import { cn, isServiceError } from "@/lib/utils";
1413
import { CirclePlusIcon, EllipsisIcon, PencilIcon, TrashIcon } from "lucide-react";
1514
import { useRouter } from "next/navigation";
@@ -23,6 +22,7 @@ import { useChatId } from "../useChatId";
2322
import { RenameChatDialog } from "./renameChatDialog";
2423
import { DeleteChatDialog } from "./deleteChatDialog";
2524
import Link from "next/link";
25+
import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
2626

2727
interface ChatSidePanelProps {
2828
order: number;
@@ -41,7 +41,6 @@ export const ChatSidePanel = ({
4141
isAuthenticated,
4242
isCollapsedInitially,
4343
}: ChatSidePanelProps) => {
44-
const domain = useDomain();
4544
const [isCollapsed, setIsCollapsed] = useState(isCollapsedInitially);
4645
const sidePanelRef = useRef<ImperativePanelHandle>(null);
4746
const router = useRouter();
@@ -72,7 +71,7 @@ export const ChatSidePanel = ({
7271
const response = await updateChatName({
7372
chatId,
7473
name: name,
75-
}, domain);
74+
});
7675

7776
if (isServiceError(response)) {
7877
toast({
@@ -84,14 +83,14 @@ export const ChatSidePanel = ({
8483
});
8584
router.refresh();
8685
}
87-
}, [router, toast, domain]);
86+
}, [router, toast]);
8887

8988
const onDeleteChat = useCallback(async (chatIdToDelete: string) => {
9089
if (!chatIdToDelete) {
9190
return;
9291
}
9392

94-
const response = await deleteChat({ chatId: chatIdToDelete }, domain);
93+
const response = await deleteChat({ chatId: chatIdToDelete });
9594

9695
if (isServiceError(response)) {
9796
toast({
@@ -104,12 +103,12 @@ export const ChatSidePanel = ({
104103

105104
// If we just deleted the current chat, navigate to new chat
106105
if (chatIdToDelete === chatId) {
107-
router.push(`/${domain}/chat`);
106+
router.push(`/${SINGLE_TENANT_ORG_DOMAIN}/chat`);
108107
}
109108

110109
router.refresh();
111110
}
112-
}, [chatId, router, toast, domain]);
111+
}, [chatId, router, toast]);
113112

114113
return (
115114
<>
@@ -131,7 +130,7 @@ export const ChatSidePanel = ({
131130
size="sm"
132131
className="w-full"
133132
onClick={() => {
134-
router.push(`/${domain}/chat`);
133+
router.push(`/${SINGLE_TENANT_ORG_DOMAIN}/chat`);
135134
}}
136135
>
137136
<CirclePlusIcon className="w-4 h-4 mr-1" />
@@ -145,7 +144,7 @@ export const ChatSidePanel = ({
145144
<div className="flex flex-col">
146145
<p className="text-sm text-muted-foreground mb-4">
147146
<Link
148-
href={`/login?callbackUrl=${encodeURIComponent(`/${domain}/chat`)}`}
147+
href={`/login?callbackUrl=${encodeURIComponent(`/${SINGLE_TENANT_ORG_DOMAIN}/chat`)}`}
149148
className="text-sm text-link hover:underline cursor-pointer"
150149
>
151150
Sign in
@@ -163,7 +162,7 @@ export const ChatSidePanel = ({
163162
chat.id === chatId && "bg-muted"
164163
)}
165164
onClick={() => {
166-
router.push(`/${domain}/chat/${chat.id}`);
165+
router.push(`/${SINGLE_TENANT_ORG_DOMAIN}/chat/${chat.id}`);
167166
}}
168167
>
169168
<span className="text-sm truncate">{chat.name ?? 'Untitled chat'}</span>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export const SearchBar = ({
221221
metadata: {
222222
message: query,
223223
},
224-
}, domain)
224+
})
225225

226226
const url = createPathWithQueryParams(`/${domain}/search`,
227227
[SearchQueryParams.query, query],

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import { symbolHoverTargetsExtension } from "@/ee/features/codeNav/components/sy
2222
import { useHasEntitlement } from "@/features/entitlements/useHasEntitlement";
2323
import { SymbolDefinition } from "@/ee/features/codeNav/components/symbolHoverPopup/useHoveredOverSymbolInfo";
2424
import { createAuditAction } from "@/ee/features/audit/actions";
25-
import { useDomain } from "@/hooks/useDomain";
26-
2725
import useCaptureEvent from "@/hooks/useCaptureEvent";
2826

2927
export interface CodePreviewFile {
@@ -53,7 +51,6 @@ export const CodePreview = ({
5351
const [editorRef, setEditorRef] = useState<ReactCodeMirrorRef | null>(null);
5452
const { navigateToPath } = useBrowseNavigation();
5553
const hasCodeNavEntitlement = useHasEntitlement("code-nav");
56-
const domain = useDomain();
5754

5855
const [gutterWidth, setGutterWidth] = useState(0);
5956
const theme = useCodeMirrorTheme();
@@ -127,7 +124,7 @@ export const CodePreview = ({
127124
metadata: {
128125
message: symbolName,
129126
},
130-
}, domain)
127+
})
131128

132129
if (symbolDefinitions.length === 0) {
133130
return;
@@ -162,7 +159,7 @@ export const CodePreview = ({
162159
}
163160
});
164161
}
165-
}, [captureEvent, file.filepath, file.language, file.revision, navigateToPath, repoName, domain]);
162+
}, [captureEvent, file.filepath, file.language, file.revision, navigateToPath, repoName]);
166163

167164
const onFindReferences = useCallback((symbolName: string) => {
168165
captureEvent('wa_find_references_pressed', {
@@ -173,7 +170,7 @@ export const CodePreview = ({
173170
metadata: {
174171
message: symbolName,
175172
},
176-
}, domain)
173+
})
177174

178175
navigateToPath({
179176
repoName,
@@ -191,7 +188,7 @@ export const CodePreview = ({
191188
isBottomPanelCollapsed: false,
192189
}
193190
})
194-
}, [captureEvent, file.filepath, file.language, file.revision, navigateToPath, repoName, domain]);
191+
}, [captureEvent, file.filepath, file.language, file.revision, navigateToPath, repoName]);
195192

196193
return (
197194
<div className="flex flex-col h-full">

0 commit comments

Comments
 (0)