feat: focus chat input after creating a new inline comment

Opens the chat tab when a new inline comment is submitted
Automatically focuses the chat composer for quicker follow-up
Leaves draft updates unchanged when editing an existing comment
This commit is contained in:
Bohdan Triapitsyn
2026-08-21 16:38:37 +03:00
parent 2f6ac48675
commit ad5bc2b01b
@@ -11,6 +11,8 @@ import { useSessionUIStore } from '@/sync/session-ui-store';
import { useI18n } from '@/lib/i18n';
import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory';
import { getRuntimeKey } from '@/lib/runtime-switch';
import { focusChatInput } from '@/components/chat/composer/editor/dom';
import { useUIStore } from '@/stores/useUIStore';
type LineRangeBase = {
start: number;
@@ -136,6 +138,7 @@ export function useInlineCommentController<TRange extends LineRangeBase>(
const normalizedStoreRange = normalizeStoreRange(toStoreRange(normalizedRange));
const code = getCodeForRange(normalizedRange);
const isNewComment = !editingDraftId;
if (editingDraftId) {
updateDraft(target, editingDraftId, {
fileLabel,
@@ -160,6 +163,10 @@ export function useInlineCommentController<TRange extends LineRangeBase>(
}
reset();
if (isNewComment) {
useUIStore.getState().setActiveMainTab('chat');
requestAnimationFrame(focusChatInput);
}
}, [addDraft, editingDraftId, fileLabel, getCodeForRange, language, reset, selection, source, t, target, toStoreRange, updateDraft]);
return {