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
6 changes: 5 additions & 1 deletion cmuxTests/WorkspaceSplitStartupCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ final class WorkspaceSplitStartupCommandTests: XCTestCase {
)
}

func testTabManagerSplitCarriesRequestedWorkingDirectoryAndStartupCommand() {
func testTabManagerSplitCarriesRequestedWorkingDirectoryAndStartupCommand() throws {
let manager = TabManager()
guard let workspace = manager.selectedWorkspace,
let sourcePanelId = workspace.focusedPanelId else {
Expand All @@ -162,6 +162,8 @@ final class WorkspaceSplitStartupCommandTests: XCTestCase {
}

let requestedDirectory = "/tmp/cmux-split-startup-\(UUID().uuidString)"
try FileManager.default.createDirectory(atPath: requestedDirectory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: requestedDirectory) }
let startupCommand = "/tmp/cmux-tmux-command-\(UUID().uuidString).sh"
let tmuxStartCommand = "node /opt/oh-my-codex/dist/omx.js hud --watch"
let initialDividerPosition = 0.875
Expand Down Expand Up @@ -239,6 +241,8 @@ final class WorkspaceSplitStartupCommandTests: XCTestCase {
let placeholderCommand = "/bin/sh -c 'printf placeholder; while :; do sleep 86400; done'"
let attachCommand = "/bin/sh -c 'opencode attach http://127.0.0.1:4096 --session subagent --dir /tmp/omo'"
let requestedDirectory = "/tmp/cmux-respawn-\(UUID().uuidString)"
try FileManager.default.createDirectory(atPath: requestedDirectory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: requestedDirectory) }
let startupEnvironment = [
"CMUX_OMO_SUBAGENT": "1",
"OMO_SUBAGENT_DESC": "test"
Expand Down
6 changes: 6 additions & 0 deletions cmuxTests/WorkspaceTerminalTabWorkingDirectoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct WorkspaceTerminalTabWorkingDirectoryTests {
@Test("Cmd+T after session restore uses workspace cwd when focused agent has no terminal cwd")
func cmdTAfterSessionRestoreUsesWorkspaceCurrentDirectoryForAgentPane() throws {
let workspaceDirectory = "/tmp/cmux-cmdt-restore-\(UUID().uuidString)"
try FileManager.default.createDirectory(atPath: workspaceDirectory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: workspaceDirectory) }
let agentPanelId = UUID()
let snapshot = SessionWorkspaceSnapshot(
workspaceId: UUID(),
Expand Down Expand Up @@ -396,6 +398,8 @@ struct WorkspaceTerminalTabWorkingDirectoryTests {
func newTerminalToRightUsesAnchorTabWorkingDirectoryWhenAnchorIsNotSelected() throws {
let selectedDirectory = "/tmp/cmux-selected-\(UUID().uuidString)"
let anchorDirectory = "/tmp/cmux-anchor-\(UUID().uuidString)"
try FileManager.default.createDirectory(atPath: anchorDirectory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: anchorDirectory) }
let workspace = Workspace(workingDirectory: "/tmp/cmux-workspace-\(UUID().uuidString)")
let paneId = try #require(workspace.bonsplitController.focusedPaneId)
let selectedPanel = try #require(workspace.focusedTerminalPanel)
Expand Down Expand Up @@ -433,6 +437,8 @@ struct WorkspaceTerminalTabWorkingDirectoryTests {
func surfaceCreateInheritsWorkspaceCurrentDirectoryForAgentPane() throws {
let previousManager = TerminalController.shared.activeTabManagerForCallerNotification()
let workspaceDirectory = "/tmp/cmux-surface-create-\(UUID().uuidString)"
try FileManager.default.createDirectory(atPath: workspaceDirectory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: workspaceDirectory) }
let manager = TabManager()
let workspace = try #require(manager.selectedWorkspace)
workspace.currentDirectory = workspaceDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ import Testing

let staleCurrentDirectory = workspace.currentDirectory
let requestedDirectory = "/tmp/cmux-requested-tab-cwd-\(UUID().uuidString)"
try FileManager.default.createDirectory(atPath: requestedDirectory, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(atPath: requestedDirectory) }
let sourcePanel = try #require(
workspace.newTerminalSurface(
inPane: sourcePaneId,
Expand Down
18 changes: 13 additions & 5 deletions cmuxTests/WorkspaceUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7494,12 +7494,20 @@ final class WorkspacePanelGitBranchTests: XCTestCase {
XCTAssertEqual(branches.map(\.isDirty), [true, false, false])
}

func testSidebarBranchDirectoryEntriesStayStableAcrossFocusedSplitChanges() {
func testSidebarBranchDirectoryEntriesStayStableAcrossFocusedSplitChanges() throws {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This PR touches a non-UI unit test in cmuxTests and leaves it in XCTestCase, but repo policy prefers Swift Testing for touched tests even in files that already contain XCTestCase suites (file-level mixing is accepted when suites are separated). Convert the touched tests to a @Suite/@Test block, as WorkspaceTerminalTabWorkingDirectoryTests.swift already does in the same PR.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At cmuxTests/WorkspaceUnitTests.swift, line 7497:

<comment>This PR touches a non-UI unit test in `cmuxTests` and leaves it in `XCTestCase`, but repo policy prefers Swift Testing for touched tests even in files that already contain XCTestCase suites (file-level mixing is accepted when suites are separated). Convert the touched tests to a `@Suite`/`@Test` block, as `WorkspaceTerminalTabWorkingDirectoryTests.swift` already does in the same PR.</comment>

<file context>
@@ -7494,12 +7494,20 @@ final class WorkspacePanelGitBranchTests: XCTestCase {
     }
 
-    func testSidebarBranchDirectoryEntriesStayStableAcrossFocusedSplitChanges() {
+    func testSidebarBranchDirectoryEntriesStayStableAcrossFocusedSplitChanges() throws {
         let workspace = Workspace()
-        let leftLiveDirectory = "/repo/left/live"
</file context>

let workspace = Workspace()
let leftLiveDirectory = "/repo/left/live"
let rightFocusedDirectory = "/repo/right/focused"
let leftFocusedDirectory = "/repo/left/focused"
let rightRequestedDirectory = "/repo/right/requested"
// New splits resolve local cwds against the filesystem (#16248), so
// the inherited directories must exist.
let root = FileManager.default.temporaryDirectory
.appendingPathComponent("cmux-sidebar-dirs-\(UUID().uuidString)", isDirectory: true)
defer { try? FileManager.default.removeItem(at: root) }
let leftLiveDirectory = root.appendingPathComponent("left/live", isDirectory: true).path
let rightFocusedDirectory = root.appendingPathComponent("right/focused", isDirectory: true).path
let leftFocusedDirectory = root.appendingPathComponent("left/focused", isDirectory: true).path
let rightRequestedDirectory = root.appendingPathComponent("right/requested", isDirectory: true).path
for directory in [leftLiveDirectory, rightFocusedDirectory, leftFocusedDirectory, rightRequestedDirectory] {
try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true)
}

guard let leftPanelId = workspace.focusedPanelId else {
XCTFail("Expected initial focused panel")
Expand Down
Loading