diff --git a/packages/ui/src/components/comments/useInlineCommentController.ts b/packages/ui/src/components/comments/useInlineCommentController.ts index 3220e07a..7009aef0 100644 --- a/packages/ui/src/components/comments/useInlineCommentController.ts +++ b/packages/ui/src/components/comments/useInlineCommentController.ts @@ -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( 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( } reset(); + if (isNewComment) { + useUIStore.getState().setActiveMainTab('chat'); + requestAnimationFrame(focusChatInput); + } }, [addDraft, editingDraftId, fileLabel, getCodeForRange, language, reset, selection, source, t, target, toStoreRange, updateDraft]); return {