diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx
index ad3ee534..884e4e95 100644
--- a/apps/x/apps/renderer/src/App.tsx
+++ b/apps/x/apps/renderer/src/App.tsx
@@ -282,6 +282,7 @@ interface ChatInputInnerProps {
isProcessing: boolean
presetMessage?: string
onPresetMessageConsumed?: () => void
+ runId?: string | null
}
function ChatInputInner({
@@ -289,6 +290,7 @@ function ChatInputInner({
isProcessing,
presetMessage,
onPresetMessageConsumed,
+ runId,
}: ChatInputInnerProps) {
const controller = usePromptInputController()
const message = controller.textInput.value
@@ -320,9 +322,9 @@ function ChatInputInner({
diff --git a/apps/x/apps/renderer/src/components/ai-elements/prompt-input.tsx b/apps/x/apps/renderer/src/components/ai-elements/prompt-input.tsx
index f0933d30..c27ab5c3 100644
--- a/apps/x/apps/renderer/src/components/ai-elements/prompt-input.tsx
+++ b/apps/x/apps/renderer/src/components/ai-elements/prompt-input.tsx
@@ -906,6 +906,7 @@ export type PromptInputTextareaProps = ComponentProps<
typeof InputGroupTextarea
> & {
autoFocus?: boolean;
+ focusTrigger?: unknown; // When this value changes, focus the textarea
};
export const PromptInputTextarea = ({
@@ -914,6 +915,7 @@ export const PromptInputTextarea = ({
placeholder = "What would you like to know?",
onKeyDown: externalOnKeyDown,
autoFocus = false,
+ focusTrigger,
...props
}: PromptInputTextareaProps) => {
const controller = useOptionalPromptInputController();
@@ -924,16 +926,16 @@ export const PromptInputTextarea = ({
const textareaRef = useRef(null);
- // Auto-focus the textarea when requested
+ // Auto-focus the textarea when requested or when focusTrigger changes
useEffect(() => {
- if (autoFocus) {
+ if (autoFocus || focusTrigger !== undefined) {
// Small delay to ensure the element is fully mounted and visible
const timer = setTimeout(() => {
textareaRef.current?.focus();
}, 50);
return () => clearTimeout(timer);
}
- }, [autoFocus]);
+ }, [autoFocus, focusTrigger]);
const containerRef = useRef(null);
const highlightRef = useRef(null);
diff --git a/apps/x/apps/renderer/src/components/chat-sidebar.tsx b/apps/x/apps/renderer/src/components/chat-sidebar.tsx
index 0d9a7d7e..4cddfdf0 100644
--- a/apps/x/apps/renderer/src/components/chat-sidebar.tsx
+++ b/apps/x/apps/renderer/src/components/chat-sidebar.tsx
@@ -260,10 +260,16 @@ export function ChatSidebar({
document.addEventListener('mouseup', handleMouseUp)
}, [width])
- // Auto-focus textarea when sidebar opens
+ // Auto-focus textarea when sidebar opens or when conversation is cleared (new chat)
useEffect(() => {
- textareaRef.current?.focus()
- }, [])
+ // Focus when conversation is empty (new chat started)
+ if (conversation.length === 0) {
+ const timer = setTimeout(() => {
+ textareaRef.current?.focus()
+ }, 50)
+ return () => clearTimeout(timer)
+ }
+ }, [conversation.length])
// Auto-populate with @currentfile when switching knowledge files
useEffect(() => {
@@ -584,9 +590,8 @@ export function ChatSidebar({
onKeyDown={handleKeyDown}
onScroll={syncHighlightScroll}
placeholder="Ask anything..."
- disabled={isProcessing}
rows={1}
- className="relative z-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:opacity-50 resize-none max-h-32 min-h-6"
+ className="relative z-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground resize-none max-h-32 min-h-6"
style={{ fieldSizing: 'content' } as React.CSSProperties}
/>