Skip to content

feat: multi-team support with team-scoped resources and setup flow#18

Open
Jacxk wants to merge 9 commits intomainfrom
feat/COOL-49-team-selection
Open

feat: multi-team support with team-scoped resources and setup flow#18
Jacxk wants to merge 9 commits intomainfrom
feat/COOL-49-team-selection

Conversation

@Jacxk
Copy link
Owner

@Jacxk Jacxk commented Jan 28, 2026

Add team selection and filter all Coolify resources by the selected team.

Team selection

  • New setup step at /setup/team; users must pick a team before entering the app.
  • Team can be changed later in Settings → Team Selection.
  • Selected team is stored in AsyncStorage (TEAM_STORAGE_KEY).

Team-scoped data

  • All list and single fetchers filter by current team via filterResourceByTeam / filterResourcesByTeam in lib/utils.ts.
  • Applied to: Applications, Databases, Services, Servers, Projects, Resources, Private Keys.
  • Single-resource queries may return null when the resource is not in the selected team.

Other

  • lib/storage.ts: getCurrentTeam() helper.
  • Root index redirects to /setup/team when no team is selected.

Note

Medium Risk
Core data-fetching hooks now filter and may return null/empty lists based on selected team, which can surface new null handling needs across screens. Setup/navigation flow changes could block entry if team selection or storage state misbehaves.

Overview
Adds multi-team support by introducing a persisted current team (TEAM_STORAGE_KEY) in useSetup, gating app entry until a team is chosen, and adding a new /setup/team step plus a Team selector in Settings.

Scopes most resource fetchers (applications, databases, services, servers, projects, generic resources, private keys) to the selected team via new filterResourceByTeam/filterResourcesByTeam helpers; single-resource queries and useResource now type as T | null when the resource is outside the current team. Also tightens optimistic-update utilities (typed onOptimisticUpdateError, safer context handling, and consistent onOptimisticUpdateSettled usage) and adjusts project list fetching to hydrate team-aware project details before returning results.

Written by Cursor Bugbot for commit 11325cc. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}
}),
);
const validProjects = projectsWithTeam.filter((p) => p !== null);
Copy link

Choose a reason for hiding this comment

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

Blocking N+1 queries cause slow project list loading

High Severity

The getProjects function now uses await Promise.all() to fetch each project individually via getProject(), blocking until all N requests complete. Previously, prefetchQuery initiated background fetches without blocking the list return. This N+1 query pattern causes the project list to load significantly slower as the number of projects increases.

Fix in Cursor Fix in Web

if (team === "NO_TEAM_SELECTED") return <Redirect href="/setup/team" />;
if (setupComplete) return <Redirect href="/main" />;
else return <Redirect href="/setup" />;
return <Redirect href="/setup" />;
Copy link

Choose a reason for hiding this comment

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

Fresh users incorrectly redirected to team selection

High Severity

The routing logic checks for team === "NO_TEAM_SELECTED" before checking setupComplete. For fresh users who haven't configured the server yet, both setupComplete is false and team is "NO_TEAM_SELECTED". This causes them to be redirected to /setup/team instead of /setup, where useTeams() attempts to fetch from an unconfigured server, resulting in a "Server address not found" error. The setupComplete check needs to come before the team check.

Fix in Cursor Fix in Web

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