π OpenHands: AI-Driven Development
fix(chat): remove the white line above the chat input resize grip (#18574)
Vasco Schiavod641563687d6
diff --git a/.pr/chat-grip-line/after-drag.png b/.pr/chat-grip-line/after-drag.pngnew file mode 100644index 0000000000..fdd264e1daBinary files /dev/null and b/.pr/chat-grip-line/after-drag.png differdiff --git a/.pr/chat-grip-line/after-hover.png b/.pr/chat-grip-line/after-hover.pngnew file mode 100644index 0000000000..b40692ce72Binary files /dev/null and b/.pr/chat-grip-line/after-hover.png differdiff --git a/.pr/chat-grip-line/before-drag.png b/.pr/chat-grip-line/before-drag.pngnew file mode 100644index 0000000000..464c142832Binary files /dev/null and b/.pr/chat-grip-line/before-drag.png differdiff --git a/.pr/chat-grip-line/before-hover.png b/.pr/chat-grip-line/before-hover.pngnew file mode 100644index 0000000000..670961de97Binary files /dev/null and b/.pr/chat-grip-line/before-hover.png differdiff --git a/src/components/features/chat/components/chat-input-grip.tsx b/src/components/features/chat/components/chat-input-grip.tsxindex eb58e47ff4..1ae67f269c 100644--- a/src/components/features/chat/components/chat-input-grip.tsx+++ b/src/components/features/chat/components/chat-input-grip.tsx@@ -2,53 +2,26 @@ import React from "react";import { cn } from "#/utils/utils";interface ChatInputGripProps {- gripRef: React.RefObject<HTMLDivElement | null>;- isGripVisible: boolean;- isGripDragging: boolean;canResize: boolean;- handleTopEdgeClick: (e: React.MouseEvent) => void;handleGripMouseDown: (e: React.MouseEvent) => void;handleGripTouchStart: (e: React.TouchEvent) => void;}export function ChatInputGrip({- gripRef,- isGripVisible,- isGripDragging,canResize,- handleTopEdgeClick,handleGripMouseDown,handleGripTouchStart,}: ChatInputGripProps) {return (<divclassName={cn(- "absolute top-0 left-0 w-full h-3 z-20 group",- !canResize && "pointer-events-none",+ "absolute top-0 left-0 w-full h-3 z-20",+ canResize ? "cursor-ns-resize select-none" : "pointer-events-none",)}id="resize-grip"- onClick={canResize ? handleTopEdgeClick : undefined}- >- {/* Resize hit target; 1px line is drawn at top-0 (flush with chat input box) */}- {canResize && (- <div- className="absolute inset-0 z-[1] cursor-ns-resize select-none"- onMouseDown={handleGripMouseDown}- onTouchStart={handleGripTouchStart}- aria-hidden- />- )}- <div- ref={gripRef}- className={cn(- "pointer-events-none absolute top-0 left-0 w-full h-px bg-contrast z-[2] transition-opacity duration-200",- !canResize && "opacity-0",- canResize &&- (isGripVisible || isGripDragging- ? "opacity-100"- : "opacity-0 group-hover:opacity-100"),- )}- />- </div>+ onMouseDown={handleGripMouseDown}+ onTouchStart={handleGripTouchStart}+ aria-hidden+ />);}diff --git a/src/components/features/chat/custom-chat-input.tsx b/src/components/features/chat/custom-chat-input.tsxindex c876c7ffef..1dc8c17640 100644--- a/src/components/features/chat/custom-chat-input.tsx+++ b/src/components/features/chat/custom-chat-input.tsx@@ -108,11 +108,7 @@ export function CustomChatInput({} = useFileHandling(onFilesPaste);const {- gripRef,- isGripVisible,- isGripDragging,canResize,- handleTopEdgeClick,smartResize,handleGripMouseDown,handleGripTouchStart,@@ -177,11 +173,7 @@ export function CustomChatInput({{/* Container with grip */}<div className="relative w-full"><ChatInputGrip- gripRef={gripRef}- isGripVisible={isGripVisible}- isGripDragging={isGripDragging}canResize={canResize}- handleTopEdgeClick={handleTopEdgeClick}handleGripMouseDown={handleGripMouseDown}handleGripTouchStart={handleGripTouchStart}/>diff --git a/src/hooks/chat/use-grip-resize.ts b/src/hooks/chat/use-grip-resize.tsindex 21cff68d06..06651901d9 100644--- a/src/hooks/chat/use-grip-resize.ts+++ b/src/hooks/chat/use-grip-resize.ts@@ -1,5 +1,5 @@-import type { RefObject, MouseEvent } from "react";-import { useRef, useState, useCallback, useEffect } from "react";+import type { RefObject } from "react";+import { useState, useCallback, useEffect } from "react";import { useAutoResize } from "#/hooks/use-auto-resize";import { isBottomAnchored } from "#/hooks/use-drag-resize";import { CHAT_INPUT } from "#/utils/constants";@@ -15,20 +15,14 @@ export const useGripResize = (chatInputRef: RefObject<HTMLDivElement | null>,messageToSend: IMessageToSend | null,) => {- const [isGripVisible, setIsGripVisible] = useState(false);- const [isGripDragging, setIsGripDragging] = useState(false);// Manual resizing only makes sense when the input is bottom-anchored (e.g.// the conversation page). On the home page the input is centred and dragging- // the top grip would grow the box downward, so we hide the grip entirely.+ // the top grip would grow the box downward, so we disable the grip.const [canResize, setCanResize] = useState(true);const { setShouldHideSuggestions, clearMessageToSend } =useConversationStore();- const gripRef = useRef<HTMLDivElement | null>(null);- /** After a real resize drag, swallow the synthetic click so it doesn't toggle `isGripVisible`. */- const suppressNextTopEdgeClickRef = useRef(false);-useEffect(() => {const check = () => setCanResize(isBottomAnchored());check();@@ -36,31 +30,6 @@ export const useGripResize = (return () => window.removeEventListener("resize", check);}, []);- const handleGripDragStart = useCallback(() => {- setIsGripDragging(true);- }, []);-- const handleGripDragEnd = useCallback(() => {- setIsGripDragging(false);- suppressNextTopEdgeClickRef.current = true;- }, []);-- // Handle click on top edge area to toggle grip visibility- const handleTopEdgeClick = useCallback(- (e: MouseEvent) => {- if (!canResize) return;- if (suppressNextTopEdgeClickRef.current) {- suppressNextTopEdgeClickRef.current = false;- e.preventDefault();- e.stopPropagation();- return;- }- e.stopPropagation();- setIsGripVisible((prev) => !prev);- },- [canResize],- );-// Callback to handle height changes and manage suggestions visibilityconst handleHeightChange = useCallback((height: number) => {@@ -82,19 +51,13 @@ export const useGripResize = (minHeight: 20,maxHeight: 400,onHeightChange: handleHeightChange,- onGripDragStart: handleGripDragStart,- onGripDragEnd: handleGripDragEnd,value: messageToSend ?? undefined,onValueApplied: clearMessageToSend, // one-shot consume (see store action)enableManualResize: true,});return {- gripRef,- isGripVisible,- isGripDragging,canResize,- handleTopEdgeClick,smartResize,handleGripMouseDown,handleGripTouchStart,