A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
ai.chat: reset input on submit (#6668)
Shahmir Varqha5789c1068dd2
diff --git a/frontend/src/plugins/impl/chat/ChatPlugin.tsx b/frontend/src/plugins/impl/chat/ChatPlugin.tsxindex 87d24de419..8e5830de39 100644--- a/frontend/src/plugins/impl/chat/ChatPlugin.tsx+++ b/frontend/src/plugins/impl/chat/ChatPlugin.tsx@@ -41,7 +41,7 @@ export const ChatPlugin = createPlugin<{ messages: ChatMessage[] }>(z.object({role: z.enum(["system", "user", "assistant"]),content: z.string(),- parts: z.array(z.any()),+ parts: z.array(z.any()).nullable(),}),),}),diff --git a/frontend/src/plugins/impl/chat/chat-ui.tsx b/frontend/src/plugins/impl/chat/chat-ui.tsxindex bfb5b9e4c8..cbd42cb42b 100644--- a/frontend/src/plugins/impl/chat/chat-ui.tsx+++ b/frontend/src/plugins/impl/chat/chat-ui.tsx@@ -253,6 +253,20 @@ export const Chatbot: React.FC<Props> = (props) => {});}, [messages.length, scrollContainerRef]);+ const codemirrorView = codeMirrorInputRef.current?.view;++ const resetInput = () => {+ // Clear input immediately by directly manipulating the editor+ // There is some delay if we use setInput("") only+ if (codemirrorView) {+ const docLength = codemirrorView.state.doc.length;+ codemirrorView.dispatch({+ changes: { from: 0, to: docLength, insert: "" },+ });+ }+ setInput("");+ };+return (<divclassName="flex flex-col h-full bg-(--slate-1) rounded-lg shadow border border-(--slate-6) overflow-hidden relative"@@ -367,6 +381,7 @@ export const Chatbot: React.FC<Props> = (props) => {role: "user",parts: [{ type: "text", text: input }, ...(fileParts ?? [])],});+ resetInput();}}ref={formRef}className="flex w-full border-t border-(--slate-6) px-2 py-1 items-center"@@ -380,8 +395,8 @@ export const Chatbot: React.FC<Props> = (props) => {onSelect={(prompt) => {setInput(prompt);requestAnimationFrame(() => {- codeMirrorInputRef.current?.view?.focus();- moveToEndOfEditor(codeMirrorInputRef.current?.view);+ codemirrorView?.focus();+ moveToEndOfEditor(codemirrorView);});}}/>diff --git a/frontend/src/plugins/impl/chat/types.ts b/frontend/src/plugins/impl/chat/types.tsindex 2c79d50255..c56d162d8d 100644--- a/frontend/src/plugins/impl/chat/types.ts+++ b/frontend/src/plugins/impl/chat/types.ts@@ -7,7 +7,7 @@ export type ChatRole = "system" | "user" | "assistant";export interface ChatMessage {role: ChatRole;content: string; // TODO: Deprecate content- parts: UIMessage["parts"];+ parts: UIMessage["parts"] | null;}export interface SendMessageRequest {