feat: move terminal settings, look and ssh tools into ssh-terminal plugin

This commit is contained in:
LukeGus committed 2026-09-29 02:38:37 -05:00
1 parent ffa872ebd3
commit d9bba10612
242 files changed
+25071 -7207

No files matched your search

@@ -0,0 +1,65 @@
import { useEffect, useState } from "react";
import {
invokeAction,
type PluginHostRecord,
} from "@termix/plugin-sdk/frontend";
/** What the SSH terminal's "terminal.resolveTheme" action answers. */
export interface ConsoleLook {
colors: Record<string, string | undefined> & {
background: string;
foreground: string;
};
fontFamily: string;
fontSize: number;
cursorStyle: "block" | "underline" | "bar";
cursorBlink: boolean;
letterSpacing: number;
lineHeight: number;
scrollback: number;
}
/** Plain colors, for when the SSH terminal plugin is off. */
export const FALLBACK_CONSOLE_LOOK: ConsoleLook = {
colors: {
background: "#0c0d0b",
foreground: "#fafafa",
cursor: "#fafafa",
cursorAccent: "#0c0d0b",
},
fontFamily: '"SF Mono", Consolas, "Liberation Mono", monospace',
fontSize: 14,
cursorStyle: "bar",
cursorBlink: true,
letterSpacing: 0,
lineHeight: 1,
scrollback: 10000,
};
/** The look the SSH terminal uses on this host, or plain colors without it. */
export function useConsoleLook(
host: PluginHostRecord | null | undefined,
appTheme: string,
): ConsoleLook {
const [look, setLook] = useState<ConsoleLook>(FALLBACK_CONSOLE_LOOK);
const hostKey = host
? `${host.id}:${JSON.stringify(host.pluginSettings ?? {})}`
: "";
useEffect(() => {
let active = true;
invokeAction("terminal.resolveTheme", { host, appTheme })
.then((resolved) => {
if (active) setLook((resolved as ConsoleLook) ?? FALLBACK_CONSOLE_LOOK);
})
.catch(() => {
if (active) setLook(FALLBACK_CONSOLE_LOOK);
});
return () => {
active = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hostKey, appTheme]);
return look;
}