-
Notifications
You must be signed in to change notification settings - Fork 127
feat: add multi-session terminal support #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
snirt
wants to merge
7
commits into
coder:main
Choose a base branch
from
snirt:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add ability to run multiple concurrent Claude Code terminal sessions with session management, smart ESC handling, and session-aware selection tracking. New commands: - ClaudeCodeNew: Create a new terminal session - ClaudeCodeSessions: Show session picker (supports fzf-lua) - ClaudeCodeSwitch: Switch to session by number - ClaudeCodeCloseSession: Close session by number or active session New features: - Smart ESC handling: double-tap ESC to exit terminal mode, single ESC sends to terminal (configurable via esc_timeout) - Session-aware selection tracking and message routing - OSC title handler for capturing terminal title changes - Configurable terminal keymaps (terminal.keymaps.exit_terminal) New modules: - lua/claudecode/session.lua: Session lifecycle management - lua/claudecode/terminal/osc_handler.lua: Terminal title detection
Author
|
Found a bug in this PR - killing the claude-code using ctrl-c closes the instance, but does not remove the session record from the session list. I'll fix it soon. |
Add jobresize() calls to notify the terminal job of window dimensions when switching between sessions. This fixes the cursor appearing in the wrong position and line shifting after session switch. The terminal job needs to know its window dimensions to correctly calculate cursor position and line wrapping. Without this, the terminal renders based on stale window state from the previous session.
- Add clickable tabbar for session switching (floating and winbar modes) - Support left-click to switch sessions, middle-click to close - Add close button (✕) on each tab with same background as tab - Add new session button (+) for creating new sessions - Add scroll wheel support to cycle sessions in floating tabbar - Add mouse selection tracking (LeftRelease/LeftDrag) for better selection capture - Fix intentional close handling to suppress exit error on X click - Add config validation for terminal.tabs options
… available When a Claude terminal session exits (e.g., via Ctrl-C), the window now stays open and switches to display another available session instead of closing entirely. This provides a smoother multi-session experience. Changes: - Add session switching logic to TermClose handlers in both providers - Disconnect old terminal instance from window before buffer switch - Check session existence before destroying to prevent double-destruction - Add close_session_keep_window() for explicit session switching
Add dedicated window_manager module that owns the single terminal window. This separates window lifecycle from buffer lifecycle, fixing issues where: - Creating new sessions would reset window to default size - Switching between tabs could cause window duplication - Closing tabs could leave windows in wrong positions Changes: - Add window_manager.lua: singleton that manages THE terminal window - Refactor snacks.lua: create buffers only, delegate window to manager - Refactor native.lua: simplified buffer-only management - Update terminal.lua: initialize window_manager, improve tab navigation - New tab now selects the created session - Closing tab selects previous tab (or next if first)
- Add "Fork Features" section highlighting multi-session support and visual tab bar features unique to this fork - Add "Recommended Configuration" with practical floating window setup - Update all repo references from coder/claudecode.nvim to snirt/claudecode.nvim - Add multi-session keymaps to installation example - Update CHANGELOG with new features and bug fixes
Fixes #1 - Add defense-in-depth PID recovery from sessions and terminal buffers - Kill entire process tree (not just direct children) using process groups - Follow up with SIGKILL for any survivors after graceful SIGTERM - Add retry mechanism for PID tracking in snacks.lua (handles delayed job_id) - Track PIDs in external terminal provider - Add VimLeavePre autocmd to call cleanup_all() before server stops - Validate cleanup_strategy config option Tests: - Unit tests for defense-in-depth PID recovery - Integration tests with real processes verifying actual termination
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add ability to run multiple concurrent Claude Code terminal sessions with session management, smart ESC handling, and session-aware selection tracking.
New commands:
New features:
New modules: