Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions GhosttyTabs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
FE001101 /* FileExplorerStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE001001 /* FileExplorerStore.swift */; };
FE001102 /* FileExplorerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE001002 /* FileExplorerView.swift */; };
FE002101 /* FileExplorerRootResolverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE002001 /* FileExplorerRootResolverTests.swift */; };
FE002102 /* FileExplorerStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE002002 /* FileExplorerStoreTests.swift */; };
A5001001 /* cmuxApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001011 /* cmuxApp.swift */; };
A5001002 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001012 /* ContentView.swift */; };
E62155868BB29FEB5DAAAF25 /* SidebarSelectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AD52285508B1D6A9875E7B3 /* SidebarSelectionState.swift */; };
Expand Down Expand Up @@ -180,6 +184,10 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
FE001001 /* FileExplorerStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileExplorerStore.swift; sourceTree = "<group>"; };
FE001002 /* FileExplorerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileExplorerView.swift; sourceTree = "<group>"; };
FE002001 /* FileExplorerRootResolverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileExplorerRootResolverTests.swift; sourceTree = "<group>"; };
FE002002 /* FileExplorerStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileExplorerStoreTests.swift; sourceTree = "<group>"; };
A5001000 /* cmux.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = cmux.app; sourceTree = BUILT_PRODUCTS_DIR; };
F1000002A1B2C3D4E5F60718 /* cmuxTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = cmuxTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7E7E6EF344A568AC7FEE3715 /* cmuxUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = cmuxUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -469,6 +477,8 @@
A5001651 /* CmuxConfig.swift */,
A5001653 /* CmuxConfigExecutor.swift */,
A5001655 /* CmuxDirectoryTrust.swift */,
FE001001 /* FileExplorerStore.swift */,
FE001002 /* FileExplorerView.swift */,
);
path = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -559,6 +569,8 @@
491751CE2321474474F27DCF /* TerminalControllerSocketSecurityTests.swift */,
10D684CFFB8CDEF89CE2D9E1 /* TabManagerSessionSnapshotTests.swift */,
C1A2B3C4D5E6F70800000002 /* CmuxConfigTests.swift */,
FE002001 /* FileExplorerRootResolverTests.swift */,
FE002002 /* FileExplorerStoreTests.swift */,
);
path = cmuxTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -768,6 +780,8 @@
A5001650 /* CmuxConfig.swift in Sources */,
A5001652 /* CmuxConfigExecutor.swift in Sources */,
A5001654 /* CmuxDirectoryTrust.swift in Sources */,
FE001101 /* FileExplorerStore.swift in Sources */,
FE001102 /* FileExplorerView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -826,6 +840,8 @@
8C4BBF2DEF6DF93F395A9EE7 /* TerminalControllerSocketSecurityTests.swift in Sources */,
2BB56A710BB1FC50367E5BCF /* TabManagerSessionSnapshotTests.swift in Sources */,
C1A2B3C4D5E6F70800000001 /* CmuxConfigTests.swift in Sources */,
FE002101 /* FileExplorerRootResolverTests.swift in Sources */,
FE002102 /* FileExplorerStoreTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
85 changes: 85 additions & 0 deletions Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -63638,6 +63638,91 @@
}
}
},
"shortcut.toggleFileExplorer.label": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Toggle File Explorer"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "ファイルエクスプローラーを切替"
}
}
}
},
"fileExplorer.empty": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "No folder open"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "フォルダが開かれていません"
}
}
}
},
"fileExplorer.error.unavailable": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "File explorer is not available"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "ファイルエクスプローラーは利用できません"
}
}
}
},
"titlebar.fileExplorer.accessibilityLabel": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Toggle File Explorer"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "ファイルエクスプローラーを切替"
}
}
}
},
"titlebar.fileExplorer.tooltip": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Show or hide the file explorer"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "ファイルエクスプローラーの表示/非表示"
}
}
}
},
"shortcut.toggleTerminalCopyMode.label": {
"extractionState": "manual",
"localizations": {
Expand Down
9 changes: 9 additions & 0 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
weak var tabManager: TabManager?
weak var notificationStore: TerminalNotificationStore?
weak var sidebarState: SidebarState?
weak var fileExplorerState: FileExplorerState?
weak var fullscreenControlsViewModel: TitlebarControlsViewModel?
weak var sidebarSelectionState: SidebarSelectionState?
var shortcutLayoutCharacterProvider: (UInt16, NSEvent.ModifierFlags) -> String? = KeyboardLayout.character(forKeyCode:modifierFlags:)
Expand Down Expand Up @@ -5881,11 +5882,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
cmuxConfigStore.wireDirectoryTracking(tabManager: tabManager)
cmuxConfigStore.loadAll()

let fileExplorerState = FileExplorerState()

let root = ContentView(updateViewModel: updateViewModel, windowId: windowId)
.environmentObject(tabManager)
.environmentObject(notificationStore)
.environmentObject(sidebarState)
.environmentObject(sidebarSelectionState)
.environmentObject(fileExplorerState)
.environmentObject(cmuxConfigStore)

// Use the current key window's size for new windows so Cmd+Shift+N
Expand Down Expand Up @@ -9447,6 +9451,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
return true
}

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .toggleFileExplorer)) {
fileExplorerState?.toggle()
return true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve file-explorer shortcut from active window context

createMainWindow creates a separate FileExplorerState per window, but the Cmd-Shift-E handler toggles the single AppDelegate.fileExplorerState reference. In multi-window sessions this can toggle the wrong window (typically the primary one) instead of the focused window, so shortcut behavior is inconsistent with per-window sidebar state.

Useful? React with 👍 / 👎.

}

if matchShortcut(event: event, shortcut: KeyboardShortcutSettings.shortcut(for: .sendFeedback)) {
guard let targetContext = preferredMainWindowContextForShortcuts(event: event),
let targetWindow = targetContext.window ?? windowForMainWindowId(targetContext.windowId) else {
Expand Down
70 changes: 67 additions & 3 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ struct ContentView: View {
@EnvironmentObject var sidebarState: SidebarState
@EnvironmentObject var sidebarSelectionState: SidebarSelectionState
@EnvironmentObject var cmuxConfigStore: CmuxConfigStore
@EnvironmentObject var fileExplorerState: FileExplorerState
@State private var sidebarWidth: CGFloat = 200
@State private var hoveredResizerHandles: Set<SidebarResizerHandle> = []
@State private var isResizerDragging = false
Expand All @@ -1565,6 +1566,7 @@ struct ContentView: View {
@State private var isFullScreen: Bool = false
@State private var observedWindow: NSWindow?
@StateObject private var fullscreenControlsViewModel = TitlebarControlsViewModel()
@StateObject private var fileExplorerStore = FileExplorerStore()
@State private var previousSelectedWorkspaceId: UUID?
@State private var retiringWorkspaceId: UUID?
@State private var workspaceHandoffGeneration: UInt64 = 0
Expand Down Expand Up @@ -2413,10 +2415,17 @@ struct ContentView: View {
}

private var terminalContentWithSidebarDropOverlay: some View {
terminalContent
.overlay {
SidebarExternalDropOverlay(draggedTabId: sidebarDraggedTabId)
HStack(spacing: 0) {
terminalContent
.overlay {
SidebarExternalDropOverlay(draggedTabId: sidebarDraggedTabId)
}
if fileExplorerState.isVisible {
Divider()
FileExplorerView(store: fileExplorerStore, state: fileExplorerState)
.frame(width: fileExplorerState.width)
}
}
}

@AppStorage("sidebarBlendMode") private var sidebarBlendMode = SidebarBlendModeOption.withinWindow.rawValue
Expand Down Expand Up @@ -2569,6 +2578,59 @@ struct ContentView: View {
)
}

private func syncFileExplorerDirectory() {
guard let selectedId = tabManager.selectedTabId,
let tab = tabManager.tabs.first(where: { $0.id == selectedId }) else {
return
Comment on lines +2967 to +2970

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard file-explorer sync path behind the feature toggle

syncFileExplorerDirectory() runs unconditionally from the currentDirectory stream, and this method immediately configures providers and starts store work even when fileExplorerState.isFeatureEnabled is false. Since setRootPath triggers reload and git-status fetches (including SSH commands for remote workspaces), users with the feature disabled still pay background filesystem/network cost for a hidden panel.

Useful? React with 👍 / 👎.

}

let dir = tab.currentDirectory.trimmingCharacters(in: .whitespacesAndNewlines)
guard !dir.isEmpty else { return }

if tab.isRemoteWorkspace {
let config = tab.remoteConfiguration
let remotePath = tab.remoteDaemonStatus.remotePath
let isReady = tab.remoteDaemonStatus.state == .ready
let homePath = remotePath.flatMap { path -> String? in
// Extract home from remote path context
// For SSH, try to derive home from the working directory if it starts with /home/
let components = dir.split(separator: "/")
if components.count >= 2, components[0] == "home" {
return "/home/\(components[1])"
}
if dir.hasPrefix("/root") {
return "/root"
}
return nil
} ?? ""

if let existingProvider = fileExplorerStore.provider as? SSHFileExplorerProvider,
existingProvider.destination == config?.destination {
Comment on lines +2997 to +2998

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recreate SSH provider when connection options change

Provider reuse is keyed only by destination, so workspaces that share host/user but differ in port, identityFile, or sshOptions will keep using the old provider configuration. That causes directory listing requests to run with stale SSH connection/auth parameters, which can point to the wrong endpoint or fail unexpectedly when switching between such workspaces.

Useful? React with 👍 / 👎.

existingProvider.updateAvailability(isReady, homePath: isReady ? homePath : nil)
if isReady {
fileExplorerStore.setRootPath(dir)
fileExplorerStore.hydrateExpandedNodes()
}
} else if let config {
let provider = SSHFileExplorerProvider(
destination: config.destination,
port: config.port,
identityFile: config.identityFile,
sshOptions: config.sshOptions,
homePath: homePath,
isAvailable: isReady
)
fileExplorerStore.setProvider(provider)
fileExplorerStore.setRootPath(dir)
}
} else {
if !(fileExplorerStore.provider is LocalFileExplorerProvider) {
fileExplorerStore.setProvider(LocalFileExplorerProvider())
}
fileExplorerStore.setRootPath(dir)
}
}

private var focusedDirectory: String? {
guard let selectedId = tabManager.selectedTabId,
let tab = tabManager.tabs.first(where: { $0.id == selectedId }) else {
Expand Down Expand Up @@ -2657,6 +2719,7 @@ struct ContentView: View {
syncSidebarSelectedWorkspaceIds()
applyUITestSidebarSelectionIfNeeded(tabs: tabManager.tabs)
updateTitlebarText()
syncFileExplorerDirectory()

// Startup recovery (#399): if session restore or a race condition leaves the
// view in a broken state (empty tabs, no selection, unmounted workspaces),
Expand Down Expand Up @@ -2726,6 +2789,7 @@ struct ContentView: View {
lastSidebarSelectionIndex = tabManager.tabs.firstIndex { $0.id == newValue }
}
updateTitlebarText()
syncFileExplorerDirectory()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Observe directory changes when syncing explorer root

syncFileExplorerDirectory() is only wired in onAppear and onChange(of: tabManager.selectedTabId), so the sidebar root is never re-synced when the selected workspace’s currentDirectory changes in-place (for example after cd in the same tab). In that common flow, the file explorer keeps showing the old folder until the user switches tabs or recreates the view.

Useful? React with 👍 / 👎.

})

view = AnyView(view.onChange(of: selectedTabIds) { _ in
Expand Down
Loading
Loading