Skip to content

refactor(frontend): organization and workspace APIs move to @agenta/entities - #5888

Draft
ardaerzin wants to merge 1 commit into
oss/drop-reexport-shimsfrom
pkg/entities-organization
Draft

refactor(frontend): organization and workspace APIs move to @agenta/entities#5888
ardaerzin wants to merge 1 commit into
oss/drop-reexport-shimsfrom
pkg/entities-organization

Conversation

@ardaerzin

Copy link
Copy Markdown
Contributor

The organization and workspace API surface and its types move into
@agenta/entities/organization. This is the dependency the Members, Organizations and Access
Controls pages need in the lane above.
Not run in a browser — static gates only (pnpm lint-fix 24/24, tsc --noEmit clean
for @agenta/shared, ui, entities, entity-ui, settings-ui, oss, ee, mobile).

Stacked on oss/drop-reexport-shims; review only this lane's diff.

@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Error Error Aug 11, 2026 5:11am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 95ddcd36-60e1-41d8-ac92-57dc3c104ff8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • The mobile Settings screen now loads and displays projects for the active workspace, including a loading state.
  • Bug Fixes

    • Organization and workspace data requests now provide more consistent handling for unauthorized responses and unavailable data.
  • Refactor

    • Organization, workspace, membership, and invitation functionality now uses shared data models and service interfaces.
  • Chores

    • Improved request configuration support for suppressing selected error notifications and authentication redirects.

Walkthrough

The change centralizes organization and workspace types and APIs in @agenta/entities/organization, updates OSS and EE consumers, adds project loading to mobile settings, and applies several formatting-only cleanup changes.

Changes

Organization entity migration

Layer / File(s) Summary
Organization entity foundation
web/packages/agenta-entities/..., web/packages/agenta-shared/src/api/axios.ts
Adds organization and workspace types, package exports, shared Axios usage, typed request flags, and workspace API integration.
Organization and workspace consumer migration
web/ee/src/components/PostSignupForm/*, web/oss/src/components/..., web/oss/src/lib/..., web/oss/src/state/...
Moves organization and workspace imports to @agenta/entities/organization and removes the legacy local declarations and workspace service.

Mobile settings projects tab

Layer / File(s) Summary
Projects query and rendering
web/mobile/src/features/settings/SettingsScreen.tsx
Passes workspaceId to TabBody, fetches projects when the projects tab is active, and renders project data with loading state.

Formatting and import cleanup

Layer / File(s) Summary
Import and UI formatting cleanup
web/packages/agenta-entity-ui/..., web/packages/agenta-home-ui/..., web/packages/agenta-settings-ui/..., web/packages/agenta-settings/..., web/packages/agenta-entities/src/webhook/atoms.ts
Reformats imports, exports, and UI blocks without changing runtime behavior or exported APIs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SettingsScreen
  participant TabBody
  participant ReactQuery
  participant fetchAllProjects
  SettingsScreen->>TabBody: pass workspaceId
  TabBody->>ReactQuery: enable projects query
  ReactQuery->>fetchAllProjects: request projects for workspace
  fetchAllProjects-->>ReactQuery: return project data
  ReactQuery-->>TabBody: provide project data and loading state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: moving organization and workspace APIs to @agenta/entities.
Description check ✅ Passed The description directly explains the API and type migration, related page support, validation status, and testing scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pkg/entities-organization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
web/mobile/src/features/settings/SettingsScreen.tsx (2)

25-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Use the required query-atom pattern.

The new projects request uses useQuery directly in TabBody. This file matches web/**/*.{ts,tsx}, and the repository rule requires API data fetching through atomWithQuery with TanStack Query. Move the workspace-dependent request into a query atom and read it from TabBody; keep workspaceId in the atom key and use enabled for the Projects tab.

As per coding guidelines, web/**/*.{ts,tsx} API data fetching must use atomWithQuery with TanStack Query.

Also applies to: 81-85

Source: Coding guidelines


81-85: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Set a deliberate refetch policy.

The canonical project query sets staleTime: 60_000 and disables refetch-on-focus, refetch-on-reconnect, and refetch-on-mount. This query leaves the policy at TanStack Query defaults. Re-enabling the query or refocusing the app can therefore cause repeated /projects requests. Add a suitable cache policy when moving this request into a query atom, unless mobile requires live refetching.

Example policy
 const projects = useQuery({
     queryKey: ["projects", workspaceId],
     queryFn: () => fetchAllProjects(workspaceId),
     enabled: tab === "projects",
+    staleTime: 60_000,
+    refetchOnWindowFocus: false,
+    refetchOnReconnect: false,
+    refetchOnMount: false,
 })

As per coding guidelines, query atoms must set a suitable staleTime.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 57ceb79d-0b1f-4be6-a19a-48af74d71248

📥 Commits

Reviewing files that changed from the base of the PR and between 5bd011e and 715b0d8.

