diff --git a/EvoScientist/cli/interactive.py b/EvoScientist/cli/interactive.py index f99a304..e75e587 100644 --- a/EvoScientist/cli/interactive.py +++ b/EvoScientist/cli/interactive.py @@ -349,7 +349,7 @@ def cmd_interactive( async def _cmd_threads(): """Handle /threads command — show recent sessions.""" threads = await list_threads( - limit=20, include_message_count=True, include_preview=True, + limit=0, include_message_count=True, include_preview=True, ) if not threads: console.print("[yellow]No saved sessions.[/yellow]") @@ -423,7 +423,7 @@ def cmd_interactive( if not arg: # Show interactive session picker with conversation previews threads = await list_threads( - limit=10, include_message_count=True, include_preview=True, + limit=0, include_message_count=True, include_preview=True, ) if not threads: console.print("[yellow]No sessions to resume.[/yellow]") @@ -453,11 +453,20 @@ def cmd_interactive( label = f"{_pad_to_width(left_text, col_width)}({tid} {when})" choices.append(questionary.Choice(title=label, value=tid)) - selected = questionary.select( + from prompt_toolkit.layout.dimension import Dimension + from questionary.prompts.common import InquirerControl + + prompt = questionary.select( "Select session to resume:", choices=choices, style=_PICKER_STYLE, - ).ask() + ) + # Limit visible list to 10 rows with scrolling + for window in prompt.application.layout.find_all_windows(): + if isinstance(window.content, InquirerControl): + window.height = Dimension(max=10) + break + selected = prompt.ask() if selected is None: return diff --git a/EvoScientist/sessions.py b/EvoScientist/sessions.py index b8ccf73..90b738c 100644 --- a/EvoScientist/sessions.py +++ b/EvoScientist/sessions.py @@ -184,9 +184,12 @@ async def list_threads( WHERE json_extract(metadata, '$.agent_name') = ? GROUP BY thread_id ORDER BY updated_at DESC - LIMIT ? """ - async with conn.execute(query, (AGENT_NAME, limit)) as cur: + params: tuple = (AGENT_NAME,) + if limit > 0: + query += " LIMIT ?\n" + params = (AGENT_NAME, limit) + async with conn.execute(query, params) as cur: rows = await cur.fetchall() threads = [