Skip to content
Merged
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
21 changes: 17 additions & 4 deletions tame/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class TAMEApp(App):
"z": "pause_all",
"u": "check_usage",
"x": "clear_notifications",
"w": "set_group",
"v": "show_diff",
"q": "quit",
}

Expand Down Expand Up @@ -648,6 +650,18 @@ def _confirm_kill_session(self, confirmed: bool | None) -> None:
if session_id is None:
return

# Determine the neighbor to switch to before removing the session
sessions = self._session_manager.list_sessions()
ids = [s.id for s in sessions]
next_session_id: str | None = None
try:
idx = ids.index(session_id)
if len(ids) > 1:
# Prefer the next session, fall back to previous
next_session_id = ids[idx + 1] if idx + 1 < len(ids) else ids[idx - 1]
except ValueError:
pass

# Clean up git worktree if one was created for this session
try:
session = self._session_manager.get_session(session_id)
Expand All @@ -674,10 +688,9 @@ def _confirm_kill_session(self, confirmed: bool | None) -> None:
sidebar.remove_session(session_id)
viewer.remove_session(session_id)

# Switch to the next available session or clear
sessions = self._session_manager.list_sessions()
if sessions:
self._select_session(sessions[0].id)
# Switch to the nearest neighbor or clear
if next_session_id is not None:
self._select_session(next_session_id)
else:
self._active_session_id = None
header = self.query_one(HeaderBar)
Expand Down
2 changes: 1 addition & 1 deletion tame/ui/themes/builtin/solarized_dark.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Screen {
}

.session-item:hover {
background: #073642;
background: #0a4a5c;
}

.session-item.--highlight {
Expand Down
2 changes: 1 addition & 1 deletion tame/ui/themes/builtin/solarized_light.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Screen {
}

.session-item:hover {
background: #eee8d5;
background: #ddd6c1;
}

.session-item.--highlight {
Expand Down
2 changes: 2 additions & 0 deletions tame/ui/widgets/command_palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
("z", "pause_all", "Pause All"),
("u", "check_usage", "Check Usage"),
("x", "clear_notifications", "Clear Notifications"),
("w", "set_group", "Set Group"),
("v", "show_diff", "Git Diff"),
("q", "quit", "Quit"),
]

Expand Down
13 changes: 11 additions & 2 deletions tame/ui/widgets/session_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_mount(self) -> None:
self._render_label()

def _render_label(self) -> None:
arrow = ">" if self._collapsed else "v"
arrow = "" if self._collapsed else ""
self.update(f"{arrow} {self._group_name}")

@property
Expand Down Expand Up @@ -120,7 +120,16 @@ def _ensure_group_header(self, group: str) -> None:
header = GroupHeader(group)
header.id = header_id
scroll = self.query_one("#session-scroll", VerticalScroll)
scroll.mount(header, before=0)
# Find the first session in this group to insert the header before it
first_in_group = None
for item in scroll.query(SessionListItem):
if item.has_class(f"group-{group}"):
first_in_group = item
break
if first_in_group is not None:
scroll.mount(header, before=first_in_group)
else:
scroll.mount(header)

def remove_session(self, session_id: str) -> None:
"""Remove a session item by its session_id."""
Expand Down
5 changes: 3 additions & 2 deletions tame/ui/widgets/session_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from textual.timer import Timer
from textual.widget import Widget

from tame import __version__
from tame.session.output_buffer import OutputBuffer
from tame.ui.events import ViewerResized

Expand Down Expand Up @@ -449,12 +450,12 @@ def _render_welcome(self) -> Text:
" |_/_/ \\_\\_| |_|___|",
]
subtitle = "Terminal Agent Management Environment"
version = "v0.1.0"
version = f"v{__version__}"
shortcuts = [
("Ctrl+Space", "Open Command Palette"),
(" c", "New Session"),
(" d", "Delete Session"),
(" n / p", "Next / Prev Session"),
(" k", "Kill Session"),
(" s", "Toggle Sidebar"),
(" q", "Quit"),
]
Expand Down