fix: remove public visibility from app-internal types; fix StatusBar arg order
This commit is contained in:
parent
267d8a0f23
commit
df85c9e85b
|
|
@ -5,21 +5,21 @@ import Foundation
|
||||||
|
|
||||||
// MARK: - SessionInfo
|
// MARK: - SessionInfo
|
||||||
|
|
||||||
public struct SessionInfo: Identifiable, Hashable, Sendable {
|
struct SessionInfo: Identifiable, Hashable, Sendable {
|
||||||
public let id: String
|
let id: String
|
||||||
public let name: String
|
let name: String
|
||||||
public let state: String // "running", "idle", etc.
|
let state: String // "running", "idle", etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - SessionRegistry
|
// MARK: - SessionRegistry
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
public final class SessionRegistry: ObservableObject {
|
final class SessionRegistry: ObservableObject {
|
||||||
@Published public var sessions: [SessionInfo] = []
|
@Published var sessions: [SessionInfo] = []
|
||||||
@Published public var isLoading = false
|
@Published var isLoading = false
|
||||||
@Published public var error: String? = nil
|
@Published var error: String? = nil
|
||||||
|
|
||||||
public init() {}
|
init() {}
|
||||||
|
|
||||||
// MARK: - Private helpers
|
// MARK: - Private helpers
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ public final class SessionRegistry: ObservableObject {
|
||||||
// MARK: - GET /sessions
|
// MARK: - GET /sessions
|
||||||
|
|
||||||
/// Fetches the current session list from the sidecar and updates `sessions`.
|
/// Fetches the current session list from the sidecar and updates `sessions`.
|
||||||
public func refresh(credential: SidecarCredential) async {
|
func refresh(credential: SidecarCredential) async {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
error = nil
|
error = nil
|
||||||
defer { isLoading = false }
|
defer { isLoading = false }
|
||||||
|
|
@ -57,7 +57,7 @@ public final class SessionRegistry: ObservableObject {
|
||||||
|
|
||||||
/// Creates a new session with the given name and returns the created `SessionInfo`.
|
/// Creates a new session with the given name and returns the created `SessionInfo`.
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public func spawnSession(name: String, credential: SidecarCredential) async throws -> SessionInfo {
|
func spawnSession(name: String, credential: SidecarCredential) async throws -> SessionInfo {
|
||||||
let url = baseURL(credential: credential).appendingPathComponent("sessions")
|
let url = baseURL(credential: credential).appendingPathComponent("sessions")
|
||||||
var req = authorizedRequest(url: url, credential: credential)
|
var req = authorizedRequest(url: url, credential: credential)
|
||||||
req.httpMethod = "POST"
|
req.httpMethod = "POST"
|
||||||
|
|
@ -81,7 +81,7 @@ public final class SessionRegistry: ObservableObject {
|
||||||
// MARK: - DELETE /sessions/<id>
|
// MARK: - DELETE /sessions/<id>
|
||||||
|
|
||||||
/// Deletes the session with the given id.
|
/// Deletes the session with the given id.
|
||||||
public func deleteSession(id: String, credential: SidecarCredential) async throws {
|
func deleteSession(id: String, credential: SidecarCredential) async throws {
|
||||||
let url = baseURL(credential: credential)
|
let url = baseURL(credential: credential)
|
||||||
.appendingPathComponent("sessions")
|
.appendingPathComponent("sessions")
|
||||||
.appendingPathComponent(id)
|
.appendingPathComponent(id)
|
||||||
|
|
@ -108,10 +108,10 @@ private struct SessionItem: Decodable {
|
||||||
|
|
||||||
// MARK: - Errors
|
// MARK: - Errors
|
||||||
|
|
||||||
public enum SessionRegistryError: LocalizedError {
|
enum SessionRegistryError: LocalizedError {
|
||||||
case unexpectedStatus
|
case unexpectedStatus
|
||||||
|
|
||||||
public var errorDescription: String? {
|
var errorDescription: String? {
|
||||||
switch self {
|
switch self {
|
||||||
case .unexpectedStatus:
|
case .unexpectedStatus:
|
||||||
return "Unexpected HTTP status from sidecar."
|
return "Unexpected HTTP status from sidecar."
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ struct MainTerminalView: View {
|
||||||
connectionStatus: statusText,
|
connectionStatus: statusText,
|
||||||
piState: $currentPiState,
|
piState: $currentPiState,
|
||||||
onSwitcher: { showSwitcher = true },
|
onSwitcher: { showSwitcher = true },
|
||||||
onSettings: { showSettings = true }, // T-2.11
|
onUnpair: { appState.unpair() },
|
||||||
onUnpair: { appState.unpair() }
|
onSettings: { showSettings = true } // T-2.11
|
||||||
)
|
)
|
||||||
|
|
||||||
// ── Terminal ────────────────────────────────────────────
|
// ── Terminal ────────────────────────────────────────────
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue