import React from "react"; import { Terminal } from "./Terminal"; import { FullScreenAppWrapper, ConnectionScreen } from "@termix/plugin-sdk/ui"; import { useTranslation } from "@termix/plugin-sdk/frontend"; interface TerminalAppProps { hostId?: string; /** tmux session to attach to once the shell is ready (tmux monitor "Attach"). */ tmuxSession?: string; } // Only the session name travels in the URL (never a raw command), so a crafted // link cannot execute arbitrary input. `=` forces exact-name matching in tmux. function tmuxAttachCommand(session: string): string { return `tmux attach-session -t '=${session.replace(/'/g, "'\\''")}'`; } const TerminalApp: React.FC = ({ hostId, tmuxSession }) => { const { t } = useTranslation(); return ( {(hostConfig, phase) => { if (phase === "loading") { return (
); } if (!hostConfig) { return (
); } return ( {}} executeCommand={ tmuxSession ? tmuxAttachCommand(tmuxSession) : undefined } /> ); }}
); }; export default TerminalApp;