feat: add WSL/Linux terminal window launching support#649
feat: add WSL/Linux terminal window launching support#649rexsilex wants to merge 1 commit intoiloom-ai:mainfrom
Conversation
Add platform-specific terminal backends for WSL (Windows Terminal) and native Linux (gnome-terminal, konsole, xterm) alongside the existing macOS backend. Extract terminal logic into backend modules while keeping the public API unchanged. Key changes: - Add platform-detect.ts for WSL/Linux environment detection - Add terminal-backends/ with darwin, wsl, linux backends and factory - Refactor terminal.ts to delegate to platform-specific backends - Fix E2BIG on Linux by externalising large CLI args to temp files - Fix race condition: write loom metadata before opening terminal tabs - Fix empty error messages in Claude CLI error handling - Update TerminalColorManager with WSL-aware messaging WIP: Terminal tabs open and Claude launches, but behavior still being refined for full end-to-end WSL support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for this PR, @rexsilex! Great work on the terminal backend architecture — the strategy pattern with platform-specific backends is clean and well-tested. The E2BIG fix and race condition fix are solid additions too. I ran a code review and found a few issues, which I've gone ahead and fixed in follow-up commits on this branch: Issues Found & FixedBug (High): Empty command produces shell syntax error on LinuxIn Fix: Trimmed the Bug (Medium):
|
* feat: add Linux, WSL, and tmux terminal backends Refactor terminal launching into pluggable backends using a strategy pattern, enabling cross-platform support. The public API (openTerminalWindow, openMultipleTerminalWindows) is unchanged — backends are selected automatically based on the detected platform. Backends: - darwin: Refactored existing macOS code (Terminal.app + iTerm2) - linux: GUI terminals (gnome-terminal, konsole, xterm) - wsl: Windows Terminal via wt.exe - tmux: Headless fallback for SSH, Docker, Code Server, CI On Linux, the factory tries GUI terminals first, then falls back to tmux automatically when no GUI is available. This unblocks `il start` on headless Linux environments where the previous "not yet supported" error made iloom unusable. Fixes gnome-terminal multi-tab by using sequential openSingle calls (gnome-terminal --tab adds to the focused window) instead of a single invocation where `--` terminates all option parsing. Based on the architecture from #649 by @rexsilex. Resolves #795. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: check DISPLAY before GUI terminals and keep tmux sessions alive Skip GUI terminal detection on Linux when no display server (X11/Wayland) is available — prevents crashes like konsole SIGABRT in headless environments (SSH, Docker, Code Server). Add `; exec bash` keep-alive to tmux backend so sessions persist after the command exits, matching the Linux GUI backend pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: deduplicate darwin command-building and platform detection Address code review feedback (PR #796): 1. darwin.ts buildTerminalAppScript now delegates to the shared buildCommandSequence instead of reimplementing the same logic. Removes unused escapeSingleQuotes and buildEnvSourceCommands imports. 2. terminal.ts detectITerm2 now delegates to darwin.ts's canonical implementation instead of duplicating the existsSync check. 3. terminal.ts detectPlatform now delegates to detectTerminalEnvironment from platform-detect.ts, eliminating the duplicate platform detection logic. Maps 'wsl' → 'linux' to preserve the Platform return type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address review feedback — session naming, WSL keep-alive, catch blocks, N+1 detection 1. [Critical] Tmux openSingle() sessions now use iloom- prefix so findIloomSession() can discover them, matching openMultiple() behavior. 2. [Critical] WSL backend appends '; exec bash' keep-alive to prevent terminal tabs from closing when the command exits. 3. [Medium] Narrowed bare catch blocks in isTmuxAvailable, sessionExists, findIloomSession, and detectLinuxTerminal to check for exitCode before swallowing — unexpected errors now propagate instead of being silently ignored. Test mocks updated to include exitCode matching real execa behavior. 4. [Medium] LinuxBackend.openMultiple() now calls execTerminal() directly with the pre-detected terminal instead of delegating to openSingle(), eliminating redundant detectLinuxTerminal() calls per window. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: ENOENT-specific catch in WSL detection, DRY linux backend, update README platform support - platform-detect: check for ENOENT specifically instead of bare catch - linux backend: extract resolveTerminal() and openSingleWithTerminal() to eliminate duplicated detection/command-building between openSingle/openMultiple - README: update OS support line to reflect Linux/WSL/tmux support, credit @TickTockBent and @rexsilex in Acknowledgments * docs: add Windows/WSL setup guide and update README platform support - New docs/windows-wsl-guide.md with full WSL setup, VS Code integration, Windows Terminal usage, and troubleshooting - Link from README system requirements to the WSL guide --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Adam Creeger <adamcreeger@gmail.com>
Add platform-specific terminal backends for WSL (Windows Terminal) and native Linux (gnome-terminal, konsole, xterm) alongside the existing macOS backend. Extract terminal logic into backend modules while keeping the public API unchanged.
Key changes:
WIP: Terminal tabs open and Claude launches, but behavior still being refined for full end-to-end WSL support.