added a disconnected info thingy, with a reconnect button that umm kinda doesnt let u use the terminal 💀

fix runtime errors when calling handler.disconnect() from bg threads
This commit is contained in:
neon443
2025-09-01 18:18:48 +01:00
parent 7c28cc79da
commit ff02122bcc
2 changed files with 38 additions and 19 deletions

View File

@@ -140,9 +140,11 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
func disconnect() {
self.hostkeyChanged = false
withAnimation { self.state = .idle }
withAnimation { self.testSuceeded = nil }
// Task {
self.hostkeyChanged = false
withAnimation { self.state = .idle }
withAnimation { self.testSuceeded = nil }
// }
if let sessionID {
Task { @MainActor in
@@ -303,21 +305,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
return
}
//MARK: very wip
// func authWithKbint() {
// withAnimation { state = .authorizingKbint }
//
// let status = ssh_userauth_kbdint(session, nil, nil)
// if status == SSH_AUTH_INFO.rawValue {
// print(ssh_userauth_kbdint_getnprompts(session))
// print(ssh_userauth_kbdint_getname(session))
// print(ssh_userauth_kbdint_getinstruction(session))
// print(ssh_userauth_kbdint_getprompt(session, <#T##i: UInt32##UInt32#>, <#T##echo: UnsafeMutablePointer<CChar>!##UnsafeMutablePointer<CChar>!#>))
// }
//
//// for prompt in
// }
func getAuthMethods() -> [AuthType] {
var result: [AuthType] = []
let recievedMethod = UInt32(ssh_userauth_list(session, nil))
@@ -390,7 +377,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
func writeToChannel(_ string: String?) {
guard let string else { return }
guard ssh_channel_is_open(channel) == 1 && ssh_channel_is_eof(channel) == 0 else {
Task { disconnect() }
Task { @MainActor in disconnect() }
return
}

View File

@@ -55,6 +55,38 @@ struct ShellView: View {
AudioServicesPlaySystemSound(1103)
}
}
if !checkShell(handler.state) {
ZStack {
RoundedRectangle(cornerRadius: 25)
.fill(hostsManager.selectedTheme.foreground.suiColor.opacity(0.5))
.blur(radius: 5)
.shadow(color: hostsManager.selectedTheme.foreground.suiColor, radius: 5)
VStack {
HStack {
Image(systemName: "wifi.exclamationmark")
.resizable().scaledToFit()
.foregroundStyle(hostsManager.selectedTheme.background.suiColor)
.frame(width: 30)
Text("Disconnected")
.foregroundStyle(hostsManager.selectedTheme.background.suiColor)
.font(.title)
}
Button {
handler.go()
} label: {
Text("Connect")
.foregroundStyle(hostsManager.selectedTheme.background.suiColor)
.padding(5)
.frame(maxWidth: .infinity)
.background(.tint)
.clipShape(RoundedRectangle(cornerRadius: 15))
}
}
.padding(10)
}
.fixedSize()
}
}
}
}