Skip to content

Commit bc93ba8

Browse files
committed
fix(ui): restore composer lint budget
1 parent 3ff459f commit bc93ba8

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎ui/src/pages/chat/components/chat-composer-dom.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ export function focusComposerFromChrome(event: MouseEvent, connected: boolean) {
129129
?.focus({ preventScroll: true });
130130
}
131131

132+
export function preserveComposerFocusOnPrimaryAction(
133+
event: PointerEvent,
134+
textarea: HTMLTextAreaElement | null,
135+
): void {
136+
const composerShell = textarea?.closest<HTMLElement>(".agent-chat__composer-shell");
137+
if (
138+
document.activeElement === textarea &&
139+
composerShell &&
140+
Number.parseFloat(getComputedStyle(composerShell).marginBottom) === 0
141+
) {
142+
event.preventDefault();
143+
}
144+
}
145+
132146
export function restoreHistoryCaret(target: HTMLTextAreaElement, direction: "up" | "down") {
133147
requestAnimationFrame(() => {
134148
if (document.activeElement !== target) {

‎ui/src/pages/chat/components/chat-composer.ts‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
adjustTextareaHeight,
1414
disconnectTextareaOverflowObserver,
1515
observeTextareaOverflow,
16+
preserveComposerFocusOnPrimaryAction,
1617
restoreHistoryCaret,
1718
scheduleTextareaHeightAdjustment,
1819
} from "./chat-composer-dom.ts";
@@ -638,18 +639,6 @@ export function renderChatComposer(props: ChatComposerProps) {
638639
target.readOnly = true;
639640
}
640641
};
641-
const handlePrimaryActionPointerDown = (event: PointerEvent) => {
642-
const composerShell = state.composerTextarea?.closest<HTMLElement>(
643-
".agent-chat__composer-shell",
644-
);
645-
if (
646-
document.activeElement === state.composerTextarea &&
647-
composerShell &&
648-
Number.parseFloat(getComputedStyle(composerShell).marginBottom) === 0
649-
) {
650-
event.preventDefault();
651-
}
652-
};
653642
const runControlsProps: ChatRunControlsProps = {
654643
canAbort: showAbortableUi,
655644
canSend: canSubmitDraft(actionDraft),
@@ -678,7 +667,8 @@ export function renderChatComposer(props: ChatComposerProps) {
678667
microphonePicker,
679668
dictation,
680669
onDictationPointerDown: handleDictationPointerDown,
681-
onPrimaryActionPointerDown: handlePrimaryActionPointerDown,
670+
onPrimaryActionPointerDown: (event) =>
671+
preserveComposerFocusOnPrimaryAction(event, state.composerTextarea),
682672
};
683673
const cameraFacingMode = props.realtimeTalkVideoStream
684674
?.getVideoTracks?.()[0]

0 commit comments

Comments
 (0)