<https://github.com/OpenHands/OpenHands/pull/11265...
# dev-pr-review
q
https://github.com/OpenHands/OpenHands/pull/11265 - introducing orgs to OpenHands SAAS, this is an intermediate step we're calling phase 1. Its in a place where people can start reviewing the changes, early feedback is appreciated while I continue refining the PR The planned phases are • Phase 1: introduce orgs structure in BE where every user is a personal workspace org by default (there should be no change existing product behavior while the new structure is introduced) • Phase 2: introduce helper utils for orgs for parity with existing app (automatically migrating default LLM models, determine super admin role, checking BE work to simplify self-hosted installs/transitions to orgs) • Phase 3: integrate FE with BE (FE to create new orgs, FE to manage org members, new BE api routes to interact with orgs) WRT to phase 1, still working on • resolving some failing tests • adding new ones to cover migration logic • figuring out how to set defaults for llm provider on the org level
🔥 1
c
"Treating each user like a mini-org" sounds like the right approach! I'm curious what was the idea behind moving all of Settings table into the 'org' table... thinky spin Is it performance? I'm skimming around and I notice that the code / constants / vars embed this notion of "personal workspace" that you mention here too. I wonder if that's important? It sounds... good, to me, but first impression is muddled by the fact that "workspace" is an overloaded term 😓
👀 1
q
I'm curious what was the idea behind moving all of Settings table into the 'org' table
We want an org admin to be able to set some reasonable defaults (llm key, model) which are inherited by all org members Figuring out when it makes sense for the org member to be able to override the defaults, and how much flexibility they have (e.g allow list of models, vs choose any model provider)
I'm skimming around and I notice that the code / constants / vars embed this notion of "personal workspace" that you mention here too. I wonder if that's important?
It sounds... good, to me, but first impression is muddled by the fact that "workspace" is an overloaded term
Yeah nice catch! I think from the user perspective users can have a "personal workspace" (an org that only belongs to them and they're the admin) This is similar to GitHub in the sense that you have personal account repos versus org repos Agreed that in our BE there shouldn't be such a distinction, everything should be an org
c
I was just thinking, application-level settings seem like a different thing than account settings, and I'm wondering if the db table needs to be the same or they could be separate and what are the consequences. 🤔 Sorry if it's obvious to you, idk. I guess performance may justify it, since you don't link two tables in the normal use... but no, you still do, regular use is: user clicks on stuff, you get enough information to know what their user selections were and if they're possible from org?
q
EDIT: just to clarify, what is an example for application settings vs account setting? Also I believe atm the settings table is moved into
org_member
table There are a couple of settings field we duplicate in the
org
table for reasonable defaults org wide (e.g
llm_api_key
which the admin may want to share with all org members)
Also based on your feedback I have a separate PR that renames
user_secrets
table to
custom_secrets
(ideally makes it in before org changes are introduced) https://github.com/OpenHands/OpenHands/pull/11525
c
Like account name, account email, contact name (for orgs), are account settings. Max iterations, LLM model, are application settings. Maybe one way to look at it is that application settings are typically 1) account-agnostic 2) present in OH (plus / minus a few specifics like solvability) So a db model could be like • user table • org table • settings table (app) • (org-defaults or org-overrides would come down to some table referencing those thinky spin ) Idk, what am I missing, WDYT?
q
Ah I see, makes sense to split the account settings This was the model we were building. I think the only thing I'm concerned about is that one user can be a part of multiple orgs, so we'd want a way for memberships across many orgs to be grouped under one OH user thonk
c
Yes… looking at this model, I think I would split the application settings out of both org and user 🤔 • could you have the case where orgs want a key for a role, and another key for another role? • or any other app setting • not sure, there’s a difference between defaults and overrides • “Settings” (as in application settings) seems easier to reason about
Re: one user in many orgs • somehow related to, user with their own settings 9/10, and from org only 1/10 (org only wanted to override LLM key, lets say) Could you just say, make a new account for the new org? Orgs with SSO will want that anyway. thinky spin
q
I think I would split the application settings out of both org and user
Makes sense! Will rework this
Could you just say, make a new account for the new org?
cc @flaky-jordan-67349 for SSO related things To me this was a product related question which influenced the underlying implementation. The product team decided that it would make sense for every user to have a personal org by default and ability to create/join new ones as needed This means a user can be part of their company's org plan, and have a personal org with a separate subscription as well
Makes less sense for SSO/self-hosted though thonk
f
self-hosted could use it to separate departments/teams.
c
How about SSO?
@quick-window-91705 Just to note quickly, sorry if I express myself poorly, please do ask whatever you like I think we might have two other reasons why
Settings
makes more sense to be its own object: •
UserContext
DI
◦
org_id
will be needed on endpoints somehow ◦ the way we do it in V1 is compute and use
UserContext
as a FastAPI dependency ◦ it's already there, Tim has implemented it, and use with DI, in the new V1 endpoints ◦ maybe we can add
org_id
, or maybe a new
Context
mini-class for org ◦ (draft reference, I sent OpenHands-GPT-5 last night to split it and figure out how much have we implemented of an older code design proposal I made) ◦ the idea here is
org
has its own authy primitives (
org_id
) and we are treating authy primitives for user this way already; it makes sense to me to be similar ("org account") • separating
Settings
for OH and for the Cloud
: ◦ the rough way I visualize it is like
Copy code
- Settings
	- Settings (OH)
		- all settings
		- filter()
		- append()
	- SaasSettings
		- build incoming: filter(); append()
The reasoning for the second one is in this proposal. It could be almost indifferent that a relational db has
account+settings
in the same table, but I'm not so sure in this case, because the SaaS uses an ORM: it gives the object, which then affects the code logic, and idk, it seems to me it's becoming sort of difficult to conceptualize it as the extension of OH Settings cleanly