Prevent multiple stacking Rename tab overlay windows

Fixes #9691
Fixes #9692
This commit is contained in:
copilot-swe-agent[bot] 2026-03-17 07:26:45 +00:00 committed by Kovid Goyal
parent f57eb74dbe
commit e98f80d836
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 4 deletions

View file

@ -1237,7 +1237,7 @@ def get_line(
is_password: bool = False,
initial_value: str = '',
window_title: str = '',
) -> None:
) -> Window | None:
result: str = ''
def callback_(res: dict[str, Any], x: int, boss: Boss) -> None:
@ -1252,7 +1252,7 @@ def on_popup_overlay_removal(wid: int, boss: Boss) -> None:
cmd.append('--default=' + initial_value)
if window_title:
cmd.append(f'--title={window_title}')
self.run_kitten_with_metadata(
return self.run_kitten_with_metadata(
'ask', cmd, window=window, custom_callback=callback_, default_data={'response': ''}, action_on_removal=on_popup_overlay_removal
)
@ -2377,12 +2377,24 @@ def set_tab_title(self, title: str | None = None) -> None:
title = ''
tab.set_title(title)
return
if tab.renaming_in_window and tab.renaming_in_window in self.window_id_map:
w = self.window_id_map[tab.renaming_in_window]
if w in tab:
tab.set_active_window(w)
return
prefilled = tab.name or tab.title
if title in ('" "', "' '"):
prefilled = ''
self.get_line(
def on_rename_done(new_title: str) -> None:
tab.renaming_in_window = 0
tab.set_title(new_title)
overlay_window = self.get_line(
_('Enter the new title for this tab below. An empty title will cause the default title to be used.'),
tab.set_title, window=tab.active_window, initial_value=prefilled, window_title=_('Rename tab'))
on_rename_done, window=tab.active_window, initial_value=prefilled, window_title=_('Rename tab'))
if overlay_window is not None:
tab.renaming_in_window = overlay_window.id
def create_special_window_for_show_error(self, title: str, msg: str, overlay_for: int | None = None) -> SpecialWindowInstance:
ec = sys.exc_info()

View file

@ -145,6 +145,7 @@ class Tab: # {{{
inactive_fg: int | None = None
inactive_bg: int | None = None
confirm_close_window_id: int = 0
renaming_in_window: int = 0
num_of_windows_with_progress: int = 0
total_progress: int = 0
has_indeterminate_progress: bool = False