Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Add space sharing setting (Together / Independently) (#3096)
Luke Vella0603fdeab14a
diff --git a/apps/docs/docs.json b/apps/docs/docs.jsonindex ff336d7d7..a39bcc9c1 100644--- a/apps/docs/docs.json+++ b/apps/docs/docs.json@@ -27,6 +27,7 @@"spaces/introduction","spaces/managing-seats","spaces/members",+ "spaces/collaboration","spaces/billing","spaces/custom-branding"]diff --git a/apps/docs/images/spaces/collaboration-settings.png b/apps/docs/images/spaces/collaboration-settings.pngnew file mode 100644index 000000000..b7b32e20cBinary files /dev/null and b/apps/docs/images/spaces/collaboration-settings.png differdiff --git a/apps/docs/spaces/collaboration.mdx b/apps/docs/spaces/collaboration.mdxnew file mode 100644index 000000000..30022b4ab--- /dev/null+++ b/apps/docs/spaces/collaboration.mdx@@ -0,0 +1,57 @@+---+icon: "handshake"+title: "Collaboration"+description: "Choose whether members of your space work together or independently."+---++Every space has a collaboration setting that controls what members can see of each other's work.++- **Collaboration on** — members work together. Everyone in the space can see and manage everything created in it, including polls and events created before collaboration was turned on.+- **Collaboration off** (the default) — members work independently. Everyone, including admins and the owner, only sees what they create themselves.++This makes spaces useful in two different ways: as a shared workspace for a team that schedules together, or as a way for an organization to give many people Pro access under one subscription while keeping each person's scheduling private.++<Frame>+ <img+ src="/images/spaces/collaboration-settings.png"+ alt="Collaboration settings page with the Team collaboration switch"+ />+</Frame>++## Turning collaboration on or off++<Steps>+ <Step title="Open your space settings">+ Go to **Settings → General** and find the **Collaboration** section. You+ need to be an admin of the space.+ </Step>+ <Step title="Toggle Team collaboration">+ Turn the **Team collaboration** switch on or off, then press **Save**.+ </Step>+</Steps>++<Warning>+Turning collaboration on gives members access to everything already in the space, not just things created afterwards.+</Warning>++Collaboration is a Pro feature. You can turn it off at any time, but turning it on requires an active Pro subscription.++## What it affects++Collaboration controls visibility between members inside the space: polls, events, and anything else created in it.++It does not affect sharing with people outside the space. Invite links and participant pages work the same in both modes, so anyone you share a poll with can always vote on it.++## Roles and visibility++Roles grant management capabilities, not visibility:++- **Owner** — manages billing, members, and space settings+- **Admin** — manages members and space settings+- **Member** — creates and manages their own polls and events++Whether anyone can see other members' work is decided only by the collaboration setting, and it applies to every role equally.++## Defaults++New spaces start with collaboration off. Spaces that already had multiple members (or pending invitations) when this setting was introduced have collaboration on, so nothing changed for existing teams.diff --git a/apps/docs/spaces/introduction.mdx b/apps/docs/spaces/introduction.mdxindex 82b378e57..21dc23735 100644--- a/apps/docs/spaces/introduction.mdx+++ b/apps/docs/spaces/introduction.mdx@@ -10,7 +10,7 @@ Spaces are Rallly's solution for team and organizational collaboration. Instead<Card title="Key Benefits" icon="rocket">- **Centralized Billing**: One subscription covers all team members- - **Team Collaboration**: Share and organize polls within your organization+ - **Optional Collaboration**: Choose whether members work together or keep their scheduling private- **Member Management**: Invite and manage team members from one place- **Seat-Based Pricing**: Pay only for the seats you need and scale as you grow</Card>@@ -37,6 +37,9 @@ Ready to create your first space? Here's what you need to know:<Card title="Member Management" icon="users" href="/spaces/members">Invite and manage your team members</Card>+ <Card title="Collaboration" icon="handshake" href="/spaces/collaboration">+ Choose whether members work together or independently+ </Card><Card title="Billing & Seats" icon="credit-card" href="/spaces/billing">Understand seat-based pricing and billing</Card>diff --git a/apps/docs/spaces/members.mdx b/apps/docs/spaces/members.mdxindex 604d86285..60c92653e 100644--- a/apps/docs/spaces/members.mdx+++ b/apps/docs/spaces/members.mdx@@ -6,31 +6,33 @@ description: "Learn how to invite, manage, and organize team members in your Ral## Understanding Member Roles-Rallly spaces have a clear hierarchy of roles and permissions:+Roles control what someone can manage in a space:<CardGroup cols={2}><Card title="Owner" icon="crown">**Full Control**- - Access to all polls and events- Member management- Space settings and configuration- - Billing management- - Seat management+ - Billing and seat management- Can delete space</Card><Card title="Admin" icon="shield">**Team Management**- - Access to all polls and events- Member management- Space settings and configuration</Card><Card title="Member" icon="user">- **Collaboration**- - Access to all polls and events-+ **Scheduling**+ - Creates and manages their own polls and events</Card></CardGroup>+<Info>+Roles do not control who can see whose polls and events — that is decided by+the space's [collaboration setting](/spaces/collaboration), which applies to+every role equally.+</Info>+## Inviting New Members### Prerequisitesdiff --git a/apps/web/biome.json b/apps/web/biome.jsonindex d2d0d6e26..dec500abf 100644--- a/apps/web/biome.json+++ b/apps/web/biome.json@@ -287,7 +287,6 @@"src/app/*/(auth)/login/verify/page.tsx","src/app/*/(optional-space)/layout.tsx","src/app/*/(space)/(dashboard)/layout.tsx",- "src/app/*/(space)/(dashboard)/polls/page.tsx","src/app/*/(space)/settings/api-keys/components/api-keys-list.tsx","src/app/*/(space)/settings/api-keys/page.tsx","src/app/*/(space)/settings/billing/page.tsx",diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex 18b3ffe72..446d90e3b 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -138,6 +138,8 @@"clockPreferences": "Clock preferences","clockPreferencesDescription": "Set your preferred time zone and time format.","closePoll": "Close",+ "collaboration": "Collaboration",+ "collaborationDescription": "How members work in this space","colors": "Colors","colorsDescription": "Primary colors used for theming","commandMenu": "Command menu",@@ -799,6 +801,7 @@"syncCalendarSuccess": "Calendar synced","teamCollaboration": "Team collaboration","teamCollaborationDescription": "Invite team members with centralized billing",+ "teamCollaborationSettingDescription": "Allow all members of this space to see and manage each other's polls, events and other content.","temporaryEmailNotAllowed": "Temporary or disposable email addresses are not allowed.","theme": "Theme","themeDark": "Dark",diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/dashboard-home.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/dashboard-home.tsxindex f15ba4de2..eced14fc0 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/dashboard-home.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/dashboard-home.tsx@@ -26,6 +26,7 @@ export async function DashboardHome({seatCount,hasNoAccounts,canManageBilling,+ canManageMembers,}: {openPollCount: number;upcomingEventCount: number;@@ -33,6 +34,7 @@ export async function DashboardHome({seatCount: number;hasNoAccounts: boolean;canManageBilling: boolean;+ canManageMembers: boolean;}) {const { t, i18n } = await getTranslation();@@ -154,28 +156,30 @@ export async function DashboardHome({</TileTitle></Tile>- <Tile render={<HoverPrefetchLink href="/members" />}>- <MembersPageIcon />- <TileTitle>- <Trans- t={t}- i18n={i18n}- ns="app"- i18nKey="members"- defaults="Members"- />- </TileTitle>- <TileDescription>- <Trans- t={t}- i18n={i18n}- ns="app"- i18nKey="memberCount"- defaults="{count, plural, =0 {No members} one {1 member} other {# members}}"- values={{ count: memberCount }}- />- </TileDescription>- </Tile>+ {canManageMembers ? (+ <Tile render={<HoverPrefetchLink href="/members" />}>+ <MembersPageIcon />+ <TileTitle>+ <Trans+ t={t}+ i18n={i18n}+ ns="app"+ i18nKey="members"+ defaults="Members"+ />+ </TileTitle>+ <TileDescription>+ <Trans+ t={t}+ i18n={i18n}+ ns="app"+ i18nKey="memberCount"+ defaults="{count, plural, =0 {No members} one {1 member} other {# members}}"+ values={{ count: memberCount }}+ />+ </TileDescription>+ </Tile>+ ) : null}{isFeatureEnabled("billing") && canManageBilling ? (<Tile render={<HoverPrefetchLink href="/settings/billing" />}>diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/events/events-page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/events/events-page.tsxindex c6934b796..7087165d7 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/events/events-page.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/events/events-page.tsx@@ -20,6 +20,7 @@ import {} from "@/components/page-layout";import { SearchInput } from "@/components/search-input";import type { Status } from "@/features/scheduled-event/schema";+import { useSpace } from "@/features/space/client";import { Trans, useTranslation } from "@/i18n/client";import { trpc } from "@/trpc/client";import { EventsInfiniteList } from "./events-infinite-list";@@ -102,11 +103,19 @@ function EventsEmptyState({ status }: { status: Status }) {function EventsPageContent() {const searchParams = useSearchParams();const { t } = useTranslation();+ const { data: space } = useSpace();const [{ data: members }] = trpc.spaces.listMembers.useSuspenseQuery();+ // Filtering by member is pointless when the space restricts this member+ // to their own events.+ const showMemberFilter = space.shared;const { status, q, member } = eventsSearchParamsSchema.parse(Object.fromEntries(searchParams.entries()),);+ // Ignore a member URL param when the filter is hidden — a bookmarked+ // ?member= URL would otherwise show an empty list with no visible+ // control to clear it.+ const visibleMember = showMemberFilter ? member : undefined;return (<PageContainer>@@ -123,12 +132,12 @@ function EventsPageContent() {defaultValue: "Search events by title...",})}/>- <MemberSelector members={members} />+ {showMemberFilter ? <MemberSelector members={members} /> : null}</div><EventsInfiniteListstatus={status}search={q}- member={member}+ member={visibleMember}emptyState={<EventsEmptyState status={status || "upcoming"} />}/></EventsTabbedView>diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsxindex 67d7f0fb1..9e56de7ed 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/page.tsx@@ -29,6 +29,7 @@ export default async function Page() {seatCount={space.seatCount}hasNoAccounts={hasNoAccounts}canManageBilling={ability.can("manage", "Billing")}+ canManageMembers={space.role === "admin"}/>);}diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/polls/page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/polls/page.tsxindex 5a3a86d95..765da8670 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/polls/page.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/polls/page.tsx@@ -1,7 +1,6 @@import { dehydrate, HydrationBoundary } from "@tanstack/react-query";import type { Metadata } from "next";-import { getPollStatusCounts } from "@/features/poll/data";-import { getActiveSpace } from "@/features/space/loaders";+import { loadPollStatusCounts } from "@/features/poll/loaders";import { getTranslation } from "@/i18n/server";import { createPrivateSSRHelper } from "@/trpc/server/create-ssr-helper";import { PollsPage } from "./polls-page";@@ -13,11 +12,10 @@ export default async function Page(props: {const searchParams = await props.searchParams;const { status, q, member } = searchParamsSchema.parse(searchParams);- const space = await getActiveSpace();const helpers = await createPrivateSSRHelper();const [counts] = await Promise.all([- getPollStatusCounts({ spaceId: space.id }),+ loadPollStatusCounts(),helpers.spaces.listMembers.prefetch(),helpers.polls.infiniteChronological.prefetchInfinite({status,diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/polls/polls-page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/polls/polls-page.tsxindex 1deffe839..e87368c4a 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/polls/polls-page.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/polls/polls-page.tsx@@ -23,6 +23,7 @@ import {import { SearchInput } from "@/components/search-input";import { PollsInfiniteList } from "@/features/poll/components/polls-infinite-list";import type { PollStatus } from "@/features/poll/schema";+import { useSpace } from "@/features/space/client";import { Trans, useTranslation } from "@/i18n/client";import { trpc } from "@/trpc/client";import { PollsTabbedView } from "./polls-tabbed-view";@@ -86,13 +87,21 @@ function PollsEmptyState() {export function PollsPage({ counts }: { counts: Record<PollStatus, number> }) {const searchParams = useSearchParams();const { t } = useTranslation();+ const { data: space } = useSpace();const [{ data: members }] = trpc.spaces.listMembers.useSuspenseQuery();+ // Filtering by member is pointless when the space restricts this member+ // to their own polls.+ const showMemberFilter = space.shared;const { status, q, member } = searchParamsSchema.parse(Object.fromEntries(searchParams.entries()),);+ // Ignore a member URL param when the filter is hidden — a bookmarked+ // ?member= URL would otherwise show an empty list with no visible+ // control to clear it.+ const visibleMember = showMemberFilter ? member : undefined;- const hasFilters = Boolean(q || member);+ const hasFilters = Boolean(q || visibleMember);const showClosedPollsPointer =status === "open" && !hasFilters && counts.closed > 0;@@ -119,12 +128,12 @@ export function PollsPage({ counts }: { counts: Record<PollStatus, number> }) {defaultValue: "Search polls by title...",})}/>- <MemberSelector members={members} />+ {showMemberFilter ? <MemberSelector members={members} /> : null}</div><PollsInfiniteListstatus={status}search={q}- member={member}+ member={visibleMember}emptyState={showClosedPollsPointer ? (<NoOpenPollsEmptyState closedCount={counts.closed} />diff --git a/apps/web/src/app/[locale]/(space)/settings/components/sidebar.tsx b/apps/web/src/app/[locale]/(space)/settings/components/sidebar.tsxindex 1949bc0af..580300275 100644--- a/apps/web/src/app/[locale]/(space)/settings/components/sidebar.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/components/sidebar.tsx@@ -103,6 +103,8 @@ export function AccountSidebarMenu() {export function SpaceSidebarMenu() {const { t } = useTranslation();const pathname = usePathname();+ const { data: space } = useSpace();+ const isAdmin = space.role === "admin";const isBillingEnabled = useFeatureFlag("billing");const isEventTypesEnabled = useFeatureFlag("eventTypes");const menuItems: {@@ -119,16 +121,22 @@ export function SpaceSidebarMenu() {icon: <BoltIcon />,href: "/settings/general",},- {- id: "members",- label: t("members", { defaultValue: "Members" }),- icon: <UsersIcon />,- href: "/members",- suffix: <ArrowUpRightIcon className="ml-auto" />,- onClick: () => {- posthog?.capture("space_settings:members_link_click");- },- },+ // The members page is a management surface; members meet the roster+ // through in-context pickers instead.+ ...(isAdmin+ ? [+ {+ id: "members",+ label: t("members", { defaultValue: "Members" }),+ icon: <UsersIcon />,+ href: "/members",+ suffix: <ArrowUpRightIcon className="ml-auto" />,+ onClick: () => {+ posthog?.capture("space_settings:members_link_click");+ },+ },+ ]+ : []),...(isEventTypesEnabled? [{diff --git a/apps/web/src/app/[locale]/(space)/settings/general/components/collaboration-section.tsx b/apps/web/src/app/[locale]/(space)/settings/general/components/collaboration-section.tsxnew file mode 100644index 000000000..33ebd5562--- /dev/null+++ b/apps/web/src/app/[locale]/(space)/settings/general/components/collaboration-section.tsx@@ -0,0 +1,143 @@+"use client";++import { cn } from "@rallly/ui";+import { Button } from "@rallly/ui/button";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldLabel,+} from "@rallly/ui/field";+import { toast } from "@rallly/ui/sonner";+import { Switch } from "@rallly/ui/switch";+import { UsersIcon } from "lucide-react";+import React from "react";+import {+ PageSection,+ PageSectionContent,+ PageSectionDescription,+ PageSectionHeader,+ PageSectionTitle,+} from "@/components/page-layout";+import { SettingIcon } from "@/components/setting-icon";+import { showPayWall, useIsFree } from "@/features/billing/client";+import { ProBadge } from "@/features/billing/components/pro-badge";+import { updateSpaceSharedAction } from "@/features/space/actions";+import { useSpace } from "@/features/space/client";+import { Trans, useTranslation } from "@/i18n/client";+import { useSafeAction } from "@/lib/safe-action/client";++export function CollaborationSection({+ disabled = false,+}: {+ disabled?: boolean;+}) {+ const { data: space } = useSpace();+ const { t } = useTranslation();+ const isFree = useIsFree();++ const updateShared = useSafeAction(updateSpaceSharedAction);++ // Optimistic value shown until the post-action router refresh delivers+ // the updated space data; reverts automatically if the action fails.+ const [optimisticShared, setOptimisticShared] = React.useOptimistic(+ space.shared,+ );++ // Toggling changes what every member can see the moment it saves, so the+ // switch only stages the change; nothing persists until Save is pressed.+ const [pendingShared, setPendingShared] = React.useState<boolean | null>(+ null,+ );++ const checked = pendingShared ?? optimisticShared;+ const isDirty = pendingShared !== null && pendingShared !== optimisticShared;+ const showSaveButton = isDirty && !disabled;++ const handleToggle = (nextShared: boolean) => {+ if (nextShared && isFree) {+ showPayWall({ from: "space-collaboration" });+ return;+ }++ setPendingShared(nextShared === optimisticShared ? null : nextShared);+ };++ const handleSave = () => {+ if (pendingShared === null) {+ return;+ }++ const next = pendingShared;++ React.startTransition(async () => {+ setOptimisticShared(next);+ setPendingShared(null);+ const result = await updateShared.executeAsync({ shared: next });++ if (!result?.serverError && !result?.validationErrors) {+ toast.success(t("saved", { defaultValue: "Saved" }));+ }+ });+ };++ return (+ <PageSection variant="card">+ <PageSectionHeader>+ <PageSectionTitle>+ <Trans i18nKey="collaboration" defaults="Collaboration" />+ </PageSectionTitle>+ <PageSectionDescription>+ <Trans+ i18nKey="collaborationDescription"+ defaults="How members work in this space"+ />+ </PageSectionDescription>+ </PageSectionHeader>+ <PageSectionContent>+ <FieldGroup>+ <Field orientation="horizontal">+ <SettingIcon>+ <UsersIcon />+ </SettingIcon>+ <FieldContent>+ <FieldLabel htmlFor="space-shared">+ <Trans+ i18nKey="teamCollaboration"+ defaults="Team collaboration"+ />+ {space.tier !== "pro" && <ProBadge />}+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="teamCollaborationSettingDescription"+ defaults="Allow all members of this space to see and manage each other's polls, events and other content."+ />+ </FieldDescription>+ </FieldContent>+ <div className="flex items-center gap-3">+ {/* Kept mounted so the row doesn't shift when it appears;+ `invisible` also keeps it out of the tab order. */}+ <Button+ size="sm"+ variant="primary"+ onClick={handleSave}+ loading={updateShared.isExecuting}+ className={cn(!showSaveButton && "invisible")}+ >+ <Trans i18nKey="save" defaults="Save" />+ </Button>+ <Switch+ id="space-shared"+ checked={checked}+ onCheckedChange={handleToggle}+ disabled={disabled || updateShared.isExecuting}+ />+ </div>+ </Field>+ </FieldGroup>+ </PageSectionContent>+ </PageSection>+ );+}diff --git a/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsx b/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsxindex 8759a64fc..2db617f2b 100644--- a/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsx@@ -29,6 +29,7 @@ import {import { useSpace } from "@/features/space/client";import { useAuthedUser } from "@/features/user/client";import { Trans } from "@/i18n/client";+import { CollaborationSection } from "./components/collaboration-section";import { CustomBrandingSection } from "./components/custom-branding-section";import { DeleteSpaceButton } from "./components/delete-space-button";import { LeaveSpaceButton } from "./components/leave-space-button";@@ -68,6 +69,7 @@ export function GeneralSettingsPageClient() {</Alert>) : null}<CustomBrandingSection disabled={!isAdmin} />+ <CollaborationSection disabled={!isAdmin} />{!isOwner || canDeleteSpace ? (<PageSection variant="card"><PageSectionHeader>diff --git a/apps/web/src/features/billing/client.tsx b/apps/web/src/features/billing/client.tsxindex 4f40fcc10..1681d8c7b 100644--- a/apps/web/src/features/billing/client.tsx+++ b/apps/web/src/features/billing/client.tsx@@ -38,6 +38,7 @@ export type PayWallTrigger = {| "custom-branding"| "api-keys"| "space-members"+ | "space-collaboration"| "billing-settings"| "sidebar";setting?: string;diff --git a/apps/web/src/features/event-types/data.ts b/apps/web/src/features/event-types/data.tsindex cb25e42ef..8e48ae2a1 100644--- a/apps/web/src/features/event-types/data.ts+++ b/apps/web/src/features/event-types/data.ts@@ -6,6 +6,7 @@ import { createLogger } from "@rallly/logger";import type { EventTypeDTO } from "@/features/event-types/types";import type { Location } from "@/lib/location";import { locationSchema } from "@/lib/location";+import type { SpaceContentScope } from "@/lib/tenant-scope";const logger = createLogger("event-types/data");@@ -42,10 +43,13 @@ export function createEventTypeDTO(};}-export async function getEventTypes(spaceId: string): Promise<EventTypeDTO[]> {+export async function getEventTypes(+ scope: SpaceContentScope,+): Promise<EventTypeDTO[]> {const rows = await prisma.eventType.findMany({where: {- spaceId,+ spaceId: scope.spaceId,+ ...(scope.createdBy && { hostId: scope.createdBy }),deleted: false,},orderBy: { updatedAt: "desc" },diff --git a/apps/web/src/features/navigation/client.tsx b/apps/web/src/features/navigation/client.tsxindex 56805d61c..8feea7b5f 100644--- a/apps/web/src/features/navigation/client.tsx+++ b/apps/web/src/features/navigation/client.tsx@@ -10,6 +10,7 @@ import {} from "lucide-react";import { usePathname } from "next/navigation";import React from "react";+import { useSpace } from "@/features/space/client";import { useTranslation } from "@/i18n/client";import { useFeatureFlag } from "@/lib/feature-flags/client";@@ -38,6 +39,11 @@ export const useSpaceMenu = () => {const { t } = useTranslation();const pathname = usePathname();const isCalendarsEnabled = useFeatureFlag("calendars");+ const { data: space } = useSpace();+ // The members page is a management surface (inviting, roles, the+ // collaboration setting); members meet the roster through in-context+ // pickers instead.+ const isAdmin = space.role === "admin";const config = React.useMemo<NavigationConfig>(() => ({sections: [@@ -76,18 +82,22 @@ export const useSpaceMenu = () => {},]: []),- {- id: "members",- label: t("members", { defaultValue: "Members" }),- href: "/members",- icon: UsersIcon,- isActive: pathname === "/members",- },+ ...(isAdmin+ ? [+ {+ id: "members",+ label: t("members", { defaultValue: "Members" }),+ href: "/members",+ icon: UsersIcon,+ isActive: pathname === "/members",+ },+ ]+ : []),],},],}),- [pathname, t, isCalendarsEnabled],+ [pathname, t, isCalendarsEnabled, isAdmin],);return React.useMemo(diff --git a/apps/web/src/features/poll/data.ts b/apps/web/src/features/poll/data.tsindex c277aad65..22db3ae23 100644--- a/apps/web/src/features/poll/data.ts+++ b/apps/web/src/features/poll/data.ts@@ -3,19 +3,23 @@ import "server-only";import type { PollStatus, Prisma } from "@rallly/database";import { prisma } from "@rallly/database";import { effectiveSpaceMemberWhere } from "@/features/space/member/utils";-import type { AuthorizedSpaceId } from "@/features/space/types";+import type {+ AuthorizedSpaceId,+ SpaceContentScope,+} from "@/features/space/types";export async function getPoll({pollId,- spaceId,+ scope,}: {pollId: string;- spaceId: AuthorizedSpaceId;+ scope: SpaceContentScope;}) {return prisma.poll.findFirst({where: {id: pollId,- spaceId,+ spaceId: scope.spaceId,+ ...(scope.createdBy && { userId: scope.createdBy }),deleted: false,},select: {@@ -247,7 +251,7 @@ type PollFilters = {pageSize?: number;q?: string;member?: string;- spaceId: string;+ scope: SpaceContentScope;};export const getPolls = async ({@@ -256,15 +260,23 @@ export const getPolls = async ({member,page = 1,pageSize = 20,- spaceId,+ scope,}: PollFilters) => {+ // The scope restriction and the member filter both apply: a restricted+ // member asking for someone else's polls gets an empty result.+ const creatorIds = [scope.createdBy, member].filter((id): id is string =>+ Boolean(id),+ );+// Build the where clause based on filtersconst where: Prisma.PollWhereInput = {- spaceId,+ spaceId: scope.spaceId,deletedAt: null,...(status && { status }),...(q && { title: { contains: q, mode: "insensitive" } }),- ...(member && { userId: member }),+ ...(creatorIds.length > 0 && {+ AND: creatorIds.map((userId) => ({ userId })),+ }),};// Get total count and paginated polls in a transaction@@ -341,14 +353,15 @@ export const getPolls = async ({};export const getPollStatusCounts = async ({- spaceId,+ scope,}: {- spaceId: AuthorizedSpaceId;+ scope: SpaceContentScope;}) => {const res = await prisma.poll.groupBy({by: ["status"],where: {- spaceId,+ spaceId: scope.spaceId,+ ...(scope.createdBy && { userId: scope.createdBy }),deletedAt: null,},_count: {@@ -392,15 +405,19 @@ export async function canUserManagePoll(}if (poll.spaceId) {- const space = await prisma.spaceMember.findFirst({+ const membership = await prisma.spaceMember.findFirst({where: {spaceId: poll.spaceId,...effectiveSpaceMemberWhere({ userId: user.id }),},+ select: {+ space: { select: { shared: true } },+ },});- if (space) {- // user a member of this space+ if (membership?.space.shared) {+ // Members manage each other's polls only in a shared space. Uniform+ // across roles: admins are members here too.return true;}}@@ -415,7 +432,14 @@ export const hasPollAdminAccess = async (pollId: string, userId: string) => {deleted: false,OR: [{ userId: userId },- { space: { members: { some: effectiveSpaceMemberWhere({ userId }) } } },+ // Members reach each other's polls only in a shared space. Uniform+ // across roles: admins are members here too.+ {+ space: {+ shared: true,+ members: { some: effectiveSpaceMemberWhere({ userId }) },+ },+ },],},select: {diff --git a/apps/web/src/features/poll/loaders.ts b/apps/web/src/features/poll/loaders.tsindex 987c6627c..a10954457 100644--- a/apps/web/src/features/poll/loaders.ts+++ b/apps/web/src/features/poll/loaders.ts@@ -3,16 +3,16 @@ import "server-only";import { notFound } from "next/navigation";import { cache } from "react";import { getPoll, getPollStatusCounts } from "@/features/poll/data";-import { getActiveSpace } from "@/features/space/loaders";+import { getActiveSpaceContentScope } from "@/features/space/loaders";export const loadPollStatusCounts = cache(async () => {- const space = await getActiveSpace();- return getPollStatusCounts({ spaceId: space.id });+ const scope = await getActiveSpaceContentScope();+ return getPollStatusCounts({ scope });});export const loadPoll = cache(async (pollId: string) => {- const space = await getActiveSpace();- const poll = await getPoll({ pollId, spaceId: space.id });+ const scope = await getActiveSpaceContentScope();+ const poll = await getPoll({ pollId, scope });if (!poll) {notFound();diff --git a/apps/web/src/features/scheduled-event/data.ts b/apps/web/src/features/scheduled-event/data.tsindex 714260256..c4da09716 100644--- a/apps/web/src/features/scheduled-event/data.ts+++ b/apps/web/src/features/scheduled-event/data.ts@@ -6,6 +6,9 @@ import { parseConferencing } from "@/features/conferencing/data";import type { Conferencing } from "@/features/conferencing/schema";import { parseLocation } from "@/features/location/data";import type { Location } from "@/features/location/schema";+// From lib, not features/space: space imports this feature for its loaders,+// so importing space back would create a feature cycle.+import type { SpaceContentScope } from "@/lib/tenant-scope";import type { Status } from "./schema";import { pastScheduledEventWhere, upcomingScheduledEventWhere } from "./utils";@@ -280,12 +283,12 @@ function transformEvent(event: RawEventData) {// Common base where clause builderfunction buildBaseWhere(- spaceId: string,+ scope: SpaceContentScope,search?: string,member?: string,): Prisma.ScheduledEventWhereInput {const baseWhere: Prisma.ScheduledEventWhereInput = {- spaceId,+ spaceId: scope.spaceId,deletedAt: null,};@@ -293,8 +296,14 @@ function buildBaseWhere(baseWhere.title = { contains: search, mode: "insensitive" };}- if (member) {- baseWhere.userId = member;+ // The scope restriction and the member filter both apply: a restricted+ // member asking for someone else's events gets an empty result.+ const creatorIds = [scope.createdBy, member].filter((id): id is string =>+ Boolean(id),+ );++ if (creatorIds.length > 0) {+ baseWhere.AND = creatorIds.map((userId) => ({ userId }));}return baseWhere;@@ -302,15 +311,16 @@ function buildBaseWhere(// Get upcoming events (confirmed events in the future)export async function getUpcomingEventCount({- spaceId,+ scope,timeZone,}: {- spaceId: string;+ scope: SpaceContentScope;timeZone: string;}) {return prisma.scheduledEvent.count({where: {- spaceId,+ spaceId: scope.spaceId,+ ...(scope.createdBy && { userId: scope.createdBy }),...upcomingScheduledEventWhere({ now: new Date(), timeZone }),},});@@ -321,18 +331,18 @@ export const getUpcomingEvents = async ({member,page = 1,pageSize = 20,- spaceId,+ scope,timeZone,}: {search?: string;member?: string;page?: number;pageSize?: number;- spaceId: string;+ scope: SpaceContentScope;timeZone: string;}) => {const where: Prisma.ScheduledEventWhereInput = {- ...buildBaseWhere(spaceId, search, member),+ ...buildBaseWhere(scope, search, member),...upcomingScheduledEventWhere({ now: new Date(), timeZone }),};@@ -367,18 +377,18 @@ export const getPastEvents = async ({member,page = 1,pageSize = 20,- spaceId,+ scope,timeZone,}: {search?: string;member?: string;page?: number;pageSize?: number;- spaceId: string;+ scope: SpaceContentScope;timeZone: string;}) => {const where: Prisma.ScheduledEventWhereInput = {- ...buildBaseWhere(spaceId, search, member),+ ...buildBaseWhere(scope, search, member),...pastScheduledEventWhere({ now: new Date(), timeZone }),};@@ -413,16 +423,16 @@ export const getUnconfirmedEvents = async ({member,page = 1,pageSize = 20,- spaceId,+ scope,}: {search?: string;member?: string;page?: number;pageSize?: number;- spaceId: string;+ scope: SpaceContentScope;}) => {const where: Prisma.ScheduledEventWhereInput = {- ...buildBaseWhere(spaceId, search, member),+ ...buildBaseWhere(scope, search, member),status: "unconfirmed",};@@ -457,16 +467,16 @@ export const getCanceledEvents = async ({member,page = 1,pageSize = 20,- spaceId,+ scope,}: {search?: string;member?: string;page?: number;pageSize?: number;- spaceId: string;+ scope: SpaceContentScope;}) => {const where: Prisma.ScheduledEventWhereInput = {- ...buildBaseWhere(spaceId, search, member),+ ...buildBaseWhere(scope, search, member),status: "canceled",};@@ -502,7 +512,7 @@ export const getEventsChronological = async ({member,page = 1,pageSize = 20,- spaceId,+ scope,timeZone,}: {status?: Status;@@ -510,10 +520,10 @@ export const getEventsChronological = async ({member?: string;page?: number;pageSize?: number;- spaceId: string;+ scope: SpaceContentScope;timeZone: string;}) => {- const commonParams = { search, member, page, pageSize, spaceId };+ const commonParams = { search, member, page, pageSize, scope };switch (status) {case "upcoming":diff --git a/apps/web/src/features/space/actions.ts b/apps/web/src/features/space/actions.tsindex f2b8e047f..305aa6892 100644--- a/apps/web/src/features/space/actions.ts+++ b/apps/web/src/features/space/actions.ts@@ -14,6 +14,7 @@ import {updateSpace,updateSpaceHideAttribution,updateSpaceImage,+ updateSpaceShared,updateSpaceShowBranding,} from "@/features/space/mutations";import {@@ -22,6 +23,7 @@ import {updateSpaceHideAttributionSchema,updateSpaceImageSchema,updateSpaceSchema,+ updateSpaceSharedSchema,updateSpaceShowBrandingSchema,} from "@/features/space/schema";import { setActiveSpace } from "@/features/user/mutations";@@ -304,6 +306,44 @@ export const updateSpaceHideAttributionAction = authActionClient});});+export const updateSpaceSharedAction = authActionClient+ .metadata({ actionName: "update_space_shared" })+ .use(spaceUpdateAbilityMiddleware)+ .inputSchema(updateSpaceSharedSchema)+ .action(async ({ ctx, parsedInput }) => {+ const { space } = ctx;++ if (parsedInput.shared && space.tier !== "pro") {+ throw new AppError({+ code: "PAYMENT_REQUIRED",+ message: "You need a Pro subscription to share a space",+ });+ }++ await updateSpaceShared({+ spaceId: space.id,+ shared: parsedInput.shared,+ });++ identifyGroup({+ groupType: "space",+ groupKey: space.id,+ properties: {+ shared: parsedInput.shared,+ },+ });++ track(ctx.user, {+ event: "space_update_shared",+ properties: {+ shared: parsedInput.shared,+ },+ groups: {+ space: space.id,+ },+ });+ });+export const getSpaceImageUploadUrlAction = authActionClient.metadata({ actionName: "get_space_image_upload_url" }).use(spaceUpdateAbilityMiddleware)diff --git a/apps/web/src/features/space/data.ts b/apps/web/src/features/space/data.tsindex de1083427..f860b6fad 100644--- a/apps/web/src/features/space/data.ts+++ b/apps/web/src/features/space/data.ts@@ -146,6 +146,7 @@ export function createSpaceDTO(space: {primaryColor?: string | null;showBranding: boolean;hideAttribution: boolean;+ shared: boolean;memberCount: number;seatCount: number;}): SpaceDTO {@@ -155,6 +156,7 @@ export function createSpaceDTO(space: {ownerId: space.ownerId,tier: isSelfHosted ? "pro" : space.tier,role: fromDBRole(space.role),+ shared: space.shared,memberCount: space.memberCount,seatCount: space.seatCount,image: space.image ?? undefined,@@ -230,6 +232,7 @@ export const listSpacesForUser = cache(async (userId: string) => {primaryColor: true,showBranding: true,hideAttribution: true,+ shared: true,_count: { select: { members: true } },subscriptions: {where: { active: true },diff --git a/apps/web/src/features/space/loaders.ts b/apps/web/src/features/space/loaders.tsindex df4db0144..3bafc9cdc 100644--- a/apps/web/src/features/space/loaders.ts+++ b/apps/web/src/features/space/loaders.ts@@ -10,6 +10,8 @@ import {getSpaceSeatCount,getTotalSeatsForSpace,} from "@/features/space/data";+import type { SpaceContentScope } from "@/features/space/types";+import { createSpaceContentScope } from "@/features/space/utils";import { requireUser } from "@/features/user/loaders";import { getSessionState } from "@/lib/auth";import { getDeviceTimeZone } from "@/lib/datetime/server";@@ -95,6 +97,18 @@ export const getActiveSpace = cache(async () => {return space;});+/**+ * The visibility scope space-scoped content reads must apply for the+ * signed-in user in their active space. Same gating as getActiveSpace;+ * server component/page use only.+ */+export const getActiveSpaceContentScope = cache(+ async (): Promise<SpaceContentScope> => {+ const [space, user] = await Promise.all([getActiveSpace(), requireUser()]);+ return createSpaceContentScope({ space, userId: user.id });+ },+);+/*** Upcoming event count for the signed-in user's active space. Lives here* rather than in scheduled-event/loaders.ts because account-deletion (user)@@ -102,9 +116,9 @@ export const getActiveSpace = cache(async () => {* close a feature import cycle; space → scheduled-event is a forward edge.*/export const loadUpcomingEventCount = cache(async () => {- const [user, space, deviceTimeZone] = await Promise.all([+ const [user, scope, deviceTimeZone] = await Promise.all([requireUser(),- getActiveSpace(),+ getActiveSpaceContentScope(),getDeviceTimeZone(),]);@@ -113,7 +127,7 @@ export const loadUpcomingEventCount = cache(async () => {// hasn't been set yet.const timeZone = deviceTimeZone ?? normalizeTimeZone(user.timeZone) ?? "UTC";- return getUpcomingEventCount({ spaceId: space.id, timeZone });+ return getUpcomingEventCount({ scope, timeZone });});/**diff --git a/apps/web/src/features/space/mutations.ts b/apps/web/src/features/space/mutations.tsindex c7c80b933..49a4957c9 100644--- a/apps/web/src/features/space/mutations.ts+++ b/apps/web/src/features/space/mutations.ts@@ -30,6 +30,10 @@ export async function createSpace({tier,spaceType,industry,+ // New spaces start unshared; sharing everything is opt-in. Matches+ // the column default — explicit here so the decision is visible in+ // code, not just the schema.+ shared: false,members: {create: {userId: ownerId,@@ -92,6 +96,19 @@ export async function updateSpaceHideAttribution({});}+export async function updateSpaceShared({+ spaceId,+ shared,+}: {+ spaceId: string;+ shared: boolean;+}) {+ await prisma.space.update({+ where: { id: spaceId },+ data: { shared },+ });+}+export async function updateSpaceImage({spaceId,imageKey,diff --git a/apps/web/src/features/space/schema.ts b/apps/web/src/features/space/schema.tsindex 041f07e71..42bcd4bd3 100644--- a/apps/web/src/features/space/schema.ts+++ b/apps/web/src/features/space/schema.ts@@ -32,6 +32,10 @@ export const updateSpaceHideAttributionSchema = z.object({hideAttribution: z.boolean(),});+export const updateSpaceSharedSchema = z.object({+ shared: z.boolean(),+});+export const spaceImageUploadSchema = z.object({fileType: z.enum(spaceIconAssetProfile.accept),fileSize: z.number().int().positive().max(spaceIconAssetProfile.maxSize),diff --git a/apps/web/src/features/space/types.ts b/apps/web/src/features/space/types.tsindex 43ecc0fa6..fe258a2d7 100644--- a/apps/web/src/features/space/types.ts+++ b/apps/web/src/features/space/types.ts@@ -1,10 +1,9 @@import type { MemberRole } from "@/features/space/schema";+import type { AuthorizedSpaceId } from "@/lib/tenant-scope";-// Tenant scope proven by auth. Minted only by the session gate and the API-// key middleware; parameterized DAL reads require it.-export type AuthorizedSpaceId = string & {- readonly __brand: "AuthorizedSpaceId";-};+// Defined in lib so content features that space itself imports can use them+// without creating a feature cycle; re-exported here as the public path.+export type { AuthorizedSpaceId, SpaceContentScope } from "@/lib/tenant-scope";export type SpaceDTO = {id: AuthorizedSpaceId;@@ -12,6 +11,9 @@ export type SpaceDTO = {ownerId: string;tier: "hobby" | "pro";role: MemberRole;+ // Whether members share everything they create; when false, everyone+ // (admins included) only sees their own content.+ shared: boolean;memberCount: number;seatCount: number;image?: string;diff --git a/apps/web/src/features/space/utils.test.ts b/apps/web/src/features/space/utils.test.tsindex 333e8ae63..c12071564 100644--- a/apps/web/src/features/space/utils.test.ts+++ b/apps/web/src/features/space/utils.test.ts@@ -1,5 +1,28 @@import { describe, expect, it } from "vitest";-import { inferIndustry } from "@/features/space/utils";+import type { AuthorizedSpaceId } from "@/features/space/types";+import { createSpaceContentScope, inferIndustry } from "@/features/space/utils";++const spaceId = "space-1" as AuthorizedSpaceId;++describe("createSpaceContentScope", () => {+ it("does not restrict members of a shared space", () => {+ expect(+ createSpaceContentScope({+ space: { id: spaceId, shared: true },+ userId: "user-1",+ }),+ ).toEqual({ spaceId });+ });++ it("restricts members of an unshared space to their own content", () => {+ expect(+ createSpaceContentScope({+ space: { id: spaceId, shared: false },+ userId: "user-1",+ }),+ ).toEqual({ spaceId, createdBy: "user-1" });+ });+});describe("inferIndustry", () => {it("infers education from an academic domain", () => {diff --git a/apps/web/src/features/space/utils.ts b/apps/web/src/features/space/utils.tsindex 7c5b5967d..35d5922b6 100644--- a/apps/web/src/features/space/utils.ts+++ b/apps/web/src/features/space/utils.ts@@ -5,6 +5,7 @@ import {industryKeywordRules,} from "@/features/space/constants";import type { MemberRole } from "@/features/space/schema";+import type { SpaceContentScope, SpaceDTO } from "@/features/space/types";export const toDBRole = (role: MemberRole): PrismaSpaceMemberRole => {switch (role) {@@ -24,6 +25,27 @@ export const fromDBRole = (role: PrismaSpaceMemberRole): MemberRole => {}};+/**+ * The visibility scope space-scoped content reads must apply for this+ * member. One rule for all content types and all roles: in an unshared+ * space, reads are restricted to what the member created themselves —+ * visibility is a property of the space, while roles only grant+ * administrative capabilities (members, billing). Admins can still reach+ * everything by making the space shared, which every member can see on+ * the members page.+ */+export function createSpaceContentScope({+ space,+ userId,+}: {+ space: Pick<SpaceDTO, "id" | "shared">;+ userId: string;+}): SpaceContentScope {+ return space.shared+ ? { spaceId: space.id }+ : { spaceId: space.id, createdBy: userId };+}+/*** Guess a work space's sector from the owner's email domain and the* organization name. Domain first — a .edu address outranks any word in adiff --git a/apps/web/src/lib/tenant-scope.ts b/apps/web/src/lib/tenant-scope.tsnew file mode 100644index 000000000..a3a52024e--- /dev/null+++ b/apps/web/src/lib/tenant-scope.ts@@ -0,0 +1,23 @@+// Tenant-scope types live in lib rather than features/space so content+// features (poll, scheduled-event, event-types) can type their+// parameterized reads without importing the space feature: space imports+// scheduled-event for its own loaders, so the reverse import would create+// a feature cycle. features/space/types re-exports both, which keeps the+// documented import path working for everything else.++// Tenant scope proven by auth. Minted only by the session gate and the API+// key middleware; parameterized DAL reads require it.+export type AuthorizedSpaceId = string & {+ readonly __brand: "AuthorizedSpaceId";+};++// Visibility scope for space-scoped content reads. Built from the session+// via createSpaceContentScope (spaceProcedure, loaders); API key handlers+// mint { spaceId } directly — a space-level credential sees everything.+export type SpaceContentScope = {+ spaceId: AuthorizedSpaceId;+ // When set, reads must only return content created by this user: the+ // requester is a member of a space where members work independently.+ // Uniform across roles — admins and owners are restricted too.+ createdBy?: string;+};diff --git a/apps/web/src/trpc/routers/event-types.ts b/apps/web/src/trpc/routers/event-types.tsindex 4a8e3f6f5..878b602d5 100644--- a/apps/web/src/trpc/routers/event-types.ts+++ b/apps/web/src/trpc/routers/event-types.ts@@ -23,7 +23,7 @@ const eventTypeProcedure = spaceProcedure.use(requireEventTypesEnabled);export const eventTypes = router({list: eventTypeProcedure.query(async ({ ctx }) => {- const eventTypes = await getEventTypes(ctx.space.id);+ const eventTypes = await getEventTypes(ctx.contentScope);return { eventTypes };}),diff --git a/apps/web/src/trpc/routers/events.ts b/apps/web/src/trpc/routers/events.tsindex 35e368132..0547acf3a 100644--- a/apps/web/src/trpc/routers/events.ts+++ b/apps/web/src/trpc/routers/events.ts@@ -42,7 +42,7 @@ export const events = router({member,page,pageSize,- spaceId: ctx.space.id,+ scope: ctx.contentScope,timeZone,});diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.tsindex bc2dbc315..75ab7bcd2 100644--- a/apps/web/src/trpc/routers/polls.ts+++ b/apps/web/src/trpc/routers/polls.ts@@ -68,7 +68,7 @@ export const polls = router({member,page,pageSize,- spaceId: ctx.space.id,+ scope: ctx.contentScope,});let nextCursor: number | undefined;diff --git a/apps/web/src/trpc/trpc.ts b/apps/web/src/trpc/trpc.tsindex 222ef3c67..fe7b0d8ee 100644--- a/apps/web/src/trpc/trpc.ts+++ b/apps/web/src/trpc/trpc.ts@@ -3,6 +3,7 @@ import { initTRPC, TRPCError } from "@trpc/server";import superjson from "superjson";import { isQuickCreateEnabled } from "@/features/quick-create/constants";import { getActiveSpaceForUser } from "@/features/space/data";+import { createSpaceContentScope } from "@/features/space/utils";import { createUserDTO } from "@/features/user/data";import { signOut } from "@/lib/auth";import { isSelfHosted } from "@/lib/constants";@@ -164,6 +165,10 @@ export const spaceProcedure = privateProcedure.use(async ({ ctx, next }) => {return next({ctx: {space,+ // Visibility scope space-scoped content reads must apply for this+ // member — restricts members of "independently" spaces to their own+ // content, regardless of role.+ contentScope: createSpaceContentScope({ space, userId: ctx.user.id }),},});});diff --git a/packages/database/prisma/migrations/20260828000000_add_space_shared_setting/migration.sql b/packages/database/prisma/migrations/20260828000000_add_space_shared_setting/migration.sqlnew file mode 100644index 000000000..346fa2fb8--- /dev/null+++ b/packages/database/prisma/migrations/20260828000000_add_space_shared_setting/migration.sql@@ -0,0 +1,15 @@+-- AlterTable+ALTER TABLE "spaces" ADD COLUMN "shared" BOOLEAN NOT NULL DEFAULT false;++-- Existing multi-member spaces, and spaces with pending invites (sent when+-- shared visibility was the only semantics), keep today's behavior.+-- Single-member spaces have nobody to share with, so starting them+-- unshared changes nothing observable while giving them the same+-- privacy-safe first invite as new spaces.+UPDATE "spaces" SET "shared" = true+WHERE "id" IN (+ SELECT "space_id" FROM "space_members" GROUP BY "space_id" HAVING count(*) > 1+ )+ OR "id" IN (+ SELECT "space_id" FROM "space_member_invites"+ );diff --git a/packages/database/prisma/models/space.prisma b/packages/database/prisma/models/space.prismaindex 2a3a7b2cd..40d195b86 100644--- a/packages/database/prisma/models/space.prisma+++ b/packages/database/prisma/models/space.prisma@@ -12,6 +12,15 @@ model Space {primaryColor String? @map("primary_color")showBranding Boolean @default(false) @map("show_branding")hideAttribution Boolean @default(false) @map("hide_attribution")+ // The Team collaboration setting (Settings -> Collaboration).+ // Whether members share everything they create (everyone sees+ // everything) or work independently (everyone, admins included, only+ // sees what they create; roles grant administrative capabilities, not+ // visibility). Defaults to not shared — sharing is opt-in; the backfill+ // kept existing multi-member spaces (and spaces with pending invites)+ // shared to preserve their behavior. When the org layer lands, shared+ // spaces map to teams and unshared spaces to organizations.+ shared Boolean @default(false)createdAt DateTime @default(now()) @map("created_at")updatedAt DateTime @updatedAt @map("updated_at")