From 319373682c23ad55f205eca3764f960082af3a02 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Thu, 26 Jun 2025 12:32:18 +0100 Subject: [PATCH] simlplify read from channel loop main thread ui updates in disconnect() --- Config.xcconfig | 2 +- ShhShell/SSH/SSHHandler.swift | 6 ++++-- ShhShell/Views/Terminal/SSHTerminalView.swift | 13 +++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Config.xcconfig b/Config.xcconfig index bb5ff4f..f1b781d 100644 --- a/Config.xcconfig +++ b/Config.xcconfig @@ -5,7 +5,7 @@ // Created by neon443 on 06/06/2025. // -VERSION = 1.1 +VERSION = 1.1.1 BUILD = 1 // Configuration settings file format documentation can be found at: diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 05c0cc1..fd68dce 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -127,8 +127,10 @@ class SSHHandler: @unchecked Sendable, ObservableObject { } func disconnect() { - withAnimation { self.state = .idle } - withAnimation { self.testSuceeded = nil } + DispatchQueue.main.async { + withAnimation { self.state = .idle } + withAnimation { self.testSuceeded = nil } + } //send eof if open if ssh_channel_is_open(channel) == 1 { diff --git a/ShhShell/Views/Terminal/SSHTerminalView.swift b/ShhShell/Views/Terminal/SSHTerminalView.swift index 7cd2cbb..fa03a8c 100644 --- a/ShhShell/Views/Terminal/SSHTerminalView.swift +++ b/ShhShell/Views/Terminal/SSHTerminalView.swift @@ -31,15 +31,12 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie while handler.connected { if let read = handler.readFromChannel() { - Task { [weak self] in - guard let self else { return } - await MainActor.run { - CATransaction.begin() - CATransaction.setDisableActions(true) - feed(text: read) - CATransaction.commit() +// Task { [weak self] in +// guard let self else { return } + Task { @MainActor in + self.feed(text: read) } - } +// } } else { try? await Task.sleep(nanoseconds: 10_000_000) //10ms }