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
22 changes: 10 additions & 12 deletions Sources/Surfaces/Workspace+CloudManualMirror.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import GhosttyKit
/// (`Workspace+CloudTerminalReservation`).
@MainActor
extension Workspace {
private static var cloudManualMirrorTabTitle: String {
String(localized: "cloudTree.terminal.untitled", defaultValue: "terminal")
}

/// Inserts a manual-mirror terminal in `destination` and returns its native surface.
///
/// - Parameters:
Expand Down Expand Up @@ -113,13 +117,13 @@ extension Workspace {
isLoading: Bool
) throws -> UUID {
panels[panel.id] = panel
panelTitles[panel.id] = panel.displayTitle
panelTitles[panel.id] = Self.cloudManualMirrorTabTitle
guard let tab = bonsplitController.createTab(
title: panel.displayTitle,
title: Self.cloudManualMirrorTabTitle,
icon: panel.displayIcon,
kind: SurfaceKind.terminal.rawValue,
isDirty: panel.isDirty,
isLoading: isLoading,
isLoading: false,
isPinned: false,
inPane: pane
) else {
Expand Down Expand Up @@ -148,13 +152,13 @@ extension Workspace {
let previousPane = bonsplitController.focusedPaneId
let previousTab = previousPane.flatMap { bonsplitController.selectedTab(inPane: $0)?.id }
panels[panel.id] = panel
panelTitles[panel.id] = panel.displayTitle
panelTitles[panel.id] = Self.cloudManualMirrorTabTitle
let tab = Bonsplit.Tab(
title: panel.displayTitle,
title: Self.cloudManualMirrorTabTitle,
icon: panel.displayIcon,
kind: SurfaceKind.terminal.rawValue,
isDirty: panel.isDirty,
isLoading: isLoading,
isLoading: false,
isPinned: false
)
bindSurface(tab.id, toPanelId: panel.id)
Expand Down Expand Up @@ -186,12 +190,6 @@ extension Workspace {
return panel.id
}

/// Flags or clears the tab-strip spinner of a pane whose terminal is still arriving.
func setCloudManualMirrorTabLoading(panelID: UUID, _ isLoading: Bool) {
guard let tabID = surfaceIdFromPanelId(panelID) else { return }
bonsplitController.updateTab(tabID, isLoading: isLoading)
}

/// The live workspace with `id` in any window, or nil once it was retired.
static func liveWorkspace(id: UUID) -> Workspace? {
AppDelegate.shared?.tabManagerFor(tabId: id)?.tabs.first { $0.id == id }
Expand Down
12 changes: 2 additions & 10 deletions Sources/Surfaces/Workspace+CloudTerminalReservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ extension Workspace {
attachment: attachment
)
clearCloudMaterializationFailure(surfaceID: reservation.panelID)
// The tab-strip spinner clears on real attachment, not on adoption.
let panelID = reservation.panelID
attachment.onStateChange = { [weak self, weak attachment] state in
guard state == .attached || state == .ended else { return }
attachment?.onStateChange = nil
self?.setCloudManualMirrorTabLoading(panelID: panelID, false)
}
if attachment.state == .attached { attachment.onStateChange?(.attached) }
panel.surface.flushPendingManualSizeReportIfAttached()
return (id, panel.id, panel.surface)
}
Expand All @@ -100,7 +92,6 @@ extension Workspace {
/// explain inside it, with Reconnect wired to the same request's retry.
func failReservedCloudTerminalPane(_ reservation: CloudTerminalPaneReservation, error: Error) {
guard cloudPendingCreations[reservation.panelID] === reservation else { return }
setCloudManualMirrorTabLoading(panelID: reservation.panelID, false)
let failure = CloudPaneCreationFailure(machine: reservation.machine, error: error, context: CloudOperationContext.current)
setCloudMaterializationFailure(
surfaceID: reservation.panelID,
Expand All @@ -113,7 +104,8 @@ extension Workspace {
func restartReservedCloudTerminalPane(_ reservation: CloudTerminalPaneReservation) {
guard cloudPendingCreations[reservation.panelID] === reservation else { return }
clearCloudMaterializationFailure(surfaceID: reservation.panelID)
setCloudManualMirrorTabLoading(panelID: reservation.panelID, true)
// Keep the reserved tab visually stable while retrying. The pane itself
// reports any failure through its reconnect affordance.
}

/// Reconnect pressed on a reserved pane's failure card replays the request.
Expand Down
Loading