1- import { Activity , useCallback , useEffect , useMemo , useState } from 'react' ;
1+ import { Activity , useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
22import styled from '@emotion/styled' ;
3+ import moment from 'moment-timezone' ;
34
4- import { DateTime } from 'sentry/components/dateTime ' ;
5+ import TimeSince from 'sentry/components/timeSince ' ;
56import { space } from 'sentry/styles/space' ;
67import { useFeedbackForm } from 'sentry/utils/useFeedbackForm' ;
78import { useExplorerSessions } from 'sentry/views/seerExplorer/hooks/useExplorerSessions' ;
@@ -129,12 +130,23 @@ export function useExplorerMenu({
129130 const isVisible = menuMode !== 'hidden' ;
130131
131132 const [ selectedIndex , setSelectedIndex ] = useState ( 0 ) ;
133+ const menuItemRefs = useRef < Array < HTMLDivElement | null > > ( [ ] ) ;
132134
133135 // Reset selected index when items change
134136 useEffect ( ( ) => {
135137 setSelectedIndex ( 0 ) ;
136138 } , [ menuItems ] ) ;
137139
140+ // Scroll selected item into view when selection changes
141+ useEffect ( ( ) => {
142+ if ( isVisible && menuItemRefs . current [ selectedIndex ] ) {
143+ menuItemRefs . current [ selectedIndex ] ?. scrollIntoView ( {
144+ block : 'nearest' ,
145+ behavior : 'smooth' ,
146+ } ) ;
147+ }
148+ } , [ selectedIndex , isVisible ] ) ;
149+
138150 // Handle keyboard navigation with higher priority
139151 const handleKeyDown = useCallback (
140152 ( e : KeyboardEvent ) => {
@@ -193,6 +205,9 @@ export function useExplorerMenu({
193205 { menuItems . map ( ( item , index ) => (
194206 < MenuItem
195207 key = { item . key }
208+ ref = { el => {
209+ menuItemRefs . current [ index ] = el ;
210+ } }
196211 isSelected = { index === selectedIndex }
197212 onClick = { ( ) => onSelect ( item ) }
198213 >
@@ -310,9 +325,11 @@ function useSessions({
310325 title : session . title ,
311326 key : session . run_id . toString ( ) ,
312327 description : (
313- < span >
314- Last updated at < DateTime date = { session . last_triggered_at } />
315- </ span >
328+ < TimeSince
329+ tooltipPrefix = "Last updated"
330+ date = { moment . utc ( session . last_triggered_at ) . toDate ( ) }
331+ suffix = "ago"
332+ />
316333 ) ,
317334 handler : ( ) => {
318335 onChangeSession ( session . run_id ) ;
@@ -338,7 +355,6 @@ const MenuPanel = styled('div')<{
338355 width: 300px;
339356 background: ${ p => p . theme . background } ;
340357 border: 1px solid ${ p => p . theme . border } ;
341- border-bottom: none;
342358 border-radius: ${ p => p . theme . borderRadius } ;
343359 box-shadow: ${ p => p . theme . dropShadowHeavy } ;
344360 max-height: ${ p =>
@@ -366,6 +382,9 @@ const ItemName = styled('div')`
366382 font-weight: 600;
367383 color: ${ p => p . theme . purple400 } ;
368384 font-size: ${ p => p . theme . fontSize . sm } ;
385+ overflow: hidden;
386+ text-overflow: ellipsis;
387+ white-space: nowrap;
369388` ;
370389
371390const ItemDescription = styled ( 'div' ) `
0 commit comments