Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code_puppy/cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ async def interactive_mode(message_renderer, initial_command: str = None) -> Non
# The renderer is stopped in the finally block of main().
break

# Check for clear command (supports both `clear` and `/clear`)
if task.strip().lower() in ("clear", "/clear"):
# Check for clear command (supports only `clear`)
if task.strip().lower() == "clear":
from code_puppy.command_line.clipboard import get_clipboard_manager
from code_puppy.messaging import (
emit_info,
Expand Down
35 changes: 35 additions & 0 deletions code_puppy/command_line/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,41 @@ def handle_paste_command(command: str) -> bool:
return True


@register_command(
name="clear",
description="Clear conversation history and rotate autosave session",
usage="/clear",
aliases=[],
category="core",
)
def handle_clear_command(command: str) -> bool:
"""Clear conversation history, rotate autosave session, and clear pending clipboard images.

Resets the agent's context so it starts fresh, persists the current session
to autosave, and notifies the user of the cleanup.
"""

from code_puppy.command_line.clipboard import get_clipboard_manager
from code_puppy.messaging import emit_warning, emit_system_message, emit_info
from code_puppy.agents import get_current_agent
from code_puppy.config import finalize_autosave_session

agent = get_current_agent()
new_session_id = finalize_autosave_session()
agent.clear_message_history()
emit_warning("Conversation history cleared!")
emit_system_message("The agent will not remember previous interactions.")
emit_info(f"Auto-save session rotated to: {new_session_id}")

# Also clear pending clipboard images
clipboard_manager = get_clipboard_manager()
clipboard_count = clipboard_manager.get_pending_count()
clipboard_manager.clear_pending()
if clipboard_count > 0:
emit_info(f"Cleared {clipboard_count} pending clipboard image(s)")
return True


@register_command(
name="tutorial",
description="Run the interactive tutorial wizard",
Expand Down