From 76dd573cc726e2a2ccf5807159183170fda2c3cf Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 27 Sep 2026 15:00:07 +0000 Subject: [PATCH] Various fixes --- .../app/hub/entry/StoreEntryInformation.java | 2 +- .../io/xpipe/app/process/ShellControl.java | 2 +- .../java/io/xpipe/app/process/ShellTemp.java | 48 +++++++++---------- .../app/terminal/CustomTerminalType.java | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/hub/entry/StoreEntryInformation.java b/app/src/main/java/io/xpipe/app/hub/entry/StoreEntryInformation.java index f5e8d9997..2a3a68e27 100644 --- a/app/src/main/java/io/xpipe/app/hub/entry/StoreEntryInformation.java +++ b/app/src/main/java/io/xpipe/app/hub/entry/StoreEntryInformation.java @@ -59,7 +59,7 @@ public class StoreEntryInformation { } if (s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE) { - l.add(StoreEntryBadge.ofConnectionType("TTY")); + l.add(StoreEntryBadge.ofFailure("TTY")); } return StoreEntryInformation.of(l); diff --git a/app/src/main/java/io/xpipe/app/process/ShellControl.java b/app/src/main/java/io/xpipe/app/process/ShellControl.java index e14edd298..d4141f160 100644 --- a/app/src/main/java/io/xpipe/app/process/ShellControl.java +++ b/app/src/main/java/io/xpipe/app/process/ShellControl.java @@ -108,7 +108,7 @@ public interface ShellControl extends ProcessControl { var oldState = store.getState(); var newState = oldState.toBuilder() .shellDialect(or.isMarkerDialect() ? oldState.getShellDialect() : or) - .ttyState(shellControl.getTtyState()) + .ttyState(or.isMarkerDialect() ? oldState.getTtyState() : shellControl.getTtyState()) .running(true); if (shellControl.getOsType() != null) { newState.osType(shellControl.getOsType()); diff --git a/app/src/main/java/io/xpipe/app/process/ShellTemp.java b/app/src/main/java/io/xpipe/app/process/ShellTemp.java index 375e59725..0b0969f78 100644 --- a/app/src/main/java/io/xpipe/app/process/ShellTemp.java +++ b/app/src/main/java/io/xpipe/app/process/ShellTemp.java @@ -24,7 +24,7 @@ public class ShellTemp { } } - public static FilePath createUserSpecificTempDataDirectory(ShellControl proc) throws Exception { + private static void initUserSpecificTempDataDirectory(ShellControl proc) throws Exception { var base = getUserSpecificTempDataDirectoryPath(proc); // On Windows and macOS, we already have user specific temp directories // Even on macOS as root is technically unique as only root will use /tmp @@ -35,7 +35,7 @@ public class ShellTemp { // This command should work in all shells var hasChmod = proc.view().findProgram("chmod").isPresent(); if (hasChmod) { - var chmodSuccess = proc.executeRobustBootstrapCommand("chmod 700 " + proc.getShellDialect().fileArgument(base)).isPresent(); + var chmodSuccess = proc.command("chmod 700 " + proc.getShellDialect().fileArgument(base)).executeAndCheck(); if (!chmodSuccess) { throw new IOException("Unexpected directory ownership and permissions for " + base); } @@ -61,11 +61,7 @@ public class ShellTemp { } } } - } - return base; - } else { - return base; } } @@ -85,29 +81,31 @@ public class ShellTemp { return hasValidTemp; } + public static FilePath createSubTempDirectory(ShellControl sc, boolean hasValidTemp) throws Exception { + if (!hasValidTemp) { + return null; + } - public static void checkSubTempDirectory(ShellControl sc, boolean hasValidTemp) throws Exception { - var subTemp = sc.getSubTemporaryDirectory(); - if (hasValidTemp) { - // When starting up multiple sessions to the same system, there might be race conditions here - // This is quite inefficient but there is no way to synchronize access on a - // specific system when multiple shell controls access it - synchronized (ShellTemp.class) { - var sessionFile = subTemp.join("xpipe-session-" - + AppProperties.get().getSessionId().toString().substring(0, 8)); - var newSession = !sc.view().fileExists(sessionFile); - if (newSession) { - clearTemp(sc); - try { - sc.view().mkdir(subTemp); - sc.view().touch(sessionFile); - } catch (ProcessOutputException pex) { - if (!pex.getOutput().toLowerCase().contains("no space left on device")) { - throw pex; - } + // When starting up multiple sessions to the same system, there might be race conditions here + // This is quite inefficient but there is no way to synchronize access on a + // specific system when multiple shell controls access it + synchronized (ShellTemp.class) { + var subTemp = getUserSpecificTempDataDirectoryPath(sc); + var sessionFile = subTemp.join("xpipe-session-" + + AppProperties.get().getSessionId().toString().substring(0, 8)); + var newSession = !sc.view().fileExists(sessionFile); + if (newSession) { + clearTemp(sc); + initUserSpecificTempDataDirectory(sc); + try { + sc.view().touch(sessionFile); + } catch (ProcessOutputException pex) { + if (!pex.getOutput().toLowerCase().contains("no space left on device")) { + throw pex; } } } + return subTemp; } } diff --git a/app/src/main/java/io/xpipe/app/terminal/CustomTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/CustomTerminalType.java index 2bed510e6..03f0f2c2c 100644 --- a/app/src/main/java/io/xpipe/app/terminal/CustomTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/CustomTerminalType.java @@ -37,7 +37,7 @@ public class CustomTerminalType implements ExternalApplicationType, ExternalTerm var format = custom.toLowerCase(Locale.ROOT).contains("$cmd") ? custom : custom + " $CMD"; try (var sc = LocalShell.getShell()) { var toExecute = ExternalApplicationHelper.replaceVariableArgument( - format, "CMD", configuration.single().getScriptFile().toString(), false); + format, "CMD", configuration.single().getScriptFile().toString(), true); // We can't be sure whether the command is blocking or not, so always make it not blocking if (sc.getOsType() == OsType.WINDOWS) { toExecute = "start \"" + configuration.getCleanTitle() + "\" " + toExecute;