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
2 changes: 1 addition & 1 deletion Sources/VaultHistoryTimelineModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum VaultHistoryMode: String, CaseIterable, Identifiable, Sendable {
events.filter { event in
switch self {
case .timeline:
return event.subject.workspaceId != nil
return event.subject.workspaceId != nil || event.subject.windowId != nil
case .folder:
let directory = event.subject.directory?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
Expand Down
2 changes: 2 additions & 0 deletions Sources/VaultHistoryWorkspaceTimelineProjection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,15 @@ struct VaultHistoryWorkspaceTimelineProjection: Sendable {
[
workspace.stableId.map { "workspace-stable:\($0.uuidString)" },
workspace.workspaceId.map { "workspace:\($0.uuidString)" },
workspace.windowId.map { "window:\($0.uuidString)" },
].compactMap { $0 }
}

private static func workspaceIdentities(_ event: VaultHistoryEvent) -> [String] {
[
event.subject.workspaceStableId.map { "workspace-stable:\($0.uuidString)" },
event.subject.workspaceId.map { "workspace:\($0.uuidString)" },
event.subject.windowId.map { "window:\($0.uuidString)" },
].compactMap { $0 }
}

Expand Down
11 changes: 11 additions & 0 deletions Sources/cmuxApp+HistoryMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ extension cmuxApp {
snapshot: recentlyClosedSnapshot
)

Button(String(localized: "command.openVaultPane.title", defaultValue: "Open History as Pane")) {
guard AppDelegate.shared?.focusRightSidebarInActiveMainWindow(
mode: .sessions,
focusFirstItem: true,
preferredWindow: NSApp.keyWindow ?? NSApp.mainWindow
) == true else {
NSSound.beep()
return
}
}

Divider()

splitCommandButton(title: String(localized: "menu.file.restorePreviousAppLaunch", defaultValue: "Restore Previous Launch"), shortcut: menuShortcut(for: .reopenPreviousSession)) {
Expand Down
42 changes: 41 additions & 1 deletion cmuxTests/VaultHistoryGroupingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,51 @@ import Testing
#expect(VaultHistoryMode.timeline.groupKey == .workspace)
#expect(VaultHistoryMode.folder.groupKey == .directory)
#expect(VaultHistoryMode.agent.groupKey == .agent)
#expect(VaultHistoryMode.timeline.includedEvents(from: events).map(\.id) == ["workspace"])
#expect(VaultHistoryMode.timeline.includedEvents(from: events).map(\.id) == ["workspace", "window"])
#expect(VaultHistoryMode.folder.includedEvents(from: events).map(\.id) == ["workspace", "session"])
#expect(VaultHistoryMode.agent.includedEvents(from: events).map(\.id) == ["session"])
}

@Test func timelineShowsWindowLifecycleEventsOnTheirWorkspace() throws {
let workspaceId = UUID()
let windowId = UUID()
let topology = VaultHistoryWorkspaceTopology(workspaces: [
VaultHistoryWorkspaceTopology.Workspace(
id: "workspace:\(workspaceId.uuidString)",
workspaceId: workspaceId,
stableId: nil,
windowId: windowId,
windowLabel: "Main",
title: "History",
directory: "/tmp/repo",
timestamp: Self.now,
state: .active,
isSelected: true,
closedItemId: nil,
terminals: []
),
])
let windowClosed = event(
id: "window-closed",
secondsAgo: 10,
kind: .windowClosed,
title: "Main",
windowId: windowId
)

let section = try #require(
VaultHistoryWorkspaceTimelineProjection().sections(
topology: topology,
events: [windowClosed],
query: VaultHistoryQuery(),
now: Self.now
).first
)

#expect(section.workspaceId == workspaceId)
#expect(section.activityEvents.map(\.id) == ["window-closed"])
}

// MARK: - Filtering, search, and sorting

@Test func timeRangesUseRollingBoundaries() {
Expand Down