feat(chat): refocus composer after adding message to context

After the add-to-context (context pin) action completes successfully, move
focus back to the chat input so the user can keep typing immediately. Uses
the existing focusChatInput helper and the requestAnimationFrame refocus
pattern already used by the model/agent selectors.

Fixes #2447
This commit is contained in:
Serhii Dziupin
2026-08-05 13:37:20 +03:00
parent 34c221b07f
commit 654e9cdb64
@@ -37,6 +37,7 @@ import { useGlobalSessionsStore } from '@/stores/useGlobalSessionsStore';
import { getContextObligatoryMessages } from '@/lib/contextObligatoryMessages';
import { setContextObligatoryMessage } from '@/sync/session-actions';
import { isVSCodeRuntime } from '@/lib/desktop';
import { focusChatInput } from './composer/editor/dom';
const ToolOutputDialog = lazyWithChunkRecovery(() => import('./message/ToolOutputDialog'));
@@ -416,6 +417,10 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
createdAt: messageCreatedAt,
role: isUser ? 'user' : 'assistant',
}, !isPinnedIntoContext);
// Return focus to the composer so the user can keep typing right
// after adding the message to context (matches the refocus pattern
// used by the model/agent selectors).
requestAnimationFrame(focusChatInput);
} catch (error) {
console.error('[chat-message] failed to update context pin', error);
toast.error(t('chat.messageBody.actions.contextPinFailed'));