diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2569756b..ea7e39eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Search context refactor to search scope and demo card UI changes. [#405](https://github.com/sourcebot-dev/sourcebot/pull/405)
- Add GitHub star toast. [#409](https://github.com/sourcebot-dev/sourcebot/pull/409)
- Added a onboarding modal when first visiting the homepage when `ask` mode is selected. [#408](https://github.com/sourcebot-dev/sourcebot/pull/408)
+- [ask sb] Added `searchReposTool` and `listAllReposTool`. [#400](https://github.com/sourcebot-dev/sourcebot/pull/400)
### Fixed
- Fixed multiple writes race condition on config file watcher. [#398](https://github.com/sourcebot-dev/sourcebot/pull/398)
@@ -21,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bumped AI SDK and associated packages version. [#404](https://github.com/sourcebot-dev/sourcebot/pull/404)
- Bumped form-data package version. [#407](https://github.com/sourcebot-dev/sourcebot/pull/407)
- Bumped next version. [#406](https://github.com/sourcebot-dev/sourcebot/pull/406)
+- [ask sb] Improved search code tool with filter options. [#400](https://github.com/sourcebot-dev/sourcebot/pull/400)
+- [ask sb] Removed search scope constraint. [#400](https://github.com/sourcebot-dev/sourcebot/pull/400)
## [4.6.0] - 2025-07-25
diff --git a/packages/web/src/app/[domain]/chat/components/newChatPanel.tsx b/packages/web/src/app/[domain]/chat/components/newChatPanel.tsx
index 91ae3f96..699e63bd 100644
--- a/packages/web/src/app/[domain]/chat/components/newChatPanel.tsx
+++ b/packages/web/src/app/[domain]/chat/components/newChatPanel.tsx
@@ -51,7 +51,6 @@ export const NewChatPanel = ({
languageModels={languageModels}
selectedSearchScopes={selectedSearchScopes}
searchContexts={searchContexts}
- onContextSelectorOpenChanged={setIsContextSelectorOpen}
/>
diff --git a/packages/web/src/features/chat/agent.ts b/packages/web/src/features/chat/agent.ts
index 73bfedf4..29307e17 100644
--- a/packages/web/src/features/chat/agent.ts
+++ b/packages/web/src/features/chat/agent.ts
@@ -6,7 +6,7 @@ import { ProviderOptions } from "@ai-sdk/provider-utils";
import { createLogger } from "@sourcebot/logger";
import { LanguageModel, ModelMessage, StopCondition, streamText } from "ai";
import { ANSWER_TAG, FILE_REFERENCE_PREFIX, toolNames } from "./constants";
-import { createCodeSearchTool, findSymbolDefinitionsTool, findSymbolReferencesTool, readFilesTool } from "./tools";
+import { createCodeSearchTool, findSymbolDefinitionsTool, findSymbolReferencesTool, readFilesTool, searchReposTool, listAllReposTool } from "./tools";
import { FileSource, Source } from "./types";
import { addLineNumbers, fileReferenceToString } from "./utils";
@@ -54,6 +54,8 @@ export const createAgentStream = async ({
[toolNames.readFiles]: readFilesTool,
[toolNames.findSymbolReferences]: findSymbolReferencesTool,
[toolNames.findSymbolDefinitions]: findSymbolDefinitionsTool,
+ [toolNames.searchRepos]: searchReposTool,
+ [toolNames.listAllRepos]: listAllReposTool,
},
prepareStep: async ({ stepNumber }) => {
// The first step attaches any mentioned sources to the system prompt.
@@ -185,13 +187,7 @@ ${searchScopeRepoNames.map(repo => `- ${repo}`).join('\n')}
-During the research phase, you have these tools available:
-- \`${toolNames.searchCode}\`: Search for code patterns, functions, or text across repositories
-- \`${toolNames.readFiles}\`: Read the contents of specific files
-- \`${toolNames.findSymbolReferences}\`: Find where symbols are referenced
-- \`${toolNames.findSymbolDefinitions}\`: Find where symbols are defined
-
-Use these tools to gather comprehensive context before answering. Always explain why you're using each tool.
+During the research phase, use the tools available to you to gather comprehensive context before answering. Always explain why you're using each tool. Depending on the user's question, you may need to use multiple tools. If the question is vague, ask the user for more information.
${answerInstructions}
diff --git a/packages/web/src/features/chat/components/chatBox/chatBox.tsx b/packages/web/src/features/chat/components/chatBox/chatBox.tsx
index 934199f2..5d539bcf 100644
--- a/packages/web/src/features/chat/components/chatBox/chatBox.tsx
+++ b/packages/web/src/features/chat/components/chatBox/chatBox.tsx
@@ -5,9 +5,10 @@ import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { CustomEditor, LanguageModelInfo, MentionElement, RenderElementPropsFor, SearchScope } from "@/features/chat/types";
import { insertMention, slateContentToString } from "@/features/chat/utils";
+import { SearchContextQuery } from "@/lib/types";
import { cn, IS_MAC } from "@/lib/utils";
import { computePosition, flip, offset, shift, VirtualElement } from "@floating-ui/react";
-import { ArrowUp, Loader2, StopCircleIcon, TriangleAlertIcon } from "lucide-react";
+import { ArrowUp, Loader2, StopCircleIcon } from "lucide-react";
import { Fragment, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";
import { Descendant, insertText } from "slate";
@@ -17,8 +18,6 @@ import { SuggestionBox } from "./suggestionsBox";
import { Suggestion } from "./types";
import { useSuggestionModeAndQuery } from "./useSuggestionModeAndQuery";
import { useSuggestionsData } from "./useSuggestionsData";
-import { useToast } from "@/components/hooks/use-toast";
-import { SearchContextQuery } from "@/lib/types";
interface ChatBoxProps {
onSubmit: (children: Descendant[], editor: CustomEditor) => void;
@@ -30,7 +29,6 @@ interface ChatBoxProps {
languageModels: LanguageModelInfo[];
selectedSearchScopes: SearchScope[];
searchContexts: SearchContextQuery[];
- onContextSelectorOpenChanged: (isOpen: boolean) => void;
}
export const ChatBox = ({
@@ -43,7 +41,6 @@ export const ChatBox = ({
languageModels,
selectedSearchScopes,
searchContexts,
- onContextSelectorOpenChanged,
}: ChatBoxProps) => {
const suggestionsBoxRef = useRef(null);
const [index, setIndex] = useState(0);
@@ -70,7 +67,6 @@ export const ChatBox = ({
const { selectedLanguageModel } = useSelectedLanguageModel({
initialLanguageModel: languageModels.length > 0 ? languageModels[0] : undefined,
});
- const { toast } = useToast();
// Reset the index when the suggestion mode changes.
useEffect(() => {
@@ -101,9 +97,9 @@ export const ChatBox = ({
return
}, []);
- const { isSubmitDisabled, isSubmitDisabledReason } = useMemo((): {
+ const { isSubmitDisabled } = useMemo((): {
isSubmitDisabled: true,
- isSubmitDisabledReason: "empty" | "redirecting" | "generating" | "no-repos-selected" | "no-language-model-selected"
+ isSubmitDisabledReason: "empty" | "redirecting" | "generating" | "no-language-model-selected"
} | {
isSubmitDisabled: false,
isSubmitDisabledReason: undefined,
@@ -129,13 +125,6 @@ export const ChatBox = ({
}
}
- if (selectedSearchScopes.length === 0) {
- return {
- isSubmitDisabled: true,
- isSubmitDisabledReason: "no-repos-selected",
- }
- }
-
if (selectedLanguageModel === undefined) {
return {
@@ -149,29 +138,11 @@ export const ChatBox = ({
isSubmitDisabledReason: undefined,
}
- }, [
- editor.children,
- isRedirecting,
- isGenerating,
- selectedSearchScopes.length,
- selectedLanguageModel,
- ])
+ }, [editor.children, isRedirecting, isGenerating, selectedLanguageModel])
const onSubmit = useCallback(() => {
- if (isSubmitDisabled) {
- if (isSubmitDisabledReason === "no-repos-selected") {
- toast({
- description: "⚠️ You must select at least one search scope",
- variant: "destructive",
- });
- onContextSelectorOpenChanged(true);
- }
-
- return;
- }
-
_onSubmit(editor.children, editor);
- }, [_onSubmit, editor, isSubmitDisabled, isSubmitDisabledReason, toast, onContextSelectorOpenChanged]);
+ }, [_onSubmit, editor]);
const onInsertSuggestion = useCallback((suggestion: Suggestion) => {
switch (suggestion.type) {
@@ -310,39 +281,15 @@ export const ChatBox = ({
Stop
) : (
-
-
-
{
- // @hack: When submission is disabled, we still want to issue
- // a warning to the user as to why the submission is disabled.
- // onSubmit on the Button will not be called because of the
- // disabled prop, hence the call here.
- if (isSubmitDisabled) {
- onSubmit();
- }
- }}
- >
-
-