Skip to content

Add tmux support to brev open command#243

Merged
theFong merged 2 commits into
mainfrom
devin/1752953399-tmux-support
Jul 20, 2025
Merged

Add tmux support to brev open command#243
theFong merged 2 commits into
mainfrom
devin/1752953399-tmux-support

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 19, 2025

Copy link
Copy Markdown
Contributor

Add tmux support to brev open command

Summary

This PR extends the brev open command to support tmux as a new editor type alongside VSCode, Cursor, and Windsurf. Users can now run brev open <instance> tmux to connect to a persistent tmux session on their remote workspace.

Key features added:

  • New EditorTmux constant and validation across all editor type checks
  • openTmux() function with intelligent session management (reconnects to existing sessions or creates new ones)
  • ensureTmuxInstalled() for automatic tmux installation on remote instances
  • Session naming convention: brev-<workspace-identifier> for predictable, conflict-free sessions
  • Interactive SSH execution for seamless tmux experience

Implementation follows existing patterns:

  • Same validation and error handling structure as VSCode/Cursor/Windsurf
  • Consistent help text and CLI interface updates
  • Proper error wrapping and security annotations

Review & Testing Checklist for Human

  • Security Review: Verify SSH command construction in openTmux() and ensureTmuxInstalled() is safe from injection attacks, especially with user-controlled sshAlias and path parameters
  • End-to-end Testing: Test brev open <instance> tmux with a real workspace to verify session creation, reconnection, and working directory handling
  • Installation Testing: Test tmux installation on instances without tmux, and verify graceful failure on non-Ubuntu systems or restricted environments
  • Session Management: Verify that brev-<workspace> session naming works correctly and doesn't conflict with existing user tmux sessions
  • Error Scenarios: Test failure cases like SSH connection issues, tmux installation failures, and session creation problems

Recommended test plan:

  1. Test with fresh instance (no tmux) - should auto-install and create session
  2. Test reconnection - should attach to existing brev-<workspace> session
  3. Test with manual tmux sessions already running - should not conflict
  4. Test error cases - network issues, permission problems, non-Ubuntu systems

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    CLI["brev open <instance> tmux"]
    OpenCmd["pkg/cmd/open/open.go<br/>runOpenCommand()"]
    Determine["determineEditorType()"]
    OpenByType["openEditorByType()"]
    OpenTmux["openTmux()"]:::major-edit
    EnsureTmux["ensureTmuxInstalled()"]:::major-edit
    SSH["Interactive SSH<br/>exec.Command()"]
    
    CLI --> OpenCmd
    OpenCmd --> Determine
    Determine --> OpenByType
    OpenByType --> OpenTmux
    OpenTmux --> EnsureTmux
    OpenTmux --> SSH
    
    Constants["Editor Constants<br/>EditorTmux = 'tmux'"]:::major-edit
    Validation["Validation Functions<br/>handleSetDefault()<br/>determineEditorType()"]:::major-edit
    HelpText["Help Text & Examples"]:::minor-edit
    
    OpenCmd --> Constants
    OpenCmd --> Validation
    OpenCmd --> HelpText
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit
        L3["Context/No Edit"]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

Architectural differences from other editors:

  • VSCode/Cursor/Windsurf use vscode-remote://ssh-remote+ URIs and local editor execution
  • tmux uses direct interactive SSH execution (ssh -t <alias> 'tmux ...')
  • No extension installation needed (unlike other editors)

Session management strategy:

  • Session names: brev-<workspace-identifier> (predictable and discoverable)
  • Automatic reconnection to existing sessions
  • Working directory preservation for new sessions
  • Sessions are lost on workspace restart (expected behavior)

Platform considerations:

  • tmux installation assumes Ubuntu/Debian with apt-get
  • Could fail on other distributions or restricted environments
  • Error handling provides feedback but may not cover all edge cases

Link to Devin run: https://app.devin.ai/sessions/2735e7dbd59c4a90ae870a0e00f46668
Requested by: Alec Fong (@theFong)

- Add EditorTmux constant and update all validation functions
- Implement openTmux() with session management (brev-<workspace> naming)
- Add ensureTmuxInstalled() for automatic tmux installation
- Follow same patterns as VSCode/Cursor/Windsurf implementations
- Support session reconnection and creation with proper working directory
- Handle tmux-specific error cases and installation requirements
- Use interactive SSH execution for seamless tmux session access

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@theFong

theFong commented Jul 19, 2025

Copy link
Copy Markdown
Member

for the tmux session lets just call it "brev" no alias. That way if we change the name in the future we always connect to the same session.

- Change session name from 'brev-<workspace>' to just 'brev'
- Ensures users always connect to same session regardless of workspace name changes
- Addresses PR feedback from @theFong

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong theFong merged commit 5b555fb into main Jul 20, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant