Skip to content

Add Windsurf IDE support to brev open command#242

Merged
theFong merged 2 commits into
mainfrom
devin/1752946109-add-windsurf-ide-support
Jul 19, 2025
Merged

Add Windsurf IDE support to brev open command#242
theFong merged 2 commits into
mainfrom
devin/1752946109-add-windsurf-ide-support

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

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

Add Windsurf IDE support to brev open command and fix lint issues

Summary

This PR adds Windsurf IDE support to the brev open command, following the existing pattern used for VS Code and Cursor. Users can now run brev open instance windsurf to open their Brev instances in Windsurf IDE with automatic SSH remote connection setup.

Additionally, this PR fixes lint issues in the codebase by refactoring two functions that exceeded complexity limits:

  • openEditorWithSSH function was reduced from 43 to ~35 statements by extracting helper functions
  • runOpenCommand cyclomatic complexity was reduced from 18 to ~12 by consolidating repeated error handling

Key additions:

  • EditorWindsurf constant and Windsurf support in editor type validation
  • Windsurf-specific utility functions for extension installation and command execution
  • Platform-specific executable path detection for Windows, macOS, and Linux
  • Automatic installation of required extensions (ms-vscode-remote.remote-ssh, ms-toolsai.jupyter-keymap, ms-python.python)

Refactoring improvements:

  • Extracted getEditorName() helper to eliminate duplicated switch statements
  • Extracted handlePathError() helper to reduce repeated UpdateUser pattern
  • Extracted openEditorByType() helper to simplify editor opening logic
  • Extracted validateRemoteWorkspace() helper to reduce function complexity

Review & Testing Checklist for Human

  • Test Windsurf opening on different platforms - Install Windsurf locally and verify brev open instance windsurf works correctly on Windows/macOS/Linux
  • Verify extension auto-installation - Check that required VS Code extensions are automatically installed in Windsurf and handle installation failures gracefully
  • Test existing VS Code/Cursor functionality - Ensure brev open instance code and brev open instance cursor still work as expected after refactoring
  • Verify PATH error handling - Test scenarios where windsurf executable is not in PATH and confirm error messages are helpful
  • Test cross-platform executable detection - Verify Windsurf is found in common installation locations across different operating systems

Recommended test plan:

  1. Install Windsurf IDE on your local machine
  2. Set up a Brev instance and test brev open instance windsurf
  3. Verify SSH remote connection establishes properly
  4. Check that required extensions are installed automatically
  5. Test fallback behavior when Windsurf is not installed or not in PATH
  6. Regression test VS Code and Cursor opening to ensure no breakage

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    CLI["brev open command<br/>pkg/cmd/open/open.go"]:::major-edit
    UTIL["Utility functions<br/>pkg/util/util.go"]:::major-edit
    
    CLI --> |"calls"| getEditorName["getEditorName()<br/>helper function"]:::major-edit
    CLI --> |"calls"| handlePathError["handlePathError()<br/>helper function"]:::major-edit
    CLI --> |"calls"| openEditorByType["openEditorByType()<br/>helper function"]:::major-edit
    CLI --> |"calls"| validateRemoteWorkspace["validateRemoteWorkspace()<br/>helper function"]:::major-edit
    
    openEditorByType --> |"windsurf case"| openWindsurf["openWindsurf()<br/>new function"]:::major-edit
    openEditorByType --> |"existing"| openVsCode["openVsCode()"]:::context
    openEditorByType --> |"existing"| openCursor["openCursor()"]:::context
    
    UTIL --> |"new"| TryRunWindsurfCommand["TryRunWindsurfCommand()"]:::major-edit
    UTIL --> |"new"| InstallWindsurfExtension["InstallWindsurfExtension()"]:::major-edit
    
    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

  • URI Scheme Assumption: The implementation assumes Windsurf uses the same vscode-remote://ssh-remote+ URI scheme as VS Code and Cursor. This should be verified with actual Windsurf documentation.
  • Platform Coverage: Added executable paths for common Windsurf installation locations, but coverage may not be exhaustive across all Linux distributions and installation methods.
  • Extension Compatibility: Assumes Windsurf is compatible with VS Code extensions, which should be validated.

Session Info:

- Add EditorWindsurf constant and validation logic
- Add Windsurf utility functions following Cursor pattern
- Add openWindsurf function with vscode-remote URI support
- Add Windsurf extension installation support
- Update help text and examples to include Windsurf
- Add Windows and macOS installation paths for Windsurf
- Convert if-else chains to switch statements for better code quality

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
Copy link
Copy Markdown
Member

theFong commented Jul 19, 2025

can you fix the lint issues?

- Extract getEditorName helper to eliminate duplicated switch statements
- Extract handlePathError helper to reduce repeated UpdateUser pattern
- Extract openEditorByType helper to simplify editor opening logic
- Extract validateRemoteWorkspace helper to reduce function complexity
- Reduce openEditorWithSSH from 43 to ~35 statements
- Reduce runOpenCommand cyclomatic complexity from 18 to ~12
- Maintain all existing Windsurf IDE functionality
- Fix gofumpt formatting issues

Fixes lint errors:
- Function 'openEditorWithSSH' has too many statements (43 > 40) (funlen)
- cyclomatic complexity 18 of func runOpenCommand is high (> 16) (gocyclo)

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong theFong merged commit b6ac0d4 into main Jul 19, 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