From cd33e90b8648380da62f77608a1eb9892f3a0d8d Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 15 Apr 2025 21:09:15 +0000 Subject: [PATCH] Fixes [stage] --- .../app/beacon/impl/AskpassExchangeImpl.java | 14 +------------- .../io/xpipe/app/issue/ErrorHandlerComp.java | 17 +++++++++++------ .../java/io/xpipe/app/prefs/AboutCategory.java | 2 +- .../java/io/xpipe/app/prefs/LinksCategory.java | 2 +- .../io/xpipe/app/terminal/TerminalLauncher.java | 6 ++++-- .../terminal/TerminalMultiplexerManager.java | 13 +++++++------ .../io/xpipe/app/terminal/TerminalView.java | 17 +++++++++++++++++ .../io/xpipe/app/resources/style/prefs.css | 2 +- version | 2 +- 9 files changed, 44 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java index b6972cee1..620974653 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java @@ -58,19 +58,7 @@ public class AskpassExchangeImpl extends AskpassExchange { if (term.isEmpty()) { return; } - - var control = term.get().controllable(); - if (control.isPresent()) { - control.get().focus(); - } else { - if (OsType.getLocal() == OsType.MACOS) { - // Just focus the app, this is correct most of the time - var terminalType = AppPrefs.get().terminalType().getValue(); - if (terminalType instanceof ExternalApplicationType.MacApplication m) { - m.focus(); - } - } - } + TerminalView.focus(term.get()); } @Override diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java index eeb4b2e30..4358ae4ea 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java @@ -6,10 +6,13 @@ import io.xpipe.app.comp.base.ButtonComp; import io.xpipe.app.core.AppFontSizes; import io.xpipe.app.core.AppI18n; import io.xpipe.app.core.AppLayoutModel; +import io.xpipe.app.util.BooleanScope; import io.xpipe.app.util.LicenseRequiredException; import io.xpipe.app.util.ThreadHelper; +import javafx.beans.property.BooleanProperty; import javafx.beans.property.Property; +import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.geometry.Insets; import javafx.geometry.Orientation; @@ -47,12 +50,12 @@ public class ErrorHandlerComp extends SimpleComp { return text; } - private Region createActionComp(ErrorAction a) { + private Region createActionComp(ErrorAction a, BooleanProperty busy) { var graphic = createActionButtonGraphic(a.getName(), a.getDescription()); var b = new ButtonComp(null, graphic, () -> { takenAction.setValue(a); ThreadHelper.runAsync(() -> { - try { + try (var ignored = new BooleanScope(busy).start()) { var r = a.handle(event); if (r) { closeDialogAction.run(); @@ -62,6 +65,7 @@ public class ErrorHandlerComp extends SimpleComp { } }); }); + b.disable(busy); b.apply(GrowAugment.create(true, false)); return b.createRegion(); } @@ -82,7 +86,7 @@ public class ErrorHandlerComp extends SimpleComp { } var descriptionField = new TextArea(desc); - descriptionField.setPrefRowCount(Math.max(5, Math.min((int) desc.lines().count() + 1, 14))); + descriptionField.setPrefRowCount(Math.max(5, Math.min((int) desc.lines().count() + 2, 14))); descriptionField.setWrapText(true); descriptionField.setEditable(false); descriptionField.setPadding(Insets.EMPTY); @@ -125,19 +129,20 @@ public class ErrorHandlerComp extends SimpleComp { } var custom = event.getCustomActions(); + var busy = new SimpleBooleanProperty(); for (var c : custom) { - var ac = createActionComp(c); + var ac = createActionComp(c, busy); ac.getStyleClass().addAll(BUTTON_OUTLINED, ACCENT); actionBox.getChildren().add(ac); } if (event.getLink() != null) { - actionBox.getChildren().add(createActionComp(ErrorAction.openDocumentation(event.getLink()))); + actionBox.getChildren().add(createActionComp(ErrorAction.openDocumentation(event.getLink()), busy)); } var hasCustomActions = event.getCustomActions().size() > 0 || event.getLink() != null; if (hasCustomActions) { - actionBox.getChildren().add(createActionComp(ErrorAction.ignore())); + actionBox.getChildren().add(createActionComp(ErrorAction.ignore(), busy)); } if (actionBox.getChildren().size() > 0) { diff --git a/app/src/main/java/io/xpipe/app/prefs/AboutCategory.java b/app/src/main/java/io/xpipe/app/prefs/AboutCategory.java index 5a8d60973..0408086ba 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AboutCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/AboutCategory.java @@ -55,7 +55,7 @@ public class AboutCategory extends AppPrefsCategory { } var section = new OptionsBuilder() - .addComp(Comp.vspacer(40)) + .addComp(Comp.vspacer(45)) .addComp(title, null) .addComp(Comp.vspacer(10)) .name("build") diff --git a/app/src/main/java/io/xpipe/app/prefs/LinksCategory.java b/app/src/main/java/io/xpipe/app/prefs/LinksCategory.java index eca91a6b9..fab2c49b4 100644 --- a/app/src/main/java/io/xpipe/app/prefs/LinksCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/LinksCategory.java @@ -58,7 +58,7 @@ public class LinksCategory extends AppPrefsCategory { }) .grow(true, false), null) - .addComp(Comp.vspacer(25)) + .addComp(Comp.vspacer(40)) .buildComp(); } diff --git a/app/src/main/java/io/xpipe/app/terminal/TerminalLauncher.java b/app/src/main/java/io/xpipe/app/terminal/TerminalLauncher.java index 35f9b7fcb..634c7b5da 100644 --- a/app/src/main/java/io/xpipe/app/terminal/TerminalLauncher.java +++ b/app/src/main/java/io/xpipe/app/terminal/TerminalLauncher.java @@ -236,7 +236,8 @@ public class TerminalLauncher { // Throw if not supported multiplexer.get().checkSupported(control); - if (TerminalMultiplexerManager.requiresNewTerminalSession(request)) { + var session = TerminalMultiplexerManager.getActiveTerminalSession(request); + if (session.isEmpty()) { return false; } @@ -246,6 +247,7 @@ public class TerminalLauncher { .launchScriptExternal(control, openCommand, initScriptConfig) .toString(); control.command(multiplexerCommand).execute(); + TerminalView.focus(session.get()); return true; } @@ -260,7 +262,7 @@ public class TerminalLauncher { // Throw if not supported multiplexer.get().checkSupported(TerminalProxyManager.getProxy().orElse(LocalShell.getShell())); - if (!TerminalMultiplexerManager.requiresNewTerminalSession(request)) { + if (TerminalMultiplexerManager.getActiveTerminalSession(request).isPresent()) { return Optional.empty(); } diff --git a/app/src/main/java/io/xpipe/app/terminal/TerminalMultiplexerManager.java b/app/src/main/java/io/xpipe/app/terminal/TerminalMultiplexerManager.java index ecf72814e..a9403a287 100644 --- a/app/src/main/java/io/xpipe/app/terminal/TerminalMultiplexerManager.java +++ b/app/src/main/java/io/xpipe/app/terminal/TerminalMultiplexerManager.java @@ -61,17 +61,18 @@ public class TerminalMultiplexerManager { lastCheck = Instant.now(); } - public static boolean requiresNewTerminalSession(UUID requestUuid) { + public static Optional getActiveTerminalSession(UUID requestUuid) { var mult = getEffectiveMultiplexer(); if (mult.isEmpty()) { connectionHubRequests.put(requestUuid, null); - return true; + return Optional.empty(); } - var hasTerminal = TerminalView.get().getSessions().stream() - .anyMatch(shellSession -> shellSession.getTerminal().isRunning() - && mult.get() == connectionHubRequests.get(shellSession.getRequest())); + var session = TerminalView.get().getSessions().stream() + .filter(shellSession -> shellSession.getTerminal().isRunning() + && mult.get() == connectionHubRequests.get(shellSession.getRequest())) + .findFirst(); connectionHubRequests.put(requestUuid, mult.get()); - return !hasTerminal; + return session.map(shellSession -> shellSession.getTerminal()); } } diff --git a/app/src/main/java/io/xpipe/app/terminal/TerminalView.java b/app/src/main/java/io/xpipe/app/terminal/TerminalView.java index b2e5960ed..866a0f922 100644 --- a/app/src/main/java/io/xpipe/app/terminal/TerminalView.java +++ b/app/src/main/java/io/xpipe/app/terminal/TerminalView.java @@ -3,6 +3,7 @@ package io.xpipe.app.terminal; import io.xpipe.app.core.window.NativeWinWindowControl; import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.prefs.AppPrefs; +import io.xpipe.app.prefs.ExternalApplicationType; import io.xpipe.app.util.ThreadHelper; import io.xpipe.core.process.OsType; @@ -77,6 +78,22 @@ public class TerminalView { this.listeners.remove(listener); } + public static void focus(TerminalSession term) { + var control = term.controllable(); + if (control.isPresent()) { + control.get().show(); + control.get().focus(); + } else { + if (OsType.getLocal() == OsType.MACOS) { + // Just focus the app, this is correct most of the time + var terminalType = AppPrefs.get().terminalType().getValue(); + if (terminalType instanceof ExternalApplicationType.MacApplication m) { + m.focus(); + } + } + } + } + public synchronized void open(UUID request, long pid) { var processHandle = ProcessHandle.of(pid); if (processHandle.isEmpty() || !processHandle.get().isAlive()) { diff --git a/app/src/main/resources/io/xpipe/app/resources/style/prefs.css b/app/src/main/resources/io/xpipe/app/resources/style/prefs.css index eebe4694b..b1f2eb5b3 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/prefs.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/prefs.css @@ -1,5 +1,5 @@ .prefs-box { - -fx-padding: 0 40 0 60; + -fx-padding: 0 40 0 80; } .prefs-container .options-comp .name { diff --git a/version b/version index 177373c8d..8706ed978 100644 --- a/version +++ b/version @@ -1 +1 @@ -16.0-43 +16.0-44