From add45fa6c56a451e0eab52287f42dff9327537c8 Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Sat, 20 Jun 2026 17:54:30 +0200 Subject: [PATCH 1/3] Make the AI Assistant panel resizable Add a drag handle on the panel's left edge and an expand/collapse button to resize the AI Assistant on desktop. Width is driven by the --ai-chat-width CSS variable, persisted via a Zustand store, and capped to the viewport so the page content stays usable. --- .../gitbook/src/components/AIChat/AIChat.tsx | 6 +- .../components/AIChat/AIChatExpandButton.tsx | 39 ++++++++ .../components/AIChat/AIChatResizeHandle.tsx | 97 +++++++++++++++++++ .../components/AIChat/useAIChatWidthStore.ts | 66 +++++++++++++ .../Announcement/AnnouncementBanner.tsx | 2 +- .../src/components/Cookies/CookiesToast.tsx | 3 +- .../gitbook/src/components/Footer/Footer.tsx | 2 +- .../gitbook/src/components/Header/Header.tsx | 4 +- .../src/components/RootLayout/globals.css | 10 ++ .../components/SpaceLayout/SpaceLayout.tsx | 2 +- packages/gitbook/src/intl/translations/ar.ts | 2 + packages/gitbook/src/intl/translations/bg.ts | 2 + packages/gitbook/src/intl/translations/cs.ts | 2 + packages/gitbook/src/intl/translations/da.ts | 2 + packages/gitbook/src/intl/translations/de.ts | 2 + packages/gitbook/src/intl/translations/el.ts | 2 + packages/gitbook/src/intl/translations/en.ts | 2 + packages/gitbook/src/intl/translations/es.ts | 2 + packages/gitbook/src/intl/translations/et.ts | 2 + packages/gitbook/src/intl/translations/fi.ts | 2 + packages/gitbook/src/intl/translations/fr.ts | 2 + packages/gitbook/src/intl/translations/he.ts | 2 + packages/gitbook/src/intl/translations/hi.ts | 2 + packages/gitbook/src/intl/translations/hr.ts | 2 + packages/gitbook/src/intl/translations/hu.ts | 2 + packages/gitbook/src/intl/translations/id.ts | 2 + packages/gitbook/src/intl/translations/it.ts | 2 + packages/gitbook/src/intl/translations/ja.ts | 2 + packages/gitbook/src/intl/translations/ko.ts | 2 + packages/gitbook/src/intl/translations/lt.ts | 2 + packages/gitbook/src/intl/translations/lv.ts | 2 + packages/gitbook/src/intl/translations/ms.ts | 2 + packages/gitbook/src/intl/translations/nl.ts | 2 + packages/gitbook/src/intl/translations/no.ts | 2 + packages/gitbook/src/intl/translations/pl.ts | 2 + .../gitbook/src/intl/translations/pt-br.ts | 2 + packages/gitbook/src/intl/translations/pt.ts | 2 + packages/gitbook/src/intl/translations/ro.ts | 2 + packages/gitbook/src/intl/translations/ru.ts | 2 + packages/gitbook/src/intl/translations/sk.ts | 2 + packages/gitbook/src/intl/translations/sl.ts | 2 + packages/gitbook/src/intl/translations/sv.ts | 2 + packages/gitbook/src/intl/translations/th.ts | 2 + packages/gitbook/src/intl/translations/tr.ts | 2 + packages/gitbook/src/intl/translations/uk.ts | 2 + packages/gitbook/src/intl/translations/vi.ts | 2 + packages/gitbook/src/intl/translations/yue.ts | 2 + .../gitbook/src/intl/translations/zh-tw.ts | 2 + packages/gitbook/src/intl/translations/zh.ts | 2 + 49 files changed, 301 insertions(+), 8 deletions(-) create mode 100644 packages/gitbook/src/components/AIChat/AIChatExpandButton.tsx create mode 100644 packages/gitbook/src/components/AIChat/AIChatResizeHandle.tsx create mode 100644 packages/gitbook/src/components/AIChat/useAIChatWidthStore.ts diff --git a/packages/gitbook/src/components/AIChat/AIChat.tsx b/packages/gitbook/src/components/AIChat/AIChat.tsx index b2214d5069..dbc6cfa3c0 100644 --- a/packages/gitbook/src/components/AIChat/AIChat.tsx +++ b/packages/gitbook/src/components/AIChat/AIChat.tsx @@ -31,9 +31,11 @@ import { ScrollContainer } from '../primitives/ScrollContainer'; import { SideSheet } from '../primitives/SideSheet'; import { AIChatControl } from './AIChatControl'; import { AIChatControlButton } from './AIChatControlButton'; +import { AIChatExpandButton } from './AIChatExpandButton'; import { AIChatIcon } from './AIChatIcon'; import { AIChatInput } from './AIChatInput'; import { AIChatMessages } from './AIChatMessages'; +import { AIChatResizeHandle } from './AIChatResizeHandle'; import AIChatSuggestedQuestions from './AIChatSuggestedQuestions'; export function AIChat() { @@ -85,9 +87,10 @@ export function AIChat() { withOverlay={true} data-ai-chat className={tcls( - 'ai-chat mx-auto ml-8 not-hydrated:hidden w-96 transition-[width] duration-300 ease-quint lg:max-xl:w-80' + 'ai-chat mx-auto ml-8 not-hydrated:hidden w-96 transition-[width] duration-300 ease-quint lg:w-(--ai-chat-width)' )} > + @@ -100,6 +103,7 @@ export function AIChat() { +