Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to cmux are documented here.
- The Settings > Mobile pairing row says Open Pairing and no longer promises a Tailscale QR code, which pairing does not use ([#14817](https://github.com/manaflow-ai/cmux/pull/14817)) -- thanks @aliyansajid!

### Fixed
- In a split, a pane you switch to no longer shows a dimmed frame before it brightens; the unfocused-pane dim now changes in the same frame as focus ([#14892](https://github.com/manaflow-ai/cmux/pull/14892)).
- Clicking a sidebar workspace keeps its highlight steady while the selection lands, instead of flickering off when the pointer moves away, and rapid clicks never show two rows selected ([#14871](https://github.com/manaflow-ai/cmux/pull/14871)).
- Closing a workspace no longer briefly flashes the close (X) button on every sidebar row, and the X no longer appears on the row that slides under a context menu's old position ([#14826](https://github.com/manaflow-ai/cmux/pull/14826)).
- Closing or creating a workspace no longer rebuilds every sidebar row, so a rename, checklist edit, or popover open on another row survives it ([#14866](https://github.com/manaflow-ai/cmux/pull/14866)).
Expand Down
11 changes: 11 additions & 0 deletions Sources/GhosttyTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10164,6 +10164,8 @@ final class GhosttySurfaceScrollView: NSView {
let surfaceView: GhosttyNSView
private let mobileViewportBorderOverlayView = TerminalViewportBorderOverlayView(frame: .zero)
private let inactiveOverlayView: GhosttyFlashOverlayView
private var inactiveOverlayColor: NSColor = .clear
private var inactiveOverlayOpacity: CGFloat = 0
private let dropZoneOverlayView: GhosttyFlashOverlayView
private let paneDropTargetView = TerminalPaneDropTargetView(frame: .zero)
private let notificationRingOverlayView: GhosttyFlashOverlayView
Expand Down Expand Up @@ -11321,13 +11323,22 @@ final class GhosttySurfaceScrollView: NSView {

func setInactiveOverlay(color: NSColor, opacity: CGFloat, visible: Bool) {
let clampedOpacity = max(0, min(1, opacity))
inactiveOverlayColor = color
inactiveOverlayOpacity = clampedOpacity
CATransaction.begin()
CATransaction.setDisableActions(true)
inactiveOverlayView.layer?.backgroundColor = color.withAlphaComponent(clampedOpacity).cgColor
inactiveOverlayView.isHidden = !(visible && clampedOpacity > 0.0001)
CATransaction.commit()
}

/// Shows or hides the unfocused-split dim with the last configured color, so
/// the workspace's synchronous portal reconcile can move it together with
/// visibility and active state.
func setInactiveOverlayVisible(_ visible: Bool) {
setInactiveOverlay(color: inactiveOverlayColor, opacity: inactiveOverlayOpacity, visible: visible)
}

func setNotificationRing(visible: Bool) {
if !Thread.isMainThread {
DispatchQueue.main.async { [weak self] in
Expand Down
15 changes: 15 additions & 0 deletions Sources/Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12507,9 +12507,17 @@ final class Workspace: Identifiable, ObservableObject, FilePreviewTabMetadataHos
return renderedVisiblePanelIdsForCurrentLayout()
}

/// Whether the split layout shows more than one surface, which is when
/// unfocused terminals dim. `WorkspaceContentView` and the portal reconcile
/// below share this so both paths agree on the dim.
var hasMultipleSplitSurfaces: Bool {
bonsplitController.allPaneIds.count > 1 || panels.count > 1
}

@discardableResult
func reconcileTerminalPortalVisibilityForCurrentRenderedLayout() -> Bool {
let visiblePanelIds = renderedVisiblePanelIdsForCurrentLayout()
let dimsUnfocusedTerminals = hasMultipleSplitSurfaces
// Focus-exclusivity: when the right sidebar (Dock) owns input focus in this
// window, no main terminal should be (re)marked active even if it is still
// this workspace's focused panel — mirroring the SwiftUI `isFocused` gate so
Expand All @@ -12535,6 +12543,13 @@ final class Workspace: Identifiable, ObservableObject, FilePreviewTabMetadataHos
terminalPanel.hostedView.setActive(shouldBeActive)
didChange = true
}
// This reveal and focus change commit now, but the SwiftUI host only
// updates the dim on its next portal turn. Move the dim here too, or a
// tab or workspace dimmed while hidden shows one dimmed frame. Canvas
// hosts own their dim rule.
if shouldBeVisible, layoutMode != .canvas {
terminalPanel.hostedView.setInactiveOverlayVisible(dimsUnfocusedTerminals && !shouldBeActive)
}
TerminalWindowPortalRegistry.updateEntryVisibility(
for: terminalPanel.hostedView,
visibleInUI: shouldBeVisible
Expand Down
3 changes: 1 addition & 2 deletions Sources/WorkspaceContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ struct WorkspaceContentView: View {
}()
#endif
let appearance = PanelAppearance.fromConfig(config)
let isSplit = workspace.bonsplitController.allPaneIds.count > 1 ||
workspace.panels.count > 1
let isSplit = workspace.hasMultipleSplitSurfaces
let usesWorkspacePaneOverlay = TmuxOverlayExperimentSettings.target().usesWorkspacePaneOverlay
let isWorkspaceManuallyUnread = notificationStore.hasManualUnread(forTabId: workspace.id)
let workspaceManualUnreadPanelId = workspace.representativePanelIdForWorkspaceManualUnread()
Expand Down
37 changes: 37 additions & 0 deletions cmuxTests/WorkspaceUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4729,6 +4729,43 @@ final class WorkspaceTeardownTests: XCTestCase {
#endif
}

func testPortalReconcileMovesUnfocusedDimWithFocus() throws {
#if DEBUG
let workspace = Workspace()
let firstPanelId = try XCTUnwrap(workspace.focusedPanelId)
let firstPanel = try XCTUnwrap(workspace.terminalPanel(for: firstPanelId))
let splitPanel = try XCTUnwrap(
workspace.newTerminalSplit(from: firstPanelId, orientation: .horizontal)
)
workspace.focusPanel(firstPanelId)
XCTAssertEqual(workspace.focusedPanelId, firstPanelId)

// The SwiftUI hosts last rendered the split as focused and have not had
// their next portal turn yet.
firstPanel.hostedView.setInactiveOverlay(color: .black, opacity: 0.3, visible: true)
splitPanel.hostedView.setInactiveOverlay(color: .black, opacity: 0.3, visible: false)
workspace.debugReconcileTerminalPortalVisibilityForTesting()
XCTAssertTrue(
firstPanel.hostedView.debugInactiveOverlayState().isHidden,
"The focused terminal must lose its dim in the same pass that activates it"
)
XCTAssertFalse(splitPanel.hostedView.debugInactiveOverlayState().isHidden)

// A background tab keeps the dim it got while hidden until it is revealed.
let paneId = try XCTUnwrap(workspace.bonsplitController.focusedPaneId)
let backgroundTab = try XCTUnwrap(workspace.newTerminalSurface(inPane: paneId, focus: false))
backgroundTab.hostedView.setInactiveOverlay(color: .black, opacity: 0.3, visible: true)
workspace.focusPanel(backgroundTab.id)
workspace.debugReconcileTerminalPortalVisibilityForTesting()
XCTAssertTrue(
backgroundTab.hostedView.debugInactiveOverlayState().isHidden,
"A revealed tab must not show the dim it got while hidden"
)
#else
throw XCTSkip("Debug-only regression test")
#endif
}

func testSelectingWorkspaceTodoPaneHidesDeselectedTerminalPortal() throws {
let workspace = Workspace()
let terminalPanelId = try XCTUnwrap(workspace.focusedPanelId)
Expand Down
Loading