From ea19801cfaa7e625ed4ede5931c6d9208fd89db0 Mon Sep 17 00:00:00 2001 From: Tomek Date: Thu, 13 Aug 2026 13:17:26 +0200 Subject: [PATCH] feat: add greeting customization to AI chat (#4483) --- .changeset/tired-mails-fall.md | 5 +++++ bun.lock | 4 ++-- package.json | 2 +- packages/gitbook/src/components/AI/useAI.tsx | 2 +- packages/gitbook/src/components/AIChat/AIChat.tsx | 3 ++- packages/gitbook/src/components/SiteLayout/SiteLayout.tsx | 3 +++ 6 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .changeset/tired-mails-fall.md diff --git a/.changeset/tired-mails-fall.md b/.changeset/tired-mails-fall.md new file mode 100644 index 000000000..e0867d728 --- /dev/null +++ b/.changeset/tired-mails-fall.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Support localized custom AI Assistant greeting subtitles. diff --git a/bun.lock b/bun.lock index ca5f7f67f..b6f2bd2f7 100644 --- a/bun.lock +++ b/bun.lock @@ -360,7 +360,7 @@ "react-dom": "catalog:", }, "catalog": { - "@gitbook/api": "0.192.0", + "@gitbook/api": "0.195.0", "@scalar/api-client-react": "^1.3.46", "@tsconfig/node20": "^20.1.6", "@tsconfig/strictest": "^2.0.6", @@ -760,7 +760,7 @@ "@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@7.2.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "7.2.0" } }, "sha512-6639htZMjEkwskf3J+e6/iar+4cTNM9qhoWuRfj9F3eJD6r7iCzV1SWnQr2Mdv0QT0suuqU8BoJCZUyCtP9R4Q=="], - "@gitbook/api": ["@gitbook/api@0.192.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-S9ceF3XspgSqXb7JH5feSHSytVkq1jRDwOKeEK4nnZs9pSiKFxHZMj/LnHi8k8anaue/FeLwWYo+Vk08Pdl0+g=="], + "@gitbook/api": ["@gitbook/api@0.195.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-66OGIiiKUfHB7dF8fb9Ai8PkhQldD4SSQXHZ+X+SSEki2WXpgn6ze+PEXRQvDsJj2JKEvD9A7FfaGzUYiYn9hA=="], "@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"], diff --git a/package.json b/package.json index c69a18743..46fd82c99 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "catalog": { "@tsconfig/strictest": "^2.0.6", "@tsconfig/node20": "^20.1.6", - "@gitbook/api": "0.192.0", + "@gitbook/api": "0.195.0", "@scalar/api-client-react": "^1.3.46", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", diff --git a/packages/gitbook/src/components/AI/useAI.tsx b/packages/gitbook/src/components/AI/useAI.tsx index e8322c1a2..5573feec8 100644 --- a/packages/gitbook/src/components/AI/useAI.tsx +++ b/packages/gitbook/src/components/AI/useAI.tsx @@ -20,7 +20,7 @@ export type AIConfig = { trademark: boolean; assistantName?: string; greeting?: { - title: string; + title?: string; subtitle: string; }; }; diff --git a/packages/gitbook/src/components/AIChat/AIChat.tsx b/packages/gitbook/src/components/AIChat/AIChat.tsx index 3b50ba9d1..03cff48a2 100644 --- a/packages/gitbook/src/components/AIChat/AIChat.tsx +++ b/packages/gitbook/src/components/AIChat/AIChat.tsx @@ -121,6 +121,7 @@ export function AIChat() { suggestions={config.suggestions} trademark={config.trademark} assistantName={config.assistantName} + greeting={config.greeting} /> @@ -212,7 +213,7 @@ export function AIChatBody(props: { /** Custom assistant name override; falls back to the branded/unbranded default name. */ assistantName?: string; greeting?: { - title: string; + title?: string; subtitle: string; }; }) { diff --git a/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx b/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx index a63ac8e6d..f984cd97f 100644 --- a/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx +++ b/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx @@ -30,6 +30,8 @@ export async function SiteLayout(props: { const { context, forcedTheme, withTracking, visitorAuthClaims, children } = props; const { customization } = context; + const { ai } = customization; + const aiGreeting = (context.locale && ai?.localizedGreeting?.[context.locale]) ?? ai?.greeting; // Scripts are disabled when tracking is disabled const scripts = withTracking ? context.scripts : []; @@ -73,6 +75,7 @@ export async function SiteLayout(props: { aiMode={customization.ai?.mode} suggestions={context.customization.ai?.suggestions} trademark={customization.trademark.enabled} + greeting={aiGreeting ? { subtitle: aiGreeting } : undefined} >