fix: route PWD action to correct TabManager per tabId#2147
fix: route PWD action to correct TabManager per tabId#2147anthhub wants to merge 1 commit intomanaflow-ai:mainfrom
Conversation
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 manaflow-ai#2125
|
@anthhub is attempting to deploy a commit to the Manaflow Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a multi-window session-restore regression (#2125) where working directories were not persisted correctly. The root cause was that The one-line fix replaces Key points:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GHOSTTY_ACTION_PWD fires] --> B{Lookup TabManager}
B -->|Before fix| C[AppDelegate.tabManager\nkey window only]
B -->|After fix| D[AppDelegate.tabManagerFor tabId\nscans all window contexts]
C --> E{Tab found in key window?}
E -->|No - different window| F[panelDirectories not updated\nfallback to HOME on restore]
E -->|Yes - single window| G[panelDirectories updated correctly]
D --> H[contextContainingTabId iterates\nmainWindowContexts]
H --> I[Returns owning TabManager]
I --> J[updateSurfaceDirectory called\non correct manager]
J --> K[panelDirectories updated\ncwd restored correctly]
|
Summary
Fixes #2125 — session restore does not recover working directories.
GHOSTTY_ACTION_PWDusedAppDelegate.shared?.tabManagerto update the current working directory. ThetabManagerproperty only returns the key window's TabManager. In multi-window scenarios, cwd updates from non-key windows were dispatched to the wrong TabManager, leavingpanelDirectories[panelId]empty at save time and causing a fallback to$HOMEon restore.tabManager?withtabManagerFor(tabId: tabId)?, which looks up the TabManager that actually owns the tab by ID — routing the update to the correct window regardless of which window currently has focus.tabManagerFor(tabId:)returns the same manager astabManager, so there is no behavioral change for single-window users.Changed files
Sources/GhosttyTerminalView.swift— 1-line change inGHOSTTY_ACTION_PWDhandlerTest plan
cdinto different project directories in each window's workspaces$HOME)🤖 Generated with Claude Code
Summary by cubic
Fixes session restore so each window/tab keeps its correct working directory. Routes the
PWDaction to the TabManager that owns the tab instead of the key window’s manager. Fixes #2125.GHOSTTY_ACTION_PWD, replaceAppDelegate.shared?.tabManagerwithtabManagerFor(tabId:)to update the right TabManager in multi-window setups; single-window behavior unchanged.Written for commit 6736e8e. Summary will update on new commits.
Summary by CodeRabbit