From f9c1b751f22ad2efa02603fc71d10a856bd22f95 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 5 Mar 2025 20:37:49 +0000 Subject: [PATCH] Fixes --- .../main/java/io/xpipe/app/ext/ContainerStoreState.java | 2 ++ .../main/java/io/xpipe/app/util/ShellStoreFormat.java | 7 ++++--- .../ext/system/incus/IncusContainerStoreProvider.java | 5 +++-- .../xpipe/ext/system/lxd/LxdContainerStoreProvider.java | 5 +++-- .../io/xpipe/ext/system/podman/PodmanContainerStore.java | 9 +++------ .../ext/system/podman/PodmanContainerStoreProvider.java | 4 +++- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/ext/ContainerStoreState.java b/app/src/main/java/io/xpipe/app/ext/ContainerStoreState.java index ff33f8497..47a7fba3e 100644 --- a/app/src/main/java/io/xpipe/app/ext/ContainerStoreState.java +++ b/app/src/main/java/io/xpipe/app/ext/ContainerStoreState.java @@ -19,6 +19,7 @@ public class ContainerStoreState extends ShellStoreState { String imageName; String containerState; + Boolean shellMissing; @Override public DataStoreState mergeCopy(DataStoreState newer) { @@ -32,5 +33,6 @@ public class ContainerStoreState extends ShellStoreState { super.mergeBuilder(css, b); b.containerState(useNewer(containerState, css.getContainerState())); b.imageName(useNewer(imageName, css.getImageName())); + b.shellMissing(useNewer(shellMissing, css.getShellMissing())); } } diff --git a/app/src/main/java/io/xpipe/app/util/ShellStoreFormat.java b/app/src/main/java/io/xpipe/app/util/ShellStoreFormat.java index cf88b8b5f..8221cbc79 100644 --- a/app/src/main/java/io/xpipe/app/util/ShellStoreFormat.java +++ b/app/src/main/java/io/xpipe/app/util/ShellStoreFormat.java @@ -15,6 +15,7 @@ import lombok.Value; import java.util.Arrays; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; @Value public class ShellStoreFormat { @@ -35,7 +36,7 @@ public class ShellStoreFormat { @SuppressWarnings("unchecked") public static ObservableValue shellStore( - StoreSection section, Function f) { + StoreSection section, Function f) { return BindingsHelper.map(section.getWrapper().getPersistentState(), o -> { var s = (T) o; var info = f.apply(s); @@ -61,11 +62,11 @@ public class ShellStoreFormat { .format(); } + var joined = Stream.concat(Stream.of(s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE ? "TTY" : null), Arrays.stream(info)).toArray(String[]::new); return new ShellStoreFormat( LicenseProvider.get().checkOsName(s.getOsName()), formattedOsName(s.getOsName()), - s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE ? "TTY" : null, - info) + joined) .format(); }); } diff --git a/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java b/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java index cf1fe8fbb..9f8ee1a47 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java @@ -83,8 +83,9 @@ public class IncusContainerStoreProvider implements ShellStoreProvider { @Override public ObservableValue informationString(StoreSection section) { - return ShellStoreFormat.shellStore( - section, (ContainerStoreState s) -> DataStoreFormatter.capitalize(s.getContainerState())); + var c = (ContainerStoreState) section.getWrapper().getPersistentState().getValue(); + var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null; + return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> new String[] {missing, s.getContainerState()}); } @Override diff --git a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java index bcb08dee0..f0160776c 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java @@ -80,8 +80,9 @@ public class LxdContainerStoreProvider implements ShellStoreProvider { @Override public ObservableValue informationString(StoreSection section) { - return ShellStoreFormat.shellStore( - section, (ContainerStoreState s) -> DataStoreFormatter.capitalize(s.getContainerState())); + var c = (ContainerStoreState) section.getWrapper().getPersistentState().getValue(); + var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null; + return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> new String[] {missing, s.getContainerState()}); } @Override diff --git a/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStore.java b/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStore.java index c53fb6e36..26c53b73d 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStore.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStore.java @@ -155,16 +155,13 @@ public class PodmanContainerStore return; } - var stateBuilder = getState().toBuilder(); - stateBuilder.running(false); var hasShell = throwable.getMessage() == null || !throwable.getMessage().contains("OCI runtime exec failed"); if (!hasShell) { - stateBuilder.containerState("No shell available"); - } else { - stateBuilder.containerState("Connection failed"); + var stateBuilder = getState().toBuilder(); + stateBuilder.shellMissing(true); + setState(stateBuilder.build()); } - setState(stateBuilder.build()); }); return pc; } diff --git a/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStoreProvider.java b/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStoreProvider.java index 2ef6c2572..0460b50c1 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStoreProvider.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/podman/PodmanContainerStoreProvider.java @@ -81,7 +81,9 @@ public class PodmanContainerStoreProvider implements ShellStoreProvider { @Override public ObservableValue informationString(StoreSection section) { - return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> s.getContainerState()); + var c = (ContainerStoreState) section.getWrapper().getPersistentState().getValue(); + var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null; + return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> new String[] {missing, s.getContainerState()}); } @Override