File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -336,11 +336,7 @@ def list_sessions(
336336 """List all sessions for an agent."""
337337 client = get_ready_client ()
338338 try :
339- sessions = list (client .list_sessions (agent_id ))
340-
341- if not sessions :
342- console .print ("No sessions found." )
343- return
339+ sessions = client .list_sessions (agent_id )
344340
345341 table = Table (title = "Sessions" )
346342 table .add_column ("Session ID" , style = "cyan" )
@@ -349,7 +345,9 @@ def list_sessions(
349345 table .add_column ("Created" )
350346 table .add_column ("Expires" )
351347
348+ has_sessions = False
352349 for session in sessions :
350+ has_sessions = True
353351 session_id = get_id (session )
354352 display_name = getattr (session , "display_name" , "" ) or ""
355353 user_id = getattr (session , "user_id" , "" ) or ""
@@ -375,6 +373,10 @@ def list_sessions(
375373 expire_time ,
376374 )
377375
376+ if not has_sessions :
377+ console .print ("No sessions found." )
378+ return
379+
378380 console .print (table )
379381 except Exception as e :
380382 console .print (f"[red]Error listing sessions: { escape (str (e ))} [/red]" )
You can’t perform that action at this time.
0 commit comments