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
27 changes: 23 additions & 4 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9012,13 +9012,28 @@ private final class SidebarTabItemSettingsStore: ObservableObject {
}
}

private struct SidebarTabItemPresentationSnapshot: Equatable {
struct SidebarTabItemPresentationSnapshot: Equatable {
let tabId: UUID
let unreadCount: Int
let latestNotificationText: String?
let showsModifierShortcutHints: Bool
}

struct SidebarTabItemPresentationResolutionPolicy {
static func resolved(
live: SidebarTabItemPresentationSnapshot,
frozen: SidebarTabItemPresentationSnapshot?
) -> SidebarTabItemPresentationSnapshot {
guard let frozen, frozen.tabId == live.tabId else { return live }
return SidebarTabItemPresentationSnapshot(
tabId: live.tabId,
unreadCount: live.unreadCount,
latestNotificationText: live.latestNotificationText,
showsModifierShortcutHints: frozen.showsModifierShortcutHints
)
}
}

struct VerticalTabsSidebar: View {
@ObservedObject var updateViewModel: UpdateViewModel
@ObservedObject var fileExplorerState: FileExplorerState
Expand Down Expand Up @@ -9491,6 +9506,10 @@ struct VerticalTabsSidebar: View {
let frozenPresentation = frozenTabItemPresentation?.tabId == tab.id
? frozenTabItemPresentation
: nil
let resolvedPresentation = SidebarTabItemPresentationResolutionPolicy.resolved(
live: livePresentation,
frozen: frozenPresentation
)

return TabItemView(
tabManager: tabManager,
Expand All @@ -9505,13 +9524,13 @@ struct VerticalTabsSidebar: View {
workspaceShortcutModifierSymbol: renderContext.workspaceNumberShortcut.numberedDigitHintPrefix,
canCloseWorkspace: renderContext.canCloseWorkspace,
accessibilityWorkspaceCount: renderContext.workspaceCount,
unreadCount: frozenPresentation?.unreadCount ?? liveUnreadCount,
latestNotificationText: frozenPresentation?.latestNotificationText ?? liveLatestNotificationText,
unreadCount: resolvedPresentation.unreadCount,
latestNotificationText: resolvedPresentation.latestNotificationText,
rowSpacing: tabRowSpacing,
setSelectionToTabs: { selection = .tabs },
selectedTabIds: $selectedTabIds,
lastSidebarSelectionIndex: $lastSidebarSelectionIndex,
showsModifierShortcutHints: frozenPresentation?.showsModifierShortcutHints ?? liveShowsModifierShortcutHints,
showsModifierShortcutHints: resolvedPresentation.showsModifierShortcutHints,
dragAutoScrollController: dragAutoScrollController,
draggedTabId: $draggedTabId,
dropIndicator: $dropIndicator,
Expand Down
27 changes: 27 additions & 0 deletions cmuxTests/SidebarWorkspaceSnapshotRefreshPolicyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,33 @@ final class SidebarWorkspaceSnapshotRefreshPolicyTests: XCTestCase {
}
}

final class SidebarTabItemPresentationResolutionPolicyTests: XCTestCase {
func testFrozenContextMenuPresentationDoesNotSuppressLiveNotificationState() {
let tabId = UUID()
let frozen = SidebarTabItemPresentationSnapshot(
tabId: tabId,
unreadCount: 0,
latestNotificationText: nil,
showsModifierShortcutHints: true
)
let live = SidebarTabItemPresentationSnapshot(
tabId: tabId,
unreadCount: 1,
latestNotificationText: "done",
showsModifierShortcutHints: false
)

let resolved = SidebarTabItemPresentationResolutionPolicy.resolved(
live: live,
frozen: frozen
)

XCTAssertEqual(resolved.unreadCount, 1)
XCTAssertEqual(resolved.latestNotificationText, "done")
XCTAssertTrue(resolved.showsModifierShortcutHints)
}
}
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

final class SidebarWorkspaceRowInteractionStateTests: XCTestCase {
func testHoverRevealIsIndependentFromStaleContextMenuVisibility() {
var state = SidebarWorkspaceRowInteractionState()
Expand Down
Loading