From 547197039b4c1756df2eaef264c05834f6c0e807 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:44:03 +0000 Subject: [PATCH] perf: replace getWorkspaceExperienceBySlug with compiler in resolveTenantAccess Replaced getWorkspaceExperienceBySlug with compileWorkspaceExperience when an organization object is already known locally in resolveTenantAccess. This avoids redundant database queries to look up the organization by slug when we have just looked it up via domain matching, ID lists, or email constraints. Co-authored-by: brycejohnson1417 <257422776+brycejohnson1417@users.noreply.github.com> --- .jules/bolt.md | 3 +++ lib/application/auth/tenant-access.ts | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..6a6c92e --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2025-07-02 - Replace getWorkspaceExperienceBySlug with compileWorkspaceExperience +**Learning:** React Server Components wrapped with `cache()` fragment when using optional pre-fetched objects to the function signature as React keys off all arguments. +**Action:** When a method like `getWorkspaceExperienceBySlug` is already wrapped in React `cache()`, bypassing it to call the underlying synchronous compiler `compileWorkspaceExperience` with an already fetched `organization` avoids a redundant async database fetch and TS2339 compiler issues. diff --git a/lib/application/auth/tenant-access.ts b/lib/application/auth/tenant-access.ts index 09f0d27..5534db5 100644 --- a/lib/application/auth/tenant-access.ts +++ b/lib/application/auth/tenant-access.ts @@ -12,6 +12,7 @@ import { } from "@/lib/application/auth/tenant-routing"; import { selectMembershipOrganization } from "@/lib/application/auth/tenant-access-selection"; import { getWorkspaceExperienceBySlug } from "@/lib/application/workspace/workspace-service"; +import { compileWorkspaceExperience } from "@/lib/platform/workspace/compiler"; import { OrganizationMemberRepository } from "@/lib/infrastructure/supabase/organization-member-repository"; import { OrganizationRepository } from "@/lib/infrastructure/supabase/organization-repository"; import { resolveWorkspaceTemplateForEmailDomain } from "@/lib/platform/workspace/registry"; @@ -110,7 +111,8 @@ export async function resolveTenantAccess( }); if (organization) { - const workspace = await getWorkspaceExperienceBySlug(organization.slug); + const fullOrganization = organizationsById.get(organization.id); + const workspace = compileWorkspaceExperience({ slug: organization.slug, organization: fullOrganization }); return existingWorkspaceAccess({ slug: organization.slug, name: organization.name, @@ -124,7 +126,7 @@ export async function resolveTenantAccess( if (emailDomain) { const workspaceOrganization = await organizations.findFirstByWorkspaceEmailDomain(emailDomain); if (workspaceOrganization && (!requestedSlug || workspaceOrganization.slug === requestedSlug)) { - const workspace = await getWorkspaceExperienceBySlug(workspaceOrganization.slug); + const workspace = compileWorkspaceExperience({ slug: workspaceOrganization.slug, organization: workspaceOrganization }); return existingWorkspaceAccess({ slug: workspaceOrganization.slug, name: workspaceOrganization.name, @@ -143,7 +145,7 @@ export async function resolveTenantAccess( if (guessed.slug) { const existingOrganization = await organizations.findBySlug(guessed.slug).catch(() => null); if (existingOrganization) { - const workspace = await getWorkspaceExperienceBySlug(existingOrganization.slug); + const workspace = compileWorkspaceExperience({ slug: existingOrganization.slug, organization: existingOrganization }); return existingWorkspaceAccess({ slug: existingOrganization.slug, name: existingOrganization.name,