-
Notifications
You must be signed in to change notification settings - Fork 372
fix(web): configure default home page for Ask GH (SOU-2281) #1677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9182ba
28d2975
00abdd9
b6e5f07
b4d8fa4
6b857e8
491c40c
dc9c9fe
3106226
cd61fe8
32d276a
40247f4
11f79d4
7842715
06d112c
6cd7e4c
063dc65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
| ### Removed | ||
| - Removed the Ask Sourcebot first-visit tutorial banner. [#1675](https://github.com/sourcebot-dev/sourcebot/pull/1675) | ||
| - Removed suggested example queries from the Ask landing page. [#1674](https://github.com/sourcebot-dev/sourcebot/pull/1674) | ||
|
|
||
| ### Fixed | ||
| - Made the default home page configurable with `DEFAULT_HOME_VIEW_PAGE`, defaulting to Code Search and supporting Ask. [#1677](https://github.com/sourcebot-dev/sourcebot/pull/1677) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Move this entry to the bottom of the Fixed section. Two Fixed entries follow this new entry. Place the new entry after them. As per coding guidelines, “Place new entries at the bottom of the appropriate section.” 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| - Require authentication for the streaming and blocking Ask APIs in Public SaaS deployments. [#1679](https://github.com/sourcebot-dev/sourcebot/pull/1679) | ||
|
|
||
| ## [5.1.14] - 2026-09-17 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { cookies } from "next/headers"; | ||
| import { auth } from "@/auth"; | ||
| import { HOME_VIEW_COOKIE_NAME } from "@/lib/constants"; | ||
| import { HomeView } from "@/hooks/useHomeView"; | ||
| import type { HomeView } from "@/hooks/useHomeView"; | ||
| import { getOrgAccountRequests } from "@/features/membership/actions"; | ||
| import { isServiceError } from "@/lib/utils"; | ||
| import { ServiceErrorException } from "@/lib/serviceError"; | ||
|
|
@@ -21,7 +21,8 @@ export const SIDEBAR_REPO_VISITS_LIMIT = 10; | |
| export async function DefaultSidebar() { | ||
| const session = await auth(); | ||
| const cookieStore = await cookies(); | ||
| const homeView = (cookieStore.get(HOME_VIEW_COOKIE_NAME)?.value ?? "search") as HomeView; | ||
| const cookieValue = cookieStore.get(HOME_VIEW_COOKIE_NAME)?.value as HomeView | undefined; | ||
| const homeView = cookieValue ?? env.DEFAULT_HOME_VIEW_PAGE; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This direct env read bypasses the promised search fallback when Prompt for AI agentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The raw cookie value is cast to Prompt for AI agents |
||
|
|
||
| // Chat history is part of the Ask experience; hide it when the deployment | ||
| // is not on a plan that includes Ask. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,18 @@ | ||||||||||
| import { HOME_VIEW_COOKIE_NAME } from "@/lib/constants"; | ||||||||||
| import type { HomeView } from "@/hooks/useHomeView"; | ||||||||||
| import { cookies } from "next/headers"; | ||||||||||
| import { ChatLandingPage } from "./chat/chatLandingPage"; | ||||||||||
| import SearchPage from "./search/page"; | ||||||||||
| import { env } from "@sourcebot/shared"; | ||||||||||
|
|
||||||||||
| interface Props { | ||||||||||
| searchParams: Promise<{ query?: string }>; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export default async function Home(props: Props) { | ||||||||||
| const cookieStore = await cookies(); | ||||||||||
| const homeView = cookieStore.get(HOME_VIEW_COOKIE_NAME)?.value; | ||||||||||
| const cookieValue = cookieStore.get(HOME_VIEW_COOKIE_NAME)?.value as HomeView | undefined; | ||||||||||
| const homeView = cookieValue ?? env.DEFAULT_HOME_VIEW_PAGE; | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: A stale or tampered Prompt for AI agents
Suggested change
|
||||||||||
| if (homeView === "ask") { | ||||||||||
| return <ChatLandingPage />; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,17 +7,14 @@ export type HomeView = "search" | "ask"; | |
|
|
||
| const COOKIE_NAME = HOME_VIEW_COOKIE_NAME; | ||
|
|
||
| function getHomeViewFromCookie(): HomeView { | ||
| function getHomeViewFromCookie(defaultHomeView: HomeView): HomeView { | ||
| if (typeof document === "undefined") { | ||
| return "search"; | ||
| return defaultHomeView; | ||
| } | ||
| const cookies = document.cookie.split(';').map(c => c.trim()); | ||
| const cookie = cookies.find(c => c.startsWith(`${COOKIE_NAME}=`)); | ||
| if (!cookie) { | ||
| return "search"; | ||
| } | ||
| const value = cookie.substring(`${COOKIE_NAME}=`.length); | ||
| return value === "ask" ? "ask" : "search"; | ||
| const value = cookie?.substring(`${COOKIE_NAME}=`.length) as HomeView | undefined; | ||
| return value ?? defaultHomeView; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The cookie fallback now accepts any runtime string as a Prompt for AI agents |
||
| } | ||
|
|
||
| function setHomeViewCookie(value: HomeView) { | ||
|
|
@@ -29,8 +26,8 @@ function setHomeViewCookie(value: HomeView) { | |
| document.cookie = `${COOKIE_NAME}=${value}; expires=${expires.toUTCString()}; path=/; SameSite=Lax`; | ||
| } | ||
|
|
||
| export const useHomeView = (): [HomeView, (value: HomeView) => void] => { | ||
| const [homeView, setHomeViewState] = useState<HomeView>(getHomeViewFromCookie); | ||
| export const useHomeView = (defaultHomeView: HomeView): [HomeView, (value: HomeView) => void] => { | ||
| const [homeView, setHomeViewState] = useState<HomeView>(() => getHomeViewFromCookie(defaultHomeView)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This initializer reads the cookie only during the client render, so the settings page renders Prompt for AI agents |
||
|
|
||
| const setHomeView = useCallback((value: HomeView) => { | ||
| setHomeViewState(value); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The new
DEFAULT_HOME_VIEW_PAGEentry sits at the top of the### Fixedsection, but repo convention (CLAUDE.md, AGENTS.md) puts new entries at the bottom of the section, in ascending PR-number order. Move it below the[#1679]line.Prompt for AI agents