Multiplexer fixes

This commit is contained in:
crschnick
2026-04-18 14:34:23 +00:00
parent 9b13fcdf14
commit 30525b3823
5 changed files with 54 additions and 13 deletions
@@ -280,7 +280,7 @@ public final class AppPrefs {
.valueClass(UUID.class)
.requiresRestart(false)
.build());
final Property<TerminalMultiplexer> terminalMultiplexer = map(Mapping.builder()
final ObjectProperty<TerminalMultiplexer> terminalMultiplexer = map(Mapping.builder()
.property(new GlobalObjectProperty<>(null))
.key("terminalMultiplexer")
.valueClass(TerminalMultiplexer.class)
@@ -23,6 +23,7 @@ import io.xpipe.app.util.*;
import io.xpipe.core.OsType;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@@ -166,9 +167,9 @@ public class TerminalCategory extends AppPrefsCategory {
return new OptionsBuilder()
.title("terminalConfiguration")
.sub(terminalChoice(true))
.sub(terminalPrompt())
.sub(terminalProxy())
.sub(terminalMultiplexerChoice())
.sub(terminalPrompt())
// .sub(terminalInitScript())
.title("sessionLogging")
.sub(new OptionsBuilder()
@@ -311,6 +312,44 @@ public class TerminalCategory extends AppPrefsCategory {
.build();
var choice = choiceBuilder.build().buildComp();
choice.maxWidth(600);
var testDisabled = new SimpleBooleanProperty();
var test = new ButtonComp(AppI18n.observable("test"), new FontIcon("mdi2p-play"), () -> {
testDisabled.set(true);
ThreadHelper.runFailableAsync(() -> {
try {
var term = AppPrefs.get().terminalType().getValue();
if (term != null) {
TerminalLaunch.builder()
.title("Tab 1 test")
.localScript(new ShellScript(ProcessControlProvider.get()
.getEffectiveLocalDialect()
.getEchoCommand("If you can read this, the terminal multiplexer integration works", false)))
.preferTabs(true)
.logIfEnabled(false)
.pauseOnExit(true)
.launch();
TerminalLaunch.builder()
.title("Tab 2 test")
.localScript(new ShellScript(ProcessControlProvider.get()
.getEffectiveLocalDialect()
.getEchoCommand("If you can read this, the tabbed terminal multiplexer integration works", false)))
.preferTabs(true)
.logIfEnabled(false)
.pauseOnExit(true)
.launch();
}
} finally {
testDisabled.set(false);
}
});
})
.disable(testDisabled)
.padding(new Insets(6, 11, 6, 5))
.apply(struc -> struc.setAlignment(Pos.CENTER_LEFT));
var options = new OptionsBuilder()
.name("terminalMultiplexer")
.description(
@@ -322,6 +361,11 @@ public class TerminalCategory extends AppPrefsCategory {
if (OsType.ofLocal() == OsType.WINDOWS) {
options.disable(BindingsHelper.map(prefs.terminalProxy(), uuid -> uuid == null));
}
options.addComp(test)
.hide(prefs.terminalMultiplexer.isNull());
if (OsType.ofLocal() == OsType.WINDOWS) {
options.disable(BindingsHelper.map(prefs.terminalProxy(), uuid -> uuid == null));
}
return options;
}
@@ -8,6 +8,7 @@ import io.xpipe.app.process.ShellControl;
import io.xpipe.app.process.ShellScript;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.xpipe.app.update.AppDistributionType;
import io.xpipe.core.OsType;
import java.util.ArrayList;
@@ -25,11 +26,7 @@ public interface TerminalMultiplexer {
}
static TerminalMultiplexer determineDefault(TerminalMultiplexer existing) {
if (!AppProperties.get().isInitialLaunch()) {
return existing;
}
if (OsType.ofLocal() == OsType.WINDOWS) {
if (!AppProperties.get().isInitialLaunch() || OsType.ofLocal() == OsType.WINDOWS || AppDistributionType.get() == AppDistributionType.WEBTOP) {
return existing;
}
@@ -48,8 +48,8 @@ public class ZellijTerminalMultiplexer implements TerminalMultiplexer {
"zellij attach --create-background xpipe",
"zellij -s xpipe action new-tab --name \"" + escape(config.getColoredTitle(), false, true) + "\"",
"zellij -s xpipe action write-chars -- " + escape(" " + firstCommand, true, true) + "\\;exit",
"zellij -s xpipe action write 10",
"zellij -s xpipe action clear"));
"zellij -s xpipe action clear",
"zellij -s xpipe action write 10"));
if (config.getPanes().size() > 1) {
var splitIterator =
@@ -69,8 +69,8 @@ public class ZellijTerminalMultiplexer implements TerminalMultiplexer {
+ escape(config.getPanes().get(i).getTitle(), false, true)
+ "\"",
"zellij -s xpipe action write-chars -- " + escape(" " + iCommand, true, true) + "\\;exit",
"zellij -s xpipe action write 10",
"zellij -s xpipe action clear",
"zellij -s xpipe action write 10",
"zellij -s xpipe action focus-next-pane"));
splitIterator.next();
}
@@ -120,8 +120,8 @@ public class ZellijTerminalMultiplexer implements TerminalMultiplexer {
"zellij -s xpipe action go-to-tab 2",
"sleep 0.5",
"zellij -s xpipe action write-chars -- " + escape(" " + firstCommand, true, true) + "\\;exit",
"zellij -s xpipe action write 10",
"zellij -s xpipe action clear",
"zellij -s xpipe action write 10",
"zellij -s xpipe action go-to-tab 1",
"zellij -s xpipe action close-tab"));
@@ -140,8 +140,8 @@ public class ZellijTerminalMultiplexer implements TerminalMultiplexer {
"zellij -s xpipe action new-pane " + directionString + " --name \""
+ escape(config.getPanes().get(i).getTitle(), false, true) + "\"",
"zellij -s xpipe action write-chars -- " + escape(" " + iCommand, true, true) + "\\;exit",
"zellij -s xpipe action write 10",
"zellij -s xpipe action clear",
"zellij -s xpipe action write 10",
"zellij -s xpipe action focus-next-pane"));
splitIterator.next();
}
@@ -46,7 +46,7 @@ public class ScriptStoreProvider implements DataStoreProvider {
});
var checkbox = new CheckBoxComp(enabled, null, null);
checkbox.describe(d -> d.nameKey("enabled"));
checkbox.describe(d -> d.nameKey("toggleEnabled"));
enabled.addListener((observable, oldValue, newValue) -> {
ScriptStore st = sec.getWrapper().getEntry().getStore().asNeeded();
var state = st.getState().toBuilder().enabled(newValue).build();