feat: add /new command
This commit is contained in:
parent
dd4c06bea5
commit
24a90af6d3
@ -28,6 +28,7 @@ app = typer.Typer(
|
|||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
EXIT_COMMANDS = {"exit", "quit", "/exit", "/quit", ":q"}
|
EXIT_COMMANDS = {"exit", "quit", "/exit", "/quit", ":q"}
|
||||||
|
NEW_SESSION_COMMANDS = {"/new", "/reset"}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# CLI input: prompt_toolkit for editing, paste, history, and display
|
# CLI input: prompt_toolkit for editing, paste, history, and display
|
||||||
@ -111,6 +112,11 @@ def _is_exit_command(command: str) -> bool:
|
|||||||
return command.lower() in EXIT_COMMANDS
|
return command.lower() in EXIT_COMMANDS
|
||||||
|
|
||||||
|
|
||||||
|
def _is_new_session_command(command: str) -> bool:
|
||||||
|
"""Return True when input should clear the session history."""
|
||||||
|
return command.lower() in NEW_SESSION_COMMANDS
|
||||||
|
|
||||||
|
|
||||||
async def _read_interactive_input_async() -> str:
|
async def _read_interactive_input_async() -> str:
|
||||||
"""Read user input using prompt_toolkit (handles paste, history, display).
|
"""Read user input using prompt_toolkit (handles paste, history, display).
|
||||||
|
|
||||||
@ -484,6 +490,15 @@ def agent(
|
|||||||
console.print("\nGoodbye!")
|
console.print("\nGoodbye!")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if _is_new_session_command(command):
|
||||||
|
session = agent_loop.sessions.get_or_create(session_id)
|
||||||
|
session.clear()
|
||||||
|
agent_loop.sessions.save(session)
|
||||||
|
console.print(
|
||||||
|
f"\n[green]{__logo__} Started new session. History cleared.[/green]\n"
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
with _thinking_ctx():
|
with _thinking_ctx():
|
||||||
response = await agent_loop.process_direct(user_input, session_id)
|
response = await agent_loop.process_direct(user_input, session_id)
|
||||||
_print_agent_response(response, render_markdown=markdown)
|
_print_agent_response(response, render_markdown=markdown)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user