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
This commit is contained in:
Achieve 2026-03-27 06:16:12 +08:00 committed by GitHub
parent ccaebbd112
commit 0978732c93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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