Initial API proposal for Ruby Environments extension#9
Conversation
40de55e to
0cba52b
Compare
vinistock
left a comment
There was a problem hiding this comment.
What do you think about breaking this down into smaller chunks? If we have bandwidth to design the API, let's do it step by step and make sure we avoid shortcomings of the current implementation.
For example:
- Better callbacks for when re-activation will happen
- Better ways to handle error scenarios gracefully (one of the biggest pain points of the LSP)
- Clearer status communication about degraded status or what caused failures to help users debug their setup
I think it will be easier if we discuss each step one by one
7c41bad to
a00ef35
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
b57951c to
71bf6b2
Compare
|
Done. I broke the PR in multiple stacks. This is the API proposal now |
71bf6b2 to
3c1a046
Compare
3c1a046 to
4e4d276
Compare
| @@ -0,0 +1,24 @@ | |||
| { | |||
There was a problem hiding this comment.
Do we need a package just for the types? From what I can tell, it's more common for VS Code extensions that export an API to just tell users to copy a d.ts file with the license written on top.
It's easier than maintaining an extra dependency.
There was a problem hiding this comment.
I debated that but copying code can cause a lot of problems. The dependency only has types, and releasing is as easy as the publish.yml workflow.
It also make easier for consumers to know which version of the extension will work with the API they are trying to console since the type definition library version will match the version of the extension.
| return {}; | ||
| return { | ||
| activate: async (_workspace: vscode.WorkspaceFolder | undefined) => {}, | ||
| getRuby: () => null, |
There was a problem hiding this comment.
Instead of having a getRuby function, how about we return the Ruby object from the activate call?
We can cache the Ruby objects internally in the extension by workspace URI, so that multiple extensions requesting it don't produce different objects.
There was a problem hiding this comment.
I think we can do that. Take a look at https://app.graphite.com/github/pr/Shopify/ruby-environments/12/Support-multiple-workspace-folders-with-independent-Ruby-environments. It supports multiple workspace folders, and a new method to activate the workspace fodler was added. We can change it to return the Ruby object and remove the getRuby(). What do you think?

Summary
This PR proposes the initial API design for the Ruby Environments VS Code extension. The goal is to establish the public interface that other extensions (like Ruby LSP) will use to obtain activated Ruby environments.
This is an API proposal focused on design and discussion—not a full feature implementation. The actual version manager integrations and environment detection logic will be added in subsequent PRs.
Proposed Public API
activate(workspace): Request Ruby environment activation for a specific workspacegetRuby(): Retrieve the current Ruby definition (success or error state)onDidRubyChange: Event to subscribe to Ruby environment changesType Definitions
RubyEnvironment: Represents a successfully activated Ruby (version, JIT compilers, env vars, gem paths)RubyError: Represents a failed activationRubyDefinition: Union type for success/error statesRubyChangeEvent: Event payload for environment changesJitType: Enum for supported JIT compilers (YJIT, ZJIT)Next Steps
Once the API design is agreed upon: