@@ -38,6 +38,37 @@ type RowProps = {
3838 maxTime : number ,
3939} ;
4040
41+ function getShortDescription ( name : string , description : string ) : string {
42+ const descMaxLength = 30 - name . length ;
43+ if ( descMaxLength > 1 ) {
44+ const l = description . length ;
45+ if ( l > 0 && l <= descMaxLength ) {
46+ // We can fit the full description
47+ return description ;
48+ } else if (
49+ description . startsWith ( 'http://' ) ||
50+ description . startsWith ( 'https://' ) ||
51+ description . startsWith ( '/' )
52+ ) {
53+ // Looks like a URL. Let's see if we can extract something shorter.
54+ // We don't have to do a full parse so let's try something cheaper.
55+ let queryIdx = description . indexOf ( '?' ) ;
56+ if ( queryIdx === - 1 ) {
57+ queryIdx = description . length ;
58+ }
59+ if ( description . charCodeAt ( queryIdx - 1 ) === 47 /* "/" */ ) {
60+ // Ends with slash. Look before that.
61+ queryIdx -- ;
62+ }
63+ const slashIdx = description . lastIndexOf ( '/' , queryIdx - 1 ) ;
64+ // This may now be either the file name or the host.
65+ // Include the slash to make it more obvious what we trimmed.
66+ return '…' + description . slice ( slashIdx , queryIdx ) ;
67+ }
68+ }
69+ return '' ;
70+ }
71+
4172function SuspendedByRow ( {
4273 bridge,
4374 element,
@@ -50,6 +81,9 @@ function SuspendedByRow({
5081} : RowProps ) {
5182 const [ isOpen , setIsOpen ] = useState ( false ) ;
5283 const name = asyncInfo . awaited . name ;
84+ const description = asyncInfo . awaited . description ;
85+ const longName = description === '' ? name : name + ' (' + description + ')' ;
86+ const shortDescription = getShortDescription ( name , description ) ;
5387 let stack ;
5488 let owner ;
5589 if ( asyncInfo . stack === null || asyncInfo . stack . length === 0 ) {
@@ -83,12 +117,22 @@ function SuspendedByRow({
83117 < Button
84118 className = { styles . CollapsableHeader }
85119 onClick = { ( ) => setIsOpen ( prevIsOpen => ! prevIsOpen ) }
86- title = { name + ' — ' + ( end - start ) . toFixed ( 2 ) + ' ms' } >
120+ title = { longName + ' — ' + ( end - start ) . toFixed ( 2 ) + ' ms' } >
87121 < ButtonIcon
88122 className = { styles . CollapsableHeaderIcon }
89123 type = { isOpen ? 'expanded' : 'collapsed' }
90124 />
91125 < span className = { styles . CollapsableHeaderTitle } > { name } </ span >
126+ { shortDescription === '' ? null : (
127+ < >
128+ < span className = { styles . CollapsableHeaderSeparator } > { ' (' } </ span >
129+ < span className = { styles . CollapsableHeaderTitle } >
130+ { shortDescription }
131+ </ span >
132+ < span className = { styles . CollapsableHeaderSeparator } > { ') ' } </ span >
133+ </ >
134+ ) }
135+ < div className = { styles . CollapsableHeaderFiller } />
92136 < div className = { styles . TimeBarContainer } >
93137 < div
94138 className = {
0 commit comments