From ff02122bcc7da31d931a691ce9120904222ced71 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Mon, 1 Sep 2025 18:18:48 +0100 Subject: [PATCH] =?UTF-8?q?added=20a=20disconnected=20info=20thingy,=20wit?= =?UTF-8?q?h=20a=20reconnect=20button=20that=20umm=20kinda=20doesnt=20let?= =?UTF-8?q?=20u=20use=20the=20terminal=20=F0=9F=92=80=20fix=20runtime=20er?= =?UTF-8?q?rors=20when=20calling=20handler.disconnect()=20from=20bg=20thre?= =?UTF-8?q?ads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShhShell/SSH/SSHHandler.swift | 25 +++++-------------- ShhShell/Views/Terminal/ShellView.swift | 32 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index fac0621..01d9292 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -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!##UnsafeMutablePointer!#>)) -// } -// -//// 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 } diff --git a/ShhShell/Views/Terminal/ShellView.swift b/ShhShell/Views/Terminal/ShellView.swift index 9a758a2..e178c7e 100644 --- a/ShhShell/Views/Terminal/ShellView.swift +++ b/ShhShell/Views/Terminal/ShellView.swift @@ -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() + } } } }