Skip to content

feat(orgs) : OHE-3303 : expose is_visible on organization listings - #461

Merged
tofarr merged 2 commits into
mainfrom
org-list-is-visible-flag
Sep 22, 2026
Merged

tofarr merged 2 commits into
mainfrom
org-list-is-visible-flag

Conversation

@tofarr

@tofarr tofarr commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

HIDE_PERSONAL_WORKSPACES is a presentation policy today, but each client re-derives it — and they disagree.

The backend never filters personal orgs out of GET /api/organizations. OrgResponse.is_personal is computed from str(org.id) == user_id, and the only three reads of the env var are the web-client config injector, the model, and the default-org bootstrap. So the list endpoint advertises personal workspaces to every caller.

The enterprise web app filters them client-side in use-organizations.ts. Agent Canvas (OpenHands/OpenHands) does not: its useAllCloudOrganizations returns the unfiltered list in cookie mode and deliberately renders a personal row, then builds /settings?org=<personal> links. Because Canvas's OptionService.getConfig() is a hardcoded stub ({ hide_llm_settings, hide_users_page }) and never fetches /api/v1/web-client/config, it cannot see hide_personal_workspaces and cannot filter even if it wanted to.

The result is a deep link that the cloud silently accepts, strips, and ignores — no switch, no feedback. This change gives every client one server-provided answer instead of each one guessing.

Summary

  • Add is_visible: bool = True to OrgResponse, threaded through from_org(...) as a new parameter that defaults to True, so switch/get/create callers are unaffected.
  • Compute it in list_user_orgs: an org is invisible when HIDE_PERSONAL_WORKSPACES is on and the user has at least one team org. The personal org stays visible when it is the user's only workspace, preserving the existing zero-org guard.
  • Add the optional is_visible field to the frontend Organization type.
  • Add three route tests covering flag-on-with-team, personal-only, and flag-off.

Issue Number

N/A — no tracking issue.

How to Test

The new tests run in CI (the suite needs Docker/Postgres):

uv run pytest tests/unit/server/routes/test_orgs.py -k "is_visible or hides_personal or stays_visible or flag_disabled" -q

Docker is not usable in my sandbox, so I could not run the DB-backed suite: the root conftest.py unconditionally starts a Postgres testcontainer. My tests are DB-free (they patch OrgService.get_user_orgs_paginated and build Org objects in memory), so I exercised the real handler directly via TestClient and confirmed all three scenarios:

  • flag on, personal + team -> personal is_visible=False, team is_visible=True
  • flag on, personal only -> personal is_visible=True (never zero selectable workspaces)
  • flag off, personal + team -> all is_visible=True

Pre-commit (ruff, ruff-format, mypy) passes on all changed backend files; npm run lint:fix and npm run build pass on the frontend.

Video/Screenshots

N/A — API-only change, no UI behavior changes in this PR. use-organizations.ts keeps its existing client-side filter, so this is a pure capability addition with no behavior change for the enterprise web app.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • Not a filter, deliberately. Hidden orgs stay in the list, marked invisible. They remain real memberships the backend will switch into and serve GET /api/organizations/{id} for, so marking rather than dropping avoids a new "invisible but addressable" contract and does not strand existing members parked on a personal org.
  • Env parsing. It reuses get_default_org_config().hide_personal_workspaces, which accepts 1/true/yes/on. Note the web-client injector still uses == 'true', so HIDE_PERSONAL_WORKSPACES=1 currently exposes the flag to the frontend but is not treated as enabled in default_org_service. Pre-existing divergence, left out of scope.
  • Not fixed here (follow-ups). (1) The ?org= deep link to a hidden personal org is still a silent no-op in frontend/src/utils/org/org-url-param.ts — it returns "handled" without switching and with no feedback. (2) Canvas must read is_visible (and skip invisible orgs when building ?org= links) to benefit; that change is in the OpenHands/OpenHands repo.

@tofarr can click here to continue refining the PR


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-6f763dd

Personal workspaces hidden by HIDE_PERSONAL_WORKSPACES are no longer
skipped inconsistently per client. The org list now reports an is_visible
flag per org so any client (enterprise web app, agent-canvas, future
clients) can honour the deployment policy without re-deriving it.

The org is only marked invisible, not dropped: it remains a real
membership that can be switched to and addressed. Personal orgs stay
visible when they are the user's only workspace, so a user is never left
with nothing selectable.
@github-actions github-actions Bot added the type: feat A new feature label Sep 22, 2026
@tofarr
tofarr marked this pull request as ready for review September 22, 2026 14:48

@hieptl hieptl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! 🙏

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  server/routes
  org_models.py
  orgs.py 97, 212-227
Project Total  

This report was generated by python-coverage-comment-action

@tofarr
tofarr merged commit e140854 into main Sep 22, 2026
20 checks passed
@tofarr
tofarr deleted the org-list-is-visible-flag branch September 22, 2026 14:59
@tofarr tofarr changed the title feat(orgs): expose is_visible on organization listings feat(orgs): OHE-3303 : expose is_visible on organization listings Sep 22, 2026
@tofarr tofarr changed the title feat(orgs): OHE-3303 : expose is_visible on organization listings feat(orgs) : expose is_visible on organization listings Sep 22, 2026
@tofarr tofarr changed the title feat(orgs) : expose is_visible on organization listings feat(orgs) : OHE-3303 : expose is_visible on organization listings Sep 22, 2026
@openhands-release-bot openhands-release-bot Bot added the released: 1.63.0 Shipped in 1.63.0 label Sep 22, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.63.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.63.0 Shipped in 1.63.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants