@@ -68,8 +68,6 @@ function resolveRenameCommit(input: {
6868 return { action : "commit" , title : trimmed } ;
6969}
7070
71- // Delay the input-swallowing native menu through the double-click rename interval.
72- const TITLE_MENU_OPEN_DELAY_MS = 500 ;
7371export const ChatHeader = memo ( function ChatHeader ( {
7472 activeThreadEnvironmentId,
7573 activeThreadId,
@@ -205,54 +203,21 @@ export const ChatHeader = memo(function ChatHeader({
205203 onFind : onFindInThread ,
206204 canShareWithGuest,
207205 } ) ;
208- const titleButtonRef = useRef < HTMLButtonElement | null > ( null ) ;
209- const titleMenuTimerRef = useRef < number | null > ( null ) ;
210- const cancelPendingTitleMenu = ( ) => {
211- if ( titleMenuTimerRef . current === null ) return ;
212- clearTimeout ( titleMenuTimerRef . current ) ;
213- titleMenuTimerRef . current = null ;
214- } ;
215- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- clears the pending title-menu timer when the thread switches or the header unmounts
216- useEffect (
217- ( ) => ( ) => {
218- if ( titleMenuTimerRef . current === null ) return ;
219- clearTimeout ( titleMenuTimerRef . current ) ;
220- titleMenuTimerRef . current = null ;
221- } ,
222- // oxlint-disable-next-line react/exhaustive-effect-dependencies -- A pending title menu belongs to the thread that was clicked, so switching threads drops it.
223- [ activeThreadEnvironmentId , activeThreadId ] ,
224- ) ;
225- const openTitleMenuNow = ( ) => {
226- cancelPendingTitleMenu ( ) ;
227- const rect = titleButtonRef . current ?. getBoundingClientRect ( ) ;
228- if ( ! rect ) return ;
229- openMenu ( { x : rect . left , y : rect . bottom + 4 } ) ;
230- } ;
231206 const openMenuFromTitle = ( event : ReactMouseEvent < HTMLButtonElement > ) => {
232207 if ( isTrailingDoubleClick ( event . detail ) ) return ;
233- const clickedChevron =
234- ( event . target as HTMLElement ) . closest ( "[data-thread-title-chevron]" ) !== null ;
235- if ( event . detail === 0 || clickedChevron || window . desktopBridge === undefined ) {
236- openTitleMenuNow ( ) ;
237- return ;
238- }
239- cancelPendingTitleMenu ( ) ;
240- titleMenuTimerRef . current = window . setTimeout ( ( ) => {
241- titleMenuTimerRef . current = null ;
242- openTitleMenuNow ( ) ;
243- } , TITLE_MENU_OPEN_DELAY_MS ) ;
208+ const rect = event . currentTarget . getBoundingClientRect ( ) ;
209+ openMenu ( { x : rect . left , y : rect . bottom + 4 } ) ;
244210 } ;
211+ // A native menu takes the second click, so only the in-page menu lets a double-click reach here.
245212 const handleTitleDoubleClick = ( event : ReactMouseEvent ) => {
246213 if ( event . metaKey || event . ctrlKey || event . shiftKey || event . altKey ) return ;
247214 if ( ( event . target as HTMLElement ) . closest ( "[data-thread-title-chevron]" ) !== null ) return ;
248- cancelPendingTitleMenu ( ) ;
249215 closeMenu ( ) ;
250216 startRename ( ) ;
251217 } ;
252218 const handleHeaderContextMenu = ( event : ReactMouseEvent ) => {
253219 if ( renamingTitle !== null ) return ;
254220 if ( ! isServerThread && onOpenProjectSettings === undefined ) return ;
255- cancelPendingTitleMenu ( ) ;
256221 event . preventDefault ( ) ;
257222 if ( ! isServerThread ) {
258223 const api = readLocalApi ( ) ;
@@ -380,13 +345,11 @@ export const ChatHeader = memo(function ChatHeader({
380345 < TooltipTrigger
381346 render = {
382347 < button
383- ref = { titleButtonRef }
384348 type = "button"
385349 aria-label = { `Thread actions for ${ activeThreadTitle } ` }
386350 aria-haspopup = "menu"
387351 onClick = { openMenuFromTitle }
388352 onDoubleClick = { canOperateThread ? handleTitleDoubleClick : undefined }
389- onBlur = { cancelPendingTitleMenu }
390353 className = "group/thread-title inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-sm text-left focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
391354 />
392355 }
0 commit comments