Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(desktop): private-by-invitation spaces (#95792)

Shy Alter4921be1a23c6
diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.ts
index 12d346a2a5b8..75820d6e4b8f 100644
--- a/products/desktop/packages/api-client/src/posthog-client.ts
+++ b/products/desktop/packages/api-client/src/posthog-client.ts
@@ -3191,21 +3191,31 @@ export class PostHogAPIClient {
return (await response.json()) as TaskChannel[];
}
- // Resolve-or-create a public channel by name (idempotent server-side). `star`
- // only applies when this call creates the channel; an existing one keeps the
- // requester's star as it was.
+ // Create a channel. A public channel (default) is resolve-or-create by name
+ // (idempotent server-side). A private channel is always created fresh with the
+ // requester plus `memberIds` as its members. `star` only applies when this call
+ // creates the channel; an existing public one keeps the requester's star as it was.
async resolveTaskChannel(
name: string,
- options: { star: boolean },
+ options: {
+ star: boolean;
+ channelType?: "public" | "private";
+ memberIds?: number[];
+ },
): Promise<TaskChannel> {
const teamId = await this.getTeamId();
const urlPath = `/api/projects/${teamId}/task_channels/`;
+ const body: Record<string, unknown> = { name, star: options.star };
+ if (options.channelType === "private") {
+ body.channel_type = "private";
+ body.member_ids = options.memberIds ?? [];
+ }
const response = await this.api.fetcher.fetch({
method: "post",
url: new URL(`${this.api.baseUrl}${urlPath}`),
path: urlPath,
overrides: {
- body: JSON.stringify({ name, star: options.star }),
+ body: JSON.stringify(body),
},
});
if (!response.ok) {
@@ -3214,6 +3224,42 @@ export class PostHogAPIClient {
return (await response.json()) as TaskChannel;
}
+ // The members of a private channel. Public and personal channels have no
+ // members and read as an empty list.
+ async listTaskChannelMembers(id: string): Promise<UserBasic[]> {
+ const teamId = await this.getTeamId();
+ const urlPath = `/api/projects/${teamId}/task_channels/${encodeURIComponent(id)}/members/`;
+ const response = await this.api.fetcher.fetch({
+ method: "get",
+ url: new URL(`${this.api.baseUrl}${urlPath}`),
+ path: urlPath,
+ });
+ if (!response.ok) {
+ throw new Error(`Failed to fetch space members: ${response.statusText}`);
+ }
+ return (await response.json()) as UserBasic[];
+ }
+
+ // Replace a private channel's member set. The creator is always kept, whatever
+ // `userIds` holds. Returns the updated members.
+ async setTaskChannelMembers(
+ id: string,
+ userIds: number[],
+ ): Promise<UserBasic[]> {
+ const teamId = await this.getTeamId();
+ const urlPath = `/api/projects/${teamId}/task_channels/${encodeURIComponent(id)}/members/`;
+ const response = await this.api.fetcher.fetch({
+ method: "put",
+ url: new URL(`${this.api.baseUrl}${urlPath}`),
+ path: urlPath,
+ overrides: { body: JSON.stringify({ user_ids: userIds }) },
+ });
+ if (!response.ok) {
+ throw new Error(`Failed to update space members: ${response.statusText}`);
+ }
+ return (await response.json()) as UserBasic[];
+ }
+
async renameTaskChannel(id: string, name: string): Promise<TaskChannel> {
const teamId = await this.getTeamId();
const urlPath = `/api/projects/${teamId}/task_channels/${encodeURIComponent(id)}/`;
@@ -3334,6 +3380,26 @@ export class PostHogAPIClient {
return (await response.json()) as TaskChannel;
}
+ async updateTaskChannelType(
+ id: string,
+ channelType: "public" | "private",
+ ): Promise<TaskChannel> {
+ const teamId = await this.getTeamId();
+ const urlPath = `/api/projects/${teamId}/task_channels/${encodeURIComponent(id)}/`;
+ const response = await this.api.fetcher.fetch({
+ method: "patch",
+ url: new URL(`${this.api.baseUrl}${urlPath}`),
+ path: urlPath,
+ overrides: { body: JSON.stringify({ channel_type: channelType }) },
+ });
+ if (!response.ok) {
+ throw new Error(
+ `Failed to update space visibility: ${response.statusText}`,
+ );
+ }
+ return (await response.json()) as TaskChannel;
+ }
+
async updateTaskChannelAutoArchive(
id: string,
inactivityDays: number | null,
diff --git a/products/desktop/packages/core/src/canvas/canvasListService.ts b/products/desktop/packages/core/src/canvas/canvasListService.ts
index 844677ccbf01..6a55239705dd 100644
--- a/products/desktop/packages/core/src/canvas/canvasListService.ts
+++ b/products/desktop/packages/core/src/canvas/canvasListService.ts
@@ -24,7 +24,7 @@ export const DEFAULT_CANVAS_LIST_SETTINGS: CanvasListSettings = {
interface CanvasListSpace {
id: string;
name: string;
- channelType: "public" | "personal";
+ channelType: "public" | "personal" | "private";
}
interface CanvasListUser {
diff --git a/products/desktop/packages/core/src/canvas/channelName.test.ts b/products/desktop/packages/core/src/canvas/channelName.test.ts
index eb808e610f12..ab40320d0675 100644
--- a/products/desktop/packages/core/src/canvas/channelName.test.ts
+++ b/products/desktop/packages/core/src/canvas/channelName.test.ts
@@ -5,48 +5,62 @@ import {
channelDisplayReference,
isGeneralChannel,
isPersonalChannel,
+ isPrivateChannel,
normalizeChannelName,
normalizeChannelNameInput,
validateChannelName,
} from "./channelName";
-describe("isPersonalChannel / isGeneralChannel", () => {
+describe("isPersonalChannel / isGeneralChannel / isPrivateChannel", () => {
it.each([
[
"system_role wins over channel_type/name when present (personal)",
{ system_role: "personal", channel_type: "public", name: "not-me" },
true,
false,
+ false,
],
[
"system_role wins over channel_type/name when present (general)",
{ system_role: "general", channel_type: "personal", name: "not-general" },
false,
true,
+ false,
],
[
"null system_role falls back to the legacy checks and matches",
{ system_role: null, channel_type: "personal", name: "me" },
true,
false,
+ false,
],
[
"null system_role falls back to the legacy checks and matches general",
{ system_role: null, channel_type: "public", name: "general" },
false,
true,
+ false,
],
[
"neither system_role nor the legacy checks match",
{ system_role: null, channel_type: "public", name: "growth" },
false,
false,
+ false,
+ ],
+ [
+ "a private space is private, and neither personal nor general",
+ { system_role: null, channel_type: "private", name: "squad" },
+ false,
+ false,
+ true,
],
- ] satisfies [string, ChannelIdentity, boolean, boolean][])(
+ ] satisfies [string, ChannelIdentity, boolean, boolean, boolean][])(
"%s",
- (_label, channel, expectedPersonal, expectedGeneral) => {
+ (_label, channel, expectedPersonal, expectedGeneral, expectedPrivate) => {
expect(isPersonalChannel(channel)).toBe(expectedPersonal);
expect(isGeneralChannel(channel)).toBe(expectedGeneral);
+ expect(isPrivateChannel(channel)).toBe(expectedPrivate);
},
);
});
@@ -79,6 +93,8 @@ describe("channelDisplayLabel", () => {
["personal", "personal" as const, "personal"],
["personal", "public" as const, "#personal"],
["engineering", "public" as const, "#engineering"],
+ // A private space is shared, so it wears a hash like any other named space.
+ ["squad", "private" as const, "#squad"],
])("formats %j (%s) as %j", (name, channelType, expected) => {
expect(channelDisplayLabel(name, channelType)).toBe(expected);
});
diff --git a/products/desktop/packages/core/src/canvas/channelName.ts b/products/desktop/packages/core/src/canvas/channelName.ts
index 7061384fcd05..1c88c7bbf511 100644
--- a/products/desktop/packages/core/src/canvas/channelName.ts
+++ b/products/desktop/packages/core/src/canvas/channelName.ts
@@ -2,9 +2,11 @@ export const PERSONAL_CHANNEL_NAME = "me";
const GENERAL_CHANNEL_NAME = "general";
+export type ChannelType = "public" | "personal" | "private";
+
export interface ChannelIdentity {
system_role?: "personal" | "general" | null;
- channel_type: "public" | "personal";
+ channel_type: ChannelType;
name: string;
}
@@ -14,6 +16,15 @@ export function isPersonalChannel(channel: ChannelIdentity): boolean {
: channel.channel_type === "personal";
}
+/**
+ * A shared space only its invited members can see. Distinct from the personal
+ * "#me" space (`isPersonalChannel`): a private space has no system role, so it
+ * is judged by its type alone.
+ */
+export function isPrivateChannel(channel: ChannelIdentity): boolean {
+ return channel.channel_type === "private";
+}
+
export function isGeneralChannel(channel: ChannelIdentity): boolean {
return channel.system_role != null
? channel.system_role === "general"
@@ -43,7 +54,7 @@ export function channelDisplayName(name: string | null): string | null {
function isPersonalChannelLabel(
name: string,
- channelType?: "public" | "personal",
+ channelType?: ChannelType,
): boolean {
return channelType !== undefined
? channelType === "personal"
@@ -52,7 +63,7 @@ function isPersonalChannelLabel(
export function channelDisplayLabel(
name: string,
- channelType?: "public" | "personal",
+ channelType?: ChannelType,
): string {
return isPersonalChannelLabel(name, channelType)
? PERSONAL_CHANNEL_LABEL
@@ -61,7 +72,7 @@ export function channelDisplayLabel(
export function channelDisplayReference(
name: string,
- channelType?: "public" | "personal",
+ channelType?: ChannelType,
): string {
return isPersonalChannelLabel(name, channelType)
? "your personal space"
diff --git a/products/desktop/packages/core/src/context-menu/schemas.ts b/products/desktop/packages/core/src/context-menu/schemas.ts
index defd59440a0d..5f29b83ecc5c 100644
--- a/products/desktop/packages/core/src/context-menu/schemas.ts
+++ b/products/desktop/packages/core/src/context-menu/schemas.ts
@@ -4,7 +4,7 @@ import { z } from "zod";
const fileToChannel = z.object({
id: z.string(),
name: z.string(),
- channelType: z.enum(["public", "personal"]).optional(),
+ channelType: z.enum(["public", "personal", "private"]).optional(),
starred: z.boolean().optional(),
});
diff --git a/products/desktop/packages/shared/src/domain-types.ts b/products/desktop/packages/shared/src/domain-types.ts
index 0c49f8cd15d1..9dd0175299f5 100644
--- a/products/desktop/packages/shared/src/domain-types.ts
+++ b/products/desktop/packages/shared/src/domain-types.ts
@@ -125,7 +125,7 @@ export interface ProvisionedTaskChannels {
export interface TaskChannel {
id: string;
name: string;
- channel_type: "public" | "personal";
+ channel_type: "public" | "personal" | "private";
starred: boolean;
github_integration?: number | null;
repositories?: string[];
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.test.tsx
index 89bedcb76075..883a2903c569 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.test.tsx
@@ -7,13 +7,17 @@ const mocks = vi.hoisted(() => ({
channels: [] as {
id: string;
name: string;
- channelType: "public" | "personal";
+ channelType: "public" | "personal" | "private";
}[],
isLoading: false,
toggleStar: vi.fn(),
+ navigate: vi.fn(),
}));
vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));
+vi.mock("@tanstack/react-router", () => ({
+ useNavigate: () => mocks.navigate,
+}));
vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
useChannelsLayout: () => true,
}));
@@ -61,6 +65,17 @@ describe("ChannelBackRow", () => {
expect(screen.getByText("engineering")).toBeTruthy();
});
+ it("opens settings for the current space", async () => {
+ const user = userEvent.setup();
+ renderRow(ENG.id);
+ await user.click(screen.getByRole("button", { name: "Space settings" }));
+ expect(mocks.navigate).toHaveBeenCalledWith({
+ to: "/spaces/$channelId/settings",
+ params: { channelId: ENG.id },
+ });
+ expect(useChannelPaneStore.getState().pane).toBe("channel");
+ });
+
it("slides back to the channel list", async () => {
const user = userEvent.setup();
renderRow(ENG.id);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx
index 0ee3dfcb1290..6d8b265236b0 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx
@@ -1,7 +1,6 @@
-import { ArrowUUpLeftIcon, StarIcon } from "@phosphor-icons/react";
+import { ArrowUUpLeftIcon, GearIcon, StarIcon } from "@phosphor-icons/react";
import {
Button,
- cn,
Kbd,
Skeleton,
Tooltip,
@@ -22,54 +21,54 @@ import {
SHORTCUTS,
} from "@posthog/ui/features/command/keyboard-shortcuts";
import { track } from "@posthog/ui/shell/analytics";
+import { useNavigate } from "@tanstack/react-router";
-// An overlay rather than a sibling: the back button fills the row, and nesting
-// the star inside it would be a button within a button.
function RowStar({ channel }: { channel: Channel }) {
const { isStarred, toggleStar } = useChannelStarToggle(channel);
+ const label = isStarred ? "Unstar space" : "Star space";
return (
- <Button
- variant="default"
- size="icon-sm"
- aria-label={isStarred ? "Unstar space" : "Star space"}
- onClick={() => {
- track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
- action_type: isStarred ? "unstar" : "star",
- surface: "sidebar",
- channel_id: channel.id,
- });
- toggleStar();
- }}
- // Parks in the row's reserved well: 8px padding + 3px gap = 11px from the
- // right edge.
- className="-translate-y-1/2 absolute top-1/2 right-2 text-muted-foreground"
- >
- <StarIcon size={14} weight={isStarred ? "fill" : "regular"} />
- </Button>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="default"
+ size="icon-sm"
+ aria-label={label}
+ onClick={() => {
+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
+ action_type: isStarred ? "unstar" : "star",
+ surface: "sidebar",
+ channel_id: channel.id,
+ });
+ toggleStar();
+ }}
+ className="text-muted-foreground"
+ >
+ <StarIcon size={14} weight={isStarred ? "fill" : "regular"} />
+ </Button>
+ }
+ />
+ <TooltipContent>{label}</TooltipContent>
+ </Tooltip>
);
}
-/**
- * The channel pane's header: the channel you're in, and the way back out of it.
- *
- * Clicking anywhere on the row slides the sidebar back to the channel list —
- * the list is where switching happens, so this row only has to be the door to
- * it. Leaving the channel scoped means the route (and the main pane) stay put.
- */
export function ChannelBackRow({ channelId }: { channelId: string }) {
+ const navigate = useNavigate();
const spacesLayout = useChannelsLayout();
const { channels, isLoading } = useChannels();
const current = channels.find((c) => c.id === channelId);
const showStar = current != null && current.channelType !== "personal";
const glyph = channelGlyph(current?.name, {
personal: current?.channelType === "personal",
+ private: current?.channelType === "private",
size: 14,
space: spacesLayout,
className: "text-muted-foreground",
});
return (
- <div className="relative h-10 border-border border-b px-1.5 pt-1.5 pb-2">
+ <div className="group/back flex h-10 items-center gap-0.5 border-border border-b px-1.5 pt-1.5 pb-2">
<Tooltip>
<TooltipTrigger
render={
@@ -85,32 +84,15 @@ export function ChannelBackRow({ channelId }: { channelId: string }) {
});
showChannelList({ animate: true });
}}
- // Quill's own height and radius, so this reads as one of the rows
- // under it rather than a control sitting on top. The right padding
- // is the star's well — the star is an overlay, because a button
- // can't nest one, so without it the row's own content runs under
- // the star. Padding rather than a spacer element: quill hides an
- // empty one (`empty:hidden`), which is how the shortcut hint ended
- // up sitting beneath the star.
- className={cn(
- "w-full gap-1.5 pr-1 text-left",
- showStar && "pr-8",
- )}
+ className="min-w-0 flex-1 gap-1.5 text-left"
>
- {/* The way out of a space, in the brand's own colour: a muted
- caret read as decoration on a header rather than the control
- it is, and people could not find their way back to the list. */}
<ArrowUUpLeftIcon
size={12}
weight="bold"
className="shrink-0 text-primary"
/>
- {/* Only #me still has a glyph under the layout, and its well is
- drawn only when there's something in it — an empty 16px column
- in front of every other space's name is worse than the name
- starting where the caret leaves off. */}
{glyph && (
- <span className="flex w-4 shrink-0 items-center justify-center text-foreground">
+ <span className="flex w-4 shrink-0 items-center justify-center">
{glyph}
</span>
)}
@@ -118,40 +100,43 @@ export function ChannelBackRow({ channelId }: { channelId: string }) {
{current ? (
current.name
) : isLoading ? (
- // A placeholder word here would read as a real channel named
- // "channel"; a skeleton says "still loading" honestly.
<Skeleton className="h-3.5 w-24" />
) : (
"Unavailable"
)}
</span>
- {/* Same key as the search box's hint: from inside a space it is
- the way back to the list, which is what this row does. */}
- <Kbd className="mr-0! shrink-0 opacity-50">
+ <Kbd className="mr-0! shrink-0 opacity-0 transition-opacity group-focus-within/back:opacity-60 group-hover/back:opacity-60">
{formatHotkey(SHORTCUTS.FOCUS_SIDEBAR_SEARCH)}
</Kbd>
- {/* The star's well. Its height is unconditional — it is what
- sets the row's height, and a row that changed height between a
- starrable space and #me made everything below it jump on
- switch. Its width is not: with no star to hold, an empty
- column just pushes the shortcut hint off the edge. */}
- <span
- aria-hidden
- className={cn(
- "h-6 shrink-0 empty:hidden",
- showStar ? "w-6" : "w-0",
- )}
- />
</Button>
}
/>
<TooltipContent side="bottom">Back to spaces</TooltipContent>
</Tooltip>
- {/* #me can't be starred, so its well stays empty — a greyed-out star read
- as a control you were being denied. The well itself is unconditional
- (see the button's reserved span), which is what keeps the row the same
- height on every space. */}
{showStar && current && <RowStar channel={current} />}
+ {current && (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="default"
+ size="icon-sm"
+ aria-label="Space settings"
+ className="text-muted-foreground"
+ onClick={() =>
+ void navigate({
+ to: "/spaces/$channelId/settings",
+ params: { channelId },
+ })
+ }
+ >
+ <GearIcon size={14} />
+ </Button>
+ }
+ />
+ <TooltipContent>Space settings</TooltipContent>
+ </Tooltip>
+ )}
</div>
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
index 9b58b8c1ab80..5cd64f556d23 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
@@ -13,7 +13,7 @@ const mocks = vi.hoisted(() => ({
channels: [] as {
id: string;
name: string;
- channelType: "public" | "personal";
+ channelType: "public" | "personal" | "private";
starred: boolean;
repositories: string[];
createdBy: null;
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
index 8707fb038554..f498083df005 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
@@ -10,6 +10,7 @@ import {
PlusIcon,
StarIcon,
TrashIcon,
+ UsersThreeIcon,
} from "@phosphor-icons/react";
import type { ChannelItemModel } from "@posthog/core/canvas/channelItems";
import type { ChannelPresence } from "@posthog/core/canvas/presence";
@@ -850,10 +851,27 @@ function useChannelActions(channel: Channel): {
},
},
];
+ // Only a private space has a member list; public and personal spaces do not.
+ const membersActions: ChannelActionItem[] =
+ channel.channelType === "private"
+ ? [
+ {
+ key: "members",
+ label: "Members",
+ icon: <UsersThreeIcon size={14} />,
+ onSelect: () =>
+ void navigate({
+ to: "/spaces/$channelId/settings",
+ params: { channelId: channel.id },
+ }),
+ },
+ ]
+ : [];
const editableSpaceActions: ChannelActionItem[] =
channel.channelType === "personal"
? []
: [
+ ...membersActions,
{
key: "rename",
label: `Rename ${noun}…`,
@@ -893,6 +911,7 @@ function useChannelActions(channel: Channel): {
channel.channelType,
channel.id,
isStarred,
+ navigate,
noun,
toggleStar,
]);
@@ -1110,6 +1129,7 @@ const ChannelSection = memo(
const glyph = channelGlyph(channel.name, {
personal: channel.channelType === "personal",
+ private: channel.channelType === "private",
size: 14,
space: spacesLayout,
weight: isUnread ? "bold" : undefined,
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx
index 6449e78b0da4..ab1af7561ccc 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx
@@ -10,7 +10,7 @@ const mocks = vi.hoisted(() => ({
channels: [] as {
id: string;
name: string;
- channelType: "public" | "personal";
+ channelType: "public" | "personal" | "private";
starred: boolean;
}[],
channelsLoading: false,
diff --git a/products/desktop/packages/ui/src/features/canvas/components/CreateChannelModal.tsx b/products/desktop/packages/ui/src/features/canvas/components/CreateChannelModal.tsx
index 8ff00ca3388a..f9193e87cced 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/CreateChannelModal.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/CreateChannelModal.tsx
@@ -31,9 +31,15 @@ import {
ANALYTICS_EVENTS,
type ChannelsSurface,
} from "@posthog/shared/analytics-events";
+import type { UserBasic } from "@posthog/shared/domain-types";
+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
+import { MemberList } from "@posthog/ui/features/canvas/components/MemberList";
+import { MemberSearch } from "@posthog/ui/features/canvas/components/MemberSearch";
import { useChannelMutations } from "@posthog/ui/features/canvas/hooks/useChannels";
import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import { useGenerateContext } from "@posthog/ui/features/canvas/hooks/useGenerateContext";
+import { useOrgMembers } from "@posthog/ui/features/canvas/hooks/useOrgMembers";
import { useUpdateTaskChannelRepositories } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
import { RepositoriesField } from "@posthog/ui/features/integrations/components/RepositoriesField";
import { AnimatedHeight } from "@posthog/ui/primitives/AnimatedHeight";
@@ -41,7 +47,7 @@ import { toast } from "@posthog/ui/primitives/toast";
import { track } from "@posthog/ui/shell/analytics";
import { useNavigate } from "@tanstack/react-router";
import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
-import { useEffect, useId, useRef, useState } from "react";
+import { useEffect, useId, useMemo, useRef, useState } from "react";
const MAX_CONTEXT_NAME_LENGTH = 80;
@@ -55,7 +61,7 @@ const DESCRIPTION_EXAMPLES = [
const DESCRIPTION_ROTATION_INTERVAL_MS = 5000;
-const CREATE_STEPS = ["name", "describe", "repositories"] as const;
+const CREATE_STEPS = ["name", "describe", "repositories", "members"] as const;
type CreateStep = (typeof CREATE_STEPS)[number];
const EASE_OUT: [number, number, number, number] = [0.215, 0.61, 0.355, 1];
@@ -122,6 +128,21 @@ export function CreateChannelModal({
number | null
>(null);
const [star, setStar] = useState(true);
+ const [visibility, setVisibility] = useState<"public" | "private">("public");
+ const [memberIds, setMemberIds] = useState<number[]>([]);
+ const authClient = useOptionalAuthenticatedClient();
+ const { data: currentUser } = useCurrentUser({ client: authClient });
+ const { members: orgMembers } = useOrgMembers();
+ const selectedMembers = useMemo(
+ () =>
+ memberIds
+ .map((id) => orgMembers.find((member) => member.id === id))
+ .filter((member): member is UserBasic => !!member),
+ [memberIds, orgMembers],
+ );
+ const memberSearchExcludes = currentUser
+ ? [...memberIds, currentUser.id]
+ : memberIds;
const [step, setStep] = useState<CreateStep>("name");
const [direction, setDirection] = useState(1);
const descriptionHelperId = useId();
@@ -144,6 +165,8 @@ export function CreateChannelModal({
setRepositories([]);
setRepositoryIntegration(null);
setStar(true);
+ setVisibility("public");
+ setMemberIds([]);
setStep("name");
}
}
@@ -168,10 +191,14 @@ export function CreateChannelModal({
}
};
- const submitCreate = async (linkSelectedRepositories: boolean) => {
+ const submitCreate = async () => {
let contextId: string;
try {
- const channel = await createChannel(trimmedName, { star });
+ const channel = await createChannel(trimmedName, {
+ star,
+ channelType: visibility,
+ memberIds: visibility === "private" ? memberIds : [],
+ });
track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
action_type: "create",
surface,
@@ -191,7 +218,7 @@ export function CreateChannelModal({
return;
}
- if (linkSelectedRepositories && repositories.length > 0) {
+ if (repositories.length > 0) {
try {
await linkRepositories.mutateAsync({
channelId: contextId,
@@ -448,6 +475,29 @@ export function CreateChannelModal({
</DialogHeader>
<DialogBody viewportClassName="flex flex-col gap-3">
+ <Item variant="outline">
+ <ItemContent>
+ <ItemTitle>
+ <Label htmlFor="context-private">
+ Private {spacesLayout ? "space" : "channel"}
+ </Label>
+ </ItemTitle>
+ <ItemDescription>
+ Only invited members can see it. Off means everyone in the
+ project can.
+ </ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Switch
+ id="context-private"
+ checked={visibility === "private"}
+ disabled={busy}
+ onCheckedChange={(on) =>
+ setVisibility(on ? "private" : "public")
+ }
+ />
+ </ItemActions>
+ </Item>
<Item variant="outline">
<ItemContent>
<ItemTitle>Repositories</ItemTitle>
@@ -468,8 +518,6 @@ export function CreateChannelModal({
/>
</ItemActions>
</Item>
- {/* Last stop before both create buttons, so the toggle is in view when
- the space is actually made. */}
<Item variant="outline">
<ItemContent>
<ItemTitle>
@@ -502,17 +550,70 @@ export function CreateChannelModal({
Back
</Button>
<Button
- variant="default"
+ variant="primary"
+ disabled={!canAdvance}
+ loading={busy}
+ onClick={() => {
+ if (visibility === "private") {
+ goToStep("members");
+ } else {
+ void submitOnce(submitCreate);
+ }
+ }}
+ >
+ {visibility === "private" ? "Next" : "Create"}
+ </Button>
+ </DialogFooter>
+ </>
+ );
+ case "members":
+ return (
+ <>
+ <DialogHeader>
+ <DialogTitle>Invite people</DialogTitle>
+ <DialogDescription>
+ Choose project members who can access this private{" "}
+ {spacesLayout ? "space" : "channel"}. You already have access
+ and can add people later.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="px-4 pt-4">
+ <MemberSearch
+ excludeIds={memberSearchExcludes}
+ onPick={(id) => setMemberIds((ids) => [...ids, id])}
+ disabled={busy}
+ placeholder="Add people…"
+ />
+ </div>
+ <DialogBody
+ className="flex max-h-[50vh] flex-col"
+ viewportClassName="flex flex-col"
+ >
+ <MemberList
+ members={selectedMembers}
+ currentUser={currentUser ?? null}
+ disabled={busy}
+ onRemove={(id) =>
+ setMemberIds((ids) =>
+ ids.filter((memberId) => memberId !== id),
+ )
+ }
+ />
+ </DialogBody>
+ <DialogFooter>
+ <Button
+ variant="outline"
+ className="sm:mr-auto"
disabled={busy}
- onClick={() => void submitOnce(() => submitCreate(false))}
+ onClick={() => goToStep("repositories")}
>
- Skip
+ Back
</Button>
<Button
variant="primary"
- disabled={busy || repositories.length === 0}
+ disabled={!canAdvance}
loading={busy}
- onClick={() => void submitOnce(() => submitCreate(true))}
+ onClick={() => void submitOnce(submitCreate)}
>
Create
</Button>
diff --git a/products/desktop/packages/ui/src/features/canvas/components/MemberList.tsx b/products/desktop/packages/ui/src/features/canvas/components/MemberList.tsx
new file mode 100644
index 000000000000..1c611a2d0e4b
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/MemberList.tsx
@@ -0,0 +1,30 @@
+import type { UserBasic } from "@posthog/shared/domain-types";
+import { MemberRow } from "@posthog/ui/features/canvas/components/MemberRow";
+import { SettingsCard } from "@posthog/ui/features/settings/components/SettingsCard";
+
+export function MemberList({
+ members,
+ currentUser = null,
+ onRemove,
+ disabled,
+}: {
+ members: UserBasic[];
+ currentUser?: UserBasic | null;
+ onRemove: (id: number) => void;
+ disabled?: boolean;
+}) {
+ const others = members.filter((member) => member.id !== currentUser?.id);
+ return (
+ <SettingsCard>
+ {currentUser && <MemberRow member={currentUser} tag="You" />}
+ {others.map((member) => (
+ <MemberRow
+ key={member.id}
+ member={member}
+ disabled={disabled}
+ onRemove={() => onRemove(member.id)}
+ />
+ ))}
+ </SettingsCard>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/MemberRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/MemberRow.tsx
new file mode 100644
index 000000000000..f188a1bb61ad
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/MemberRow.tsx
@@ -0,0 +1,43 @@
+import { XIcon } from "@phosphor-icons/react";
+import { Badge, Button } from "@posthog/quill";
+import type { UserBasic } from "@posthog/shared/domain-types";
+import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";
+import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";
+
+export function MemberRow({
+ member,
+ tag,
+ onRemove,
+ disabled,
+}: {
+ member: UserBasic;
+ tag?: string;
+ onRemove?: () => void;
+ disabled?: boolean;
+}) {
+ return (
+ <div className="flex min-h-11 items-center gap-3 px-3.5 py-2">
+ <UserAvatar user={member} size="sm" className="shrink-0" />
+ <div className="flex min-w-0 flex-1 flex-col leading-snug">
+ <span className="truncate font-medium text-[13px] text-foreground">
+ {userDisplayName(member)}
+ </span>
+ <span className="truncate text-[12px] text-muted-foreground">
+ {member.email}
+ </span>
+ </div>
+ {tag && <Badge variant="default">{tag}</Badge>}
+ {onRemove && (
+ <Button
+ variant="default"
+ size="icon-sm"
+ aria-label={`Remove ${userDisplayName(member)}`}
+ disabled={disabled}
+ onClick={onRemove}
+ >
+ <XIcon size={14} />
+ </Button>
+ )}
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/MemberSearch.tsx b/products/desktop/packages/ui/src/features/canvas/components/MemberSearch.tsx
new file mode 100644
index 000000000000..687bdcf1f2ab
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/MemberSearch.tsx
@@ -0,0 +1,92 @@
+import {
+ Combobox,
+ ComboboxContent,
+ ComboboxEmpty,
+ ComboboxInput,
+ ComboboxItem,
+ ComboboxList,
+} from "@posthog/quill";
+import type { UserBasic } from "@posthog/shared/domain-types";
+import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";
+import { useOrgMembers } from "@posthog/ui/features/canvas/hooks/useOrgMembers";
+import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";
+import { useMemo } from "react";
+
+export function MemberSearch({
+ excludeIds,
+ onPick,
+ disabled,
+ placeholder = "Search people…",
+}: {
+ excludeIds: number[];
+ onPick: (id: number) => void;
+ disabled?: boolean;
+ placeholder?: string;
+}) {
+ const { members, isLoading } = useOrgMembers();
+ const byId = useMemo(() => {
+ const map = new Map<number, UserBasic>();
+ for (const member of members) map.set(member.id, member);
+ return map;
+ }, [members]);
+ const excluded = useMemo(() => new Set(excludeIds), [excludeIds]);
+ const addableIds = useMemo(
+ () =>
+ members
+ .filter((member) => !excluded.has(member.id))
+ .map((member) => String(member.id)),
+ [members, excluded],
+ );
+
+ return (
+ <Combobox<string>
+ items={addableIds}
+ value={null}
+ onValueChange={(value) => value && onPick(Number(value))}
+ itemToStringLabel={(id) => {
+ const member = byId.get(Number(id));
+ return member ? userDisplayName(member) : "";
+ }}
+ filter={(id, query) => {
+ const needle = query.trim().toLowerCase();
+ if (!needle) return true;
+ const member = byId.get(Number(id));
+ if (!member) return false;
+ return (
+ userDisplayName(member).toLowerCase().includes(needle) ||
+ (member.email ?? "").toLowerCase().includes(needle)
+ );
+ }}
+ autoHighlight
+ disabled={disabled}
+ >
+ <ComboboxInput
+ placeholder={placeholder}
+ disabled={disabled}
+ className="w-full"
+ />
+ <ComboboxContent className="w-[var(--anchor-width)] min-w-[240px]">
+ <ComboboxEmpty>
+ {isLoading ? "Loading people…" : "No people to add."}
+ </ComboboxEmpty>
+ <ComboboxList className="max-h-[min(18rem,calc(var(--available-height,18rem)-2rem))]">
+ {(itemId: string) => {
+ const member = byId.get(Number(itemId));
+ if (!member) return null;
+ return (
+ <ComboboxItem key={itemId} value={itemId}>
+ <UserAvatar user={member} size="xs" className="shrink-0" />
+ <span className="min-w-0 truncate">
+ {userDisplayName(member)}
+ </span>
+ <span className="ml-auto shrink-0 truncate text-muted-foreground text-xs">
+ {member.email}
+ </span>
+ </ComboboxItem>
+ );
+ }}
+ </ComboboxList>
+ </ComboboxContent>
+ </Combobox>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/RenameChannelModal.tsx b/products/desktop/packages/ui/src/features/canvas/components/RenameChannelModal.tsx
index a38d60331166..4fffe8eac9f0 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/RenameChannelModal.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/RenameChannelModal.tsx
@@ -117,6 +117,7 @@ export function RenameChannelModal({
<TextField.Slot>
{channelGlyph(channel.name, {
personal: channel.channelType === "personal",
+ private: channel.channelType === "private",
size: 16,
space: spacesLayout,
})}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceMembersSettings.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceMembersSettings.tsx
new file mode 100644
index 000000000000..491592b0f634
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceMembersSettings.tsx
@@ -0,0 +1,70 @@
+import type { UserBasic } from "@posthog/shared/domain-types";
+import { MemberRow } from "@posthog/ui/features/canvas/components/MemberRow";
+import { MemberSearch } from "@posthog/ui/features/canvas/components/MemberSearch";
+import {
+ useChannelMembers,
+ useSetChannelMembers,
+} from "@posthog/ui/features/canvas/hooks/useChannelMembers";
+import type { Channel } from "@posthog/ui/features/canvas/hooks/useChannels";
+import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";
+import { SettingsCard } from "@posthog/ui/features/settings/components/SettingsCard";
+import { toast } from "@posthog/ui/primitives/toast";
+
+export function SpaceMembersSettings({ channel }: { channel: Channel }) {
+ const { members, isLoading, error } = useChannelMembers(channel.id);
+ const { setMembers, isSaving } = useSetChannelMembers(channel.id);
+ const creatorId = channel.createdBy?.id ?? null;
+ const memberIds = members.map((member) => member.id);
+
+ const commit = async (ids: number[], failure: string) => {
+ try {
+ await setMembers(ids);
+ } catch (error) {
+ toast.error(failure, {
+ description: error instanceof Error ? error.message : String(error),
+ });
+ }
+ };
+ const addMember = (id: number) =>
+ void commit([...memberIds, id], "Couldn't add this person. Try again.");
+ const removeMember = (member: UserBasic) =>
+ void commit(
+ memberIds.filter((id) => id !== member.id),
+ `Couldn't remove ${userDisplayName(member)}. Try again.`,
+ );
+
+ if (isLoading)
+ return (
+ <p className="text-[12px] text-muted-foreground">Loading members…</p>
+ );
+ if (error)
+ return (
+ <p role="alert" className="text-[12px] text-red-11">
+ Couldn't load members. Reload to try again.
+ </p>
+ );
+
+ return (
+ <div className="flex flex-col gap-2">
+ <MemberSearch
+ excludeIds={memberIds}
+ onPick={addMember}
+ disabled={isSaving}
+ placeholder="Add people…"
+ />
+ <SettingsCard>
+ {members.map((member) => (
+ <MemberRow
+ key={member.id}
+ member={member}
+ tag={member.id === creatorId ? "Creator" : undefined}
+ disabled={isSaving}
+ onRemove={
+ member.id === creatorId ? undefined : () => removeMember(member)
+ }
+ />
+ ))}
+ </SettingsCard>
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceRepositories.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceRepositories.tsx
new file mode 100644
index 000000000000..cba72d71cd7c
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceRepositories.tsx
@@ -0,0 +1,48 @@
+import { Spinner } from "@posthog/quill";
+import type { TaskChannel } from "@posthog/shared/domain-types";
+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
+import { useUpdateTaskChannelRepositories } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
+import { RepositoriesField } from "@posthog/ui/features/integrations/components/RepositoriesField";
+import { SettingsCard } from "@posthog/ui/features/settings/components/SettingsCard";
+
+export function SpaceRepositories({ channel }: { channel: TaskChannel }) {
+ const update = useUpdateTaskChannelRepositories();
+ const client = useOptionalAuthenticatedClient();
+ const { data: currentUser } = useCurrentUser({ client });
+ const canEdit = currentUser?.id === channel.created_by?.id;
+
+ return (
+ <SettingsCard>
+ <div className="flex flex-col gap-2 px-3.5 py-3">
+ <RepositoriesField
+ selected={channel.repositories ?? []}
+ integrationId={channel.github_integration ?? null}
+ disabled={!canEdit || update.isPending}
+ onChange={(repositories, githubIntegration) =>
+ update.mutate({
+ channelId: channel.id,
+ githubIntegration,
+ repositories,
+ })
+ }
+ />
+ {update.isPending && (
+ <span className="flex items-center gap-1.5 text-[12px] text-muted-foreground">
+ <Spinner /> Saving…
+ </span>
+ )}
+ {update.error && (
+ <span className="text-[12px] text-red-11">
+ Couldn't save. Try again.
+ </span>
+ )}
+ {!canEdit && (
+ <span className="text-[12px] text-muted-foreground">
+ Only the space creator can change repositories.
+ </span>
+ )}
+ </div>
+ </SettingsCard>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx
index f70ff69b97dc..08688b1fb7e5 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceSelect.tsx
@@ -77,6 +77,7 @@ export function SpaceSelect({
const triggerGlyph = channelGlyph(current?.name, {
personal: current?.channelType === "personal",
+ private: current?.channelType === "private",
size: 14,
space: true,
});
@@ -145,6 +146,7 @@ export function SpaceSelect({
>
{channelGlyph(space.name, {
personal: space.channelType === "personal",
+ private: space.channelType === "private",
size: 14,
space: true,
})}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsx
new file mode 100644
index 000000000000..fc297bd5f0ed
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceSettings.tsx
@@ -0,0 +1,100 @@
+import { ChannelHeader } from "@posthog/ui/features/canvas/components/ChannelHeader";
+import { SpaceMembersSettings } from "@posthog/ui/features/canvas/components/SpaceMembersSettings";
+import { SpaceRepositories } from "@posthog/ui/features/canvas/components/SpaceRepositories";
+import { SpaceVisibility } from "@posthog/ui/features/canvas/components/SpaceVisibility";
+import { useChannelMembers } from "@posthog/ui/features/canvas/hooks/useChannelMembers";
+import {
+ type Channel,
+ useChannels,
+} from "@posthog/ui/features/canvas/hooks/useChannels";
+import { useTaskChannels } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
+import { SettingsSection } from "@posthog/ui/features/settings/components/SettingsCard";
+import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
+import {
+ PageHeader,
+ PageHeaderDescription,
+ PageHeaderHeading,
+ PageHeaderTitle,
+} from "@posthog/ui/primitives/PageHeader";
+import { useMemo } from "react";
+
+function isShared(
+ channel: Channel,
+): channel is Channel & { channelType: "public" | "private" } {
+ return channel.channelType !== "personal";
+}
+
+function memberCountLabel(count: number): string {
+ return count === 1 ? "1 member" : `${count} members`;
+}
+
+export function SpaceSettings({ channelId }: { channelId: string }) {
+ const { channels, isLoading } = useChannels();
+ const { channels: taskChannels, isLoading: tasksLoading } = useTaskChannels();
+ const channel = channels.find((item) => item.id === channelId);
+ const taskChannel = taskChannels.find((item) => item.id === channelId);
+ const header = useMemo(
+ () => <ChannelHeader channelId={channelId} page="settings" />,
+ [channelId],
+ );
+ useSetHeaderContent(header);
+ const isPrivate = channel?.channelType === "private";
+ const { members } = useChannelMembers(isPrivate ? channelId : null);
+
+ if (isLoading || tasksLoading)
+ return (
+ <p className="p-6 text-muted-foreground text-sm">Loading settings…</p>
+ );
+ if (!channel || !taskChannel)
+ return (
+ <p className="p-6 text-muted-foreground text-sm">
+ This space is unavailable. Choose another space from the sidebar.
+ </p>
+ );
+
+ return (
+ <div className="h-full overflow-y-auto">
+ <PageHeader>
+ <PageHeaderHeading>
+ <PageHeaderTitle>Settings</PageHeaderTitle>
+ <PageHeaderDescription>
+ Repositories and who can see this space. Changes save as you make
+ them.
+ </PageHeaderDescription>
+ </PageHeaderHeading>
+ </PageHeader>
+ <div className="flex max-w-[800px] flex-col gap-7 px-6 py-5">
+ <SettingsSection
+ label="Repositories"
+ description="Sessions in this space start with these repositories checked out."
+ >
+ <SpaceRepositories channel={taskChannel} />
+ </SettingsSection>
+ <SettingsSection label="Access">
+ {isShared(channel) ? (
+ <SpaceVisibility key={channel.channelType} channel={channel} />
+ ) : (
+ <p className="text-[12px] text-muted-foreground">
+ Only you can see this personal space.
+ </p>
+ )}
+ </SettingsSection>
+ {isPrivate && (
+ <SettingsSection
+ label="Members"
+ description="Any member can add or remove people."
+ action={
+ members.length > 0 ? (
+ <span className="text-[12px] text-muted-foreground">
+ {memberCountLabel(members.length)}
+ </span>
+ ) : null
+ }
+ >
+ <SpaceMembersSettings key={channel.id} channel={channel} />
+ </SettingsSection>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceVisibility.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceVisibility.tsx
new file mode 100644
index 000000000000..5f24778b6f33
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceVisibility.tsx
@@ -0,0 +1,129 @@
+import {
+ AlertDialog,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+ Button,
+} from "@posthog/quill";
+import {
+ type Channel,
+ useChannelMutations,
+} from "@posthog/ui/features/canvas/hooks/useChannels";
+import {
+ SettingsCard,
+ SettingsCardRow,
+} from "@posthog/ui/features/settings/components/SettingsCard";
+import { toast } from "@posthog/ui/primitives/toast";
+import { useState } from "react";
+
+type SharedType = "public" | "private";
+
+const VISIBILITY: Record<
+ SharedType,
+ {
+ label: string;
+ description: string;
+ action: string;
+ confirmTitle: string;
+ confirmBody: string;
+ }
+> = {
+ public: {
+ label: "Public",
+ description: "Everyone in the project can see this space.",
+ action: "Make private",
+ confirmTitle: "Make this space private?",
+ confirmBody:
+ "Only you and the creator keep access. Other people lose access until you add them as members.",
+ },
+ private: {
+ label: "Private",
+ description: "Only members can see this space.",
+ action: "Make public",
+ confirmTitle: "Make this space public?",
+ confirmBody:
+ "Everyone in the project gains access to this space and its sessions. The member list is removed.",
+ },
+};
+
+function oppositeOf(type: SharedType): SharedType {
+ return type === "public" ? "private" : "public";
+}
+
+export function SpaceVisibility({
+ channel,
+}: {
+ channel: Channel & { channelType: SharedType };
+}) {
+ const { updateChannelType, isUpdatingChannelType } = useChannelMutations();
+ const [confirming, setConfirming] = useState(false);
+ const current = VISIBILITY[channel.channelType];
+ const canChange = channel.systemRole !== "general";
+
+ const confirm = async () => {
+ try {
+ await updateChannelType(channel.id, oppositeOf(channel.channelType));
+ setConfirming(false);
+ } catch (error) {
+ toast.error("Couldn't change who can see this space. Try again.", {
+ description: error instanceof Error ? error.message : String(error),
+ });
+ }
+ };
+
+ return (
+ <>
+ <SettingsCard>
+ <SettingsCardRow
+ label={current.label}
+ description={current.description}
+ >
+ {canChange && (
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={isUpdatingChannelType}
+ onClick={() => setConfirming(true)}
+ >
+ {current.action}
+ </Button>
+ )}
+ </SettingsCardRow>
+ </SettingsCard>
+ <AlertDialog
+ open={confirming}
+ onOpenChange={(next) => {
+ if (!next && !isUpdatingChannelType) setConfirming(false);
+ }}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>{current.confirmTitle}</AlertDialogTitle>
+ <AlertDialogDescription>
+ {current.confirmBody}
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <Button
+ variant="outline"
+ onClick={() => setConfirming(false)}
+ disabled={isUpdatingChannelType}
+ >
+ Cancel
+ </Button>
+ <Button
+ variant="primary"
+ onClick={() => void confirm()}
+ loading={isUpdatingChannelType}
+ disabled={isUpdatingChannelType}
+ >
+ {current.action}
+ </Button>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx
index 3a4b4ff385e0..a69f042d49b8 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpacesIndex.tsx
@@ -34,7 +34,11 @@ function SpaceCard({ channel }: { channel: Channel }) {
<Card className="h-full transition-colors hover:bg-fill-hover">
<CardContent className="flex flex-col gap-2 p-4">
<div className="flex min-w-0 items-center gap-1.5">
- {channelGlyph(channel.name, { size: 14, personal })}
+ {channelGlyph(channel.name, {
+ size: 14,
+ personal,
+ private: channel.channelType === "private",
+ })}
<Text weight="semibold" className="truncate">
{channelDisplayLabel(channel.name, channel.channelType)}
</Text>
diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx
index 8c2629a5f5f8..2b18d313e057 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteContext.tsx
@@ -1,8 +1,4 @@
-import {
- FileTextIcon,
- GitBranchIcon,
- SparkleIcon,
-} from "@phosphor-icons/react";
+import { FileTextIcon, SparkleIcon } from "@phosphor-icons/react";
import {
ContextWikiUnavailableError,
FolderInstructionsConflictError,
@@ -18,9 +14,6 @@ import {
Button as QuillButton,
} from "@posthog/quill";
import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
-import type { TaskChannel } from "@posthog/shared/domain-types";
-import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
-import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
import { ChannelHeader } from "@posthog/ui/features/canvas/components/ChannelHeader";
import { CreateChannelModal } from "@posthog/ui/features/canvas/components/CreateChannelModal";
import { channelPageIcon } from "@posthog/ui/features/canvas/components/channelPages";
@@ -31,15 +24,10 @@ import {
useFolderInstructionsMutations,
useFolderInstructionsVersions,
} from "@posthog/ui/features/canvas/hooks/useFolderInstructions";
-import {
- useTaskChannels,
- useUpdateTaskChannelRepositories,
-} from "@posthog/ui/features/canvas/hooks/useTaskChannels";
import { ContextWikiPagePane } from "@posthog/ui/features/context-wiki/components/ContextWikiPagePane";
import { useChannelContextWikiPage } from "@posthog/ui/features/context-wiki/hooks/useContextWiki";
import { MarkdownRenderer } from "@posthog/ui/features/editor/components/MarkdownRenderer";
import { useContextLayerFlag } from "@posthog/ui/features/feature-flags/useContextLayerFlag";
-import { RepositoriesField } from "@posthog/ui/features/integrations/components/RepositoriesField";
import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
import {
PageHeader,
@@ -131,8 +119,6 @@ function WikiWebsiteContext({
path: string;
}) {
const spacesLayout = useChannelsLayout();
- const { channels: taskChannels } = useTaskChannels();
- const taskChannel = taskChannels.find((channel) => channel.id === channelId);
const headerContent = useMemo(
() => <ChannelHeader channelId={channelId} page="context" />,
[channelId],
@@ -166,9 +152,6 @@ function WikiWebsiteContext({
</PageHeaderActions>
</PageHeader>
) : null}
- {spacesLayout && taskChannel ? (
- <SpaceRepositories channel={taskChannel} />
- ) : null}
<ContextWikiPagePane key={path} path={path} />
</div>
);
@@ -183,8 +166,6 @@ function LegacyWebsiteContext({ channelId }: WebsiteContextProps) {
const channelName =
channels.find((c) => c.id === channelId)?.name ??
(spacesLayout ? "Space" : "Channel");
- const { channels: taskChannels } = useTaskChannels();
- const taskChannel = taskChannels.find((channel) => channel.id === channelId);
const {
data: latest,
@@ -292,17 +273,7 @@ function LegacyWebsiteContext({ channelId }: WebsiteContextProps) {
</PageHeaderHeading>
</PageHeader>
)}
- {spacesLayout && taskChannel ? (
- <SpaceRepositories channel={taskChannel} />
- ) : null}
- <Flex
- align="center"
- justify="between"
- gap="3"
- px="4"
- py="2"
- className="shrink-0 border-b border-b-(--gray-5)"
- >
+ <div className="flex shrink-0 items-center justify-between gap-3 border-b border-b-(--gray-5) px-6 py-2">
<Flex align="center" gap="3">
<SegmentedControl.Root
value={mode}
@@ -391,10 +362,10 @@ function LegacyWebsiteContext({ channelId }: WebsiteContextProps) {
</Button>
</Flex>
) : null}
- </Flex>
+ </div>
{publishError ? (
- <Box px="4" pt="3">
+ <div className="px-6 pt-3">
<Callout.Root color={isConflict ? "amber" : "red"} size="1">
<Callout.Text>
{isConflict
@@ -402,11 +373,11 @@ function LegacyWebsiteContext({ channelId }: WebsiteContextProps) {
: `Save failed: ${publishError.message}`}
</Callout.Text>
</Callout.Root>
- </Box>
+ </div>
) : null}
{!selectedVersion && mode === "edit" ? (
- <Box p="4" className="flex min-h-0 flex-1">
+ <div className="flex min-h-0 flex-1 px-6 py-4">
<TextArea
value={draft}
onChange={(e) => {
@@ -421,14 +392,14 @@ function LegacyWebsiteContext({ channelId }: WebsiteContextProps) {
}
className="min-h-0 flex-1 font-[var(--code-font-family)]"
/>
- </Box>
+ </div>
) : (
<ScrollArea
type="auto"
scrollbars="vertical"
className="scroll-area-constrain-width min-h-0 flex-1"
>
- <Box p="4">
+ <div className="px-6 py-4">
{selectedVersion ? (
<Callout.Root color="gray" size="1">
<Callout.Text>
@@ -452,48 +423,13 @@ function LegacyWebsiteContext({ channelId }: WebsiteContextProps) {
}}
/>
)}
- </Box>
+ </div>
</ScrollArea>
)}
</Flex>
);
}
-function SpaceRepositories({ channel }: { channel: TaskChannel }) {
- const update = useUpdateTaskChannelRepositories();
- const client = useOptionalAuthenticatedClient();
- const { data: currentUser } = useCurrentUser({ client });
- const canEdit = currentUser?.id === channel.created_by?.id;
-
- return (
- <div className="flex shrink-0 flex-col gap-2 border-b border-b-(--gray-5) px-4 py-3">
- <div className="flex items-center gap-2">
- <GitBranchIcon size={15} className="text-muted-foreground" />
- <span className="font-medium text-[13px]">Repositories</span>
- {update.isPending ? (
- <Spinner size="1" />
- ) : update.error ? (
- <span className="text-[12px] text-red-11">
- Couldn't save. Try again.
- </span>
- ) : null}
- </div>
- <RepositoriesField
- selected={channel.repositories ?? []}
- integrationId={channel.github_integration ?? null}
- disabled={!canEdit || update.isPending}
- onChange={(repositories, githubIntegration) =>
- update.mutate({
- channelId: channel.id,
- githubIntegration,
- repositories,
- })
- }
- />
- </div>
- );
-}
-
function EmptyState({
channelId,
channelName,
diff --git a/products/desktop/packages/ui/src/features/canvas/components/canvasSpaceOptions.tsx b/products/desktop/packages/ui/src/features/canvas/components/canvasSpaceOptions.tsx
index 8494bb5117ea..2268c1ac9f47 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/canvasSpaceOptions.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/canvasSpaceOptions.tsx
@@ -10,6 +10,7 @@ function optionForChannel(channel: Channel): CanvasMultiSelectOption {
icon: channelGlyph(channel.name, {
size: 16,
personal,
+ private: channel.channelType === "private",
space: true,
className: "shrink-0 text-muted-foreground",
}),
diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.test.tsx
index 4ed130715e93..98d63f747352 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.test.tsx
@@ -1,9 +1,9 @@
import { HashIcon, LockSimpleIcon } from "@phosphor-icons/react";
import type { ReactElement } from "react";
import { describe, expect, it } from "vitest";
-import { channelGlyph, isPrivateChannel } from "./channelGlyph";
+import { channelGlyph, isPersonalChannelName } from "./channelGlyph";
-describe("isPrivateChannel", () => {
+describe("isPersonalChannelName", () => {
it.each([
["personal", true],
[" Personal ", true],
@@ -13,13 +13,13 @@ describe("isPrivateChannel", () => {
["me", false],
["code", false],
["posthog-feedback", false],
- // Not a prefix match: only the personal channel itself is private.
+ // Not a prefix match: only the personal channel itself is the #me space.
["personal-notes", false],
["team-personal", false],
[undefined, false],
["", false],
])("%s -> %s", (name, expected) => {
- expect(isPrivateChannel(name)).toBe(expected);
+ expect(isPersonalChannelName(name)).toBe(expected);
});
});
@@ -56,4 +56,13 @@ describe("channelGlyph", () => {
channelGlyph("personal", { personal: false, space: true }),
).toBeNull();
});
+
+ it("gives a private space the same lock as a personal space", () => {
+ const glyph = channelGlyph("squad", {
+ private: true,
+ space: true,
+ }) as ReactElement;
+
+ expect(glyph.type).toBe(LockSimpleIcon);
+ });
});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.tsx b/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.tsx
index 06a8ebd1bcf5..17234e19f14f 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/channelGlyph.tsx
@@ -7,24 +7,27 @@ import { PERSONAL_CHANNEL_LABEL } from "@posthog/ui/features/canvas/hooks/useTas
import type { ReactNode } from "react";
/**
- * Whether only its own members can see a channel, judged by its name.
+ * Whether a name reads as the viewer's own "#me" space, judged by the name.
*
* This is a fallback for surfaces that hold a name and nothing else. A caller
- * with the channel in hand must pass `personal` to avoid deciding privacy from
- * a display label.
+ * with the channel in hand must pass `personal` to avoid deciding it from a
+ * display label.
*/
-export function isPrivateChannel(channelName: string | undefined): boolean {
+export function isPersonalChannelName(
+ channelName: string | undefined,
+): boolean {
if (!channelName) return false;
return channelName.trim().toLowerCase() === PERSONAL_CHANNEL_LABEL;
}
/**
- * A channel's leading glyph: a lock when it's private, a hash under the legacy
- * Channels layout, and nothing at all for a space.
+ * A channel's leading glyph: the viewer's own "#me" space wears a plain lock, a
+ * private shared space the same lock, the legacy Channels layout a hash, and an
+ * ordinary space nothing at all.
*
* Spaces dropped their cube because it said nothing the name didn't — a column
* of identical marks is noise, and the only thing worth calling out in that list
- * is the one space that isn't shared. The hash stays where it still separates a
+ * is a space not everyone can see. The hash stays where it still separates a
* channel from the other things in that tree.
*/
export function channelGlyph(
@@ -35,16 +38,21 @@ export function channelGlyph(
weight?: IconWeight;
space?: boolean;
/**
- * Whether this is the viewer's private space. Pass it wherever the channel
+ * Whether this is the viewer's own "#me" space. Pass it wherever the channel
* is in hand: the lock says "only you can see this", and deciding that from
* a name hands it to any public space that took the name.
*/
personal?: boolean;
+ /**
+ * Whether this is a private shared space with access limited to members.
+ */
+ private?: boolean;
},
): ReactNode {
- const personal = opts?.personal ?? isPrivateChannel(channelName);
- if (!personal && opts?.space) return null;
- const Icon = personal ? LockSimpleIcon : HashIcon;
+ const personal = opts?.personal ?? isPersonalChannelName(channelName);
+ const isPrivate = opts?.private ?? false;
+ if (!personal && !isPrivate && opts?.space) return null;
+ const Icon = personal || isPrivate ? LockSimpleIcon : HashIcon;
return (
<Icon
size={opts?.size ?? 16}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelPages.tsx b/products/desktop/packages/ui/src/features/canvas/components/channelPages.tsx
index c7417dda6ed6..8e8a86df35b1 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/channelPages.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/channelPages.tsx
@@ -2,6 +2,7 @@ import {
BookOpenTextIcon,
ChatsCircleIcon,
ClockCounterClockwiseIcon,
+ GearIcon,
type IconProps,
ShapesIcon,
} from "@phosphor-icons/react";
@@ -24,7 +25,8 @@ export type ChannelPageKey =
| "context"
| "loops"
| "canvases"
- | "history";
+ | "history"
+ | "settings";
export const CHANNEL_PAGES: Record<
ChannelPageKey,
@@ -35,6 +37,7 @@ export const CHANNEL_PAGES: Record<
loops: { label: "Loops", Icon: LoopIcon },
canvases: { label: "Canvases", Icon: ShapesIcon },
history: { label: "Recents", Icon: ClockCounterClockwiseIcon },
+ settings: { label: "Settings", Icon: GearIcon },
};
export function channelPageLabel(key: ChannelPageKey): string {
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.test.tsx b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.test.tsx
index 4d832a4449ff..26605261b3b5 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelItems.test.tsx
@@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({
channels: [] as {
id: string;
name: string;
- channelType: "public" | "personal";
+ channelType: "public" | "personal" | "private";
starred: boolean;
}[],
isLoading: true,
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannelMembers.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelMembers.ts
new file mode 100644
index 000000000000..9ace017224b4
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannelMembers.ts
@@ -0,0 +1,59 @@
+import type { UserBasic } from "@posthog/shared/domain-types";
+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import { TASK_CHANNELS_QUERY_KEY } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
+import { useAuthenticatedQuery } from "@posthog/ui/hooks/useAuthenticatedQuery";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+
+export const channelMembersQueryKey = (channelId: string | null) =>
+ ["channel-members", channelId] as const;
+
+/** The members of a private channel. Disabled until a channel id is known. */
+export function useChannelMembers(channelId: string | null): {
+ members: UserBasic[];
+ isLoading: boolean;
+ error: Error | null;
+} {
+ const query = useAuthenticatedQuery<UserBasic[]>(
+ channelMembersQueryKey(channelId),
+ (client) => client.listTaskChannelMembers(channelId as string),
+ { enabled: !!channelId },
+ );
+ return {
+ members: query.data ?? [],
+ isLoading: query.isLoading,
+ error: query.error,
+ };
+}
+
+/**
+ * Replace a private channel's member set. Invalidates both the members query and
+ * the channel list, so a space that just became visible or hidden updates too.
+ */
+export function useSetChannelMembers(channelId: string): {
+ setMembers: (userIds: number[]) => Promise<UserBasic[]>;
+ isSaving: boolean;
+} {
+ const client = useOptionalAuthenticatedClient();
+ const queryClient = useQueryClient();
+
+ const mutation = useMutation({
+ mutationFn: async (userIds: number[]) => {
+ if (!client) throw new Error("Not authenticated");
+ return client.setTaskChannelMembers(channelId, userIds);
+ },
+ onSuccess: (members) => {
+ // The PUT returns the authoritative set, so write it straight in. The channel
+ // list still needs a refetch: a space may have just become visible or hidden.
+ queryClient.setQueryData<UserBasic[]>(
+ channelMembersQueryKey(channelId),
+ members,
+ );
+ void queryClient.invalidateQueries({ queryKey: TASK_CHANNELS_QUERY_KEY });
+ },
+ });
+
+ return {
+ setMembers: (userIds: number[]) => mutation.mutateAsync(userIds),
+ isSaving: mutation.isPending,
+ };
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useChannels.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useChannels.ts
index 5e853057e6f6..3d63f0b24eb2 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useChannels.ts
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useChannels.ts
@@ -1,5 +1,6 @@
import type { TaskChannel, UserBasic } from "@posthog/shared/domain-types";
import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import { channelMembersQueryKey } from "@posthog/ui/features/canvas/hooks/useChannelMembers";
import {
TASK_CHANNELS_QUERY_KEY,
useTaskChannels,
@@ -13,8 +14,13 @@ export interface Channel {
id: string;
/** Normalized display name (lowercase-dashed; rendered "#name"). */
name: string;
- /** `personal` is the user's private "#me" channel. */
- channelType: "public" | "personal";
+ /**
+ * `personal` is the user's private "#me" channel. `private` is a shared space
+ * only its members can see.
+ */
+ channelType: "public" | "personal" | "private";
+ /** Set on the two provisioned spaces, which cannot change type or name. */
+ systemRole?: "personal" | "general" | null;
/** Whether the current user starred this channel. */
starred: boolean;
/** The repos the space is wired to. Empty where none are. */
@@ -32,6 +38,7 @@ function toChannel(channel: TaskChannel): Channel {
id: channel.id,
name: channel.name,
channelType: channel.channel_type,
+ systemRole: channel.system_role ?? null,
starred: channel.starred,
repositories: channel.repositories ?? NO_REPOSITORIES,
autoArchiveAfterDays: channel.auto_archive_after_days ?? null,
@@ -72,7 +79,17 @@ export function useChannelMutations() {
}, [queryClient]);
const createMutation = useMutation({
- mutationFn: async ({ name, star }: { name: string; star: boolean }) => {
+ mutationFn: async ({
+ name,
+ star,
+ channelType,
+ memberIds,
+ }: {
+ name: string;
+ star: boolean;
+ channelType?: "public" | "private";
+ memberIds?: number[];
+ }) => {
if (!client) throw new Error("Not authenticated");
// Resolve-or-create is idempotent server-side, so racing creators of the
// same name converge on one channel.
@@ -84,7 +101,11 @@ export function useChannelMutations() {
const isNewToTheList = queryClient
.getQueryData<TaskChannel[]>(TASK_CHANNELS_QUERY_KEY)
?.every((channel) => channel.name !== name);
- const created = await client.resolveTaskChannel(name, { star });
+ const created = await client.resolveTaskChannel(name, {
+ star,
+ channelType,
+ memberIds,
+ });
if (!star || created.starred || !isNewToTheList) return created;
// TODO: delete once `star` on create is live on Cloud. A backend that
// predates it drops the flag and hands back an unstarred channel, so ask
@@ -154,17 +175,60 @@ export function useChannelMutations() {
},
});
+ const channelTypeMutation = useMutation({
+ mutationFn: async ({
+ id,
+ channelType,
+ }: {
+ id: string;
+ channelType: "public" | "private";
+ }) => {
+ if (!client) throw new Error("Not authenticated");
+ return client.updateTaskChannelType(id, channelType);
+ },
+ onSuccess: (updatedChannel) => {
+ queryClient.setQueryData<TaskChannel[]>(
+ TASK_CHANNELS_QUERY_KEY,
+ (channels) =>
+ channels?.map((channel) =>
+ channel.id === updatedChannel.id ? updatedChannel : channel,
+ ),
+ );
+ void queryClient.invalidateQueries({
+ queryKey: channelMembersQueryKey(updatedChannel.id),
+ });
+ invalidate();
+ },
+ });
+
return {
- createChannel: (name: string, options: { star: boolean }) =>
- createMutation.mutateAsync({ name, star: options.star }).then(toChannel),
+ createChannel: (
+ name: string,
+ options: {
+ star: boolean;
+ channelType?: "public" | "private";
+ memberIds?: number[];
+ },
+ ) =>
+ createMutation
+ .mutateAsync({
+ name,
+ star: options.star,
+ channelType: options.channelType,
+ memberIds: options.memberIds,
+ })
+ .then(toChannel),
deleteChannel: (id: string) => deleteMutation.mutateAsync(id),
renameChannel: (id: string, name: string) =>
renameMutation.mutateAsync({ id, name }).then(toChannel),
updateAutoArchive: (id: string, inactivityDays: number | null) =>
autoArchiveMutation.mutateAsync({ id, inactivityDays }).then(toChannel),
+ updateChannelType: (id: string, channelType: "public" | "private") =>
+ channelTypeMutation.mutateAsync({ id, channelType }).then(toChannel),
isCreating: createMutation.isPending,
isDeleting: deleteMutation.isPending,
isRenaming: renameMutation.isPending,
isUpdatingAutoArchive: autoArchiveMutation.isPending,
+ isUpdatingChannelType: channelTypeMutation.isPending,
};
}
diff --git a/products/desktop/packages/ui/src/features/command/CommandMenu.tsx b/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
index d5fa12a02790..dcea8a58c255 100644
--- a/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
+++ b/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
@@ -714,6 +714,7 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
keywords: "space channel",
icon: channelGlyph(channel.name, {
personal: channel.channelType === "personal",
+ private: channel.channelType === "private",
size: 12,
space: spacesLayout,
className: "text-muted-foreground",
diff --git a/products/desktop/packages/ui/src/router/routeTree.gen.ts b/products/desktop/packages/ui/src/router/routeTree.gen.ts
index 7aac9eb6bf40..da40fdfb7e6d 100644
--- a/products/desktop/packages/ui/src/router/routeTree.gen.ts
+++ b/products/desktop/packages/ui/src/router/routeTree.gen.ts
@@ -56,6 +56,7 @@ import { Route as ShellSpacesContextRouteImport } from './routes/_shell/spaces/c
import { Route as ShellSettingsCategoryRouteImport } from './routes/_shell/settings/$category'
import { Route as ShellFeedsFeedIdRouteImport } from './routes/_shell/feeds/$feedId'
import { Route as ShellSpacesChannelIdIndexRouteImport } from './routes/_shell/spaces/$channelId/index'
+import { Route as ShellSpacesChannelIdSettingsRouteImport } from './routes/_shell/spaces/$channelId/settings'
import { Route as ShellSpacesChannelIdNewRouteImport } from './routes/_shell/spaces/$channelId/new'
import { Route as ShellSpacesChannelIdLoopsRouteImport } from './routes/_shell/spaces/$channelId/loops'
import { Route as ShellSpacesChannelIdHistoryRouteImport } from './routes/_shell/spaces/$channelId/history'
@@ -301,6 +302,12 @@ const ShellSpacesChannelIdIndexRoute =
path: '/spaces/$channelId/',
getParentRoute: () => ShellRoute,
} as any)
+const ShellSpacesChannelIdSettingsRoute =
+ ShellSpacesChannelIdSettingsRouteImport.update({
+ id: '/spaces/$channelId/settings',
+ path: '/spaces/$channelId/settings',
+ getParentRoute: () => ShellRoute,
+ } as any)
const ShellSpacesChannelIdNewRoute = ShellSpacesChannelIdNewRouteImport.update({
id: '/spaces/$channelId/new',
path: '/spaces/$channelId/new',
@@ -407,6 +414,7 @@ export interface FileRoutesByFullPath {
'/spaces/$channelId/history': typeof ShellSpacesChannelIdHistoryRoute
'/spaces/$channelId/loops': typeof ShellSpacesChannelIdLoopsRoute
'/spaces/$channelId/new': typeof ShellSpacesChannelIdNewRoute
+ '/spaces/$channelId/settings': typeof ShellSpacesChannelIdSettingsRoute
'/spaces/$channelId/': typeof ShellSpacesChannelIdIndexRoute
'/spaces/$channelId/dashboards/$dashboardId': typeof ShellSpacesChannelIdDashboardsDashboardIdRoute
'/spaces/$channelId/reports/$reportId': typeof ShellSpacesChannelIdReportsReportIdRoute
@@ -458,6 +466,7 @@ export interface FileRoutesByTo {
'/spaces/$channelId/history': typeof ShellSpacesChannelIdHistoryRoute
'/spaces/$channelId/loops': typeof ShellSpacesChannelIdLoopsRoute
'/spaces/$channelId/new': typeof ShellSpacesChannelIdNewRoute
+ '/spaces/$channelId/settings': typeof ShellSpacesChannelIdSettingsRoute
'/spaces/$channelId': typeof ShellSpacesChannelIdIndexRoute
'/spaces/$channelId/dashboards/$dashboardId': typeof ShellSpacesChannelIdDashboardsDashboardIdRoute
'/spaces/$channelId/reports/$reportId': typeof ShellSpacesChannelIdReportsReportIdRoute
@@ -517,6 +526,7 @@ export interface FileRoutesById {
'/_shell/spaces/$channelId/history': typeof ShellSpacesChannelIdHistoryRoute
'/_shell/spaces/$channelId/loops': typeof ShellSpacesChannelIdLoopsRoute
'/_shell/spaces/$channelId/new': typeof ShellSpacesChannelIdNewRoute
+ '/_shell/spaces/$channelId/settings': typeof ShellSpacesChannelIdSettingsRoute
'/_shell/spaces/$channelId/': typeof ShellSpacesChannelIdIndexRoute
'/_shell/spaces/$channelId/dashboards/$dashboardId': typeof ShellSpacesChannelIdDashboardsDashboardIdRoute
'/_shell/spaces/$channelId/reports/$reportId': typeof ShellSpacesChannelIdReportsReportIdRoute
@@ -576,6 +586,7 @@ export interface FileRouteTypes {
| '/spaces/$channelId/history'
| '/spaces/$channelId/loops'
| '/spaces/$channelId/new'
+ | '/spaces/$channelId/settings'
| '/spaces/$channelId/'
| '/spaces/$channelId/dashboards/$dashboardId'
| '/spaces/$channelId/reports/$reportId'
@@ -627,6 +638,7 @@ export interface FileRouteTypes {
| '/spaces/$channelId/history'
| '/spaces/$channelId/loops'
| '/spaces/$channelId/new'
+ | '/spaces/$channelId/settings'
| '/spaces/$channelId'
| '/spaces/$channelId/dashboards/$dashboardId'
| '/spaces/$channelId/reports/$reportId'
@@ -685,6 +697,7 @@ export interface FileRouteTypes {
| '/_shell/spaces/$channelId/history'
| '/_shell/spaces/$channelId/loops'
| '/_shell/spaces/$channelId/new'
+ | '/_shell/spaces/$channelId/settings'
| '/_shell/spaces/$channelId/'
| '/_shell/spaces/$channelId/dashboards/$dashboardId'
| '/_shell/spaces/$channelId/reports/$reportId'
@@ -1042,6 +1055,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ShellSpacesChannelIdIndexRouteImport
parentRoute: typeof ShellRoute
}
+ '/_shell/spaces/$channelId/settings': {
+ id: '/_shell/spaces/$channelId/settings'
+ path: '/spaces/$channelId/settings'
+ fullPath: '/spaces/$channelId/settings'
+ preLoaderRoute: typeof ShellSpacesChannelIdSettingsRouteImport
+ parentRoute: typeof ShellRoute
+ }
'/_shell/spaces/$channelId/new': {
id: '/_shell/spaces/$channelId/new'
path: '/spaces/$channelId/new'
@@ -1128,6 +1148,7 @@ interface ShellRouteChildren {
ShellSpacesChannelIdHistoryRoute: typeof ShellSpacesChannelIdHistoryRoute
ShellSpacesChannelIdLoopsRoute: typeof ShellSpacesChannelIdLoopsRoute
ShellSpacesChannelIdNewRoute: typeof ShellSpacesChannelIdNewRoute
+ ShellSpacesChannelIdSettingsRoute: typeof ShellSpacesChannelIdSettingsRoute
ShellSpacesChannelIdIndexRoute: typeof ShellSpacesChannelIdIndexRoute
ShellSpacesChannelIdDashboardsDashboardIdRoute: typeof ShellSpacesChannelIdDashboardsDashboardIdRoute
ShellSpacesChannelIdReportsReportIdRoute: typeof ShellSpacesChannelIdReportsReportIdRoute
@@ -1154,6 +1175,7 @@ const ShellRouteChildren: ShellRouteChildren = {
ShellSpacesChannelIdHistoryRoute: ShellSpacesChannelIdHistoryRoute,
ShellSpacesChannelIdLoopsRoute: ShellSpacesChannelIdLoopsRoute,
ShellSpacesChannelIdNewRoute: ShellSpacesChannelIdNewRoute,
+ ShellSpacesChannelIdSettingsRoute: ShellSpacesChannelIdSettingsRoute,
ShellSpacesChannelIdIndexRoute: ShellSpacesChannelIdIndexRoute,
ShellSpacesChannelIdDashboardsDashboardIdRoute:
ShellSpacesChannelIdDashboardsDashboardIdRoute,
diff --git a/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsx b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsx
new file mode 100644
index 000000000000..c3685603fe73
--- /dev/null
+++ b/products/desktop/packages/ui/src/router/routes/_shell/spaces/$channelId/settings.tsx
@@ -0,0 +1,11 @@
+import { SpaceSettings } from "@posthog/ui/features/canvas/components/SpaceSettings";
+import { createFileRoute } from "@tanstack/react-router";
+
+export const Route = createFileRoute("/_shell/spaces/$channelId/settings")({
+ component: SettingsRoute,
+});
+
+function SettingsRoute() {
+ const { channelId } = Route.useParams();
+ return <SpaceSettings channelId={channelId} />;
+}