: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(today): build the space page and settings on quill (#109115)
Shy Alter7c315125feb0
diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scssindex bc4e700e3761..737d61027d12 100644--- a/frontend/src/layout/today/TodayShell.scss+++ b/frontend/src/layout/today/TodayShell.scss@@ -51,21 +51,6 @@letter-spacing: 0.08em;}-.TodaySpaceFeed {- max-width: 720px;-}--.TodayPane__group {- padding: 12px 8px 4px;- font-size: 11px;- font-weight: 500;- color: var(--today-muted);-- &--first {- padding-top: 4px;- }-}-.TodayPane__state {display: flex;flex-direction: column;diff --git a/frontend/src/styles/quill-bridge.scss b/frontend/src/styles/quill-bridge.scssindex 250e18b55b47..3f8a66d437da 100644--- a/frontend/src/styles/quill-bridge.scss+++ b/frontend/src/styles/quill-bridge.scss@@ -180,6 +180,10 @@color: var(--info-foreground);}+[data-quill] .text-warning-foreground {+ color: var(--warning-foreground);+}+[data-quill] .text-accent-foreground {color: var(--accent-foreground);}diff --git a/products/tasks/frontend/spaces/SpaceAccess.tsx b/products/tasks/frontend/spaces/SpaceAccess.tsxnew file mode 100644index 000000000000..ee18cc73acf5--- /dev/null+++ b/products/tasks/frontend/spaces/SpaceAccess.tsx@@ -0,0 +1,114 @@+import { useActions, useValues } from 'kea'+import { useRef } from 'react'++import {+ Combobox,+ ComboboxChip,+ ComboboxChips,+ ComboboxChipsInput,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxItem,+ ComboboxList,+ ComboboxValue,+ FieldDescription,+ Label,+ RadioGroup,+ RadioGroupItem,+ Skeleton,+ Text,+} from '@posthog/quill'++import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { fullName } from 'lib/utils/strings'+import { membersLogic } from 'scenes/organization/membersLogic'++import { spaceSceneLogic } from './spaceSceneLogic'++export function SpaceAccess({ id }: { id: string }): JSX.Element | null {+ const { space, savingSpace, members, membersLoading } = useValues(spaceSceneLogic({ id }))+ const { updateSpace, setMemberIds } = useActions(spaceSceneLogic({ id }))+ const { meFirstMembers } = useValues(membersLogic)+ const { ensureAllMembersLoaded } = useActions(membersLogic)+ const anchor = useRef<HTMLDivElement>(null)++ useOnMountEffect(ensureAllMembersLoaded)++ if (!space) {+ return null+ }+ if (space.system_role === 'personal') {+ return (+ <Text size="sm" variant="muted">+ Only you can see your personal space.+ </Text>+ )+ }+ const isPrivate = space.channel_type === 'private'+ const generalSpace = space.system_role === 'general'+ const names = new Map<number, string>([+ ...meFirstMembers.map((member) => [member.user.id, fullName(member.user)] as [number, string]),+ ...members.map((member) => [member.id, fullName(member)] as [number, string]),+ ])+ const memberIds = members.map((member) => member.id)+ const allIds = [...new Set([...meFirstMembers.map((member) => member.user.id), ...memberIds])]++ return (+ <div className="flex flex-col gap-3">+ <RadioGroup+ value={isPrivate ? 'private' : 'public'}+ onValueChange={(channelType: 'public' | 'private') => updateSpace({ channel_type: channelType })}+ disabled={generalSpace || savingSpace}+ data-attr="today-space-settings-access"+ >+ <div className="flex items-center gap-2">+ <RadioGroupItem value="public" id="space-access-public" />+ <Label htmlFor="space-access-public">Everyone in the project</Label>+ </div>+ <div className="flex items-center gap-2">+ <RadioGroupItem value="private" id="space-access-private" />+ <Label htmlFor="space-access-private">Only members</Label>+ </div>+ </RadioGroup>+ {generalSpace && <FieldDescription>The general space is open to everyone in the project.</FieldDescription>}+ {isPrivate &&+ (membersLoading && !members.length ? (+ <Skeleton className="h-8 w-full max-w-100" />+ ) : (+ <div className="flex flex-col gap-1">+ <Combobox+ multiple+ items={allIds}+ value={memberIds}+ onValueChange={(userIds: number[]) => setMemberIds(userIds)}+ itemToStringLabel={(userId: number) => names.get(userId) ?? ''}+ >+ <ComboboxChips ref={anchor} className="max-w-100" data-attr="today-space-settings-members">+ <ComboboxValue>+ {(userIds: number[]) => (+ <>+ {userIds.map((userId) => (+ <ComboboxChip key={userId}>{names.get(userId) ?? ''}</ComboboxChip>+ ))}+ <ComboboxChipsInput placeholder="Add people" aria-label="Add people" />+ </>+ )}+ </ComboboxValue>+ </ComboboxChips>+ <ComboboxContent anchor={anchor}>+ <ComboboxEmpty>No one matches that name.</ComboboxEmpty>+ <ComboboxList>+ {(userId: number) => (+ <ComboboxItem key={userId} value={userId}>+ {names.get(userId)}+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ <FieldDescription>Any member can add or remove people.</FieldDescription>+ </div>+ ))}+ </div>+ )+}diff --git a/products/tasks/frontend/spaces/SpaceFeed.tsx b/products/tasks/frontend/spaces/SpaceFeed.tsxindex d3db33d39279..222a29aecf96 100644--- a/products/tasks/frontend/spaces/SpaceFeed.tsx+++ b/products/tasks/frontend/spaces/SpaceFeed.tsx@@ -1,9 +1,18 @@import { useActions, useValues } from 'kea'import { Fragment } from 'react'-import { LemonButton, Spinner } from '@posthog/lemon-ui'--import { cn } from 'lib/utils/css-classes'+import { IconCloud } from '@posthog/icons'+import {+ Button,+ Empty,+ EmptyDescription,+ EmptyHeader,+ EmptyMedia,+ EmptyTitle,+ Skeleton,+ Text,+ cn,+} from '@posthog/quill'import { TodaySessionRow } from '~/layout/today/TodaySessionRow'import { todaySpacesLogic } from '~/layout/today/todaySpacesLogic'@@ -18,36 +27,54 @@ export function SpaceFeed({ id }: { id: string }): JSX.Element {if (sessionsLoading && !feedGroups.length) {return (- <div className="TodayPane__state">- <Spinner />+ <div className="flex max-w-3xl flex-col gap-3 px-2 py-2">+ <Skeleton className="h-4 w-1/4" />+ <Skeleton className="h-4 w-3/4" />+ <Skeleton className="h-4 w-2/3" />+ <Skeleton className="h-4 w-1/2" /></div>)}if (sessionsUnavailable && !feedGroups.length) {return (- <div className="TodayPane__state">- <span>This space’s sessions didn’t load.</span>- <LemonButton- size="small"- type="secondary"+ <div className="flex flex-col items-start gap-2 px-2 py-2">+ <Text size="sm" variant="muted">+ This space’s sessions didn’t load.+ </Text>+ <Button+ variant="outline"+ size="sm"+ loading={sessionsLoading}onClick={() => loadSessions()}data-attr="today-space-feed-retry">Try again- </LemonButton>+ </Button></div>)}if (!feedGroups.length) {- return <div className="TodayPane__state">No sessions in this space yet.</div>+ return (+ <Empty className="py-12">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <IconCloud />+ </EmptyMedia>+ <EmptyTitle>No sessions yet</EmptyTitle>+ <EmptyDescription>+ Sessions that you or your agents start in this space show up here.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ )}return (- <div className="TodaySpaceFeed">+ <div className="flex max-w-3xl flex-col gap-px">{feedGroups.map((group, index) => (<Fragment key={group.key}>- <div className={cn('TodayPane__group', index === 0 && 'TodayPane__group--first')}>+ <Text size="xs" variant="muted" className={cn('block px-2 pb-1', index === 0 ? 'pt-1' : 'pt-3')}>{group.label}- </div>+ </Text>{group.items.map((item) => (<TodaySessionRowkey={item.id}diff --git a/products/tasks/frontend/spaces/SpaceRepositories.tsx b/products/tasks/frontend/spaces/SpaceRepositories.tsxnew file mode 100644index 000000000000..1aef288e85bb--- /dev/null+++ b/products/tasks/frontend/spaces/SpaceRepositories.tsx@@ -0,0 +1,90 @@+import { useActions, useValues } from 'kea'++import { IconGithub } from '@posthog/icons'+import { Button, Chip, ChipClose, Skeleton, Text } from '@posthog/quill'++import api from 'lib/api'+import { GitHubRepositoryCombobox } from 'lib/integrations/GitHubRepositoryCombobox'+import { integrationsLogic } from 'lib/integrations/integrationsLogic'+import { LinkPrimitive } from 'lib/lemon-ui/Link'++import { spaceSceneLogic } from './spaceSceneLogic'++const MAX_REPOSITORIES = 10++export function SpaceRepositories({ id }: { id: string }): JSX.Element | null {+ const { space, savingSpace } = useValues(spaceSceneLogic({ id }))+ const { updateSpace } = useActions(spaceSceneLogic({ id }))+ const { getIntegrationsByKind, integrationsLoading } = useValues(integrationsLogic)++ if (!space) {+ return null+ }+ const githubIntegrations = getIntegrationsByKind(['github'])+ const integrationId = space.github_integration ?? githubIntegrations[0]?.id+ const repositories = space.repositories++ return (+ <div className="flex flex-col items-start gap-2">+ {repositories.length ? (+ <div className="flex flex-wrap gap-1">+ {repositories.map((repository) => (+ <Chip key={repository} data-attr="today-space-settings-repository">+ {repository}+ <ChipClose+ aria-label={`Remove ${repository}`}+ disabled={savingSpace}+ onClick={() =>+ updateSpace({ repositories: repositories.filter((r) => r !== repository) })+ }+ />+ </Chip>+ ))}+ </div>+ ) : (+ <Text size="sm" variant="muted">+ No repositories yet.+ </Text>+ )}+ {integrationsLoading ? (+ <Skeleton className="h-8 w-60" />+ ) : !integrationId ? (+ <Button+ variant="outline"+ render={+ <LinkPrimitive+ to={api.integrations.authorizeUrl({ kind: 'github', next: window.location.pathname })}+ disableClientSideRouting+ />+ }+ data-attr="today-space-settings-connect-github"+ >+ <IconGithub />+ Connect GitHub+ </Button>+ ) : repositories.length < MAX_REPOSITORIES ? (+ <div className="w-full max-w-100">+ <GitHubRepositoryCombobox+ integrationId={integrationId}+ value=""+ placeholder="Add a repository"+ disabledReason={savingSpace ? 'Saving your last change' : undefined}+ onChange={(repository) => {+ if (repository && !repositories.includes(repository)) {+ updateSpace({+ repositories: [...repositories, repository],+ github_integration: integrationId,+ })+ }+ }}+ fullWidth+ />+ </div>+ ) : (+ <Text size="sm" variant="muted">+ A space can have up to {MAX_REPOSITORIES} repositories.+ </Text>+ )}+ </div>+ )+}diff --git a/products/tasks/frontend/spaces/SpaceScene.tsx b/products/tasks/frontend/spaces/SpaceScene.tsxindex 636b676e1960..7677213baa5c 100644--- a/products/tasks/frontend/spaces/SpaceScene.tsx+++ b/products/tasks/frontend/spaces/SpaceScene.tsx@@ -2,7 +2,22 @@ import { useActions, useValues } from 'kea'import { router } from 'kea-router'import { IconStar, IconStarFilled } from '@posthog/icons'-import { LemonButton, LemonTabs } from '@posthog/lemon-ui'+import {+ Button,+ Empty,+ EmptyContent,+ EmptyDescription,+ EmptyHeader,+ EmptyTitle,+ Tabs,+ TabsContent,+ TabsList,+ TabsTrigger,+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from '@posthog/quill'import { NotFound } from 'lib/components/NotFound'import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'@@ -36,50 +51,83 @@ export function SpaceScene({ id }: SpaceSceneLogicProps): JSX.Element {if (spaceUnavailable && !space) {return (<SceneContent>- <div className="TodayPane__state">- <span>This space didn’t load.</span>- <LemonButton- size="small"- type="secondary"- loading={spaceLoading}- onClick={() => loadSpace()}- data-attr="today-space-retry"- >- Try again- </LemonButton>- </div>+ <Empty className="py-12" data-quill>+ <EmptyHeader>+ <EmptyTitle>This space didn’t load</EmptyTitle>+ <EmptyDescription>Check your connection and try again.</EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button+ variant="outline"+ loading={spaceLoading}+ onClick={() => loadSpace()}+ data-attr="today-space-retry"+ >+ Try again+ </Button>+ </EmptyContent>+ </Empty></SceneContent>)}+ const starLabel = space?.starred ? 'Unstar space' : 'Star space'return (- <SceneContent>- <SceneTitleSection- name={space ? spaceLabel(space) : null}- isLoading={spaceLoading && !space}- resourceType={{ type: 'task' }}- nameSuffix={- space && space.system_role !== 'personal' ? (- <LemonButton- size="small"- icon={space.starred ? <IconStarFilled className="text-warning" /> : <IconStar />}- tooltip={space.starred ? 'Unstar space' : 'Star space'}- disabledReason={savingSpace ? 'Saving your last change' : undefined}- onClick={() => setStarred(!space.starred)}- data-attr="today-space-star"- />- ) : null- }- />- <LemonTabs<SpaceTab>- activeKey={activeTab}- onChange={(tab) =>- router.actions.push(tab === 'settings' ? urls.taskSpaceSettings(id) : urls.taskSpace(id))- }- tabs={[- { key: 'feed', label: 'Feed', content: <SpaceFeed id={id} /> },- { key: 'settings', label: 'Settings', content: <SpaceSettings key={space?.id} id={id} /> },- ]}- />- </SceneContent>+ <TooltipProvider>+ <SceneContent>+ <SceneTitleSection+ name={space ? spaceLabel(space) : null}+ isLoading={spaceLoading && !space}+ resourceType={{ type: 'task' }}+ nameSuffix={+ space && space.system_role !== 'personal' ? (+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon-sm"+ aria-label={starLabel}+ aria-pressed={space.starred}+ disabled={savingSpace}+ onClick={() => setStarred(!space.starred)}+ data-attr="today-space-star"+ />+ }+ >+ {space.starred ? (+ <IconStarFilled className="text-warning-foreground" />+ ) : (+ <IconStar />+ )}+ </TooltipTrigger>+ <TooltipContent>{savingSpace ? 'Saving your last change' : starLabel}</TooltipContent>+ </Tooltip>+ ) : null+ }+ />+ <Tabs+ value={activeTab}+ onValueChange={(tab: SpaceTab) =>+ router.actions.push(tab === 'settings' ? urls.taskSpaceSettings(id) : urls.taskSpace(id))+ }+ data-quill+ >+ <TabsList variant="line">+ <TabsTrigger value="feed" data-attr="today-space-tab-feed">+ Feed+ </TabsTrigger>+ <TabsTrigger value="settings" data-attr="today-space-tab-settings">+ Settings+ </TabsTrigger>+ </TabsList>+ <TabsContent value="feed">+ <SpaceFeed id={id} />+ </TabsContent>+ <TabsContent value="settings">+ <SpaceSettings key={space?.id} id={id} />+ </TabsContent>+ </Tabs>+ </SceneContent>+ </TooltipProvider>)}diff --git a/products/tasks/frontend/spaces/SpaceSettings.tsx b/products/tasks/frontend/spaces/SpaceSettings.tsxindex 1ac1e1d37aa9..fa3894cb7979 100644--- a/products/tasks/frontend/spaces/SpaceSettings.tsx+++ b/products/tasks/frontend/spaces/SpaceSettings.tsx@@ -1,10 +1,36 @@import { useActions, useValues } from 'kea'-import { useState } from 'react'+import { ChangeEvent, useState } from 'react'-import { LemonButton, LemonDialog, LemonInput, LemonLabel, LemonSelect } from '@posthog/lemon-ui'+import {+ AlertDialog,+ AlertDialogClose,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ AlertDialogTrigger,+ Button,+ Field,+ FieldDescription,+ FieldGroup,+ FieldLabel,+ FieldTitle,+ Input,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@posthog/quill'import { spaceLabel } from '~/layout/today/todaySpacesLogic'+import { SpaceAccess } from './SpaceAccess'+import { SpaceRepositories } from './SpaceRepositories'import { spaceSceneLogic } from './spaceSceneLogic'const AUTO_ARCHIVE_DAYS = [1, 3, 7, 14, 30]@@ -26,84 +52,134 @@ export function SpaceSettings({ id }: { id: string }): JSX.Element | null {.map((days) => ({ value: days, label: `After ${days} ${days === 1 ? 'day' : 'days'}` })),]const trimmedName = name.trim()+ const renameDisabledReason = defaultSpace+ ? 'Default spaces can’t be renamed'+ : !trimmedName+ ? 'Enter a name'+ : trimmedName === space.name+ ? 'Change the name first'+ : null+ const deleteDisabledReason = defaultSpace+ ? 'Default spaces can’t be deleted'+ : savingSpace+ ? 'Saving your last change'+ : nullreturn (- <div className="flex max-w-160 flex-col gap-6">- <div className="flex flex-col gap-2">- <LemonLabel htmlFor="space-name">Name</LemonLabel>+ <FieldGroup className="max-w-160">+ <Field>+ <FieldLabel htmlFor="space-name">Name</FieldLabel><div className="flex flex-wrap gap-2">- <LemonInput+ <Inputid="space-name"className="min-w-60 flex-1"value={defaultSpace ? spaceLabel(space) : name}- onChange={setName}- disabledReason={defaultSpace ? 'Default spaces can’t be renamed' : undefined}+ onChange={(event: ChangeEvent<HTMLInputElement>) => setName(event.target.value)}+ disabled={defaultSpace}data-attr="today-space-settings-name"/>- <LemonButton- type="secondary"- loading={savingSpace}- disabledReason={- defaultSpace- ? 'Default spaces can’t be renamed'- : !trimmedName- ? 'Enter a name'- : trimmedName === space.name- ? 'Change the name first'- : undefined- }- onClick={() => updateSpace({ name: trimmedName })}- data-attr="today-space-settings-rename"+ <Tooltip disabled={!renameDisabledReason || savingSpace}>+ <TooltipTrigger+ render={+ <Button+ variant="outline"+ loading={savingSpace}+ disabled={!!renameDisabledReason}+ onClick={() => updateSpace({ name: trimmedName })}+ data-attr="today-space-settings-rename"+ />+ }+ >+ Save+ </TooltipTrigger>+ <TooltipContent>{renameDisabledReason}</TooltipContent>+ </Tooltip>+ </div>+ {defaultSpace && <FieldDescription>Default spaces can’t be renamed.</FieldDescription>}+ </Field>+ <Field>+ <FieldTitle>Repositories</FieldTitle>+ <SpaceRepositories id={id} />+ <FieldDescription>Sessions in this space start with these repositories checked out.</FieldDescription>+ </Field>+ <Field>+ <FieldTitle>Access</FieldTitle>+ <SpaceAccess id={id} />+ </Field>+ <Field>+ <FieldLabel htmlFor="space-auto-archive">Auto-archive sessions</FieldLabel>+ <div>+ <Select+ items={autoArchiveOptions}+ value={autoArchiveDays}+ onValueChange={(days: number | null) => updateSpace({ auto_archive_after_days: days })}+ disabled={savingSpace}>- Save- </LemonButton>+ <SelectTrigger id="space-auto-archive" data-attr="today-space-settings-auto-archive">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {autoArchiveOptions.map((option) => (+ <SelectItem key={option.label} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ <FieldDescription>+ Sessions with no activity for this long move to the archive. In shared spaces, only project admins+ can change this.+ </FieldDescription>+ </Field>+ <Field>+ <FieldTitle>Delete space</FieldTitle>+ <div>+ <AlertDialog>+ <Tooltip disabled={!deleteDisabledReason}>+ <TooltipTrigger+ render={+ <AlertDialogTrigger+ render={+ <Button+ variant="destructive-outline"+ disabled={!!deleteDisabledReason}+ data-attr="today-space-settings-delete"+ />+ }+ />+ }+ >+ Delete space+ </TooltipTrigger>+ <TooltipContent>{deleteDisabledReason}</TooltipContent>+ </Tooltip>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>{`Delete ${spaceLabel(space)}?`}</AlertDialogTitle>+ <AlertDialogDescription>+ This removes the space for everyone. You can only delete a space that has no+ sessions or canvases.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>+ <AlertDialogClose+ render={+ <Button+ variant="destructive-outline"+ onClick={() => deleteSpace()}+ data-attr="today-space-settings-delete-confirm"+ />+ }+ >+ Delete+ </AlertDialogClose>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog></div>- </div>- <div className="flex flex-col gap-2">- <LemonLabel info="Sessions with no activity for this long move to the archive. In shared spaces, only project admins can change this.">- Auto-archive sessions- </LemonLabel>- <LemonSelect- className="self-start"- value={autoArchiveDays}- options={autoArchiveOptions}- onChange={(days) => updateSpace({ auto_archive_after_days: days })}- disabledReason={savingSpace ? 'Saving your last change' : undefined}- data-attr="today-space-settings-auto-archive"- />- </div>- <div className="flex flex-col gap-2">- <LemonLabel>Delete space</LemonLabel>- <LemonButton- className="self-start"- type="secondary"- status="danger"- disabledReason={- defaultSpace- ? 'Default spaces can’t be deleted'- : savingSpace- ? 'Saving your last change'- : undefined- }- onClick={() =>- LemonDialog.open({- title: `Delete ${spaceLabel(space)}?`,- description:- 'This removes the space for everyone. You can only delete a space that has no sessions or canvases.',- primaryButton: {- children: 'Delete',- status: 'danger',- onClick: deleteSpace,- 'data-attr': 'today-space-settings-delete-confirm',- },- secondaryButton: { children: 'Cancel' },- })- }- data-attr="today-space-settings-delete"- >- Delete space- </LemonButton>- </div>- </div>+ </Field>+ </FieldGroup>)}diff --git a/products/tasks/frontend/spaces/spaceSceneLogic.test.ts b/products/tasks/frontend/spaces/spaceSceneLogic.test.tsindex 481b1577ed73..0e46dfdf7258 100644--- a/products/tasks/frontend/spaces/spaceSceneLogic.test.ts+++ b/products/tasks/frontend/spaces/spaceSceneLogic.test.ts@@ -18,6 +18,9 @@ describe('spaceSceneLogic', () => {200,{ id: params.id, name: String(params.id), system_role: null },],+ '/api/projects/:team_id/task_channels/:id/members/': [+ { id: 7, uuid: 'user-7', first_name: 'Ada', email: '[email protected]' },+ ],'/api/projects/:team_id/tasks/': ({ request }) => {const channel = new URL(request.url).searchParams.get('channel')const results =@@ -80,4 +83,16 @@ describe('spaceSceneLogic', () => {expect(logic.values.spaceMissing).toBe(missing)expect(logic.values.spaceUnavailable).toBe(true)})++ it('loads the members once the space turns private', async () => {+ const logic = spaceSceneLogic({ id: 'space-a' })+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ expect(logic.values.members).toEqual([])++ logic.actions.updateSpace({ channel_type: 'private' })+ await expectLogic(logic).toDispatchActions(['spaceSaved', 'loadMembersSuccess'])++ expect(logic.values.members.map((member) => member.id)).toEqual([7])+ })})diff --git a/products/tasks/frontend/spaces/spaceSceneLogic.ts b/products/tasks/frontend/spaces/spaceSceneLogic.tsindex 264a78583701..e317c79136b2 100644--- a/products/tasks/frontend/spaces/spaceSceneLogic.ts+++ b/products/tasks/frontend/spaces/spaceSceneLogic.ts@@ -2,7 +2,7 @@ import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path,import { loaders } from 'kea-loaders'import { router } from 'kea-router'-import { lemonToast } from '@posthog/lemon-ui'+import { toast } from '@posthog/quill'import { Scene } from 'scenes/sceneTypes'import { teamLogic } from 'scenes/teamLogic'@@ -15,12 +15,14 @@ import { Breadcrumb } from '~/types'import {taskChannelsDestroy,+ taskChannelsMembersRetrieve,+ taskChannelsMembersUpdate,taskChannelsPartialUpdate,taskChannelsRetrieve,taskChannelsStarCreate,tasksList,} from '../generated/api'-import { ChannelDTOApi, PatchedChannelUpdateApi, TaskListItemApi } from '../generated/api.schemas'+import { ChannelDTOApi, PatchedChannelUpdateApi, TaskListItemApi, TaskUserBasicInfoApi } from '../generated/api.schemas'const SPACE_FEED_LIMIT = 50@@ -36,6 +38,8 @@ export interface spaceSceneLogicValues {activeTab: SpaceTabbreadcrumbs: Breadcrumb[]feedGroups: TodayWorkGroup[]+ members: TaskUserBasicInfoApi[]+ membersLoading: booleansavingSpace: booleansessions: TaskListItemApi[]sessionsLoading: boolean@@ -55,6 +59,21 @@ export interface spaceSceneLogicActions {deleteSpace: () => {value: true}+ loadMembers: () => any+ loadMembersFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadMembersSuccess: (+ members: TaskUserBasicInfoApi[],+ payload?: any+ ) => {+ members: TaskUserBasicInfoApi[]+ payload?: any+ }loadSessions: () => anyloadSessionsFailure: (error: string,@@ -88,6 +107,21 @@ export interface spaceSceneLogicActions {savingFinished: () => {value: true}+ setMemberIds: (userIds: number[]) => number[]+ setMemberIdsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ setMemberIdsSuccess: (+ members: TaskUserBasicInfoApi[],+ payload?: number[]+ ) => {+ members: TaskUserBasicInfoApi[]+ payload?: number[]+ }setStarred: (starred: boolean) => {starred: boolean}@@ -139,6 +173,14 @@ export const spaceSceneLogic = kea<spaceSceneLogicType>([values.currentTeamId ? await taskChannelsRetrieve(String(values.currentTeamId), props.id) : null,},],+ members: [+ [] as TaskUserBasicInfoApi[],+ {+ loadMembers: async () => await taskChannelsMembersRetrieve(String(values.currentTeamId), props.id),+ setMemberIds: async (userIds: number[]) =>+ await taskChannelsMembersUpdate(String(values.currentTeamId), props.id, { user_ids: userIds }),+ },+ ],sessions: [[] as TaskListItemApi[],{@@ -209,12 +251,28 @@ export const spaceSceneLogic = kea<spaceSceneLogicType>([sessionUpdated: () => {actions.loadSessions()},+ loadSpaceSuccess: ({ space }) => {+ if (space?.channel_type === 'private') {+ actions.loadMembers()+ }+ },+ spaceSaved: ({ space }) => {+ if (space.channel_type === 'private') {+ actions.loadMembers()+ }+ },+ setMemberIdsFailure: ({ errorObject }) => {+ toast.error({+ title: (errorObject as { detail?: string })?.detail ?? 'Couldn’t update the members. Try again.',+ })+ actions.loadMembers()+ },updateSpace: async ({ patch }) => {try {actions.spaceSaved(await taskChannelsPartialUpdate(String(values.currentTeamId), props.id, patch))actions.loadSpaces()} catch (error) {- lemonToast.error((error as { detail?: string }).detail ?? 'Couldn’t save this change. Try again.')+ toast.error({ title: (error as { detail?: string }).detail ?? 'Couldn’t save this change. Try again.' })actions.savingFinished()}},@@ -224,7 +282,7 @@ export const spaceSceneLogic = kea<spaceSceneLogicType>([actions.savingFinished()actions.loadSpaces()} catch {- lemonToast.error(`Couldn’t ${starred ? 'star' : 'unstar'} this space. Try again.`)+ toast.error({ title: `Couldn’t ${starred ? 'star' : 'unstar'} this space. Try again.` })actions.loadSpace()actions.savingFinished()}@@ -232,11 +290,13 @@ export const spaceSceneLogic = kea<spaceSceneLogicType>([deleteSpace: async () => {try {await taskChannelsDestroy(String(values.currentTeamId), props.id)- lemonToast.success('Space deleted')+ toast.success({ title: 'Space deleted' })actions.loadSpaces()router.actions.push(urls.projectHomepage())} catch (error) {- lemonToast.error((error as { detail?: string }).detail ?? 'Couldn’t delete this space. Try again.')+ toast.error({+ title: (error as { detail?: string }).detail ?? 'Couldn’t delete this space. Try again.',+ })actions.savingFinished()}},