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
12 changes: 9 additions & 3 deletions cmuxTests/CLIExplicitSurfaceRoutingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,13 @@ struct CLIExplicitSurfaceRoutingTests {
#expect((result.stderr + result.stdout).contains("Surface ref not found: surface:99999"))
#expect(state.mutationCountSnapshot() == 0)

// #13964 resolves a workspace ref client-side: the parameterless
// workspace.list snapshot, then the window scan. This host answers
// neither, so the ref passes through unresolved on the one listing.
let requests = try state.requestObjects()
#expect(requests.compactMap { $0["method"] as? String } == ["surface.list"])
let listParams = try #require(requests.first?["params"] as? [String: Any])
#expect(requests.compactMap { $0["method"] as? String } == ["workspace.list", "window.list", "surface.list"])
let listRequest = try #require(requests.first { $0["method"] as? String == "surface.list" })
let listParams = try #require(listRequest["params"] as? [String: Any])
#expect(listParams["workspace_id"] as? String == Self.reproWorkspaceRef)
}

Expand Down Expand Up @@ -480,7 +484,9 @@ struct CLIExplicitSurfaceRoutingTests {
#expect(state.mutationCountSnapshot() == 0)

let requests = try state.requestObjects()
#expect(requests.compactMap { $0["method"] as? String } == ["window.list", "workspace.list", "surface.list"])
// #13964 resolves the workspace ref from the parameterless workspace.list
// snapshot first, so the window scan is no longer needed here.
#expect(requests.compactMap { $0["method"] as? String } == ["workspace.list", "surface.list"])
let listParams = try #require(requests.last?["params"] as? [String: Any])
#expect(listParams["workspace_id"] as? String == Self.reproWorkspaceId)
}
Expand Down
15 changes: 14 additions & 1 deletion cmuxTests/CLIWorkspaceStableIDTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,23 @@ struct CLIWorkspaceStableIDTests {
environment: environment
)
let received = await requests.value
#expect(received.count == 1, Comment(rawValue: "command=\(command) requests=\(received)"))
// A `workspace:N` selector is resolved client-side first (#13964): one
// parameterless `workspace.list` read ahead of the command's own request.
let commandRequests = received.count == 2 && Self.isWorkspaceRefResolution(received[0])
? Array(received.dropFirst())
: received
#expect(commandRequests.count == 1, Comment(rawValue: "command=\(command) requests=\(received)"))
return result
}

private static func isWorkspaceRefResolution(_ line: String) -> Bool {
guard let object = try? JSONSerialization.jsonObject(with: Data(line.utf8)) as? [String: Any],
object["method"] as? String == "workspace.list" else {
return false
}
return (object["params"] as? [String: Any])?.isEmpty ?? true
}

private func responseObject(in stdout: String) throws -> [String: Any] {
try #require(
JSONSerialization.jsonObject(with: Data(stdout.utf8)) as? [String: Any],
Expand Down