fix(workspace): clear sidebar git branch and PR when focused panel closes

Closed
BI
7mo ago
+10-0

Summary

  • What changed? Clear workspace-level gitBranch and pullRequest properties when the focused panel is closed in didCloseTab and splitTabBar(_:didClosePane:).
  • Why? The sidebar notification message for a workspace (e.g., "PR opened: ...") was persisting even after all processes exited and the branch changed. This caused stale PR information to remain visible in the sidebar.

Root Cause

When a panel was closed, the code correctly removed entries from panelGitBranches and panelPullRequests dictionaries, but the workspace-level gitBranch and pullRequest properties were not being cleared if the closed panel was the currently focused panel.

Fix

Added checks after removing panel entries to clear gitBranch and pullRequest when panelId == focusedPanelId in both:

  1. didCloseTab method (single tab close)
  2. splitTabBar(_:didClosePane:) method (pane close with multiple tabs)

Testing

  • Verified the fix compiles successfully with swiftc -parse
  • The change is minimal and follows the existing code patterns in clearPanelGitBranch and clearPanelPullRequest

Fixes #1642


Summary by cubic

Clear workspace gitBranch and pullRequest when the focused panel or tab closes to stop stale branch/PR notifications in the sidebar.

  • Bug Fixes
    • In didCloseTab and splitTabBar(_:didClosePane:), when panelId == focusedPanelId, set gitBranch and pullRequest to nil after removing panel entries.
    • Addresses #1642 where the sidebar kept showing PR info from a closed panel.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where closing a focused panel could leave outdated Git branch and pull request data in the application state, potentially causing unexpected behavior or display issues.