Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add Jupyter support to brev open command

Summary

This PR extends the brev open command to support Jupyter notebooks by adding brev open <instance-id> jupyter. The implementation:

  • Adds EditorJupyter constant and updates all validation logic to include "jupyter" as a valid editor type
  • Implements openJupyter() function that starts port forwarding on port 8888 and opens browser to localhost:8888
  • Extends OpenStore interface to include util.MakeWorkspaceWithMetaStore for port forwarding compatibility
  • Updates help text, examples, and error messages to include Jupyter support
  • Follows existing patterns from the brev notebook command for Jupyter integration

The implementation reuses existing port forwarding infrastructure and browser opening utilities, maintaining consistency with the current codebase architecture.

Review & Testing Checklist for Human

  • Test with live instance: Verify brev open <instance-id> jupyter actually works with a real Brev workspace
  • Test port forwarding timing: Check if 2-second delay is sufficient for port forwarding to establish before browser opens
  • Test error scenarios: Verify behavior when port forwarding fails or Jupyter isn't running on the instance
  • Verify interface compatibility: Ensure OpenStore interface extension doesn't break existing implementations
  • Test browser opening: Confirm browser opening works on different platforms (especially headless environments)

Recommended Test Plan:

  1. Start a Brev workspace with Jupyter installed
  2. Run brev open <workspace> jupyter
  3. Verify browser opens to localhost:8888 and Jupyter is accessible
  4. Test with workspace that doesn't have Jupyter running
  5. Test existing editors still work: brev open <workspace> code

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    OpenCmd["pkg/cmd/open/open.go<br/>Main open command logic"]:::major-edit
    PortForward["pkg/cmd/portforward/portforward.go<br/>Port forwarding utilities"]:::context
    Browser["github.com/pkg/browser<br/>Browser opening library"]:::context
    UtilStore["pkg/cmd/util/util.go<br/>MakeWorkspaceWithMetaStore interface"]:::context
    
    OpenCmd -->|"Uses RunPortforward()"| PortForward
    OpenCmd -->|"Uses OpenURL()"| Browser
    OpenCmd -->|"Extends interface with"| UtilStore
    
    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

  • The openJupyter() function blocks indefinitely with select {} following the pattern from the notebook command
  • Port forwarding runs in a goroutine with error handling that only prints to terminal
  • Interface extension was necessary to satisfy portforward.PortforwardStore requirements
  • Implementation assumes Jupyter will be accessible on port 8888 within the workspace

Link to Devin run: https://app.devin.ai/sessions/fd9c4f3f8e0648e0ade8845094dbb8ef
Requested by: @theFong

- Add EditorJupyter constant and update validation logic
- Update help text and examples to include jupyter option
- Implement openJupyter function with port forwarding on 8888
- Add browser opening functionality using pkg/browser
- Extend OpenStore interface to include MakeWorkspaceWithMetaStore
- Follow existing patterns from notebook command for Jupyter integration

Co-Authored-By: Alec Fong <[email protected]>
@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

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