From 5770d88695b9cd57a13b53a413688d34f97b2183 Mon Sep 17 00:00:00 2001 From: "Sam (automated drift fix)" Date: Thu, 22 Oct 2026 13:25:42 +0300 Subject: [PATCH 1/2] docs(platform): useChat examples for answer(), submit(), and clearError() Co-Authored-By: Claude Opus 5.5 --- packages/platform/src/react/chat.types.ts | 57 ++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/packages/platform/src/react/chat.types.ts b/packages/platform/src/react/chat.types.ts index 4cc8836..0bca46f 100644 --- a/packages/platform/src/react/chat.types.ts +++ b/packages/platform/src/react/chat.types.ts @@ -200,6 +200,23 @@ export interface ChoiceQuestion { * @param picked - One list of picked labels per question, in the order of `questions`. * @param texts - One free-text answer per question, in the same order. Use it for a `text_input` question, or as a note beside a pick. A question with no pick and no text is skipped. * @returns Promise resolving once Base44 accepts the answer, or once sending it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Answer a one-question choice with a button per option + * function ChoiceButtons({ question }: { question: ChoiceQuestion }) { + * const [entry] = question.questions; + * return ( + *
+ *

{entry.text}

+ * {entry.options.map((label) => ( + * + * ))} + * + *
+ * ); + * } + * ``` */ answer(picked: string[][], texts?: string[]): Promise; /** @@ -229,6 +246,31 @@ export interface SecretsQuestion { * * @param values - The values, keyed by each field's `name`. * @returns Promise resolving once Base44 accepts the values, or once sending it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Ask for each secret, then submit the values by name + * function SecretsForm({ question }: { question: SecretsQuestion }) { + * return ( + *
{ + * event.preventDefault(); + * const form = new FormData(event.currentTarget); + * question.submit(Object.fromEntries(question.fields.map((field) => [field.name, String(form.get(field.name) ?? "")]))); + * }} + * > + * {question.fields.map((field) => ( + * + * ))} + * + * + *
+ * ); + * } + * ``` */ submit(values: Record): Promise; /** @@ -392,6 +434,19 @@ export interface UseChatResult { * @returns Promise resolving once the app exists, or once creating it fails and sets [`error`](#error). It never rejects. */ create(prompt: string): Promise; - /** Clears a failed call's or the connection's [`error`](#error). A failed build's error stays while Base44 reports it. */ + /** + * Clears a failed call's or the connection's [`error`](#error). A failed build's error stays while Base44 reports it. + * + * @example + * ```tsx + * // Show the error, with a dismiss button unless the build failed + * {chat.error && ( + *
+ * {chat.error.message} + * {chat.error.code !== "build_failed" && } + *
+ * )} + * ``` + */ clearError(): void; } From b0f0812c03943265146d26768d0a45cbf36b63fd Mon Sep 17 00:00:00 2001 From: "Sam (automated drift fix)" Date: Thu, 22 Oct 2026 14:04:05 +0300 Subject: [PATCH 2/2] docs(platform): examples for every useChat action, question action, and two backend routes send(), create(), approve(), and each decline() get an example, and createApp() and openLiveSession() get the server route each one calls. The routes for sendMessage() and submitToolCallInput() wait on how a backend should answer Base44's long-running chat requests. Co-Authored-By: Claude Opus 5.5 --- packages/platform/src/react/chat.types.ts | 96 +++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/packages/platform/src/react/chat.types.ts b/packages/platform/src/react/chat.types.ts index 0bca46f..243a2f2 100644 --- a/packages/platform/src/react/chat.types.ts +++ b/packages/platform/src/react/chat.types.ts @@ -63,6 +63,22 @@ export interface ChatBackend { * * @param prompt - The first prompt, which describes the app. * @returns Promise resolving to the new app. + * + * @example + * ```typescript + * // Your server route for createApp(), with a personal access token + * export async function POST(request: Request) { + * const { prompt } = await request.json(); + * const response = await fetch("https://app.base44.com/api/apps", { + * method: "POST", + * headers: { Authorization: `Bearer ${process.env.BASE44_ACCESS_TOKEN}`, "Content-Type": "application/json" }, + * body: JSON.stringify({ initial_message: { content: prompt } }), + * }); + * if (!response.ok) return new Response("Create app failed", { status: response.status }); + * const app = await response.json(); + * return Response.json({ id: app.id, name: app.name }); + * } + * ``` */ createApp(prompt: string): Promise; /** @@ -71,6 +87,23 @@ export interface ChatBackend { * * @param appId - ID of the app to follow. * @returns Promise resolving to the session. + * + * @example + * ```typescript + * // Your server route for openLiveSession(), with a workspace API key + * export async function POST(request: Request) { + * const { appId } = await request.json(); + * const response = await fetch("https://app.base44.com/api/v1/socket-sessions", { + * method: "POST", + * headers: { Authorization: `Bearer ${process.env.BASE44_API_KEY}`, "Content-Type": "application/json" }, + * body: JSON.stringify({ app_ids: [appId] }), + * }); + * if (!response.ok) return new Response("Create socket session failed", { status: response.status }); + * const { session_token, socket_url, socket_path, session_id } = await response.json(); + * await saveSession(appId, session_id); // Keep it on your server to change or end the session + * return Response.json({ session_token, socket_url, socket_path }); + * } + * ``` */ openLiveSession(appId: string): Promise; /** @@ -223,6 +256,12 @@ export interface ChoiceQuestion { * Declines the question. The AI continues without the answer. * * @returns Promise resolving once Base44 accepts the decline, or once sending it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Skip the question + * + * ``` */ decline(): Promise; } @@ -277,6 +316,12 @@ export interface SecretsQuestion { * Declines the question. The AI continues without the values. * * @returns Promise resolving once Base44 accepts the decline, or once sending it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Skip without entering the secrets + * + * ``` */ decline(): Promise; } @@ -297,12 +342,33 @@ export interface ApprovalQuestion { * Lets the action run. * * @returns Promise resolving once Base44 accepts the approval, or once sending it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Show what the action would do, then allow or decline it + * function ApprovalPrompt({ question }: { question: ApprovalQuestion }) { + * return ( + *
+ *

