feat(cli): add /exit --delete flag to remove session on quit#17665
Closed
teknium1 wants to merge 1 commit into
Closed
feat(cli): add /exit --delete flag to remove session on quit#17665teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
Port from google-gemini/gemini-cli#19332. Users can now exit with '/exit --delete' (or '/quit --delete', '/exit -d') to permanently remove the current session's SQLite history plus on-disk transcripts (*.json / *.jsonl / request_dump_*) in one shot. Useful for privacy-sensitive workflows and one-off interactions where leaving a session recording behind is undesirable. Implementation: - New HermesCLI._delete_session_on_exit one-shot flag (defaults False). - process_command() parses --delete / -d after /exit or /quit and arms the flag. Unknown args print a hint and keep the CLI running (prevents typos like '/exit -delete' from accidentally exiting). - Shutdown path calls SessionDB.delete_session(session_id, sessions_dir=...) right after end_session() when the flag is set. That API already existed for 'hermes sessions delete' and handles both SQLite removal (orphaning child sessions so FK constraints hold) and on-disk file cleanup. - /quit CommandDef now advertises '[--delete]' in args_hint so /help and CLI autocomplete surface it. Tests: tests/cli/test_exit_delete_session.py (12 cases covering both aliases, case insensitivity, whitespace, short form, unknown-arg rejection, and registry metadata). E2E-verified with isolated HERMES_HOME: session row deleted, all three transcript/request-dump files removed, second delete_session call correctly returns False.
Contributor
Author
|
Closing in favor of #27101, which salvages this PR onto current main. Two conflicts resolved (main's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port from google-gemini/gemini-cli#19332.
Summary
Users can now run
/exit --delete(or/quit --delete,/exit -d) to permanently remove the current session's SQLite history plus on-disk transcripts in one shot — useful for privacy-sensitive workflows and one-off interactions.Changes
cli.py--delete/-dafter /exit or /quit → arm_delete_session_on_exit→ shutdown path callsSessionDB.delete_session(session_id, sessions_dir=...)afterend_session(). Unknown args are rejected (prevents typos like/exit -deletefrom exiting).hermes_cli/commands.py/quitCommandDef now carriesargs_hint="[--delete]"so /help and autocomplete surface the flag.tests/cli/test_exit_delete_session.py/q-is-not-quit clarification.website/docs/reference/slash-commands.mdNo new SQL or on-disk cleanup code — the
SessionDB.delete_session(session_id, sessions_dir=...)API already existed forhermes sessions deleteand handles SQLite removal (orphaning child sessions to satisfy FK constraints) plus.json/.jsonl/request_dump_*file cleanup.Validation
scripts/run_tests.sh tests/cli/test_exit_delete_session.py tests/cli/test_quick_commands.py tests/cli/test_cli_init.py tests/hermes_cli/test_commands.py tests/cli/test_cli_prefix_matching.py→ 194 passed.<sid>.json+<sid>.jsonl+request_dump_<sid>_turn1.json, called the realend_session()+delete_session()path. DB row deleted, all three transcript files removed, repeat call correctly returns False.Why this port
Gemini CLI shipped the same UX feature last week (#19332). The primitives it needs (
SessionDB.delete_session(),sessions_dircleanup) already existed in hermes-agent forhermes sessions delete; this PR just wires them into the/exitslash command. Surfacing deletion at the slash-command level is the flow a privacy-conscious user actually reaches for — having to/exit→hermes sessions list→hermes sessions delete <id>is three steps too many.Part of the weekly Gemini CLI PR scout. Out of 76 merged PRs in the past week, this was the cleanest self-contained port candidate — most of the rest were either TypeScript infra (ACP refactor), Google-specific (cloud-shell auth, undici timeouts, devtools logging), or duplicating features hermes already has (timeout retry classification, MCP ping handling, search tool case-sensitivity which rg already handles correctly).