Fix new_tab_with_cwd not adding to active session

Fixes #9614
Fixes #9615
This commit is contained in:
copilot-swe-agent[bot]
2026-03-06 06:46:00 +00:00
committed by Kovid Goyal
parent 68ef054676
commit 6b2a8b6a65
2 changed files with 17 additions and 6 deletions

View File

@@ -665,11 +665,15 @@ class Boss:
startup_session = next(create_sessions(get_options(), special_window=sw, cwd_from=cwd_from))
startup_session.session_name = ''
ans = self.add_os_window(startup_session)
if cwd_from is not None and (sow := cwd_from.window) and (tm := self.os_window_map.get(ans)) and sow.created_in_session_name:
for tab in tm:
tab.created_in_session_name = sow.created_in_session_name
for w in tab:
w.created_in_session_name = sow.created_in_session_name
if cwd_from is not None and (sow := cwd_from.window) and (tm := self.os_window_map.get(ans)):
session_name = sow.created_in_session_name
if not session_name and (sow_tab := sow.tabref()):
session_name = sow_tab.created_in_session_name
if session_name:
for tab in tm:
tab.created_in_session_name = session_name
for w in tab:
w.created_in_session_name = session_name
return ans
@ac('win', 'New OS Window')
@@ -2942,7 +2946,10 @@ class Boss:
else:
w = tab.new_window(cwd_from=cwd_from, location=location, allow_remote_control=allow_remote_control)
if cwd_from is not None and (sw := cwd_from.window):
w.created_in_session_name = sw.created_in_session_name
session_name = sw.created_in_session_name
if not session_name and (sw_tab := sw.tabref()):
session_name = sw_tab.created_in_session_name
w.created_in_session_name = session_name
return w
@ac('win', 'Create a new window')

View File

@@ -280,6 +280,8 @@ class Tab: # {{{
launched_window: Window | None = None
if isinstance(spec, SpecialWindowInstance):
launched_window = self.new_special_window(spec)
if launched_window is not None:
launched_window.created_in_session_name = self.created_in_session_name
else:
from .launch import launch
spec.opts.add_to_session = self.created_in_session_name
@@ -1463,6 +1465,8 @@ class TabManager: # {{{
session_name = ''
if cwd_from is not None and (sw := cwd_from.window):
session_name = sw.created_in_session_name
if not session_name and (sw_tab := sw.tabref()):
session_name = sw_tab.created_in_session_name
t = Tab(self, no_initial_window=True, session_name=session_name) if empty_tab else Tab(
self, special_window=special_window, cwd_from=cwd_from, session_name=session_name)
if not empty_tab and session_name: