Skip to content

Conversation

xingyaoww
Copy link
Collaborator

@xingyaoww xingyaoww commented Sep 25, 2025

  • This change is worth documenting at https://docs.all-hands.dev/
  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

End-user friendly description of the problem this fixes or functionality this introduces.

Fixed an issue where the CLI /new command would show old session statistics before starting a new conversation. Now when users type /new, the screen is cleared immediately for a cleaner transition to the new session.


Summarize what the PR does, explaining any non-trivial design decisions.

This PR fixes issue #11123 where the CLI /new command wasn't properly resetting the conversation display. The problem was that when users requested a new session, the old session's statistics (usage metrics, conversation history) were displayed before the new session started, creating a confusing user experience.

Changes made:

  1. Modified handle_new_command() in openhands/cli/commands.py: Replaced the call to display_shutdown_message(usage_metrics, sid) with clear() from prompt_toolkit.shortcuts. This provides a cleaner transition by immediately clearing the screen instead of showing old session stats.

  2. Added comprehensive tests in tests/unit/cli/test_new_command_reset.py to verify:

    • Session IDs are properly generated as unique values
    • Usage metrics are reset for new sessions
    • The /new command behavior correctly clears the screen instead of displaying shutdown messages

Design decision rationale:
The core session mechanics (unique session ID generation, fresh UsageMetrics objects, proper state reset) were already working correctly. The issue was purely a user experience problem where old session information was displayed during the transition. By clearing the screen immediately, users get a clean slate when they explicitly request a new session with /new.


Link of any specific issues this addresses:

Fixes #11123

@xingyaoww can click here to continue refining the PR


To run this PR locally, use the following command:

GUI with Docker:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0afbe22-nikolaik   --name openhands-app-0afbe22   docker.all-hands.dev/all-hands-ai/openhands:0afbe22

CLI with uvx:

uvx --python 3.12 --from git+https://github.com/All-Hands-AI/OpenHands@openhands-workspace-kxha57nv openhands

- Replace display_shutdown_message() with clear() in handle_new_command()
- This prevents showing old session stats when starting a new session
- Add comprehensive tests to verify the fix
- Fixes #11123
Copy link

openhands-ai bot commented Sep 25, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Run Python Tests

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #11125 at branch `openhands-workspace-kxha57nv`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: v1 CLI /new doesn't reset conversation
2 participants