Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 5 additions & 3 deletions lib/application/auth/tenant-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Loading