Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor session management #1810

Merged
merged 89 commits into from
May 22, 2024
Merged

Refactor session management #1810

merged 89 commits into from
May 22, 2024

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented May 15, 2024

Big goals in this PR:

  • Support multiple concurrent sessions (from different browsers, for now)
  • Full support for different runtimes (e.g. the E2B runtime)
  • Ability to restore sessions even after a server restart

A few things in here:

  • Pass file operations to the runtime
    • Previously we were listing files on the local machine
  • Change the auth handshake
    • Previously we weren't great about authenticating all API calls
    • Now the websocket sends a JWT token back (with the sid) as the first message, and that gets sent in all subsequent calls
  • Change up server-side session management
    • Mostly deleted code here
    • Removed the extra session/message serialization (EventStream will handle this now)

Testing

I'd love for folks to play with this locally to make sure it's running smoothly. I've found a few edge cases (like clearing local storage and starting fresh).

docker run \
  --pull=always \
  -it  \
  -e SANDBOX_USER_ID=$(id -u) \
  -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
  -v $WORKSPACE_BASE:/opt/workspace_base \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -p 3000:3000 \
  --add-host host.docker.internal:host-gateway \
  ghcr.io/opendevin/opendevin:1810-merge

@rbren
Copy link
Collaborator Author

rbren commented May 21, 2024

Yup! I've been chatting with @johnnyaug to get that done here: #1448

We're mostly waiting on this PR.

I'd also like to see multi-session in the same browser, which we have some designs for.

Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked through! It's a lot of code, but nothing jumped out at me as being wrong, so LGTM.

I also downloaded and tested, and everything worked as expected. Thanks for all the work on this @rbren !

@assertion
Copy link
Contributor

Awesome work, this is a very big improvement on session management!

Copy link
Collaborator

@li-boxuan li-boxuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really love the fact that this PR contributes net negative lines of code!

LGTM in general, and most of my comments are small/local issues/nitpicks, not design/framework related:

frontend/src/services/api.ts Show resolved Hide resolved
frontend/src/services/api.ts Outdated Show resolved Hide resolved
frontend/src/services/api.ts Outdated Show resolved Hide resolved
frontend/src/services/session.ts Outdated Show resolved Hide resolved
frontend/src/services/fileService.ts Show resolved Hide resolved
opendevin/server/session/agent.py Show resolved Hide resolved
opendevin/server/session/agent.py Show resolved Hide resolved
opendevin/server/session/agent.py Show resolved Hide resolved
opendevin/server/session/agent.py Outdated Show resolved Hide resolved
opendevin/server/session/session.py Show resolved Hide resolved
rbren and others added 2 commits May 22, 2024 14:23
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
@rbren rbren enabled auto-merge (squash) May 22, 2024 18:23
@rbren rbren merged commit 5bdacf7 into main May 22, 2024
25 checks passed
@rbren rbren deleted the rb/api-sessions branch May 22, 2024 18:33
super-dainiu pushed a commit to super-dainiu/OpenDevin that referenced this pull request May 23, 2024
* refactor session mgmt

* defer file handling to runtime

* add todo

* refactor sessions a bit more

* remove messages logic from FE

* fix up socket handshake

* refactor frontend auth a bit

* first pass at redoing file explorer

* implement directory suffix

* fix up file tree

* close agent on websocket close

* remove session saving

* move file refresh

* remove getWorkspace

* plumb path/code differently

* fix build issues

* fix the tests

* fix npm build

* add session rehydration

* fix event serialization

* logspam

* fix user message rehydration

* add get_event fn

* agent state restoration

* change history tracking for codeact

* fix responsiveness of init

* fix lint

* lint

* delint

* fix prop

* update tests

* logspam

* lint

* fix test

* revert codeact

* change fileService to use API

* fix up session loading

* delint

* delint

* fix integration tests

* revert test

* fix up access to options endpoints

* fix initial files load

* delint

* fix file initialization

* fix mock server

* fixl int

* fix auth for html

* Update frontend/src/i18n/translation.json

Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>

* refactor sessions and sockets

* avoid reinitializing the same session

* fix reconnect issue

* change up intro message

* more guards on reinit

* rename agent_session

* delint

* fix a bunch of tests

* delint

* fix last test

* remove code editor context

* fix build

* fix any

* fix dot notation

* Update frontend/src/services/api.ts

Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>

* fix up error handling

* Update opendevin/server/session/agent.py

Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>

* Update opendevin/server/session/agent.py

Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>

* Update frontend/src/services/session.ts

Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>

* fix build errs

* fix else

* add closed state

* delint

* Update opendevin/server/session/session.py

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>

---------

Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
Co-authored-by: Graham Neubig <neubig@gmail.com>
Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
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.

None yet

7 participants