feat(interactive): update thread limit to 0 for session commands and enhance session picker display

This commit is contained in:
X-iZhang
2026-02-13 00:29:38 +00:00
parent a7f1e166d7
commit 2265fb70b7
2 changed files with 18 additions and 6 deletions
+13 -4
View File
@@ -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
+5 -2
View File
@@ -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 = [