remote: fix list not showing when a single VM is unavailable

Fixes #6380
This commit is contained in:
osy
2024-08-19 18:32:28 -05:00
parent 1e0e6b2062
commit 8779e3624a
3 changed files with 14 additions and 7 deletions
@@ -73,6 +73,8 @@ fileprivate struct WrappedVMDetailsView: View {
}
#if os(macOS)
.frame(width: 230)
#else
.padding()
#endif
}
}
@@ -92,6 +94,8 @@ fileprivate struct UnsupportedVMDetailsView: View {
}
#if os(macOS)
.frame(width: 230)
#else
.padding()
#endif
}
}
+1 -1
View File
@@ -521,7 +521,7 @@ extension VMRemoteDataError: LocalizedError {
case .notImplemented:
return NSLocalizedString("This function is not implemented.", comment: "VMData")
case .backendNotSupported:
return NSLocalizedString("This VM is configured for a backend that does not support remote clients.", comment: "VMData")
return NSLocalizedString("This VM is not available or is configured for a backend that does not support remote clients.", comment: "VMData")
}
}
}
+9 -6
View File
@@ -683,13 +683,16 @@ extension UTMRemoteServer {
}
@MainActor
private func findVM(withId id: UUID) throws -> VMData {
private func findVM(withId id: UUID, allowNotLoaded: Bool = false) throws -> VMData {
let vm = data.virtualMachines.first(where: { $0.id == id })
if let vm = vm, let _ = vm.wrapped {
return vm
} else {
throw UTMRemoteServer.ServerError.notFound(id)
if let vm = vm {
if let _ = vm.wrapped {
return vm
} else if allowNotLoaded {
return vm
}
}
throw UTMRemoteServer.ServerError.notFound(id)
}
@MainActor
@@ -735,7 +738,7 @@ extension UTMRemoteServer {
private func _getVirtualMachineInformation(parameters: M.GetVirtualMachineInformation.Request) async throws -> M.GetVirtualMachineInformation.Reply {
let informations = try await Task { @MainActor in
try parameters.ids.map { id in
let vm = try findVM(withId: id)
let vm = try findVM(withId: id, allowNotLoaded: true)
let mountedDrives = vm.registryEntry?.externalDrives.mapValues({ $0.path }) ?? [:]
let isTakeoverAllowed = data.vmWindows[vm] is VMRemoteSessionState && (vm.state == .started || vm.state == .paused)
return M.VirtualMachineInformation(id: vm.id,