feat(terminal): tmux shell navigator with presets and mobile support#4
feat(terminal): tmux shell navigator with presets and mobile support#4dguerizec wants to merge 17 commits intotwidi:mainfrom
Conversation
|
Thanks for this contribution! The tmux navigator with presets and mobile support is a solid feature. After going through the overall approach, here's some feedback: 1. Documentation: preset path resolution is misleadingThe docs ( This means that if a session has a specific 2. Consider adding global presets + a UI editorCurrently presets are per-project only (one A possible improvement:
The file is already re-read on every refresh, so changes from a UI editor would take effect immediately. 3. Consider splitting this PR into smaller, focused PRsThis PR bundles three fairly independent concerns: A — Tmux window management: creating/switching/monitoring windows, the TmuxNavigator component, presets, the tab bar and mobile dropdown. This is the core feature. B — Scroll and touch interaction: desktop mouse wheel fix (WheelUpPane/WheelDownPane bindings), mobile touch scroll with context-aware behavior (shell vs alternate screen), copy mode toggle, C — Mobile action buttons: Ctrl+C and Ctrl+Z buttons. These are hardcoded right now, but this could be designed as a generic configurable shortcuts toolbar from the start — letting users define their own buttons (label + escape sequence) via settings. This would be more useful and more extensible than two fixed buttons. Splitting would make each PR easier to review, and would allow merging B (scroll fixes) and C (action buttons) independently since they provide value even without multi-window support. This review reflects a discussion between @twidi and Claude Code on the overall approach — not a detailed code review. |
|
Please consider splitting this PR into smaller, focused PRs as explained above |
Add list, create, select, and rename window operations for tmux sessions, following existing patterns (timeout, error handling, socket naming).
Add WebSocket message handlers for list_windows, create_window, and select_window operations, enabling the frontend to manage tmux windows. Rename the default tmux window to "main" on connection, and update the protocol documentation to reflect the new control messages and response types.
wa-tab-show doesn't fire when re-clicking an already-active tab.
Pass -c cwd to tmux new-window so new shells open in the project's working directory instead of tmux's session-level default.
Add support for a .twicc-tmux.json config file in the project root
that defines reusable shell presets with name, optional cwd, and
optional command. Presets appear in the TmuxNavigator and can be
launched with one click.
Backend: load_tmux_presets() reads the config, tmux_send_keys() runs
the optional command after window creation. Both list_windows and
create_window handlers are extended to support presets.
Frontend: TmuxNavigator shows available presets (not yet running)
with a play icon. useTerminal.createWindow() accepts either a string
or a preset object {name, cwd, command}.
Desktop: horizontal tab bar with active state highlighting. Mobile: wa-select dropdown + Ctrl+C/Z buttons always accessible. Auto-focus terminal after switching windows on both platforms. Fetch window list on connect so tabs/dropdown appear immediately. Poll tmux window list to detect external changes (shell exit, etc.).
Mobile toolbar gets a Copy toggle button (off by default):
- Off (scroll mode): swipe scrolls the terminal with natural direction
- On (copy mode): swipe selects text, auto-resets after copy
Scroll adapts to context via tmux pane state detection:
- Shell prompt: SGR mouse wheel → tmux copy-mode scrollback
- Alternate screen (less, vim): arrow keys → app handles scroll
- Raw shell (no tmux): xterm.js viewport scrollLines()
Backend polls tmux #{alternate_on} every 2s alongside window list,
sends state to frontend so scroll method switches automatically.
Also enables tmux mouse mode for proper wheel event handling.
…h icon Presets now always stay in their section (even when running) with a green icon indicator. Clicking a running preset selects it instead of creating a duplicate. Preset shells are prefixed with a circle-play icon in both the desktop tab bar and mobile dropdown.
…icc-tmux.json Replace flat preset list with grouped sources (project dir, git root, CWD walk-up). Each source resolves its own .twicc-tmux.json and appears as a labeled section in the navigator. Context is refreshed from DB on each list_windows/create_window to reflect CWD changes. Presets without explicit cwd now default to their config directory.
…aste In tmux mode, SGR mouse tracking causes xterm.js to send all mouse events as escape sequences to tmux instead of handling them locally. This breaks text selection and paste on desktop. A capture-phase mousedown listener on the terminal container blocks all mouse buttons from reaching xterm.js. Left-button gets preventDefault for custom drag selection via terminal.select(). Middle/right-click only get stopPropagation so browser default actions (X11 paste, context menu) flow through to xterm.js's native paste handler. Also removes ClipboardAddon so Ctrl+V reaches the shell (quoted-insert) instead of being intercepted for clipboard paste.
442d5aa to
288b757
Compare
Summary
.twicc-tmux.jsonat the project root (documented indocs/terminal-presets.md)Test plan
🤖 Generated with Claude Code