Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: optimize & highlight for setting (#20907)
ecmadao4902765bea46
diff --git a/frontend/src/react/components/BannersWrapper.test.tsx b/frontend/src/react/components/BannersWrapper.test.tsxindex dc7682ed0d..df5bdb6eb2 100644--- a/frontend/src/react/components/BannersWrapper.test.tsx+++ b/frontend/src/react/components/BannersWrapper.test.tsx@@ -212,6 +212,7 @@ describe("BannersWrapper", () => {expect(mocks.routerPush).toHaveBeenCalledWith({name: "setting.workspace.general",+ query: { intro: "external-url" },});unmount();});diff --git a/frontend/src/react/components/BannersWrapper.tsx b/frontend/src/react/components/BannersWrapper.tsxindex 808d73847f..52a7af829a 100644--- a/frontend/src/react/components/BannersWrapper.tsx+++ b/frontend/src/react/components/BannersWrapper.tsx@@ -17,6 +17,10 @@ import {useWorkspacePermission,useWorkspaceProfile,} from "@/react/hooks/useAppState";+import {+ EXTERNAL_URL_PRODUCT_INTRO,+ PRODUCT_INTRO_QUERY_KEY,+} from "@/react/lib/productIntro";import {SETTING_ROUTE_WORKSPACE_GENERAL,SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,@@ -89,11 +93,16 @@ function BannerExternalUrl() {{hasPermission ? (<div className="order-3 mt-2 w-full shrink-0 sm:order-2 sm:mt-0 sm:w-auto"><RouterLink- to={{ name: SETTING_ROUTE_WORKSPACE_GENERAL }}+ to={{+ name: SETTING_ROUTE_WORKSPACE_GENERAL,+ query: {+ [PRODUCT_INTRO_QUERY_KEY]: EXTERNAL_URL_PRODUCT_INTRO,+ },+ }}className={buttonVariants({appearance: "secondary",className:- "h-auto rounded-md bg-white py-2 pr-2 pl-4 text-base font-medium text-accent shadow-xs hover:bg-indigo-50",+ "h-auto bg-white py-2 pr-2 pl-4 text-base font-medium text-accent shadow-xs hover:bg-indigo-50",})}>{t("common.configure-now")}diff --git a/frontend/src/react/components/ExternalUrlAlert.test.tsx b/frontend/src/react/components/ExternalUrlAlert.test.tsxnew file mode 100644index 0000000000..847e1345e0--- /dev/null+++ b/frontend/src/react/components/ExternalUrlAlert.test.tsx@@ -0,0 +1,112 @@+import { act } from "react";+import { createRoot } from "react-dom/client";+import { beforeEach, describe, expect, test, vi } from "vitest";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++const mocks = vi.hoisted(() => ({+ hasWorkspacePermissionV2: vi.fn(),+ routerPush: vi.fn(),+ useServerState: vi.fn(),+}));++vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock("@/react/router/handles", () => ({+ SETTING_ROUTE_WORKSPACE_GENERAL: "setting.workspace.general",+}));++vi.mock("@/react/router", () => ({+ router: {+ push: mocks.routerPush,+ resolve: (to: unknown) => ({ href: JSON.stringify(to) }),+ },+}));++vi.mock("@/react/hooks/useAppState", () => ({+ useServerState: mocks.useServerState,+}));++vi.mock("@/utils", () => ({+ hasWorkspacePermissionV2: mocks.hasWorkspacePermissionV2,+}));++let ExternalUrlAlert: typeof import("./ExternalUrlAlert").ExternalUrlAlert;++describe("ExternalUrlAlert", () => {+ beforeEach(async () => {+ mocks.hasWorkspacePermissionV2.mockReset();+ mocks.hasWorkspacePermissionV2.mockReturnValue(true);+ mocks.routerPush.mockReset();+ mocks.useServerState.mockReset();+ mocks.useServerState.mockReturnValue({ needConfigureExternalUrl: true });+ ({ ExternalUrlAlert } = await import("./ExternalUrlAlert"));+ });++ test("routes configure action to workspace general settings with external URL intro", () => {+ const container = document.createElement("div");+ const root = createRoot(container);++ act(() => {+ root.render(<ExternalUrlAlert />);+ });++ const link = Array.from(container.querySelectorAll("a")).find(+ (element) => element.textContent === "common.configure-now"+ ) as HTMLAnchorElement;++ expect(link).toBeTruthy();++ act(() => {+ link.click();+ });++ expect(mocks.routerPush).toHaveBeenCalledWith({+ name: "setting.workspace.general",+ query: { intro: "external-url" },+ });++ act(() => {+ root.unmount();+ });+ });++ test("hides configure action without workspace profile permission", () => {+ mocks.hasWorkspacePermissionV2.mockReturnValue(false);++ const container = document.createElement("div");+ const root = createRoot(container);++ act(() => {+ root.render(<ExternalUrlAlert />);+ });++ expect(container.querySelector("a")).toBeNull();++ act(() => {+ root.unmount();+ });+ });++ test("renders nothing when external URL does not need configuration", () => {+ mocks.useServerState.mockReturnValue({ needConfigureExternalUrl: false });++ const container = document.createElement("div");+ const root = createRoot(container);++ act(() => {+ root.render(<ExternalUrlAlert />);+ });++ expect(container.textContent).toBe("");++ act(() => {+ root.unmount();+ });+ });+});diff --git a/frontend/src/react/components/ExternalUrlAlert.tsx b/frontend/src/react/components/ExternalUrlAlert.tsxnew file mode 100644index 0000000000..f7ca73f76a--- /dev/null+++ b/frontend/src/react/components/ExternalUrlAlert.tsx@@ -0,0 +1,64 @@+import { useTranslation } from "react-i18next";+import { RouterLink } from "@/react/components/RouterLink";+import { Alert, type AlertProps } from "@/react/components/ui/alert";+import { type ButtonProps, buttonVariants } from "@/react/components/ui/button";+import { useServerState } from "@/react/hooks/useAppState";+import {+ EXTERNAL_URL_PRODUCT_INTRO,+ PRODUCT_INTRO_QUERY_KEY,+} from "@/react/lib/productIntro";+import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/react/router/handles";+import { hasWorkspacePermissionV2 } from "@/utils";++type ExternalUrlAlertProps = Omit<AlertProps, "title" | "description"> & {+ actionAppearance?: ButtonProps["appearance"];+ actionClassName?: string;+};++export function ExternalUrlAlert({+ variant = "error",+ actionAppearance,+ actionClassName,+ children,+ ...props+}: ExternalUrlAlertProps) {+ const { t } = useTranslation();+ const { needConfigureExternalUrl } = useServerState();+ const canConfigure = hasWorkspacePermissionV2(+ "bb.settings.setWorkspaceProfile"+ );++ if (!needConfigureExternalUrl) {+ return null;+ }++ return (+ <Alert+ variant={variant}+ title={t("banner.external-url")}+ description={t("settings.general.workspace.external-url.description")}+ {...props}+ >+ {children}+ {canConfigure && (+ <div className="mt-2">+ <RouterLink+ to={{+ name: SETTING_ROUTE_WORKSPACE_GENERAL,+ query: {+ [PRODUCT_INTRO_QUERY_KEY]: EXTERNAL_URL_PRODUCT_INTRO,+ },+ }}+ className={buttonVariants({+ appearance: actionAppearance,+ size: "sm",+ className: actionClassName ?? "w-fit",+ })}+ >+ {t("common.configure-now")}+ </RouterLink>+ </div>+ )}+ </Alert>+ );+}diff --git a/frontend/src/react/components/sql-editor/OpenAIButton.test.tsx b/frontend/src/react/components/sql-editor/OpenAIButton.test.tsxindex 1f7cc735ab..190f13a11a 100644--- a/frontend/src/react/components/sql-editor/OpenAIButton.test.tsx+++ b/frontend/src/react/components/sql-editor/OpenAIButton.test.tsx@@ -298,6 +298,33 @@ describe("OpenAIButton", () => {unmount();});+ test("routes AI configure link to general settings with intro", () => {+ setupDefaultMocks({ openAIEnabled: false });+ const { container, render, unmount } = renderIntoContainer(+ <OpenAIButton />+ );+ render();++ const configureLink = Array.from(container.querySelectorAll("a")).find(+ (link) =>+ link.textContent === "plugin.ai.not-configured.go-to-configure"+ ) as HTMLAnchorElement;++ expect(configureLink).toBeTruthy();++ act(() => {+ configureLink.click();+ });++ expect(mocks.routerPush).toHaveBeenCalledWith({+ name: "setting.workspace.general",+ hash: "#ai-assistant",+ query: { intro: "ai-assistant" },+ });++ unmount();+ });+test("click toggles showAIPanel when enabled", () => {setupDefaultMocks();const { container, render, unmount } = renderIntoContainer(diff --git a/frontend/src/react/components/sql-editor/OpenAIButton.tsx b/frontend/src/react/components/sql-editor/OpenAIButton.tsxindex 839f77729c..7f15e04fd5 100644--- a/frontend/src/react/components/sql-editor/OpenAIButton.tsx+++ b/frontend/src/react/components/sql-editor/OpenAIButton.tsx@@ -17,6 +17,10 @@ import {PopoverTrigger,} from "@/react/components/ui/popover";import { useConnectionOfCurrentSQLEditorTab } from "@/react/hooks/useSQLEditorBridge";+import {+ AI_ASSISTANT_PRODUCT_INTRO,+ PRODUCT_INTRO_QUERY_KEY,+} from "@/react/lib/productIntro";import { cn } from "@/react/lib/utils";import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/react/router/handles";import { useAppStore } from "@/react/stores/app";@@ -250,6 +254,9 @@ function AINotConfiguredButton({to={{name: SETTING_ROUTE_WORKSPACE_GENERAL,hash: "#ai-assistant",+ query: {+ [PRODUCT_INTRO_QUERY_KEY]: AI_ASSISTANT_PRODUCT_INTRO,+ },}}tabIndex={-1}className={buttonVariants({diff --git a/frontend/src/react/lib/productIntro.css b/frontend/src/react/lib/productIntro.cssindex 7e55304fa4..482c2631c4 100644--- a/frontend/src/react/lib/productIntro.css+++ b/frontend/src/react/lib/productIntro.css@@ -2,7 +2,7 @@position: fixed;inset: 0;z-index: 1000000000;- pointer-events: none;+ pointer-events: auto;}.bb-product-intro-stage {diff --git a/frontend/src/react/lib/productIntro.test.ts b/frontend/src/react/lib/productIntro.test.tsindex 1905f5bf36..f0bce9a511 100644--- a/frontend/src/react/lib/productIntro.test.ts+++ b/frontend/src/react/lib/productIntro.test.ts@@ -2,31 +2,22 @@ import { readFileSync } from "node:fs";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";+import { act, createElement } from "react";+import { createRoot } from "react-dom/client";import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";-const appStoreMocks = vi.hoisted(() => {- const introState = new Map<string, boolean>();- return {- introState,- getIntroStateByKey: vi.fn((key: string) => introState.get(key) ?? false),- saveIntroStateByKey: vi.fn(- ({ key, newState }: { key: string; newState: boolean }) => {- introState.set(key, newState);- }- ),- };-});--vi.mock("@/react/stores/app", () => ({- useAppStore: {- getState: () => ({- getIntroStateByKey: appStoreMocks.getIntroStateByKey,- saveIntroStateByKey: appStoreMocks.saveIntroStateByKey,- }),+vi.mock("@/react/router", () => ({+ router: {+ replace: ({ fullPath }: { fullPath: string }) => {+ window.history.replaceState(window.history.state, "", fullPath);+ },},+ useCurrentRoute: () => ({+ query: Object.fromEntries(new URLSearchParams(window.location.search)),+ }),}));-import { showProductIntroOnce } from "./productIntro";+import { showProductIntro, useProductIntro } from "./productIntro";const setRect = (element: HTMLElement, rect: Partial<DOMRect>) => {element.getBoundingClientRect = vi.fn(@@ -56,17 +47,19 @@ const introOptions = {id: "connect-database",title: "Connect your first database",description: "Connect a database.",- closeLabel: "Close",+};++const ProductIntroHost = () => {+ useProductIntro(introOptions);+ return null;};const libDir = dirname(fileURLToPath(import.meta.url));-describe("showProductIntroOnce", () => {+describe("showProductIntro", () => {beforeEach(() => {vi.useFakeTimers();- appStoreMocks.introState.clear();- appStoreMocks.getIntroStateByKey.mockClear();- appStoreMocks.saveIntroStateByKey.mockClear();+ window.history.replaceState({}, "", "/");window.localStorage.clear();document.body.innerHTML = "";});@@ -88,7 +81,7 @@ describe("showProductIntroOnce", () => {height: 40,});- await expect(showProductIntroOnce(introOptions)).resolves.toBe(true);+ await expect(showProductIntro(introOptions)).resolves.toBe(true);expect(document.querySelectorAll(".bb-product-intro")).toHaveLength(1);expect(button.classList.contains("bb-product-intro-active")).toBe(true);@@ -108,6 +101,25 @@ describe("showProductIntroOnce", () => {);});+ test("scrolls the target before rendering the intro", async () => {+ const button = createButton({+ top: 240,+ left: 400,+ right: 560,+ bottom: 280,+ width: 160,+ height: 40,+ });+ button.scrollIntoView = vi.fn();++ await showProductIntro(introOptions);++ expect(button.scrollIntoView).toHaveBeenCalledWith({+ block: "nearest",+ inline: "nearest",+ });+ });+test("uses the visible target when responsive layouts render multiple matches", async () => {const hiddenButton = createButton({top: 0,@@ -126,7 +138,7 @@ describe("showProductIntroOnce", () => {height: 40,});- await showProductIntroOnce(introOptions);+ await showProductIntro(introOptions);expect(hiddenButton.classList.contains("bb-product-intro-active")).toBe(false@@ -146,7 +158,7 @@ describe("showProductIntroOnce", () => {height: 40,});- await showProductIntroOnce(introOptions);+ await showProductIntro(introOptions);setRect(oldButton, {top: 0,@@ -182,8 +194,7 @@ describe("showProductIntroOnce", () => {);});- test("does not show an already dismissed intro", async () => {- appStoreMocks.introState.set("connect-database", true);+ test("always renders the intro when the target exists", async () => {createButton({top: 240,left: 400,@@ -193,15 +204,12 @@ describe("showProductIntroOnce", () => {height: 40,});- await expect(showProductIntroOnce(introOptions)).resolves.toBe(false);+ await expect(showProductIntro(introOptions)).resolves.toBe(true);- expect(appStoreMocks.getIntroStateByKey).toHaveBeenCalledWith(- "connect-database"- );- expect(document.querySelector(".bb-product-intro")).toBeNull();+ expect(document.querySelector(".bb-product-intro")).not.toBeNull();});- test("marks the intro dismissed when the close button is clicked", async () => {+ test("destroys the intro when the close button is clicked", async () => {createButton({top: 240,left: 400,@@ -211,17 +219,12 @@ describe("showProductIntroOnce", () => {height: 40,});- await showProductIntroOnce(introOptions);+ await showProductIntro(introOptions);- expect(appStoreMocks.saveIntroStateByKey).not.toHaveBeenCalled();(document.querySelector(".bb-product-intro-close") as HTMLButtonElement).click();- expect(appStoreMocks.saveIntroStateByKey).toHaveBeenCalledWith({- key: "connect-database",- newState: true,- });expect(document.querySelector(".bb-product-intro")).toBeNull();});@@ -237,18 +240,134 @@ describe("showProductIntroOnce", () => {});button.addEventListener("click", onClick);- await showProductIntroOnce(introOptions);+ await showProductIntro(introOptions);button.click();expect(onClick).toHaveBeenCalledTimes(1);- expect(appStoreMocks.saveIntroStateByKey).toHaveBeenCalledWith({- key: "connect-database",- newState: true,+ expect(document.querySelector(".bb-product-intro")).toBeNull();+ });++ test("destroys the intro when the mask is clicked", async () => {+ createButton({+ top: 240,+ left: 400,+ right: 560,+ bottom: 280,+ width: 160,+ height: 40,});++ await showProductIntro(introOptions);++ (document.querySelector(".bb-product-intro") as HTMLDivElement).click();+expect(document.querySelector(".bb-product-intro")).toBeNull();});+ test("replaces an existing intro instead of stacking duplicate masks", async () => {+ window.history.replaceState({}, "", "/?intro=connect-database");+ createButton({+ top: 240,+ left: 400,+ right: 560,+ bottom: 280,+ width: 160,+ height: 40,+ });++ await showProductIntro(introOptions);+ await showProductIntro(introOptions);++ expect(document.querySelectorAll(".bb-product-intro")).toHaveLength(1);+ expect(window.location.search).toBe("?intro=connect-database");++ (document.querySelector(".bb-product-intro") as HTMLDivElement).click();++ expect(document.querySelector(".bb-product-intro")).toBeNull();+ expect(window.location.search).toBe("");+ });++ test("destroys the intro when the target DOM is removed", async () => {+ window.history.replaceState({}, "", "/?intro=connect-database");+ const button = createButton({+ top: 240,+ left: 400,+ right: 560,+ bottom: 280,+ width: 160,+ height: 40,+ });++ await showProductIntro(introOptions);++ button.remove();+ await Promise.resolve();++ expect(document.querySelector(".bb-product-intro")).toBeNull();+ expect(button.classList.contains("bb-product-intro-active")).toBe(false);+ expect(window.location.search).toBe("?intro=connect-database");+ });++ test("clears the active intro when the query no longer requests it", async () => {+ window.history.replaceState({}, "", "/?intro=connect-database");+ createButton({+ top: 240,+ left: 400,+ right: 560,+ bottom: 280,+ width: 160,+ height: 40,+ });+ const container = document.createElement("div");+ const root = createRoot(container);++ await act(async () => {+ root.render(createElement(ProductIntroHost));+ await Promise.resolve();+ });++ expect(document.querySelector(".bb-product-intro")).not.toBeNull();++ window.history.replaceState({}, "", "/");+ await act(async () => {+ root.render(createElement(ProductIntroHost));+ await Promise.resolve();+ });++ expect(document.querySelector(".bb-product-intro")).toBeNull();++ act(() => {+ root.unmount();+ });+ });++ test("removes the intro query parameter when the intro is dismissed", async () => {+ window.history.replaceState(+ {},+ "",+ "/settings/general?intro=connect-database&tab=workspace#ai-assistant"+ );+ createButton({+ top: 240,+ left: 400,+ right: 560,+ bottom: 280,+ width: 160,+ height: 40,+ });++ await showProductIntro(introOptions);++ (+ document.querySelector(".bb-product-intro-close") as HTMLButtonElement+ ).click();++ expect(window.location.pathname).toBe("/settings/general");+ expect(window.location.search).toBe("?tab=workspace");+ expect(window.location.hash).toBe("#ai-assistant");+ });+test("keeps the page cover light enough to preserve context", () => {const css = readFileSync(join(libDir, "productIntro.css"), "utf8");diff --git a/frontend/src/react/lib/productIntro.ts b/frontend/src/react/lib/productIntro.tsindex f40a6c2dd1..41a5837a6d 100644--- a/frontend/src/react/lib/productIntro.ts+++ b/frontend/src/react/lib/productIntro.ts@@ -1,15 +1,22 @@-import "./productIntro.css";+import { useEffect } from "react";+import { router, useCurrentRoute } from "@/react/router";-import { useAppStore } from "@/react/stores/app";+import "./productIntro.css";export const PRODUCT_INTRO_QUERY_KEY = "intro";export const CONNECT_DATABASE_PRODUCT_INTRO = "connect-database";+export const EXTERNAL_URL_PRODUCT_INTRO = "external-url";+export const AI_ASSISTANT_PRODUCT_INTRO = "ai-assistant";+export const DOMAIN_RESTRICTION_PRODUCT_INTRO = "domain-restriction";export type ProductIntroOptions = {id: string;title: string;description: string;- closeLabel: string;+};++export type UseProductIntroOptions = ProductIntroOptions & {+ disabled?: boolean;};const ACTIVE_TARGET_CLASS = "bb-product-intro-active";@@ -24,6 +31,9 @@ const POPOVER_WIDTH = 320;const POPOVER_HEIGHT = 128;const VIEWPORT_PADDING = 16;+let activeCleanup: (() => void) | undefined;+let activeIntroId: string | undefined;+const getTargetSelector = (id: string) => `[data-product-intro-target="${id}"]`;const isVisibleRect = (rect: DOMRect) => rect.width > 0 && rect.height > 0;@@ -73,8 +83,7 @@ const markActiveTarget = (element: HTMLElement) => {const createIntroElements = ({title,description,- closeLabel,-}: Pick<ProductIntroOptions, "title" | "description" | "closeLabel">) => {+}: Pick<ProductIntroOptions, "title" | "description">) => {const root = document.createElement("div");root.className = ROOT_CLASS;@@ -100,7 +109,7 @@ const createIntroElements = ({const closeButton = document.createElement("button");closeButton.className = "bb-product-intro-close";closeButton.type = "button";- closeButton.setAttribute("aria-label", closeLabel);+ closeButton.setAttribute("aria-label", "close");closeButton.textContent = "×";popover.append(arrow, closeButton, titleElement, descriptionElement);@@ -109,31 +118,47 @@ const createIntroElements = ({return { root, stage, popover, arrow, closeButton };};-export const showProductIntroOnce = async ({+const removeIntroQuery = () => {+ const url = new URL(window.location.href);+ if (!url.searchParams.has(PRODUCT_INTRO_QUERY_KEY)) {+ return;+ }+ url.searchParams.delete(PRODUCT_INTRO_QUERY_KEY);+ void router.replace({+ fullPath: `${url.pathname}${url.search}${url.hash}`,+ });+};++const cleanupProductIntro = (id?: string) => {+ if (id && activeIntroId !== id) {+ return;+ }+ activeCleanup?.();+};++export const showProductIntro = async ({id,title,description,- closeLabel,}: ProductIntroOptions): Promise<boolean> => {const target = getTargetSelector(id);- const store = useAppStore.getState();-- if (store.getIntroStateByKey(id)) {- return false;- }const element = await findElement(target);if (!element) {return false;}+ activeCleanup?.();+let activeElement = element;+ activeElement.scrollIntoView?.({ block: "nearest", inline: "nearest" });+let destroyed = false;let refreshTimer: number | undefined;+ let targetObserver: MutationObserver | undefined;const { root, stage, popover, arrow, closeButton } = createIntroElements({title,description,- closeLabel,});const render = () => {@@ -176,13 +201,25 @@ export const showProductIntroOnce = async ({refreshTimer = undefined;}closeButton.removeEventListener("click", handleCloseClick);+ root.removeEventListener("click", handleMaskClick);document.removeEventListener("click", handleDocumentClick, true);document.removeEventListener("keydown", handleDocumentKeydown, true);+ targetObserver?.disconnect();+ targetObserver = undefined;window.removeEventListener("resize", scheduleRefreshTarget);window.removeEventListener("scroll", scheduleRefreshTarget, true);root.remove();+ activeElement.classList.remove(ACTIVE_TARGET_CLASS);removeActiveTargetClass();- store.saveIntroStateByKey({ key: id, newState: true });+ if (activeCleanup === cleanup) {+ activeCleanup = undefined;+ activeIntroId = undefined;+ }+ };++ const dismissIntro = () => {+ cleanup();+ removeIntroQuery();};const refreshTarget = () => {@@ -210,7 +247,14 @@ export const showProductIntroOnce = async ({function handleCloseClick(event: MouseEvent) {event.preventDefault();event.stopPropagation();- cleanup();+ dismissIntro();+ }++ function handleMaskClick(event: MouseEvent) {+ if (event.target instanceof Node && popover.contains(event.target)) {+ return;+ }+ dismissIntro();}function handleDocumentClick(event: MouseEvent) {@@ -220,23 +264,51 @@ export const showProductIntroOnce = async ({return;}if (event.target instanceof Node && currentElement.contains(event.target)) {- cleanup();+ dismissIntro();}}function handleDocumentKeydown(event: KeyboardEvent) {if (event.key === "Escape") {- cleanup();+ dismissIntro();}}markActiveTarget(activeElement);+ activeCleanup = cleanup;+ activeIntroId = id;document.body.appendChild(root);render();+ targetObserver = new MutationObserver(refreshTarget);+ targetObserver.observe(document.body, { childList: true, subtree: true });closeButton.addEventListener("click", handleCloseClick);+ root.addEventListener("click", handleMaskClick);document.addEventListener("click", handleDocumentClick, true);document.addEventListener("keydown", handleDocumentKeydown, true);window.addEventListener("resize", scheduleRefreshTarget);window.addEventListener("scroll", scheduleRefreshTarget, true);return true;};++export const useProductIntro = ({+ id,+ title,+ description,+ disabled = false,+}: UseProductIntroOptions) => {+ const route = useCurrentRoute();+ const productIntroValue = route.query[PRODUCT_INTRO_QUERY_KEY];+ const productIntro =+ typeof productIntroValue === "string" ? productIntroValue : undefined;++ useEffect(() => {+ if (disabled || productIntro !== id) {+ cleanupProductIntro(id);+ return;+ }+ void showProductIntro({ id, title, description });+ return () => {+ cleanupProductIntro(id);+ };+ }, [description, disabled, id, productIntro, title]);+};diff --git a/frontend/src/react/pages/project/ProjectDatabasesPage.test.tsx b/frontend/src/react/pages/project/ProjectDatabasesPage.test.tsxindex 62036b8b44..2dfc77e57e 100644--- a/frontend/src/react/pages/project/ProjectDatabasesPage.test.tsx+++ b/frontend/src/react/pages/project/ProjectDatabasesPage.test.tsx@@ -11,7 +11,7 @@ const mocks = vi.hoisted(() => ({visibleDatabases: [] as { name: string }[],routerCurrentQuery: {} as Record<string, unknown>,routerPush: vi.fn(),- showProductIntroOnce: vi.fn(),+ useProductIntro: vi.fn(),removeDatabaseMetadataCache: vi.fn(),fetchInstanceList: vi.fn(async () => ({instances: [] as { name: string; title: string }[],@@ -94,7 +94,7 @@ vi.mock("@/react/lib/plan/issue", () => ({vi.mock("@/react/lib/productIntro", () => ({CONNECT_DATABASE_PRODUCT_INTRO: "connect-database",PRODUCT_INTRO_QUERY_KEY: "intro",- showProductIntroOnce: mocks.showProductIntroOnce,+ useProductIntro: mocks.useProductIntro,}));vi.mock("@/react/stores/app", () => {@@ -181,11 +181,11 @@ describe("ProjectDatabasesPage", () => {await Promise.resolve();});- expect(mocks.showProductIntroOnce).toHaveBeenCalledWith({+ expect(mocks.useProductIntro).toHaveBeenCalledWith({id: "connect-database",title: "project.connect-database-intro-title",description: "project.connect-database-intro-description",- closeLabel: "common.close",+ disabled: false,});act(() => {diff --git a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx b/frontend/src/react/pages/project/ProjectDatabasesPage.tsxindex c1cd0331bd..0bd58e6bad 100644--- a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx+++ b/frontend/src/react/pages/project/ProjectDatabasesPage.tsx@@ -35,8 +35,7 @@ import type { DatabaseFilter } from "@/react/lib/databaseFilter";import { preCreateIssue } from "@/react/lib/plan/issue";import {CONNECT_DATABASE_PRODUCT_INTRO,- PRODUCT_INTRO_QUERY_KEY,- showProductIntroOnce,+ useProductIntro,} from "@/react/lib/productIntro";import { router } from "@/react/router";import {@@ -236,11 +235,6 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {const value = syncingInstance ?? syncInstance;return typeof value === "string" && value ? value : undefined;}, []);- const productIntro = useMemo(() => {- const value = router.currentRoute.value.query[PRODUCT_INTRO_QUERY_KEY];- return typeof value === "string" ? value : undefined;- }, []);-const selectedDatabases = useMemo(() => {if (selectedNames.size === 0) return [];return Array.from(selectedNames)@@ -482,30 +476,16 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {});}, [projectId, visibleDatabases]);- useEffect(() => {- if (productIntro !== CONNECT_DATABASE_PRODUCT_INTRO) return;- if (+ useProductIntro({+ id: CONNECT_DATABASE_PRODUCT_INTRO,+ title: t("project.connect-database-intro-title"),+ description: t("project.connect-database-intro-description"),+ disabled:showSyncingInstanceHint ||hasVisibleDatabase ||workspaceHasInstance !== false ||- !canCreateInstance- ) {- return;- }- void showProductIntroOnce({- id: CONNECT_DATABASE_PRODUCT_INTRO,- title: t("project.connect-database-intro-title"),- description: t("project.connect-database-intro-description"),- closeLabel: t("common.close"),- });- }, [- canCreateInstance,- hasVisibleDatabase,- productIntro,- showSyncingInstanceHint,- workspaceHasInstance,- t,- ]);+ !canCreateInstance,+ });const handleCreateDatabaseAction = useCallback(() => {if (checkingWorkspaceInstance) return;diff --git a/frontend/src/react/pages/project/ProjectGitOpsPage.tsx b/frontend/src/react/pages/project/ProjectGitOpsPage.tsxindex 772a6b80db..86184d3bf0 100644--- a/frontend/src/react/pages/project/ProjectGitOpsPage.tsx+++ b/frontend/src/react/pages/project/ProjectGitOpsPage.tsx@@ -3,11 +3,11 @@ import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import gitopsWorkflowImage from "@/assets/gitops-workflow.svg";import { CreateWorkloadIdentitySheet } from "@/react/components/CreateWorkloadIdentitySheet";+import { ExternalUrlAlert } from "@/react/components/ExternalUrlAlert";import { PermissionGuard } from "@/react/components/PermissionGuard";import { ProjectPageLayout } from "@/react/components/ProjectPageLayout";-import { RouterLink } from "@/react/components/RouterLink";import { Alert } from "@/react/components/ui/alert";-import { Button, buttonVariants } from "@/react/components/ui/button";+import { Button } from "@/react/components/ui/button";import { Combobox, type ComboboxOption } from "@/react/components/ui/combobox";import { CopyButton } from "@/react/components/ui/copy-button";import { Switch } from "@/react/components/ui/switch";@@ -19,7 +19,6 @@ import {} from "@/react/components/ui/tabs";import { useProjectByName } from "@/react/hooks/useProjectByName";import { cn } from "@/react/lib/utils";-import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/react/router/handles";import { useAppStore } from "@/react/stores/app";import { extractWorkloadIdentityId } from "@/react/stores/app/workloadIdentity";import { projectNamePrefix } from "@/store/modules/v1/common";@@ -31,7 +30,6 @@ import {getDefaultPagination,getWorkloadIdentityProviderText,hasProjectPermissionV2,- hasWorkspacePermissionV2,parseWorkloadIdentitySubjectPattern,} from "@/utils";@@ -668,30 +666,7 @@ function CheckOrX({ ok }: { ok: boolean }) {}function MissingExternalURLAttention() {- const { t } = useTranslation();- const canConfigure = hasWorkspacePermissionV2(- "bb.settings.setWorkspaceProfile"- );-- return (- <Alert- variant="error"- className="mt-1"- title={t("banner.external-url")}- description={t("settings.general.workspace.external-url.description")}- >- {canConfigure && (- <div className="mt-1">- <RouterLink- to={{ name: SETTING_ROUTE_WORKSPACE_GENERAL }}- className={buttonVariants({ size: "sm", className: "w-fit" })}- >- {t("common.configure-now")}- </RouterLink>- </div>- )}- </Alert>- );+ return <ExternalUrlAlert className="mt-1" />;}function CodeBlock({ code }: { code: string }) {diff --git a/frontend/src/react/pages/project/ProjectWebhookForm.tsx b/frontend/src/react/pages/project/ProjectWebhookForm.tsxindex 6048109305..8bc4b93cd0 100644--- a/frontend/src/react/pages/project/ProjectWebhookForm.tsx+++ b/frontend/src/react/pages/project/ProjectWebhookForm.tsx@@ -3,6 +3,7 @@ import { isEqual } from "lodash-es";import { EllipsisVertical, Info } from "lucide-react";import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";+import { ExternalUrlAlert } from "@/react/components/ExternalUrlAlert";import { RouterLink } from "@/react/components/RouterLink";import {AlertDialog,@@ -11,7 +12,7 @@ import {AlertDialogFooter,AlertDialogTitle,} from "@/react/components/ui/alert-dialog";-import { Button, buttonVariants } from "@/react/components/ui/button";+import { Button } from "@/react/components/ui/button";import { Checkbox } from "@/react/components/ui/checkbox";import {DropdownMenu,@@ -28,7 +29,6 @@ import { router } from "@/react/router";import {PROJECT_V1_ROUTE_WEBHOOK_DETAIL,PROJECT_V1_ROUTE_WEBHOOKS,- SETTING_ROUTE_WORKSPACE_GENERAL,WORKSPACE_ROUTE_IM,} from "@/react/router/handles";import { useAppStore } from "@/react/stores/app";@@ -44,7 +44,7 @@ import type {} from "@/types/proto-es/v1/project_service_pb";import { WebhookSchema } from "@/types/proto-es/v1/project_service_pb";import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";-import { extractProjectWebhookID, hasWorkspacePermissionV2 } from "@/utils";+import { extractProjectWebhookID } from "@/utils";interface Props {allowEdit?: boolean;@@ -87,8 +87,6 @@ export function ProjectWebhookForm({useAppStore.getState().getOrFetchSettingByName(Setting_SettingName.APP_IM);}, []);- const externalUrl = useAppStore((s) => s.externalUrl());-const webhookTypeItemList = useMemo(() => projectWebhookV1TypeItemList(), []);const webhookActivityItemList = useMemo(() => projectWebhookV1ActivityItemList(),@@ -335,22 +333,7 @@ export function ProjectWebhookForm({)}{/* Missing external URL warning */}- {!externalUrl && (- <div className="mb-6 p-3 border border-error/30 bg-error/5 rounded-xs text-sm text-error">- <div className="font-medium">{t("banner.external-url")}</div>- <div className="mt-1">- {t("settings.general.workspace.external-url.description")}- </div>- {hasWorkspacePermissionV2("bb.settings.setWorkspaceProfile") && (- <RouterLink- to={{ name: SETTING_ROUTE_WORKSPACE_GENERAL }}- className={buttonVariants({ size: "sm", className: "mt-2" })}- >- {t("common.configure-now")}- </RouterLink>- )}- </div>- )}+ <ExternalUrlAlert className="mb-6" /><div className="flex flex-col gap-y-4">{/* Destination type selector (create only) */}diff --git a/frontend/src/react/pages/settings/GroupsPage.test.tsx b/frontend/src/react/pages/settings/GroupsPage.test.tsxindex 55ed3d216d..4e01b963e7 100644--- a/frontend/src/react/pages/settings/GroupsPage.test.tsx+++ b/frontend/src/react/pages/settings/GroupsPage.test.tsx@@ -1,3 +1,6 @@+import { readFileSync } from "node:fs";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";import type {ButtonHTMLAttributes,InputHTMLAttributes,@@ -29,6 +32,8 @@ const mocks = vi.hoisted(() => ({routerReplace: vi.fn(),}));+const pageDir = dirname(fileURLToPath(import.meta.url));+vi.mock("@/react/components/ComponentPermissionGuard", () => ({ComponentPermissionGuard: ({ children }: { children: ReactNode }) =>createElement("div", {}, children),@@ -313,6 +318,21 @@ async function renderPage(): Promise<void> {}describe("GroupsPage create group sheet", () => {+ it("routes domain restriction configuration with intro highlight", () => {+ const source = readFileSync(join(pageDir, "GroupsPage.tsx"), "utf8");+ const domainRestrictionIndex = source.indexOf(+ 'hash: "#domain-restriction"'+ );+ const domainRestrictionRoute = source.slice(+ Math.max(0, domainRestrictionIndex - 300),+ domainRestrictionIndex + 300+ );++ expect(domainRestrictionIndex).toBeGreaterThan(0);+ expect(domainRestrictionRoute).toContain("DOMAIN_RESTRICTION_PRODUCT_INTRO");+ expect(domainRestrictionRoute).toContain("PRODUCT_INTRO_QUERY_KEY");+ });+it("renders the title-required error under the title field", async () => {await renderPage();diff --git a/frontend/src/react/pages/settings/GroupsPage.tsx b/frontend/src/react/pages/settings/GroupsPage.tsxindex d5cffd8fac..82d5e1489f 100644--- a/frontend/src/react/pages/settings/GroupsPage.tsx+++ b/frontend/src/react/pages/settings/GroupsPage.tsx@@ -64,6 +64,10 @@ import {} from "@/react/components/WorkspacePageLayout";import { useCurrentUser } from "@/react/hooks/useAppState";import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";+import {+ DOMAIN_RESTRICTION_PRODUCT_INTRO,+ PRODUCT_INTRO_QUERY_KEY,+} from "@/react/lib/productIntro";import { cn } from "@/react/lib/utils";import type { NavigationHistoryAction } from "@/react/router";import { router } from "@/react/router";@@ -1235,6 +1239,10 @@ export function GroupsPage() {to={{name: SETTING_ROUTE_WORKSPACE_GENERAL,hash: "#domain-restriction",+ query: {+ [PRODUCT_INTRO_QUERY_KEY]:+ DOMAIN_RESTRICTION_PRODUCT_INTRO,+ },}}className="underline text-accent">diff --git a/frontend/src/react/pages/settings/MCPPage.tsx b/frontend/src/react/pages/settings/MCPPage.tsxindex 75548ea568..b84a308182 100644--- a/frontend/src/react/pages/settings/MCPPage.tsx+++ b/frontend/src/react/pages/settings/MCPPage.tsx@@ -1,8 +1,7 @@import { useMemo } from "react";import { useTranslation } from "react-i18next";-import { RouterLink } from "@/react/components/RouterLink";+import { ExternalUrlAlert } from "@/react/components/ExternalUrlAlert";import { Alert } from "@/react/components/ui/alert";-import { buttonVariants } from "@/react/components/ui/button";import { CopyButton } from "@/react/components/ui/copy-button";import { Input } from "@/react/components/ui/input";import {@@ -13,15 +12,10 @@ import {} from "@/react/components/ui/tabs";import { Textarea } from "@/react/components/ui/textarea";import { useServerState } from "@/react/hooks/useAppState";-import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/react/router/handles";-import { hasWorkspacePermissionV2 } from "@/utils";export function MCPPage() {const { t } = useTranslation();const { externalUrl, needConfigureExternalUrl } = useServerState();- const canConfigureExternalUrl = hasWorkspacePermissionV2(- "bb.settings.setWorkspaceProfile"- );const mcpEndpointUrl = useMemo(() => {if (needConfigureExternalUrl || !externalUrl) {@@ -88,31 +82,7 @@ export function MCPPage() {</div>{/* Warning if external URL not configured */}- {needConfigureExternalUrl && (- <Alert- variant="error"- title={t("banner.external-url")}- description={- <>- <span>- {t("settings.general.workspace.external-url.description")}- </span>- {canConfigureExternalUrl && (- <RouterLink- to={{ name: SETTING_ROUTE_WORKSPACE_GENERAL }}- className={buttonVariants({- appearance: "outline",- size: "sm",- className: "ml-3",- })}- >- {t("common.configure-now")}- </RouterLink>- )}- </>- }- />- )}+ <ExternalUrlAlert actionAppearance="outline" />{/* Authentication Notice */}<Alertdiff --git a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsxindex 0722241316..2fd19fc167 100644--- a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx+++ b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx@@ -29,6 +29,10 @@ import {SelectValue,} from "@/react/components/ui/select";import { useServerState } from "@/react/hooks/useAppState";+import {+ AI_ASSISTANT_PRODUCT_INTRO,+ useProductIntro,+} from "@/react/lib/productIntro";import { useAppStore } from "@/react/stores/app";import {AISetting_Provider,@@ -116,6 +120,12 @@ export const AIAugmentationSection = forwardRef<}}, []);+ useProductIntro({+ id: AI_ASSISTANT_PRODUCT_INTRO,+ title: t("settings.general.workspace.ai-assistant.self"),+ description: t("settings.general.workspace.ai-assistant.description"),+ });+const providerDefault =PROVIDER_DEFAULTS[state.provider] ??PROVIDER_DEFAULTS[AISetting_Provider.OPEN_AI];@@ -214,7 +224,12 @@ export const AIAugmentationSection = forwardRef<};return (- <FormSection id="ai" ref={containerRef} title={title}>+ <FormSection+ id="ai"+ ref={containerRef}+ title={title}+ data-product-intro-target={AI_ASSISTANT_PRODUCT_INTRO}+ ><ComponentPermissionGuard permissions={["bb.settings.get"]}><PermissionGuard permissions={["bb.settings.set"]} display="block"><FormFieldGroup>diff --git a/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts b/frontend/src/react/pages/settings/general/GeneralPageLayout.test.tsindex c55f1c2705..79ffc6be88 100644--- a/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts+++ b/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts@@ -95,4 +95,22 @@ describe("GeneralPage section layout", () => {'<span className="flex items-start gap-x-2">');});++ test("wires product intro targets for general settings deep links", () => {+ const aiSource = readFileSync(+ join(sectionDir, "AIAugmentationSection.tsx"),+ "utf8"+ );+ const securitySource = readFileSync(+ join(sectionDir, "SecuritySection.tsx"),+ "utf8"+ );++ expect(aiSource).toContain("AI_ASSISTANT_PRODUCT_INTRO");+ expect(aiSource).toContain("data-product-intro-target");+ expect(aiSource).toContain("useProductIntro");+ expect(securitySource).toContain("DOMAIN_RESTRICTION_PRODUCT_INTRO");+ expect(securitySource).toContain("data-product-intro-target");+ expect(securitySource).toContain("useProductIntro");+ });});diff --git a/frontend/src/react/pages/settings/general/GeneralSection.tsx b/frontend/src/react/pages/settings/general/GeneralSection.tsxindex eef4ed0da9..39c8055409 100644--- a/frontend/src/react/pages/settings/general/GeneralSection.tsx+++ b/frontend/src/react/pages/settings/general/GeneralSection.tsx@@ -29,6 +29,10 @@ import {import { Input } from "@/react/components/ui/input";import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";import { useServerState } from "@/react/hooks/useAppState";+import {+ EXTERNAL_URL_PRODUCT_INTRO,+ useProductIntro,+} from "@/react/lib/productIntro";import { router } from "@/react/router";import { SQL_EDITOR_HOME_MODULE } from "@/react/router/handles";import { useAppStore } from "@/react/stores/app";@@ -124,6 +128,13 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(onDirtyChange();}, [state, onDirtyChange]);+ useProductIntro({+ id: EXTERNAL_URL_PRODUCT_INTRO,+ title: t("settings.general.workspace.external-url.self"),+ description: t("settings.general.workspace.external-url.description"),+ disabled: isSaaSMode,+ });+const goToSQLEditor = () => {router.push({ name: SQL_EDITOR_HOME_MODULE });};@@ -219,6 +230,7 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(/>)}<Input+ data-product-intro-target={EXTERNAL_URL_PRODUCT_INTRO}value={state.externalUrl}className="w-full"disabled={!canEdit || externalUrlFromFlag}diff --git a/frontend/src/react/pages/settings/general/SecuritySection.tsx b/frontend/src/react/pages/settings/general/SecuritySection.tsxindex ea28c76409..87e0459c00 100644--- a/frontend/src/react/pages/settings/general/SecuritySection.tsx+++ b/frontend/src/react/pages/settings/general/SecuritySection.tsx@@ -26,6 +26,10 @@ import {} from "@/react/components/ui/form";import { Input } from "@/react/components/ui/input";import { usePlanFeature } from "@/react/hooks/useAppState";+import {+ DOMAIN_RESTRICTION_PRODUCT_INTRO,+ useProductIntro,+} from "@/react/lib/productIntro";import { useAppStore } from "@/react/stores/app";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import type { SectionHandle } from "./useSettingSection";@@ -219,6 +223,14 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(onDirtyChange();}, [state, domainInput, onDirtyChange]);+ useProductIntro({+ id: DOMAIN_RESTRICTION_PRODUCT_INTRO,+ title: t("settings.general.workspace.domain-restriction.self"),+ description: t(+ "settings.general.workspace.domain-restriction.description"+ ),+ });+const addDomain = () => {if (!domainInput.trim()) return;setState((prev) => ({@@ -377,6 +389,7 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>({/* Domain Restriction */}<FormFieldid="domain-restriction"+ data-product-intro-target={DOMAIN_RESTRICTION_PRODUCT_INTRO}title={t("settings.general.workspace.domain-restriction.self")}description={t("settings.general.workspace.domain-restriction.description"diff --git a/frontend/src/react/pages/settings/shared/AADSyncSheet.tsx b/frontend/src/react/pages/settings/shared/AADSyncSheet.tsxindex 91c47ba3a6..aed0fa1a1b 100644--- a/frontend/src/react/pages/settings/shared/AADSyncSheet.tsx+++ b/frontend/src/react/pages/settings/shared/AADSyncSheet.tsx@@ -2,8 +2,8 @@ import { create } from "@bufbuild/protobuf";import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";import { Copy } from "lucide-react";import { useTranslation } from "react-i18next";+import { ExternalUrlAlert } from "@/react/components/ExternalUrlAlert";import { LearnMoreLink } from "@/react/components/LearnMoreLink";-import { Alert } from "@/react/components/ui/alert";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import {@@ -101,9 +101,7 @@ export function AADSyncSheet({</p>{/* Missing external URL warning */}- {!externalUrl && (- <Alert variant="warning" description={t("banner.external-url")} />- )}+ <ExternalUrlAlert variant="warning" actionAppearance="outline" />{/* SCIM Endpoint URL */}<div className="flex flex-col gap-y-2">diff --git a/frontend/src/react/plugins/agent/components/AgentChat.test.tsx b/frontend/src/react/plugins/agent/components/AgentChat.test.tsxindex 5abf96b0bd..115539976d 100644--- a/frontend/src/react/plugins/agent/components/AgentChat.test.tsx+++ b/frontend/src/react/plugins/agent/components/AgentChat.test.tsx@@ -13,6 +13,7 @@ const mocks = vi.hoisted(() => ({t: (key: string) => key,})),hasWorkspacePermissionV2: vi.fn(() => true),+ routerPush: vi.fn(),}));let AgentChat: typeof import("./AgentChat").AgentChat;@@ -42,13 +43,15 @@ function createMockStorage(): Storage {}vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },useTranslation: mocks.useTranslation,}));vi.mock("@/react/router", async (importOriginal) => ({...(await importOriginal<typeof import("@/react/router")>()),router: {- push: vi.fn(),+ push: mocks.routerPush,+ resolve: (to: unknown) => ({ href: JSON.stringify(to) }),},}));@@ -96,6 +99,7 @@ beforeEach(async () => {});mocks.hasWorkspacePermissionV2.mockReset();mocks.hasWorkspacePermissionV2.mockReturnValue(true);+ mocks.routerPush.mockReset();({ AgentChat } = await import("./AgentChat"));});@@ -202,4 +206,35 @@ describe("AgentChat", () => {unmount();});++ test("routes AI configuration recovery to general settings with intro", () => {+ const chat = useAgentStore.getState().ensureCurrentChat();+ useAgentStore.setState((state) => ({+ chats: state.chats.map((item) =>+ item.id === chat.id ? { ...item, requiresAIConfiguration: true } : item+ ),+ }));++ const { container, render, unmount } = renderIntoContainer(<AgentChat />);++ render();++ const configureLink = Array.from(container.querySelectorAll("a")).find(+ (link) => link.textContent === "agent.ai-not-configured.configure"+ ) as HTMLAnchorElement;++ expect(configureLink).toBeTruthy();++ act(() => {+ configureLink.click();+ });++ expect(mocks.routerPush).toHaveBeenCalledWith({+ name: "setting.workspace.general",+ hash: "#ai-assistant",+ query: { intro: "ai-assistant" },+ });++ unmount();+ });});diff --git a/frontend/src/react/plugins/agent/components/AgentChat.tsx b/frontend/src/react/plugins/agent/components/AgentChat.tsxindex c4269b566c..946f5b4ab1 100644--- a/frontend/src/react/plugins/agent/components/AgentChat.tsx+++ b/frontend/src/react/plugins/agent/components/AgentChat.tsx@@ -4,6 +4,10 @@ import ReactMarkdown from "react-markdown";import remarkGfm from "remark-gfm";import { RouterLink } from "@/react/components/RouterLink";import { Button, buttonVariants } from "@/react/components/ui/button";+import {+ AI_ASSISTANT_PRODUCT_INTRO,+ PRODUCT_INTRO_QUERY_KEY,+} from "@/react/lib/productIntro";import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/react/router/handles";import { hasWorkspacePermissionV2 } from "@/utils";import type { AgentMessage, ToolCall } from "../logic/types";@@ -223,6 +227,9 @@ export function AgentChat({ className }: AgentChatProps) {to={{name: SETTING_ROUTE_WORKSPACE_GENERAL,hash: "#ai-assistant",+ query: {+ [PRODUCT_INTRO_QUERY_KEY]: AI_ASSISTANT_PRODUCT_INTRO,+ },}}className={buttonVariants({ size: "sm" })}onClick={goConfigure}