Skip to content

Offer Rename / Kill when long pressing a session in the drawer - #5264

Open
kedimuzafer wants to merge 2 commits into
termux:masterfrom
kedimuzafer:session-kill-from-drawer
Open

Offer Rename / Kill when long pressing a session in the drawer#5264
kedimuzafer wants to merge 2 commits into
termux:masterfrom
kedimuzafer:session-kill-from-drawer

Conversation

@kedimuzafer

Copy link
Copy Markdown

Long pressing a session in the drawer goes straight to renaming it, so there is no way to close a
session from the drawer at all. Killing one means switching to it first and using the terminal's own
context menu, or typing exit.

This makes long press open a two item dialog offering Rename and Kill. Rename keeps the
existing behaviour; Kill reuses the same confirmation prompt (title_confirm_kill_session) before
calling finishIfRunning() and removing the finished session, matching what the terminal context
menu already does.

Two strings are added for the menu items and one for the confirmation.

Tested on an Android 16 device and an API 31 emulator: renaming still works, killing removes the
session from the drawer list, and cancelling leaves it running.

kedimuzafer and others added 2 commits August 16, 2026 03:40
Long pressing a session in the drawer went straight to renaming it, so there was
no way to close a session from the drawer at all. Killing one meant switching to
it first and using the terminal's own context menu, or typing exit.

Long press now opens a two item dialog offering Rename and Kill, with the same
confirmation prompt the terminal context menu uses before killing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
finishIfRunning() only sends SIGKILL. The process exits asynchronously, and
TermuxSession.finish() ignores a session that is still running, so removing
the session in the same breath silently did nothing: killing a live session
from the drawer left it in the list. An already exited session was removed
fine, which hid the bug.

Defer the removal to onSessionFinished() instead, via killAndRemoveSession().
Sessions that exit on their own are unaffected.

Also build the dialogs with android.app.AlertDialog, as the rest of the app
does. The appcompat builder picks up the activity theme, whose window
background is black, leaving the buttons unreadable.
@kedimuzafer

Copy link
Copy Markdown
Author

Pushed a fix for two problems in the original commit, found while using it.

Killing a running session did not remove it. finishIfRunning() only sends SIGKILL; the process exits asynchronously, and TermuxSession.finish() returns early for a session that is still running, so calling removeFinishedSession() in the same breath silently did nothing. An already exited session was removed fine, which hid the bug.

The removal is now deferred to onSessionFinished() through a new killAndRemoveSession(). Sessions that exit on their own take the existing path unchanged, and the auto-close rule for exit codes 0 and 130 is untouched.

The confirmation dialog was unreadable. It was built with androidx.appcompat.app.AlertDialog, which picks up the activity theme; Theme.TermuxActivity.DayNight.NoActionBar sets a black window background, so the buttons ended up dark on dark. Switched to android.app.AlertDialog, which is what showKillSessionDialog() and TextInputDialogUtils already use.

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