Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(ui): auto-focus the chat composer on open (desktop) (#464)

Call White1deec7677b06
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 1044df49a..9744ff4c6 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -943,6 +943,7 @@ const Compose: React.FC<ComposeProps> = ({ onSend, onStop, busy, sessionId, init
sessionId={sessionId}
initialDraft={initialDraft}
onDraftChange={onDraftChange}
+ autoFocus
/>
</div>
);
diff --git a/ui/src/components/workbench/Composer.tsx b/ui/src/components/workbench/Composer.tsx
index 3f4933ee0..39a01d88b 100644
--- a/ui/src/components/workbench/Composer.tsx
+++ b/ui/src/components/workbench/Composer.tsx
@@ -4,7 +4,7 @@ import { Clock, Loader2, Mic, Paperclip, Plus, Send, Square, Trash2, X } from 'l
import clsx from 'clsx';
import { apiFetch } from '../../lib/apiFetch';
-import { isSoftKeyboardOpen } from '../../lib/softKeyboard';
+import { isSoftKeyboardOpen, isTouchCapableDevice } from '../../lib/softKeyboard';
import { cn } from '../../lib/utils';
import { Button } from '../ui/button';
@@ -65,6 +65,10 @@ export interface ComposerProps {
/** When set, enables file upload + voice input scoped to this session. The
* Workbench home leaves it unset → a plain text-only composer. */
sessionId?: string;
+ /** Focus the textarea on mount (desktop only — skipped on touch devices so it
+ * never pops the on-screen keyboard). The chat composer remounts per session,
+ * so this also covers opening / switching sessions. */
+ autoFocus?: boolean;
}
// The chat-style input row: an auto-growing textarea + a Send/Stop icon button,
@@ -82,6 +86,7 @@ export const Composer: React.FC<ComposerProps> = ({
disabled = false,
className,
sessionId,
+ autoFocus = false,
}) => {
const { t } = useTranslation();
const [value, setValue] = useState('');
@@ -130,6 +135,14 @@ export const Composer: React.FC<ComposerProps> = ({
el.style.height = `${Math.min(el.scrollHeight, 160)}px`;
}, [value]);
+ // Desktop only: focus the textarea on mount so opening a chat (and — via the
+ // per-session remount — switching sessions) lands the cursor in the input.
+ // Skipped on touch devices so it never pops the on-screen keyboard.
+ useEffect(() => {
+ if (!autoFocus || isTouchCapableDevice()) return;
+ textareaRef.current?.focus();
+ }, [autoFocus]);
+
// The mic button only appears when transcription is wired up (Vibe Cloud
// paired + enabled), so it never dead-ends on click.
useEffect(() => {
diff --git a/ui/src/lib/softKeyboard.ts b/ui/src/lib/softKeyboard.ts
index 41ca50648..5e7f990ac 100644
--- a/ui/src/lib/softKeyboard.ts
+++ b/ui/src/lib/softKeyboard.ts
@@ -51,3 +51,10 @@ export function isSoftKeyboardOpen(): boolean {
if (!isTouchDevice || typeof window === 'undefined' || !window.visualViewport) return false;
return restingHeight - window.visualViewport.height > KEYBOARD_MIN_DELTA;
}
+
+// True on devices with an on-screen keyboard (touch). Callers gate on this to
+// avoid auto-focusing inputs where focusing would pop the soft keyboard (e.g.
+// opening a chat on mobile); "desktop only" is ``!isTouchCapableDevice()``.
+export function isTouchCapableDevice(): boolean {
+ return isTouchDevice;
+}