Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Sources/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3396,16 +3396,17 @@ class TabManager: ObservableObject {
#endif
return false
}
if let surfaceId, tab.panels[surfaceId] == nil {
let requestedPanelId = surfaceId.flatMap { panelId(forSurfaceOrPanelId: $0, in: tab) }
if let requestedSurfaceId = surfaceId, requestedPanelId == nil {
#if DEBUG
cmuxDebugLog(
"notification.focus.fail tab=\(tabId.uuidString.prefix(5)) " +
"panel=\(surfaceId.uuidString.prefix(5)) reason=missingPanel"
"panel=\(requestedSurfaceId.uuidString.prefix(5)) reason=missingPanel"
)
#endif
return false
}
let desiredPanelId = surfaceId ?? tab.focusedPanelId
let desiredPanelId = requestedPanelId ?? tab.focusedPanelId
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
#if DEBUG
if let desiredPanelId {
AppDelegate.shared?.armJumpUnreadFocusRecord(tabId: tabId, surfaceId: desiredPanelId)
Expand Down
23 changes: 23 additions & 0 deletions cmuxTests/TabManagerUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2219,6 +2219,29 @@ final class TabManagerNotificationFocusTests: XCTestCase {
XCTAssertEqual(workspace.focusedPanelId, rightPanel.id, "Expected notification target panel to be focused")
}

func testFocusTabFromNotificationAcceptsBonsplitSurfaceIdForNestedTabNotification() throws {
let manager = TabManager()
guard let workspace = manager.selectedWorkspace,
let firstPanelId = workspace.focusedPanelId,
let paneId = workspace.bonsplitController.focusedPaneId else {
XCTFail("Expected selected workspace with focused panel")
return
}
_ = workspace.newTerminalSurface(inPane: paneId, focus: false)
let thirdPanel = try XCTUnwrap(workspace.newTerminalSurface(inPane: paneId, focus: false))
let thirdSurfaceId = try XCTUnwrap(workspace.surfaceIdFromPanelId(thirdPanel.id)?.uuid)

workspace.focusPanel(firstPanelId)
XCTAssertEqual(workspace.focusedPanelId, firstPanelId)

XCTAssertTrue(manager.focusTabFromNotification(workspace.id, surfaceId: thirdSurfaceId))
drainMainQueue()
drainMainQueue()

XCTAssertEqual(workspace.focusedPanelId, thirdPanel.id)
XCTAssertEqual(workspace.bonsplitController.selectedTab(inPane: paneId)?.id.uuid, thirdSurfaceId)
}

func testFocusTabFromNotificationReturnsFalseForMissingPanel() {
let manager = TabManager()
guard let workspace = manager.selectedWorkspace else {
Expand Down
Loading