Open
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
ffd64a3 to
55b264b
Compare
55b264b to
ae5943b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What's going on?
When a user works on a task, the work happens somewhere, either locally on their machine or in a cloud sandbox. Right now, those two paths are different codepaths. Every feature that touches git, the filesystem, or the shell needs to know which mode it's in, which makes cloud parity with local very difficult.
That's one part of the problem. We also ideally want to be able to run PostHog Code on a bunch of different platforms:
We also have a bunch of data/functionality dependencies:
What are we doing?
To make the above possible we need to split our node server (which we currently run inside electron) into two packages that can run anywhere. To achieve that, we need to get rid of the electron dependencies in the node server.
This makes the first step, by defining a package that all platforms must adhere to, in
packages/platform.We make an initial start at implementing one of those interfaces via
apps/code/platform-adapters/electron-url-launcher.ts. At runtime we inject this into our server. In a browser context we'd injectweb-url-launcher.ts etc.. It's a toy example for the rest of the stack.That's great but aren't you just massively overengineering this?
Fully extracting electron will eventually allow us to split the node server we run in electron into
packages/server, then expose that node server via the modal sandbox over hono with TRPC.This is good because we can then route to either local or the sandbox based on whether the task run is cloud or local, which IN THEORY could make cloud feel identical to local.
It's a bigger lift, but IMO the right way to do this. As far as I can see it's the only way to prevent 50 (and soon more)
if workspace.mode === 'cloud'statements scattered throughout our codebase. Without this, every feature that touches git/shell/files needs a local codepath and a cloud codepath, and that will become more painful as time goes on.Instead we just call
trpc.git.getCurrentBranchand route it to the right spot (either local or a sandbox) based on whether the task run is local or cloud.It also open avenues to supporting other platforms such PostHog Code in the web :) (This is a nice side effect, definitely not the main concern). A more direct benefit is that we could share a lot of the code between PostHog Mobile and PostHog Code desktop
I've spent quite a while thinking about this, and this architecture is loosely based on VSCode's internal structure. Happy to hear feedback