+
{/* Display an error banner when something went wrong. */}
{chat.error ?
: null}
-
{
- chatController.postMessage({ message: value });
- }}
- />
+ {chat.control ? (
+
+ ) : (
+ {
+ chatController.postMessage({ message: value });
+ }}
+ />
+ )}
>
);
diff --git a/packages/gitbook/src/components/AIChat/AIChatControl.tsx b/packages/gitbook/src/components/AIChat/AIChatControl.tsx
new file mode 100644
index 000000000..0b350f7ee
--- /dev/null
+++ b/packages/gitbook/src/components/AIChat/AIChatControl.tsx
@@ -0,0 +1,8 @@
+'use client';
+
+import type { AnyAIControl } from '../AI/controls';
+
+export function AIChatControl(props: { control: AnyAIControl }) {
+ const { control } = props;
+ return control.render();
+}
diff --git a/packages/gitbook/src/components/AIChat/AIChatMessages.tsx b/packages/gitbook/src/components/AIChat/AIChatMessages.tsx
index e120ed8e6..abdaed9ba 100644
--- a/packages/gitbook/src/components/AIChat/AIChatMessages.tsx
+++ b/packages/gitbook/src/components/AIChat/AIChatMessages.tsx
@@ -3,7 +3,6 @@ import { tString } from '@/intl/translate';
import { tcls } from '@/lib/tailwind';
import { AIMessageRole } from '@gitbook/api';
import type { AIChatController, AIChatState } from '../AI';
-import { AIChatToolConfirmations } from './AIChatToolConfirmations';
import { AIResponseFeedback } from './AIResponseFeedback';
import { AIChatFollowupSuggestions } from './AiChatFollowupSuggestions';
@@ -67,7 +66,6 @@ export function AIChatMessages(props: {
'break-words',
'group/message',
'animate-blur-in-slow',
- isLastMessage ? 'basis-full' : '',
message.role === AIMessageRole.User
? 'max-w-[80%] origin-top-right self-end circular-corners:rounded-2xl rounded-corners:rounded-md bg-tint px-4 py-2'
: 'origin-top-left text-tint-strong'
@@ -96,14 +94,13 @@ export function AIChatMessages(props: {
!chat.error &&
chat.query &&
chat.responseId &&
- chat.pendingTools.length === 0 ? (
+ chat.control ? (
) : null}
-
{
- e.preventDefault();
- chat.pendingTools[0]?.confirm();
- },
- {
- enableOnFormTags: true,
- },
- [chat.pendingTools]
- );
-
- return (
-
- {chat.pendingTools.map((tool, index) => (
-
-
- ))}
-
- );
-}
diff --git a/packages/gitbook/src/components/primitives/Input.tsx b/packages/gitbook/src/components/primitives/Input.tsx
index 8a3f03f3f..c8ffdb3c1 100644
--- a/packages/gitbook/src/components/primitives/Input.tsx
+++ b/packages/gitbook/src/components/primitives/Input.tsx
@@ -57,11 +57,11 @@ export type InputProps = CustomInputProps &
(
| ({ multiline?: false } & Omit<
React.InputHTMLAttributes,
- 'value' | 'onChange'
+ 'value' | 'onChange' | 'onSubmit'
>)
| ({ multiline: true } & Omit<
React.TextareaHTMLAttributes,
- 'value' | 'onChange'
+ 'value' | 'onChange' | 'onSubmit'
>)
);