📒 Files selected for processing (41)
  • web/ee/src/components/PostSignupForm/PostSignupForm.tsx
  • web/ee/src/components/PostSignupForm/PostSignupHeader.tsx
  • web/ee/src/components/PostSignupForm/PostSignupSkeleton.tsx
  • web/ee/src/components/PostSignupForm/PostSignupSubmitting.tsx
  • web/ee/src/components/PostSignupForm/hooks/usePostSignupReadiness.ts
  • web/mobile/src/features/settings/SettingsScreen.tsx
  • web/oss/src/components/Sidebar/components/ListOfOrgs.tsx
  • web/oss/src/components/Sidebar/components/ListOfProjects.tsx
  • web/oss/src/components/Sidebar/hooks/useProjectOrgSwitcher.ts
  • web/oss/src/components/pages/settings/Organization/General.tsx
  • web/oss/src/components/pages/settings/Organization/index.tsx
  • web/oss/src/components/pages/settings/WorkspaceManage/Modals/InviteUsersModal.tsx
  • web/oss/src/components/pages/settings/WorkspaceManage/WorkspaceManage.tsx
  • web/oss/src/components/pages/settings/WorkspaceManage/cellRenderers.tsx
  • web/oss/src/hooks/usePostAuthRedirect.ts
  • web/oss/src/lib/Types.ts
  • web/oss/src/lib/atoms/organization.ts
  • web/oss/src/lib/helpers/authMethodFilter.ts
  • web/oss/src/lib/hooks/useAnnotations/assets/transformer.ts
  • web/oss/src/lib/hooks/usePreviewEvaluations/types.ts
  • web/oss/src/pages/workspaces/accept.tsx
  • web/oss/src/services/workspace/index.ts
  • web/oss/src/state/org/hooks.ts
  • web/oss/src/state/org/selectors/org.ts
  • web/oss/src/state/org/selectors/orgsDemoFilter.test.ts
  • web/oss/src/state/workspace/atoms/mutations.ts
  • web/oss/src/state/workspace/atoms/selectors.ts
  • web/packages/agenta-entities/package.json
  • web/packages/agenta-entities/src/organization/api.ts
  • web/packages/agenta-entities/src/organization/index.ts
  • web/packages/agenta-entities/src/organization/types.ts
  • web/packages/agenta-entities/src/organization/workspaceApi.ts
  • web/packages/agenta-entities/src/webhook/atoms.ts
  • web/packages/agenta-entity-ui/src/agent/AgentFilesCard.tsx
  • web/packages/agenta-home-ui/src/HomeTaskComposer.tsx
  • web/packages/agenta-settings-ui/src/AccountPage.tsx
  • web/packages/agenta-settings-ui/src/ApiKeysPage.tsx
  • web/packages/agenta-settings-ui/src/index.ts
  • web/packages/agenta-settings/src/api/apiKeys.ts
  • web/packages/agenta-settings/src/index.ts
  • web/packages/agenta-shared/src/api/axios.ts
💤 Files with no reviewable changes (2)
  • web/oss/src/services/workspace/index.ts
  • web/oss/src/lib/Types.ts

Comment on lines +1 to +10
import {axios, getAgentaApiUrl} from "@agenta/shared/api"

import {fetchJson, getBaseUrl} from "../../../lib/api/assets/fetchClient"
import {Org, OrgDetails} from "../../../lib/Types"
import type {
Org,
OrgDetails,
OrganizationDomain,
OrganizationProvider,
OrganizationProviderSettings,
OrganizationUpdatePayload,
} from "./types"

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Use Fern resource accessors and validate API responses.

These modules add shared frontend API implementations with raw Axios. This bypasses the required per-resource Fern accessors and does not validate response payloads at the API boundary.

  • web/packages/agenta-entities/src/organization/api.ts#L1-L10: add or use organization Fern accessors from @agenta/sdk/resources; validate each response with safeParseWithLogging.
  • web/packages/agenta-entities/src/organization/workspaceApi.ts#L1-L8: add or use workspace Fern accessors from @agenta/sdk/resources; pass query values through {queryParams: {...}} and validate each response with safeParseWithLogging.

As per coding guidelines, “Frontend API code must use per-resource Fern client accessors from @agenta/sdk/resources, never raw axios,” and API boundaries must use safeParseWithLogging.

📍 Affects 2 files
  • web/packages/agenta-entities/src/organization/api.ts#L1-L10 (this comment)
  • web/packages/agenta-entities/src/organization/workspaceApi.ts#L1-L8

Source: Coding guidelines

…ntities

Members, Organizations and Access & Security all need org and workspace data, and
none of it was reachable from a package. The two service modules move to
@agenta/entities/organization, which is what /m has to import from — it cannot
reach @/oss/*.

The org and workspace TYPES had been declared in oss/lib/Types and are now
declared once, in the package. That mattered: two structurally different
`Workspace` types made jotai-tanstack-query give up on inferring the org query,
which showed up as 69 `NonNullable<TQueryFnData>` errors across 19 files that had
nothing to do with the move.

Two reads used the app's fetch client, which a package cannot reach; they now use
the shared axios instance like the rest, keeping their empty-not-throw contract.
`getProjectValues()` becomes a read of `projectIdAtom`, which both apps hydrate.

The `_ignoreError` / `_skipAuthUpgradeRedirect` request flags are now declared on
AxiosRequestConfig in @agenta/shared/api, so the 20 call sites that carried
`as any` to set them no longer need the cast.

Also fixes /m's Projects tab, which was passing a hardcoded empty array and so
could only ever render its empty state.

Gates: lint 24/24, tsc 0 across entities, oss, ee and mobile.
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.

1 participant