refactor(frontend): organization and workspace APIs move to @agenta/entities - #5888
refactor(frontend): organization and workspace APIs move to @agenta/entities#5888ardaerzin wants to merge 1 commit into
Conversation
|
@coderabbitai review |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change centralizes organization and workspace types and APIs in ChangesOrganization entity migration
Mobile settings projects tab
Formatting and import cleanup
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
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
5065141 to
e32f4af
Compare
f72ae58 to
1b681c8
Compare
e32f4af to
5bd011e
Compare
1b681c8 to
715b0d8
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
web/mobile/src/features/settings/SettingsScreen.tsx (2)
25-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftUse the required query-atom pattern.
The new projects request uses
useQuerydirectly inTabBody. This file matchesweb/**/*.{ts,tsx}, and the repository rule requires API data fetching throughatomWithQuerywith TanStack Query. Move the workspace-dependent request into a query atom and read it fromTabBody; keepworkspaceIdin the atom key and useenabledfor the Projects tab.As per coding guidelines,
web/**/*.{ts,tsx}API data fetching must useatomWithQuerywith TanStack Query.Also applies to: 81-85
Source: Coding guidelines
81-85: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winSet a deliberate refetch policy.
The canonical project query sets
staleTime: 60_000and 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/projectsrequests. 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
📒 Files selected for processing (41)
web/ee/src/components/PostSignupForm/PostSignupForm.tsxweb/ee/src/components/PostSignupForm/PostSignupHeader.tsxweb/ee/src/components/PostSignupForm/PostSignupSkeleton.tsxweb/ee/src/components/PostSignupForm/PostSignupSubmitting.tsxweb/ee/src/components/PostSignupForm/hooks/usePostSignupReadiness.tsweb/mobile/src/features/settings/SettingsScreen.tsxweb/oss/src/components/Sidebar/components/ListOfOrgs.tsxweb/oss/src/components/Sidebar/components/ListOfProjects.tsxweb/oss/src/components/Sidebar/hooks/useProjectOrgSwitcher.tsweb/oss/src/components/pages/settings/Organization/General.tsxweb/oss/src/components/pages/settings/Organization/index.tsxweb/oss/src/components/pages/settings/WorkspaceManage/Modals/InviteUsersModal.tsxweb/oss/src/components/pages/settings/WorkspaceManage/WorkspaceManage.tsxweb/oss/src/components/pages/settings/WorkspaceManage/cellRenderers.tsxweb/oss/src/hooks/usePostAuthRedirect.tsweb/oss/src/lib/Types.tsweb/oss/src/lib/atoms/organization.tsweb/oss/src/lib/helpers/authMethodFilter.tsweb/oss/src/lib/hooks/useAnnotations/assets/transformer.tsweb/oss/src/lib/hooks/usePreviewEvaluations/types.tsweb/oss/src/pages/workspaces/accept.tsxweb/oss/src/services/workspace/index.tsweb/oss/src/state/org/hooks.tsweb/oss/src/state/org/selectors/org.tsweb/oss/src/state/org/selectors/orgsDemoFilter.test.tsweb/oss/src/state/workspace/atoms/mutations.tsweb/oss/src/state/workspace/atoms/selectors.tsweb/packages/agenta-entities/package.jsonweb/packages/agenta-entities/src/organization/api.tsweb/packages/agenta-entities/src/organization/index.tsweb/packages/agenta-entities/src/organization/types.tsweb/packages/agenta-entities/src/organization/workspaceApi.tsweb/packages/agenta-entities/src/webhook/atoms.tsweb/packages/agenta-entity-ui/src/agent/AgentFilesCard.tsxweb/packages/agenta-home-ui/src/HomeTaskComposer.tsxweb/packages/agenta-settings-ui/src/AccountPage.tsxweb/packages/agenta-settings-ui/src/ApiKeysPage.tsxweb/packages/agenta-settings-ui/src/index.tsweb/packages/agenta-settings/src/api/apiKeys.tsweb/packages/agenta-settings/src/index.tsweb/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
| 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" |
There was a problem hiding this comment.
🗄️ 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 withsafeParseWithLogging.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 withsafeParseWithLogging.
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.
5bd011e to
1727819
Compare
715b0d8 to
53d070f
Compare
The organization and workspace API surface and its types move into
@agenta/entities/organization. This is the dependency the Members, Organizations and AccessControls pages need in the lane above.
Not run in a browser — static gates only (
pnpm lint-fix24/24,tsc --noEmitcleanfor
@agenta/shared,ui,entities,entity-ui,settings-ui,oss,ee,mobile).Stacked on
oss/drop-reexport-shims; review only this lane's diff.