mirror of
https://github.com/ghndrx/shellmate.git
synced 2026-02-10 06:45:02 +00:00
fix: use simple menu directly (Textual over SSH unreliable)
This commit is contained in:
@@ -65,36 +65,7 @@ async def handle_client(process: asyncssh.SSHServerProcess) -> None:
|
|||||||
mode = "play"
|
mode = "play"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from shellmate.tui.app import ShellMateApp
|
# Use simple Rich-based menu (more reliable over SSH)
|
||||||
|
|
||||||
# Set environment for Textual
|
|
||||||
os.environ["TERM"] = term_type
|
|
||||||
os.environ["COLORTERM"] = "truecolor"
|
|
||||||
|
|
||||||
app = ShellMateApp(username=username, mode=mode)
|
|
||||||
|
|
||||||
# Run the app with the SSH process I/O
|
|
||||||
# Use headless driver with the process stdin/stdout
|
|
||||||
from textual.drivers.headless_driver import HeadlessDriver
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
# Create a wrapper that bridges asyncssh to textual
|
|
||||||
class SSHDriver(HeadlessDriver):
|
|
||||||
def __init__(self, app, process, size):
|
|
||||||
super().__init__(app, size=size)
|
|
||||||
self._process = process
|
|
||||||
|
|
||||||
def write(self, data: str) -> None:
|
|
||||||
try:
|
|
||||||
self._process.stdout.write(data)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
driver = SSHDriver(app, process, (width, height))
|
|
||||||
await app._run_async(driver=driver)
|
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
# Fallback to simple Rich-based menu
|
|
||||||
await run_simple_menu(process, username, mode, width, height)
|
await run_simple_menu(process, username, mode, width, height)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Error in ShellMate session: {e}")
|
logger.exception(f"Error in ShellMate session: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user