Various fixes

This commit is contained in:
crschnick 2024-11-12 09:57:06 +00:00
parent 4e5f09d354
commit 6cf5b8ad45
7 changed files with 29 additions and 16 deletions

View file

@ -12,7 +12,7 @@ public class TerminalWaitExchangeImpl extends TerminalWaitExchange {
@Override
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException, BeaconServerException {
TerminalView.get().open(msg.getRequest(), msg.getPid());
TerminalLauncherManager.waitExchange(msg.getRequest());
TerminalLauncherManager.waitExchange(msg.getRequest(), msg.getPid());
return Response.builder().build();
}

View file

@ -47,7 +47,7 @@ public class AppLayoutComp extends Comp<CompStructure<Pane>> {
var sidebarR = sidebar.createRegion();
pane.setRight(sidebarR);
model.getSelected().addListener((c, o, n) -> {
if (o != null && o.equals(model.getEntries().get(3))) {
if (o != null && o.equals(model.getEntries().get(2))) {
AppPrefs.get().save();
DataStorage.get().saveAsync();
}
@ -55,8 +55,6 @@ public class AppLayoutComp extends Comp<CompStructure<Pane>> {
if (o != null && o.equals(model.getEntries().get(0))) {
StoreViewState.get().updateDisplay();
}
// TerminalView.get().toggleView(model.getEntries().get(2).equals(n));
});
pane.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
sidebarR.getChildrenUnmodifiable().forEach(node -> {

View file

@ -52,7 +52,7 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
var desc = new Label();
desc.textProperty().bind(PlatformThread.sync(description));
AppFont.small(desc);
desc.setOpacity(0.65);
desc.setOpacity(0.8);
var text = new VBox(header, desc);
text.setSpacing(2);

View file

@ -56,6 +56,11 @@ public interface TabbyTerminalType extends ExternalTerminalType, TrackableTermin
super("app.tabby", "Tabby.exe");
}
@Override
public int getProcessHierarchyOffset() {
return 1;
}
@Override
public boolean isRecommended() {
return false;
@ -72,15 +77,14 @@ public interface TabbyTerminalType extends ExternalTerminalType, TrackableTermin
.add("run")
.addFile(configuration.getScriptFile())
.discardOutput());
} else {
// This is probably not going to work as it does not launch a bat file
LocalShell.getShell().executeSimpleCommand(CommandBuilder.of()
.addFile(file.toString())
.add("run")
.add(configuration.getDialectLaunchCommand())
.discardOutput());
}
// This is probably not going to work as it does not launch a bat file
LocalShell.getShell()
.executeSimpleCommand(CommandBuilder.of()
.addFile(file.toString())
.add("run")
.add(configuration.getDialectLaunchCommand())
.discardOutput());
}
@Override

View file

@ -22,6 +22,10 @@ public class TerminalLaunchRequest {
TerminalInitScriptConfig config;
String workingDirectory;
@Setter
@NonFinal
long pid;
@Setter
@NonFinal
TerminalLaunchResult result;

View file

@ -51,7 +51,7 @@ public class TerminalLauncherManager {
synchronized (entries) {
var req = entries.get(request);
if (req == null) {
req = new TerminalLaunchRequest(request, processControl, config, directory, null, false, null);
req = new TerminalLaunchRequest(request, processControl, config, directory, -1, null, false, null);
entries.put(request, req);
} else {
req.setResult(null);
@ -74,7 +74,7 @@ public class TerminalLauncherManager {
return last.waitForCompletion();
}
public static Path waitExchange(UUID request) throws BeaconClientException, BeaconServerException {
public static Path waitExchange(UUID request, long pid) throws BeaconClientException, BeaconServerException {
TerminalLaunchRequest req;
synchronized (entries) {
req = entries.get(request);
@ -85,6 +85,13 @@ public class TerminalLauncherManager {
if (req.isSetupCompleted() && AppPrefs.get().dontAllowTerminalRestart().get()) {
throw new BeaconClientException("Terminal session restarts have been disabled in the security settings");
}
var shell = ProcessHandle.of(pid).orElseThrow().parent().orElseThrow();
if (req.getPid() != -1 && shell.pid() != req.getPid()) {
throw new BeaconClientException("Wrong launch context");
}
req.setPid(shell.pid());
if (req.isSetupCompleted()) {
submitAsync(req.getRequest(), req.getProcessControl(), req.getConfig(), req.getWorkingDirectory());
}

View file

@ -16,6 +16,6 @@
.dialog-comp .buttons {
-fx-padding: 10;
-fx-border-color: -color-border-default;
-fx-background-color: -color-bg-subtle;
-fx-background-color: -color-bg-inset;
-fx-border-width: 1 0 0 0;
}