@@ -165,41 +165,51 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
165
165
_interactionService . DisplayDashboardUrls ( dashboardUrls ) ;
166
166
167
167
var table = new Table ( ) . Border ( TableBorder . Rounded ) ;
168
+
169
+ table . AddColumn ( "Resource" ) ;
170
+ table . AddColumn ( "Type" ) ;
171
+ table . AddColumn ( "State" ) ;
172
+ table . AddColumn ( "Health" ) ;
173
+ table . AddColumn ( "Endpoint(s)" ) ;
174
+
175
+ // We add a default row here to say that
176
+ // there are no resources in the app host.
177
+ // This will be replaced once the first
178
+ // resource is streamed back from the
179
+ // app host which should be almost immediate
180
+ // if no resources are present.
181
+ table . Rows . Add ( [
182
+ new Markup ( "--" ) ,
183
+ new Markup ( "--" ) ,
184
+ new Markup ( "--" ) ,
185
+ new Markup ( "--" ) ,
186
+ new Markup ( "--" ) ,
187
+ ] ) ;
188
+
168
189
var message = new Markup ( "Press [bold]Ctrl+C[/] to stop the app host and exit." ) ;
169
- var noResourcesMessage = new Markup ( "No resources are present." ) ;
170
190
171
- // Start with noResourcesMessage as the default
172
191
var renderables = new List < IRenderable > {
173
- noResourcesMessage ,
192
+ table ,
174
193
message
175
194
} ;
176
195
var rows = new Rows ( renderables ) ;
177
196
178
197
await _ansiConsole . Live ( rows ) . StartAsync ( async context =>
179
198
{
180
- var knownResources = new SortedDictionary < string , RpcResourceState > ( ) ;
181
- var hasResources = false ;
199
+ // If we are running an apphost that has no
200
+ // resources in it then we want to display
201
+ // the message that there are no resources.
202
+ // That is why we immediately do a refresh.
203
+ context . Refresh ( ) ;
182
204
183
- table . AddColumn ( "Resource" ) ;
184
- table . AddColumn ( "Type" ) ;
185
- table . AddColumn ( "State" ) ;
186
- table . AddColumn ( "Health" ) ;
187
- table . AddColumn ( "Endpoint(s)" ) ;
205
+ var knownResources = new SortedDictionary < string , RpcResourceState > ( ) ;
188
206
189
207
var resourceStates = backchannel . GetResourceStatesAsync ( cancellationToken ) ;
190
208
191
209
try
192
210
{
193
211
await foreach ( var resourceState in resourceStates )
194
212
{
195
- if ( ! hasResources )
196
- {
197
- // First resource found, switch from message to table
198
- hasResources = true ;
199
- renderables [ 0 ] = table ;
200
- context . Refresh ( ) ;
201
- }
202
-
203
213
knownResources [ resourceState . Resource ] = resourceState ;
204
214
205
215
table . Rows . Clear ( ) ;
0 commit comments