@@ -568,7 +568,7 @@ export class LaunchpadCommand extends QuickCommand<State> {
568568 function getItemsAndQuickpickProps ( isFiltering ?: boolean ) {
569569 const result = context . inSearch ? context . searchResult : context . result ;
570570
571- if ( result ?. error != null ) {
571+ if ( result ?. error != null && ! result ?. items ?. length ) {
572572 return {
573573 title : `${ context . title } \u00a0\u2022\u00a0 Unable to Load Items` ,
574574 placeholder : `Unable to load items (${
@@ -582,7 +582,7 @@ export class LaunchpadCommand extends QuickCommand<State> {
582582 } ;
583583 }
584584
585- if ( ! result ?. items . length ) {
585+ if ( ! result ?. items ? .length ) {
586586 if ( context . inSearch === 'mode' ) {
587587 return {
588588 title : `Search For Pull Request \u00a0\u2022\u00a0 ${ context . title } ` ,
@@ -616,6 +616,21 @@ export class LaunchpadCommand extends QuickCommand<State> {
616616 }
617617
618618 const items = getLaunchpadQuickPickItems ( result . items , isFiltering ) ;
619+
620+ // Add error information item if there's an error but items were still loaded
621+ const errorItem : DirectiveQuickPickItem | undefined =
622+ result ?. error != null
623+ ? createDirectiveQuickPickItem ( Directive . Noop , false , {
624+ label : '$(warning) Unable to fully load items' ,
625+ detail :
626+ result . error . name === 'HttpError' &&
627+ 'status' in result . error &&
628+ typeof result . error . status === 'number'
629+ ? `${ result . error . status } : ${ String ( result . error ) } `
630+ : String ( result . error ) ,
631+ } )
632+ : undefined ;
633+
619634 const hasPicked = items . some ( i => i . picked ) ;
620635 if ( context . inSearch === 'mode' ) {
621636 const offItem : ToggleSearchModeQuickPickItem = {
@@ -630,7 +645,9 @@ export class LaunchpadCommand extends QuickCommand<State> {
630645 return {
631646 title : `Search For Pull Request \u00a0\u2022\u00a0 ${ context . title } ` ,
632647 placeholder : 'Enter a term to search for a pull request to act on' ,
633- items : isFiltering ? [ ...items , offItem ] : [ offItem , ...items ] ,
648+ items : isFiltering
649+ ? [ ...( errorItem != null ? [ errorItem ] : [ ] ) , ...items , offItem ]
650+ : [ offItem , ...( errorItem != null ? [ errorItem ] : [ ] ) , ...items ] ,
634651 } ;
635652 }
636653
@@ -646,8 +663,12 @@ export class LaunchpadCommand extends QuickCommand<State> {
646663 title : context . title ,
647664 placeholder : 'Choose a pull request or paste a pull request URL to act on' ,
648665 items : isFiltering
649- ? [ ...items , onItem ]
650- : [ onItem , ...getLaunchpadQuickPickItems ( result . items , isFiltering ) ] ,
666+ ? [ ...( errorItem != null ? [ errorItem ] : [ ] ) , ...items , onItem ]
667+ : [
668+ onItem ,
669+ ...( errorItem != null ? [ errorItem ] : [ ] ) ,
670+ ...getLaunchpadQuickPickItems ( result . items , isFiltering ) ,
671+ ] ,
651672 } ;
652673 }
653674
@@ -1657,10 +1678,10 @@ function updateTelemetryContext(context: Context) {
16571678 if ( context . telemetryContext == null ) return ;
16581679
16591680 let updatedContext : NonNullable < ( typeof context ) [ 'telemetryContext' ] > ;
1660- if ( context . result . error != null ) {
1681+ if ( context . result . error != null || ! context . result . items ) {
16611682 updatedContext = {
16621683 ...context . telemetryContext ,
1663- 'items.error' : String ( context . result . error ) ,
1684+ 'items.error' : String ( context . result . error ?? 'items not loaded' ) ,
16641685 } ;
16651686 } else {
16661687 const grouped = countLaunchpadItemGroups ( context . result . items ) ;
0 commit comments