Skip to content

Commit 4343b3c

Browse files
feat(ask_sb): Add onboarding tutorial (#408)
1 parent 45416a4 commit 4343b3c

File tree

16 files changed

+385
-28
lines changed

16 files changed

+385
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Add ability to include/exclude connection in search context. [#399](https://github.com/sourcebot-dev/sourcebot/pull/399)
1313
- Search context refactor to search scope and demo card UI changes. [#405](https://github.com/sourcebot-dev/sourcebot/pull/405)
1414
- Add GitHub star toast. [#409](https://github.com/sourcebot-dev/sourcebot/pull/409)
15+
- Added a onboarding modal when first visiting the homepage when `ask` mode is selected. [#408](https://github.com/sourcebot-dev/sourcebot/pull/408)
1516

1617
### Fixed
1718
- Fixed multiple writes race condition on config file watcher. [#398](https://github.com/sourcebot-dev/sourcebot/pull/398)
413 KB
Loading
1.51 MB
Loading
381 KB
Loading

packages/web/src/actions.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { auth } from "./auth";
2525
import { getConnection } from "./data/connection";
2626
import { IS_BILLING_ENABLED } from "./ee/features/billing/stripe";
2727
import InviteUserEmail from "./emails/inviteUserEmail";
28-
import { MOBILE_UNSUPPORTED_SPLASH_SCREEN_DISMISSED_COOKIE_NAME, SEARCH_MODE_COOKIE_NAME, SINGLE_TENANT_ORG_DOMAIN, SOURCEBOT_GUEST_USER_ID, SOURCEBOT_SUPPORT_EMAIL } from "./lib/constants";
28+
import { AGENTIC_SEARCH_TUTORIAL_DISMISSED_COOKIE_NAME, MOBILE_UNSUPPORTED_SPLASH_SCREEN_DISMISSED_COOKIE_NAME, SEARCH_MODE_COOKIE_NAME, SINGLE_TENANT_ORG_DOMAIN, SOURCEBOT_GUEST_USER_ID, SOURCEBOT_SUPPORT_EMAIL } from "./lib/constants";
2929
import { orgDomainSchema, orgNameSchema, repositoryQuerySchema } from "./lib/schemas";
3030
import { TenancyMode, ApiKeyPayload } from "./lib/types";
3131
import { decrementOrgSeatCount, getSubscriptionForOrg } from "./ee/features/billing/serverUtils";
@@ -2015,6 +2015,13 @@ export async function setSearchModeCookie(searchMode: "precise" | "agentic") {
20152015
});
20162016
}
20172017

2018+
export async function setAgenticSearchTutorialDismissedCookie(dismissed: boolean) {
2019+
const cookieStore = await cookies();
2020+
cookieStore.set(AGENTIC_SEARCH_TUTORIAL_DISMISSED_COOKIE_NAME, dismissed ? "true" : "false", {
2021+
httpOnly: false, // Allow client-side access
2022+
});
2023+
}
2024+
20182025
////// Helpers ///////
20192026

20202027
const parseConnectionConfig = (config: string) => {

packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { ChatBoxToolbar } from "@/features/chat/components/chatBox/chatBoxToolba
66
import { LanguageModelInfo, SearchScope } from "@/features/chat/types";
77
import { useCreateNewChatThread } from "@/features/chat/useCreateNewChatThread";
88
import { RepositoryQuery, SearchContextQuery } from "@/lib/types";
9-
import { useState } from "react";
9+
import { useCallback, useState } from "react";
1010
import { SearchModeSelector, SearchModeSelectorProps } from "./toolbar";
1111
import { useLocalStorage } from "usehooks-ts";
1212
import { DemoExamples } from "@/types";
1313
import { AskSourcebotDemoCards } from "./askSourcebotDemoCards";
14+
import { AgenticSearchTutorialDialog } from "./agenticSearchTutorialDialog";
15+
import { setAgenticSearchTutorialDismissedCookie } from "@/actions";
1416

1517
interface AgenticSearchProps {
1618
searchModeSelectorProps: SearchModeSelectorProps;
@@ -23,6 +25,7 @@ interface AgenticSearchProps {
2325
name: string | null;
2426
}[];
2527
demoExamples: DemoExamples | undefined;
28+
isTutorialDismissed: boolean;
2629
}
2730

2831
export const AgenticSearch = ({
@@ -31,11 +34,18 @@ export const AgenticSearch = ({
3134
repos,
3235
searchContexts,
3336
demoExamples,
37+
isTutorialDismissed,
3438
}: AgenticSearchProps) => {
3539
const { createNewChatThread, isLoading } = useCreateNewChatThread();
3640
const [selectedSearchScopes, setSelectedSearchScopes] = useLocalStorage<SearchScope[]>("selectedSearchScopes", [], { initializeWithValue: false });
3741
const [isContextSelectorOpen, setIsContextSelectorOpen] = useState(false);
3842

43+
const [isTutorialOpen, setIsTutorialOpen] = useState(!isTutorialDismissed);
44+
const onTutorialDismissed = useCallback(() => {
45+
setIsTutorialOpen(false);
46+
setAgenticSearchTutorialDismissedCookie(true);
47+
}, []);
48+
3949
return (
4050
<div className="flex flex-col items-center w-full">
4151
<div className="mt-4 w-full border rounded-md shadow-sm max-w-[800px]">
@@ -75,6 +85,12 @@ export const AgenticSearch = ({
7585
demoExamples={demoExamples}
7686
/>
7787
)}
88+
89+
{isTutorialOpen && (
90+
<AgenticSearchTutorialDialog
91+
onClose={onTutorialDismissed}
92+
/>
93+
)}
7894
</div >
7995
)
8096
}

0 commit comments

Comments
 (0)