mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-05-03 19:30:31 +00:00
Add support for waveterm [stage]
This commit is contained in:
@@ -566,7 +566,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||
}
|
||||
};
|
||||
ExternalTerminalType WARP = new WarpTerminalType();
|
||||
ExternalTerminalType WAVE = new WaveTerminalType();
|
||||
ExternalTerminalType CUSTOM = new CustomTerminalType();
|
||||
List<ExternalTerminalType> WINDOWS_TERMINALS = List.of(
|
||||
WindowsTerminalType.WINDOWS_TERMINAL_CANARY,
|
||||
@@ -581,7 +580,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||
SECURECRT,
|
||||
TERMIUS,
|
||||
XSHELL,
|
||||
TabbyTerminalType.TABBY_WINDOWS);
|
||||
TabbyTerminalType.TABBY_WINDOWS,
|
||||
WaveTerminalType.WAVE_WINDOWS);
|
||||
List<ExternalTerminalType> LINUX_TERMINALS = List.of(
|
||||
AlacrittyTerminalType.ALACRITTY_LINUX,
|
||||
WezTerminalType.WEZTERM_LINUX,
|
||||
@@ -600,17 +600,18 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||
DEEPIN_TERMINAL,
|
||||
FOOT,
|
||||
Q_TERMINAL,
|
||||
TERMIUS);
|
||||
TERMIUS,
|
||||
WaveTerminalType.WAVE_LINUX);
|
||||
List<ExternalTerminalType> MACOS_TERMINALS = List.of(
|
||||
WARP,
|
||||
// WAVE,
|
||||
ITERM2,
|
||||
KittyTerminalType.KITTY_MACOS,
|
||||
TabbyTerminalType.TABBY_MAC_OS,
|
||||
AlacrittyTerminalType.ALACRITTY_MAC_OS,
|
||||
WezTerminalType.WEZTERM_MAC_OS,
|
||||
MACOS_TERMINAL,
|
||||
TERMIUS);
|
||||
TERMIUS,
|
||||
WaveTerminalType.WAVE_MAC_OS);
|
||||
|
||||
List<ExternalTerminalType> ALL = getTypes(OsType.getLocal(), true);
|
||||
|
||||
|
||||
@@ -1,51 +1,68 @@
|
||||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.util.CommandSupport;
|
||||
import io.xpipe.app.util.LocalShell;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
import io.xpipe.core.util.XPipeInstallation;
|
||||
|
||||
public class WaveTerminalType extends ExternalTerminalType.MacOsType {
|
||||
public interface WaveTerminalType extends ExternalTerminalType, TrackableTerminalType {
|
||||
|
||||
public WaveTerminalType() {
|
||||
super("app.wave", "Wave");
|
||||
}
|
||||
ExternalTerminalType WAVE_WINDOWS = new Windows();
|
||||
ExternalTerminalType WAVE_LINUX = new Linux();
|
||||
ExternalTerminalType WAVE_MAC_OS = new MacOs();
|
||||
|
||||
@Override
|
||||
public TerminalOpenFormat getOpenFormat() {
|
||||
return TerminalOpenFormat.TABBED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessHierarchyOffset() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWebsite() {
|
||||
default String getWebsite() {
|
||||
return "https://www.waveterm.dev/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecommended() {
|
||||
default TerminalOpenFormat getOpenFormat() {
|
||||
return TerminalOpenFormat.NEW_WINDOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isRecommended() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean supportsColoredTitle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsColoredTitle() {
|
||||
return true;
|
||||
default String getId() {
|
||||
return "app.wave";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(TerminalLaunchConfiguration configuration) throws Exception {
|
||||
default void launch(TerminalLaunchConfiguration configuration) throws Exception {
|
||||
try (var sc = LocalShell.getShell().start()) {
|
||||
var wsh = CommandSupport.findProgram(sc, "wsh");
|
||||
var def = sc.getOsType().getUserHomeDirectory(sc) + "/Library/Application Support/waveterm/bin/wsh";
|
||||
var absPath = wsh.orElse(def);
|
||||
var env = sc.command(sc.getShellDialect().getPrintEnvironmentVariableCommand("WAVETERM_JWT")).readStdoutOrThrow();
|
||||
if (wsh.isEmpty() || env.isEmpty()) {
|
||||
var inPath = CommandSupport.findProgram(sc, "xpipe").isPresent();
|
||||
var msg = """
|
||||
The Wave integration requires XPipe to be launched from Wave itself to have access to its environment variables. Otherwise, XPipe does not have access to the token to control Wave.
|
||||
|
||||
You can do this by running the command "%s" in a local terminal inside Wave.
|
||||
""".formatted(inPath ? "xpipe open" : XPipeInstallation.getLocalDefaultCliExecutable() + " open");
|
||||
throw ErrorEvent.expected(new IllegalStateException(msg));
|
||||
}
|
||||
|
||||
sc.command(CommandBuilder.of()
|
||||
.addFile(absPath)
|
||||
.add("run", "--")
|
||||
.addFile("wsh")
|
||||
.add("run", "--forceexit", "--")
|
||||
.add(configuration.getDialectLaunchCommand()))
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
class Windows implements WaveTerminalType {}
|
||||
|
||||
class Linux implements WaveTerminalType {}
|
||||
|
||||
class MacOs implements WaveTerminalType {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user