Skip to content

fix(tui): Ctrl+L and :clear start a new session like /clear - #483

Merged
mrnasil merged 3 commits into
mainfrom
fix/tui-clear-session
Nov 25, 2026
Merged

mrnasil merged 3 commits into
mainfrom
fix/tui-clear-session

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Problem

There are three ways to "clear the session"; only /clear actually did:

  • /clear (run/slash.rs) replaces the session, clears history and undo, drops the goal and todos.
  • Ctrl+L → confirm and :clear (input.rs) only ran app.messages.clear() and showed "Session cleared".

After Ctrl+L the screen was empty, but the next prompt still sent the whole old conversation to the model, and resuming brought the old transcript back.

Fix

  • Both set app.clear_session_requested (via request_clear_session).
  • After each handled event, the run loop, when idle, takes the flag and runs IdleLoopKey::ClearSession. That is the same handle_slash("/clear", …) call /clear uses. The prompt draft is kept (it is not the command).
  • During a running turn the request is refused with a status line ("Finish or cancel the running turn before clearing"). Otherwise it would sit and fire on some later keypress.

Tests

  • apply_idle_loop_key_covers_session_and_slash_arms: ClearSession gives a new session id, the old turn is gone, and the draft is kept.
  • run_headless_ctrl_l_confirm_starts_a_new_session: Ctrl+L, Enter, quit through the real loop.
  • Input tests: Ctrl+L confirm, dialog Enter and :clear request the clear; the transcript is untouched until the loop runs /clear; mid-turn is refused.
  • All 1503 tui lib tests pass. clippy, fmt, budgets.

🤖 Generated with Claude Code

"Clear session" (Ctrl+L, confirmed) and `:clear` only emptied the chat
on screen and said "Session cleared". The session, its history, undo
stack and goal were untouched, so the next prompt still sent the whole
old conversation and resuming brought the old transcript back.

Both now set `clear_session_requested`; the run loop, once idle, runs
the same `/clear` handler (`IdleLoopKey::ClearSession`), keeping the
prompt draft. A request made mid-turn is refused with a status line
instead of firing on some later keypress.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil enabled auto-merge (squash) November 25, 2026 13:27
@mrnasil
mrnasil merged commit fc88f3b into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/tui-clear-session branch November 25, 2026 15:15
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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.

1 participant