feat(chat): update message sending behavior and input focus management

This commit is contained in:
Abhimanyu Saharan
2026-02-07 16:32:49 +05:30
parent 13b3701810
commit 4cf68a4c87
2 changed files with 18 additions and 4 deletions

View File

@@ -342,6 +342,7 @@ export default function BoardDetailPage() {
const [isCommentsLoading, setIsCommentsLoading] = useState(false);
const [commentsError, setCommentsError] = useState<string | null>(null);
const [newComment, setNewComment] = useState("");
const taskCommentInputRef = useRef<HTMLTextAreaElement | null>(null);
const [isPostingComment, setIsPostingComment] = useState(false);
const [postCommentError, setPostCommentError] = useState<string | null>(null);
const [isDetailOpen, setIsDetailOpen] = useState(false);
@@ -1713,6 +1714,7 @@ export default function BoardDetailPage() {
);
} finally {
setIsPostingComment(false);
taskCommentInputRef.current?.focus();
}
};
@@ -2612,8 +2614,18 @@ export default function BoardDetailPage() {
</p>
<div className="space-y-2 rounded-xl border border-slate-200 bg-slate-50 p-3">
<Textarea
ref={taskCommentInputRef}
value={newComment}
onChange={(event) => setNewComment(event.target.value)}
onKeyDown={(event) => {
if (event.key !== "Enter") return;
if (event.nativeEvent.isComposing) return;
if (event.shiftKey) return;
event.preventDefault();
if (isPostingComment) return;
if (!newComment.trim()) return;
void handlePostComment();
}}
placeholder="Write a message for the assigned agent…"
className="min-h-[80px] bg-white"
/>

View File

@@ -415,8 +415,9 @@ export function BoardOnboardingChat({
value={extraContext}
onChange={(event) => setExtraContext(event.target.value)}
onKeyDown={(event) => {
if (!(event.ctrlKey || event.metaKey)) return;
if (event.key !== "Enter") return;
if (event.nativeEvent.isComposing) return;
if (event.shiftKey) return;
event.preventDefault();
if (loading) return;
void submitExtraContext();
@@ -434,7 +435,7 @@ export function BoardOnboardingChat({
</Button>
</div>
<p className="text-xs text-slate-500">
Tip: press Ctrl+Enter (or Cmd+Enter) to send.
Tip: press Enter to send. Shift+Enter for a newline.
</p>
</div>
) : (
@@ -479,15 +480,16 @@ export function BoardOnboardingChat({
value={otherText}
onChange={(event) => setOtherText(event.target.value)}
onKeyDown={(event) => {
if (!(event.ctrlKey || event.metaKey)) return;
if (event.key !== "Enter") return;
if (event.nativeEvent.isComposing) return;
if (event.shiftKey) return;
event.preventDefault();
if (loading) return;
submitAnswer();
}}
/>
<p className="text-xs text-slate-500">
Tip: press Ctrl+Enter (or Cmd+Enter) to send.
Tip: press Enter to send. Shift+Enter for a newline.
</p>
</div>
) : null}