diff --git a/frontend/app/aipanel/aipanelinput.tsx b/frontend/app/aipanel/aipanelinput.tsx
index 0dad5e4d5..6eb8aff63 100644
--- a/frontend/app/aipanel/aipanelinput.tsx
+++ b/frontend/app/aipanel/aipanelinput.tsx
@@ -17,6 +17,7 @@ interface AIPanelInputProps {
export interface AIPanelInputRef {
focus: () => void;
resize: () => void;
+ scrollToBottom: () => void;
}
export const AIPanelInput = memo(({ onSubmit, status, model }: AIPanelInputProps) => {
@@ -43,6 +44,12 @@ export const AIPanelInput = memo(({ onSubmit, status, model }: AIPanelInputProps
textareaRef.current?.focus();
},
resize: resizeTextarea,
+ scrollToBottom: () => {
+ const textarea = textareaRef.current;
+ if (textarea) {
+ textarea.scrollTop = textarea.scrollHeight;
+ }
+ },
},
};
model.registerInputRef(inputRefObject);
diff --git a/frontend/app/aipanel/waveai-model.tsx b/frontend/app/aipanel/waveai-model.tsx
index 258bdf9de..7af0914e8 100644
--- a/frontend/app/aipanel/waveai-model.tsx
+++ b/frontend/app/aipanel/waveai-model.tsx
@@ -301,7 +301,7 @@ export class WaveAIModel {
return input != null && input.trim().length > 0;
}
- appendText(text: string, newLine?: boolean) {
+ appendText(text: string, newLine?: boolean, opts?: { scrollToBottom?: boolean }) {
const currentInput = globalStore.get(this.inputAtom);
let newInput = currentInput;
@@ -317,6 +317,10 @@ export class WaveAIModel {
newInput += text;
globalStore.set(this.inputAtom, newInput);
+
+ if (opts?.scrollToBottom && this.inputRef?.current) {
+ setTimeout(() => this.inputRef.current.scrollToBottom(), 10);
+ }
}
setModel(model: string) {
diff --git a/frontend/builder/builder-buildpanel.tsx b/frontend/builder/builder-buildpanel.tsx
index 1ce2dc7ac..59f0a8815 100644
--- a/frontend/builder/builder-buildpanel.tsx
+++ b/frontend/builder/builder-buildpanel.tsx
@@ -82,7 +82,24 @@ const BuilderBuildPanel = memo(() => {
BuilderAppPanelModel.getInstance().restartBuilder();
}, []);
- const filteredLines = showDebug ? outputLines : outputLines.filter((line) => !line.startsWith("[debug]") && line.trim().length > 0);
+ const handleSendToAI = useCallback(() => {
+ const currentShowDebug = globalStore.get(model.showDebug);
+ const currentOutputLines = globalStore.get(model.outputLines);
+ const filtered = currentShowDebug
+ ? currentOutputLines
+ : currentOutputLines.filter((line) => !line.startsWith("[debug]") && line.trim().length > 0);
+
+ const linesToSend = filtered.slice(-200);
+ const text = linesToSend.join("\n");
+ const aiModel = WaveAIModel.getInstance();
+ const formattedText = `from builder output:\n\`\`\`\n${text}\n\`\`\`\n`;
+ aiModel.appendText(formattedText, true, { scrollToBottom: true });
+ aiModel.focusInput();
+ }, [model]);
+
+ const filteredLines = showDebug
+ ? outputLines
+ : outputLines.filter((line) => !line.startsWith("[debug]") && line.trim().length > 0);
return (
@@ -98,6 +115,12 @@ const BuilderBuildPanel = memo(() => {
/>
Debug
+