The AI wants to run {question.action}.

+ * {question.reason &&

{question.reason}

} + * + * + *
+ * ); + * } + * ``` */ approve(): Promise; /** * Declines the action. It never runs, and the AI continues. * * @returns Promise resolving once Base44 accepts the decline, or once sending it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Decline the action + * + * ``` */ decline(): Promise; } @@ -423,6 +489,27 @@ export interface UseChatResult { * * @param prompt - The prompt to send. * @returns Promise resolving once Base44 accepts the prompt, or once the send fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Send the prompt from a form + * function PromptForm({ chat }: { chat: UseChatResult }) { + * const [prompt, setPrompt] = useState(""); + * return ( + *
{ + * event.preventDefault(); + * chat.send(prompt); + * setPrompt(""); + * }} + * > + * setPrompt(event.target.value)} /> + * + * {chat.status === "building" && The AI is working. New prompts wait in the queue.} + *
+ * ); + * } + * ``` */ send(prompt: string): Promise; /** @@ -432,6 +519,15 @@ export interface UseChatResult { * * @param prompt - The first prompt, which describes the app. * @returns Promise resolving once the app exists, or once creating it fails and sets [`error`](#error). It never rejects. + * + * @example + * ```tsx + * // Create the app from the first prompt, and send the next prompts to it + * const [appId, setAppId] = useState(null); + * const chat = useChat({ appId, backend, onAppCreated: (app) => setAppId(app.id) }); + * + * const submit = (prompt: string) => (appId ? chat.send(prompt) : chat.create(prompt)); + * ``` */ create(prompt: string): Promise; /**