Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

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

Add support for brev open code/cursor commands and default editor setting

Summary

This PR implements multi-editor support for the brev open command, allowing users to explicitly choose between VSCode and Cursor, and set a default editor preference.

Key Changes:

  • New command syntax: brev open <workspace> code and brev open <workspace> cursor
  • Default editor setting: brev open --set-default <editor> to configure preference
  • Backward compatibility: Existing brev open <workspace> continues to work
  • Personal settings: New infrastructure to store user preferences in ~/.brev/personal_settings.json
  • Cursor utilities: Full cursor support with path detection, extension management, and SSH integration

Breaking Change: Removed the existing --cursor flag (which was non-functional) in favor of the new argument-based approach.

Review & Testing Checklist for Human

⚠️ High Priority (5 items)

  • Verify compilation and basic functionality - Ensure the code compiles and existing brev open <workspace> usage still works
  • Test new command syntax - Verify brev open <workspace> code and brev open <workspace> cursor work correctly
  • Validate Cursor integration - Test that Cursor actually opens correctly and extensions install (I made assumptions about CLI compatibility with VSCode)
  • Check default editor setting - Test brev open --set-default cursor persists preference and brev open <workspace> uses it
  • Verify error handling - Test with missing executables, invalid editor types, and permission issues with settings file

Recommended Test Plan:

  1. Compile and run existing workflows to ensure no regressions
  2. Test each new command variant with both editors installed and missing
  3. Verify settings persistence across CLI sessions
  4. Test edge cases like invalid arguments, corrupted settings file, etc.

Diagram

%%{ init : { "theme" : "default" }}%%
graph TB
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit  
        L3["Context/No Edit"]:::context
    end
    
    OpenCmd["pkg/cmd/open/open.go<br/>Main command logic"]:::major-edit
    UtilPkg["pkg/util/util.go<br/>Editor utilities"]:::major-edit
    FilesPkg["pkg/files/files.go<br/>Settings management"]:::major-edit
    
    PersonalSettings["PersonalSettings struct<br/>Default editor storage"]:::minor-edit
    CursorUtils["Cursor utilities<br/>TryRunCursorCommand, etc."]:::minor-edit
    
    OpenCmd -->|"uses"| UtilPkg
    OpenCmd -->|"reads/writes"| FilesPkg  
    FilesPkg -->|"contains"| PersonalSettings
    UtilPkg -->|"contains"| CursorUtils
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB  
    classDef context fill:#FFFFFF
Loading

Notes

…ting

- Add cursor utilities in pkg/util/util.go with TryRunCursorCommand, InstallCursorExtension, etc.
- Add personal settings management in pkg/files/files.go for storing default editor preference
- Update open command to support 'brev open <workspace> <editor>' syntax
- Add --set-default flag to configure default editor (code or cursor)
- Remove broken --cursor flag in favor of argument-based approach
- Maintain backward compatibility with existing 'brev open <workspace>' usage
- Add proper error handling for invalid editor types and missing executables

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@devin-ai-integration
Copy link
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

- Remove unused store parameter from handleSetDefault function
- Remove unused store parameter from determineEditorType function
- Update function calls to match new signatures

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong
Copy link
Member

theFong commented Jul 19, 2025

When I run the set default flow, I get the following error resulting in me not being able to set default

➜  brev-cli git:(devin/1752610763-add-editor-support) ./brev open --set-default cursor
accepts between 1 and 2 arg(s), received 0

- Replace static cobra.RangeArgs(1, 2) with custom validation function
- Allow 0 arguments when --set-default flag is provided
- Maintain 1-2 argument requirement for normal workspace operations
- Resolves issue where 'brev open --set-default cursor' failed with arg validation error

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong
Copy link
Member

theFong commented Jul 19, 2025

Setting the default ide results in a strange success error message

➜  brev-cli git:(devin/1752610763-add-editor-support) ./brev open --set-default cursor
Default editor set to %!!(string=cursor)s(MISSING)

devin-ai-integration bot and others added 2 commits July 19, 2025 02:35
- Change t.Vprintf to t.Printf to fix format string mismatch
- Resolves malformed success message '%!!(string=cursor)s(MISSING)'
- Success message now displays correctly as 'Default editor set to cursor'

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Terminal type doesn't have Printf method, only Print/Vprint/Vprintf
- Use t.Vprint with string concatenation following codebase patterns
- Resolves build error: 't.Printf undefined'

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong theFong self-assigned this Jul 19, 2025
devin-ai-integration bot and others added 2 commits July 19, 2025 02:43
- Remove extra blank lines on lines 80 and 85 that violated gofumpt formatting rules
- Resolves CI lint failure in 'ci (ubuntu-22.04)' check
- All formatting now complies with gofumpt standards

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Run gofumpt on pkg/cmd/open/open.go to fix all formatting violations
- Remove trailing spaces and fix indentation issues
- Resolves remaining CI lint failure in 'ci (ubuntu-22.04)' check

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong theFong merged commit 53896a9 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.

2 participants