From 0978732c93e4ec2a488c0ed3d655bd37c03032f2 Mon Sep 17 00:00:00 2001 From: Achieve Date: Fri, 27 Mar 2026 06:16:12 +0800 Subject: [PATCH] fix: route PWD action to correct TabManager per tabId (#2147) Previously, GHOSTTY_ACTION_PWD used AppDelegate.shared?.tabManager to update the current working directory, which only returns the key window's TabManager. In multi-window scenarios, cwd updates from non-key windows were written to the wrong TabManager, causing panelDirectories to be empty at save time and falling back to $HOME on restore. Fix by using tabManagerFor(tabId:) to precisely route the update to whichever window owns the tab, ensuring all windows persist their working directories correctly. Fixes #2125 --- Sources/GhosttyTerminalView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/GhosttyTerminalView.swift b/Sources/GhosttyTerminalView.swift index 2306bbdd..db6cf9e1 100644 --- a/Sources/GhosttyTerminalView.swift +++ b/Sources/GhosttyTerminalView.swift @@ -2468,7 +2468,7 @@ class GhosttyApp { let surfaceId = surfaceView.terminalSurface?.id else { return true } let pwd = action.action.pwd.pwd.flatMap { String(cString: $0) } ?? "" DispatchQueue.main.async { - AppDelegate.shared?.tabManager?.updateSurfaceDirectory( + AppDelegate.shared?.tabManagerFor(tabId: tabId)?.updateSurfaceDirectory( tabId: tabId, surfaceId: surfaceId, directory: pwd