Skip to content

Commit 1edc5d6

Browse files
authored
Assistant hold message (#3603)
1 parent 61b8507 commit 1edc5d6

File tree

14 files changed

+91
-11
lines changed

14 files changed

+91
-11
lines changed

.changeset/friendly-geese-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Add "hold message" to Assistant

packages/gitbook/src/components/AIChat/AIChatMessages.tsx

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useLanguage } from '@/intl/client';
2+
import { tString } from '@/intl/translate';
13
import { tcls } from '@/lib/tailwind';
24
import { AIMessageRole } from '@gitbook/api';
35
import type React from 'react';
@@ -46,17 +48,9 @@ export function AIChatMessages(props: {
4648
{message.content ? message.content : null}
4749

4850
{isLastMessage && chat.loading ? (
49-
<div className="flex w-full animate-fade-in-slow flex-wrap gap-2">
50-
{Array.from({ length: 7 }).map((_, index) => (
51-
<div
52-
key={index}
53-
className="h-4 animate-[fadeIn_500ms_ease_both,pulse_1.5s_infinite] circular-corners:rounded-2xl rounded-corners:rounded-md bg-tint-4"
54-
style={{
55-
width: `calc(${(index % 4) * 20 + 10}% - 4px)`,
56-
animationDelay: `${index * 0.1}s`,
57-
}}
58-
/>
59-
))}
51+
<div className="flex w-full animate-fade-in-slow flex-col gap-2">
52+
{!message.content ? <HoldMessage /> : null}
53+
<LoadingSkeleton />
6054
</div>
6155
) : null}
6256

@@ -86,3 +80,55 @@ export function AIChatMessages(props: {
8680
</>
8781
);
8882
}
83+
84+
function HoldMessage() {
85+
const language = useLanguage();
86+
87+
return (
88+
<div className="animate-[heightIn_500ms_4500ms_ease_both] py-2 text-tint-subtle">
89+
{tString(language, 'ai_chat_hold_message_1')
90+
.split(' ')
91+
.map((word, index) => (
92+
<span
93+
key={index}
94+
className="animate-fade-in-slow"
95+
style={{
96+
animationDelay: `${5000 + index * 200}ms`,
97+
}}
98+
>
99+
{word}{' '}
100+
</span>
101+
))}
102+
{tString(language, 'ai_chat_hold_message_2')
103+
.split(' ')
104+
.map((word, index) => (
105+
<span
106+
key={index}
107+
className="animate-fade-in-slow"
108+
style={{
109+
animationDelay: `${10000 + index * 200}ms`,
110+
}}
111+
>
112+
{word}{' '}
113+
</span>
114+
))}
115+
</div>
116+
);
117+
}
118+
119+
function LoadingSkeleton() {
120+
return (
121+
<div className="flex flex-wrap gap-2">
122+
{Array.from({ length: 7 }).map((_, index) => (
123+
<div
124+
key={index}
125+
className="h-4 animate-[fadeIn_500ms_ease_both,pulse_1.5s_infinite] circular-corners:rounded-2xl rounded-corners:rounded-md bg-tint-4"
126+
style={{
127+
width: `calc(${(index % 4) * 20 + 10}% - 4px)`,
128+
animationDelay: `${index * 0.1}s`,
129+
}}
130+
/>
131+
))}
132+
</div>
133+
);
134+
}

packages/gitbook/src/components/RootLayout/globals.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@
213213
:root {
214214
--scrollbar-width: calc(100vw - 100%);
215215
@apply leading-relaxed;
216+
interpolate-size: allow-keywords; /* Opt-in for modern browsers to interpolate "auto" values in transitions/animations. */
216217
}
217218
body {
218219
@apply text-tint-strong antialiased;

packages/gitbook/src/intl/translations/de.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export const de = {
8282
ai_chat_working: 'Arbeite...',
8383
ai_chat_context_badge: 'KI',
8484
ai_chat_error: 'Etwas ist schief gelaufen.',
85+
ai_chat_hold_message_1: 'Überlege es mir durch…',
86+
ai_chat_hold_message_2: 'Einen Moment…',
8587
ai_chat_context_title: 'Basierend auf Ihrem Kontext',
8688
ai_chat_context_description:
8789
'Der Assistent verwendet KI und Ihren Kontext, um Antworten zu generieren und Aktionen durchzuführen.',

packages/gitbook/src/intl/translations/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export const en = {
7979
ai_chat_working: 'Working...',
8080
ai_chat_context_badge: 'AI',
8181
ai_chat_error: 'Something went wrong.',
82+
ai_chat_hold_message_1: 'Thinking it through…',
83+
ai_chat_hold_message_2: 'Just a moment…',
8284
ai_chat_context_title: 'Based on your context',
8385
ai_chat_context_description:
8486
'The assistant uses AI and your context to generate answers and perform actions.',

packages/gitbook/src/intl/translations/es.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export const es: TranslationLanguage = {
8383
ai_chat_working: 'Trabajando...',
8484
ai_chat_context_badge: 'IA',
8585
ai_chat_error: 'Algo salió mal.',
86+
ai_chat_hold_message_1: 'Pensándolo bien…',
87+
ai_chat_hold_message_2: 'Un momento…',
8688
ai_chat_context_title: 'Basado en tu contexto',
8789
ai_chat_context_description:
8890
'El asistente usa IA y tu contexto para generar respuestas y realizar acciones.',

packages/gitbook/src/intl/translations/fr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export const fr = {
7878
ai_chat_working: 'Traitement en cours…',
7979
ai_chat_context_badge: 'IA',
8080
ai_chat_error: 'Une erreur est survenue.',
81+
ai_chat_hold_message_1: 'Je réfléchis…',
82+
ai_chat_hold_message_2: 'Un instant…',
8183
ai_chat_context_title: 'En se basant sur votre contexte',
8284
ai_chat_context_description:
8385
'L’assistant utilise l’IA et votre contexte pour répondre et vous aider.',

packages/gitbook/src/intl/translations/ja.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export const ja: TranslationLanguage = {
8181
ai_chat_working: '作業中...',
8282
ai_chat_context_badge: 'AI',
8383
ai_chat_error: '何らかのエラーが発生しました。',
84+
ai_chat_hold_message_1: '考え中…',
85+
ai_chat_hold_message_2: '少々お待ちください…',
8486
ai_chat_context_title: 'あなたのコンテキストに基づいて',
8587
ai_chat_context_description:
8688
'アシスタントはAIとあなたのコンテキストを使用して回答を生成し、アクションを実行します。',

packages/gitbook/src/intl/translations/nl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export const nl: TranslationLanguage = {
8181
ai_chat_working: 'Werkt...',
8282
ai_chat_context_badge: 'AI',
8383
ai_chat_error: 'Er is iets misgegaan.',
84+
ai_chat_hold_message_1: 'Even nadenken…',
85+
ai_chat_hold_message_2: 'Een momentje…',
8486
ai_chat_context_title: 'Gebaseerd op je context',
8587
ai_chat_context_description:
8688
'De assistent gebruikt AI en je context om antwoorden te genereren en acties uit te voeren.',

packages/gitbook/src/intl/translations/no.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export const no: TranslationLanguage = {
8282
ai_chat_working: 'Arbeider...',
8383
ai_chat_context_badge: 'AI',
8484
ai_chat_error: 'Noe gikk galt.',
85+
ai_chat_hold_message_1: 'Tenker det gjennom…',
86+
ai_chat_hold_message_2: 'Et øyeblikk…',
8587
ai_chat_context_title: 'Basert på din kontekst',
8688
ai_chat_context_description:
8789
'Assistenten bruker AI og din kontekst til å generere svar og utføre handlinger.',

0 commit comments

Comments
 (0)