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:
@@ -11,6 +11,8 @@ import { useSessionUIStore } from '@/sync/session-ui-store';
|
|||||||
import { useI18n } from '@/lib/i18n';
|
import { useI18n } from '@/lib/i18n';
|
||||||
import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory';
|
import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory';
|
||||||
import { getRuntimeKey } from '@/lib/runtime-switch';
|
import { getRuntimeKey } from '@/lib/runtime-switch';
|
||||||
|
import { focusChatInput } from '@/components/chat/composer/editor/dom';
|
||||||
|
import { useUIStore } from '@/stores/useUIStore';
|
||||||
|
|
||||||
type LineRangeBase = {
|
type LineRangeBase = {
|
||||||
start: number;
|
start: number;
|
||||||
@@ -136,6 +138,7 @@ export function useInlineCommentController<TRange extends LineRangeBase>(
|
|||||||
const normalizedStoreRange = normalizeStoreRange(toStoreRange(normalizedRange));
|
const normalizedStoreRange = normalizeStoreRange(toStoreRange(normalizedRange));
|
||||||
const code = getCodeForRange(normalizedRange);
|
const code = getCodeForRange(normalizedRange);
|
||||||
|
|
||||||
|
const isNewComment = !editingDraftId;
|
||||||
if (editingDraftId) {
|
if (editingDraftId) {
|
||||||
updateDraft(target, editingDraftId, {
|
updateDraft(target, editingDraftId, {
|
||||||
fileLabel,
|
fileLabel,
|
||||||
@@ -160,6 +163,10 @@ export function useInlineCommentController<TRange extends LineRangeBase>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
if (isNewComment) {
|
||||||
|
useUIStore.getState().setActiveMainTab('chat');
|
||||||
|
requestAnimationFrame(focusChatInput);
|
||||||
|
}
|
||||||
}, [addDraft, editingDraftId, fileLabel, getCodeForRange, language, reset, selection, source, t, target, toStoreRange, updateDraft]);
|
}, [addDraft, editingDraftId, fileLabel, getCodeForRange, language, reset, selection, source, t, target, toStoreRange, updateDraft]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user