fix(macos): surface gateway sessions load errors
This commit is contained in:
@@ -122,7 +122,15 @@ final class MenuContextCardInjector: NSObject, NSMenuDelegate {
|
|||||||
self.cacheUpdatedAt = Date()
|
self.cacheUpdatedAt = Date()
|
||||||
} catch {
|
} catch {
|
||||||
if self.cachedRows.isEmpty {
|
if self.cachedRows.isEmpty {
|
||||||
self.cacheErrorText = "Could not load sessions"
|
let raw = (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
|
||||||
|
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
if trimmed.isEmpty {
|
||||||
|
self.cacheErrorText = "Could not load sessions"
|
||||||
|
} else {
|
||||||
|
// Keep the menu readable: one line, short.
|
||||||
|
let firstLine = trimmed.split(whereSeparator: \.isNewline).first.map(String.init) ?? trimmed
|
||||||
|
self.cacheErrorText = firstLine.count > 90 ? "\(firstLine.prefix(87))…" : firstLine
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.cacheUpdatedAt = Date()
|
self.cacheUpdatedAt = Date()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,12 @@ enum SessionLoader {
|
|||||||
do {
|
do {
|
||||||
data = try await ControlChannel.shared.request(method: "sessions.list", params: params)
|
data = try await ControlChannel.shared.request(method: "sessions.list", params: params)
|
||||||
} catch {
|
} catch {
|
||||||
throw SessionLoadError.gatewayUnavailable(error.localizedDescription)
|
let msg = (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
|
||||||
|
if msg.localizedCaseInsensitiveContains("unknown method: sessions.list") {
|
||||||
|
throw SessionLoadError.gatewayUnavailable(
|
||||||
|
"Gateway is too old (missing sessions.list). Restart/update the gateway.")
|
||||||
|
}
|
||||||
|
throw SessionLoadError.gatewayUnavailable(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
let decoded: GatewaySessionsListResponse
|
let decoded: GatewaySessionsListResponse
|
||||||
|
|||||||
Reference in New Issue
Block a user