: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): create a space from the rail and polish the spaces page (#109249)
Shy Alter6d7a5449a84d
diff --git a/frontend/src/layout/today/TodayShell.tsx b/frontend/src/layout/today/TodayShell.tsxindex e0371d5997a9..29f84951aff5 100644--- a/frontend/src/layout/today/TodayShell.tsx+++ b/frontend/src/layout/today/TodayShell.tsx@@ -11,6 +11,8 @@ import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLimport { cn } from 'lib/utils/css-classes'import { TodayHomeSidebar } from 'scenes/project-homepage/today/TodayHomeSidebar'+import { NewSpaceDialog } from 'products/tasks/frontend/spaces/NewSpaceDialog'+import { TodayLibrarySidebar } from './TodayLibrarySidebar'import { TodayRail } from './TodayRail'import { TODAY_SIDEBAR_CLOSE_THRESHOLD, clampSidebarWidth, todayShellLogic } from './todayShellLogic'@@ -70,6 +72,8 @@ export function TodayShell({ className }: { className?: string }): JSX.Element {<Resizer {...resizerLogicProps} className="z-2" offset={0} /></aside>)}+ {/* Mounted here so the sidebar and the spaces page open the same dialog. */}+ <NewSpaceDialog /></div></ToastProvider>)diff --git a/frontend/src/layout/today/TodaySpacesSidebar.tsx b/frontend/src/layout/today/TodaySpacesSidebar.tsxindex 43db4bccc4e2..00496a0b50d0 100644--- a/frontend/src/layout/today/TodaySpacesSidebar.tsx+++ b/frontend/src/layout/today/TodaySpacesSidebar.tsx@@ -8,11 +8,13 @@ import { Button, Skeleton, Text, Tooltip, TooltipContent, TooltipProvider, Tooltimport { LinkPrimitive } from 'lib/lemon-ui/Link'import { urls } from 'scenes/urls'+import { newSpaceLogic } from 'products/tasks/frontend/spaces/newSpaceLogic'+import { TodayPaneSection, TodayPaneSectionProps } from './TodayPaneSection'import { TodayRecentFilterMenu } from './TodayRecentFilterMenu'import { TodayRecentSearchField } from './TodayRecentSearchField'import { TodaySessionRow } from './TodaySessionRow'-import { TodayWorkSectionId, spaceLabel, todaySpacesLogic } from './todaySpacesLogic'+import { TodayWorkSectionId, isLockedSpace, spaceLabel, todaySpacesLogic } from './todaySpacesLogic'import { TodaySpacesRow } from './TodaySpacesRow'import { TodayWorkItem } from './todayWorkItems'import { useTodaySectionLayout } from './useTodaySectionLayout'@@ -33,6 +35,7 @@ export function TodaySpacesSidebar(): JSX.Element {} = useValues(todaySpacesLogic)const { loadSpaces, loadRecentTasks, toggleSection, setRecentSearchOpen, clearRecentSearchAndFilters } =useActions(todaySpacesLogic)+ const { openNewSpace } = useActions(newSpaceLogic)const { location, searchParams } = useValues(router)const pinnedIds = new Set(pinnedItems.map((item) => item.id))const browsingSpaces = location.pathname.endsWith(urls.taskSpaces())@@ -209,24 +212,42 @@ export function TodaySpacesSidebar(): JSX.Element {dividerdataAttr="today-section-spaces"actions={- <Tooltip>- <TooltipTrigger- delay={0}- render={- <Button- size="icon-sm"- render={<LinkPrimitive to={urls.taskSpaces()} />}- aria-current={browsingSpaces ? 'page' : undefined}- className={cn(browsingSpaces && 'bg-fill-selected')}- aria-label="Browse spaces"- data-attr="today-spaces-browse"- />- }- >- <IconList />- </TooltipTrigger>- <TooltipContent>Browse spaces</TooltipContent>- </Tooltip>+ <>+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon-sm"+ render={<LinkPrimitive to={urls.taskSpaces()} />}+ aria-current={browsingSpaces ? 'page' : undefined}+ className={cn(browsingSpaces && 'bg-fill-selected')}+ aria-label="Browse spaces"+ data-attr="today-spaces-browse"+ />+ }+ >+ <IconList />+ </TooltipTrigger>+ <TooltipContent>Browse spaces</TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon-sm"+ aria-label="New space"+ onClick={openNewSpace}+ data-attr="today-new-space-open-sidebar"+ />+ }+ >+ <IconPlus />+ </TooltipTrigger>+ <TooltipContent>New space</TooltipContent>+ </Tooltip>+ </>}>{spacesLoading && !visibleSpaces.length ? (@@ -240,7 +261,7 @@ export function TodaySpacesSidebar(): JSX.Element {key={space.id}label={spaceLabel(space)}icon={- space.channel_type === 'private' ? (+ isLockedSpace(space) ? (<IconLock className="text-muted-foreground" />) : (<span aria-hidden className="font-mono text-muted-foreground">diff --git a/frontend/src/layout/today/todaySpacesLogic.ts b/frontend/src/layout/today/todaySpacesLogic.tsindex f3cf5c32b168..dd6de9caef59 100644--- a/frontend/src/layout/today/todaySpacesLogic.ts+++ b/frontend/src/layout/today/todaySpacesLogic.ts@@ -45,6 +45,11 @@ export function spaceLabel(space: Pick<ChannelDTOApi, 'name' | 'system_role'>):return space.system_role === 'personal' ? 'Me' : space.name}+/** Only some people can see it: the personal space, or a private shared space. */+export function isLockedSpace(space: Pick<ChannelDTOApi, 'channel_type' | 'system_role'>): boolean {+ return space.system_role === 'personal' || space.channel_type === 'personal' || space.channel_type === 'private'+}+export function starredSpaces(spaces: ChannelDTOApi[]): ChannelDTOApi[] {return [...spaces.filter((space) => space.system_role === 'personal'),diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsxindex 5329ff220090..9f609d5eabb6 100644--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx@@ -16,7 +16,7 @@ const SPACES = [{id: 'space-me',name: 'me',- channel_type: 'private',+ channel_type: 'personal',github_integration: null,repositories: [],auto_archive_after_days: null,diff --git a/products/tasks/frontend/spaces/NewSpaceDialog.tsx b/products/tasks/frontend/spaces/NewSpaceDialog.tsxnew file mode 100644index 000000000000..d06f2d13882b--- /dev/null+++ b/products/tasks/frontend/spaces/NewSpaceDialog.tsx@@ -0,0 +1,89 @@+import { useActions, useValues } from 'kea'+import { ChangeEvent, KeyboardEvent } from 'react'++import {+ Button,+ Dialog,+ DialogBody,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ Field,+ FieldDescription,+ FieldError,+ FieldLabel,+ Input,+} from '@posthog/quill'++import { NEW_SPACE_NAME_MAX_LENGTH, newSpaceLogic } from './newSpaceLogic'++export function NewSpaceDialog(): JSX.Element {+ const { isOpen, name, nameError, submitting } = useValues(newSpaceLogic)+ const { closeNewSpace, setName, submitNewSpace } = useActions(newSpaceLogic)++ return (+ <Dialog+ open={isOpen}+ onOpenChange={(open: boolean) => {+ if (!open && !submitting) {+ closeNewSpace()+ }+ }}+ >+ <DialogContent>+ <DialogHeader>+ <DialogTitle>New space</DialogTitle>+ <DialogDescription>+ A space keeps related sessions together. Everyone in this project can find it.+ </DialogDescription>+ </DialogHeader>+ <DialogBody>+ <Field data-invalid={!!nameError}>+ <FieldLabel htmlFor="today-new-space-name">Name</FieldLabel>+ <Input+ id="today-new-space-name"+ autoFocus+ placeholder="e.g. mobile"+ value={name}+ maxLength={NEW_SPACE_NAME_MAX_LENGTH}+ aria-invalid={!!nameError}+ onChange={(event: ChangeEvent<HTMLInputElement>) => setName(event.target.value)}+ onKeyDown={(event: KeyboardEvent<HTMLInputElement>) => {+ if (event.key === 'Enter') {+ event.preventDefault()+ submitNewSpace()+ }+ }}+ data-attr="today-new-space-name"+ />+ {nameError ? (+ <FieldError>{nameError}</FieldError>+ ) : (+ <FieldDescription>Use lowercase letters, numbers, and hyphens.</FieldDescription>+ )}+ </Field>+ </DialogBody>+ <DialogFooter>+ <Button+ variant="outline"+ onClick={closeNewSpace}+ disabled={submitting}+ data-attr="today-new-space-cancel"+ >+ Cancel+ </Button>+ <Button+ variant="primary"+ loading={submitting}+ onClick={submitNewSpace}+ data-attr="today-new-space-create"+ >+ Create space+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ )+}diff --git a/products/tasks/frontend/spaces/SpacesIndexRow.tsx b/products/tasks/frontend/spaces/SpacesIndexRow.tsxindex 8ead353b42f9..1e8ef2612474 100644--- a/products/tasks/frontend/spaces/SpacesIndexRow.tsx+++ b/products/tasks/frontend/spaces/SpacesIndexRow.tsx@@ -6,7 +6,7 @@ import { Button, Text, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/import { LinkPrimitive } from 'lib/lemon-ui/Link'import { urls } from 'scenes/urls'-import { spaceLabel } from '~/layout/today/todaySpacesLogic'+import { isLockedSpace, spaceLabel } from '~/layout/today/todaySpacesLogic'import { ChannelDTOApi } from '../generated/api.schemas'import { spacesSceneLogic } from './spacesSceneLogic'@@ -28,7 +28,7 @@ export function SpacesIndexRow({ space }: { space: ChannelDTOApi }): JSX.Elementdata-attr="today-spaces-index-row"><span className="flex size-4 shrink-0 items-center justify-center text-muted-foreground" aria-hidden>- {space.channel_type === 'private' ? <IconLock /> : <span className="font-mono">#</span>}+ {isLockedSpace(space) ? <IconLock /> : <span className="font-mono">#</span>}</span><span className="shrink-0 truncate font-medium">{spaceLabel(space)}</span><Text render={<span />} size="xs" variant="muted" className="min-w-0 flex-1 truncate">diff --git a/products/tasks/frontend/spaces/SpacesScene.tsx b/products/tasks/frontend/spaces/SpacesScene.tsxindex b4799be356d4..eecdba7e3e2c 100644--- a/products/tasks/frontend/spaces/SpacesScene.tsx+++ b/products/tasks/frontend/spaces/SpacesScene.tsx@@ -1,13 +1,14 @@import { useActions, useValues } from 'kea'import { ChangeEvent } from 'react'-import { IconSearch } from '@posthog/icons'+import { IconChat, IconPlus, IconSearch } from '@posthog/icons'import {Button,Empty,EmptyContent,EmptyDescription,EmptyHeader,+ EmptyMedia,EmptyTitle,Heading,InputGroup,@@ -26,6 +27,7 @@ import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { ChannelDTOApi } from '../generated/api.schemas'+import { newSpaceLogic } from './newSpaceLogic'import { SpacesIndexRow } from './SpacesIndexRow'import { spacesSceneLogic } from './spacesSceneLogic'@@ -38,19 +40,23 @@ export function SpacesScene(): JSX.Element {const enabled = useFeatureFlag('TODAY_RAIL_NAV')const { lists, search, spacesLoading, spacesUnavailable, sortedSpaces } = useValues(spacesSceneLogic)const { setSearch, loadSpaces } = useActions(spacesSceneLogic)+ const { openNewSpace } = useActions(newSpaceLogic)if (!enabled) {return <NotFound object="page" />}- const section = (label: string, spaces: ChannelDTOApi[]): JSX.Element | null =>+ // With nothing starred there is one list, so it needs no heading.+ const section = (label: string | null, spaces: ChannelDTOApi[]): JSX.Element | null =>spaces.length > 0 ? (- <section className="flex flex-col gap-1" aria-label={label}>- <Heading size="sm" render={<h3 />} className="px-2 pb-1">- <span>{label}</span>{' '}- <Text render={<span />} size="sm" variant="muted" className="tabular-nums">- {spaces.length}- </Text>- </Heading>+ <section className="flex flex-col gap-1" aria-label={label ?? 'Spaces'}>+ {label && (+ <Heading size="sm" render={<h3 />} className="px-2 pb-1">+ <span>{label}</span>{' '}+ <Text render={<span />} size="sm" variant="muted" className="tabular-nums">+ {spaces.length}+ </Text>+ </Heading>+ )}<div className="flex flex-col gap-px">{spaces.map((space) => (<SpacesIndexRow key={space.id} space={space} />@@ -62,7 +68,16 @@ export function SpacesScene(): JSX.Element {return (<TooltipProvider><SceneContent>- <SceneTitleSection name="Spaces" resourceType={{ type: 'task' }} />+ <SceneTitleSection+ name="Spaces"+ resourceType={{ type: 'task' }}+ actions={+ <Button variant="primary" onClick={openNewSpace} data-attr="today-new-space-open-index">+ <IconPlus />+ New space…+ </Button>+ }+ /><div className="mx-auto flex w-full max-w-5xl flex-col gap-5" data-quill><InputGroup className="max-w-80"><InputGroupInput@@ -78,10 +93,10 @@ export function SpacesScene(): JSX.Element {</InputGroupAddon></InputGroup>{spacesLoading && !sortedSpaces.length ? (- <div className="flex flex-col gap-3 px-2">- <Skeleton className="h-4 w-1/4" />- <Skeleton className="h-4 w-1/2" />- <Skeleton className="h-4 w-1/3" />+ <div className="flex flex-col gap-px">+ {[0, 1, 2, 3, 4, 5].map((row) => (+ <Skeleton key={row} className="h-9 w-full" />+ ))}</div>) : spacesUnavailable && !sortedSpaces.length ? (<Empty className="py-12">@@ -103,18 +118,35 @@ export function SpacesScene(): JSX.Element {) : !lists.starred.length && !lists.rest.length ? (<Empty className="py-12"><EmptyHeader>+ {!search && (+ <EmptyMedia variant="icon">+ <IconChat />+ </EmptyMedia>+ )}<EmptyTitle>{search ? 'No spaces match your search' : 'No spaces yet'}</EmptyTitle><EmptyDescription>{search? 'Try a different name or repository.'- : 'Spaces group the sessions you and your agents work on. Create one from PostHog Desktop.'}+ : 'Spaces group the sessions you and your agents work on.'}</EmptyDescription></EmptyHeader>+ {!search && (+ <EmptyContent>+ <Button+ variant="outline"+ onClick={openNewSpace}+ data-attr="today-new-space-open-empty"+ >+ <IconPlus />+ New space…+ </Button>+ </EmptyContent>+ )}</Empty>) : (<>{section('Starred', lists.starred)}- {section('All spaces', lists.rest)}+ {section(lists.starred.length ? 'Everything else' : null, lists.rest)}</>)}</div>diff --git a/products/tasks/frontend/spaces/newSpaceLogic.test.ts b/products/tasks/frontend/spaces/newSpaceLogic.test.tsnew file mode 100644index 000000000000..b872c27ff59e--- /dev/null+++ b/products/tasks/frontend/spaces/newSpaceLogic.test.ts@@ -0,0 +1,93 @@+import { router } from 'kea-router'+import { expectLogic } from 'kea-test-utils'++import { urls } from 'scenes/urls'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { newSpaceLogic } from './newSpaceLogic'++describe('newSpaceLogic', () => {+ let createBody: Record<string, unknown> | null = null+ let starBody: Record<string, unknown> | null = null+ let createStatus = 201+ let createdStarred = true++ beforeEach(() => {+ createBody = null+ starBody = null+ createStatus = 201+ createdStarred = true+ useMocks({+ get: {+ '/api/projects/:team_id/task_channels/': [{ id: 'space-billing', name: 'billing', system_role: null }],+ },+ post: {+ '/api/projects/:team_id/task_channels/': async ({ request }) => {+ createBody = (await request.json()) as Record<string, unknown>+ return createStatus === 201+ ? [201, { id: 'space-new', name: createBody.name, starred: createdStarred }]+ : [createStatus, { detail: 'Something went wrong' }]+ },+ '/api/projects/:team_id/task_channels/:id/star/': async ({ request }) => {+ starBody = (await request.json()) as Record<string, unknown>+ return [204]+ },+ },+ })+ initKeaTests()+ })++ it.each([+ ['stars on create', true, null],+ ['stars through the star endpoint when create returns it unstarred', false, { starred: true }],+ ])('creates a public space, %s, and opens it', async (_, starred, expectedStarBody) => {+ createdStarred = starred+ const logic = newSpaceLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.openNewSpace()+ logic.actions.setName('Mobile App ')+ logic.actions.submitNewSpace()+ await expectLogic(logic).toDispatchActions(['createSpaceSuccess']).toFinishAllListeners()++ expect(createBody).toEqual({ name: 'mobile-app', channel_type: 'public', star: true })+ expect(starBody).toEqual(expectedStarBody)+ expect(logic.values).toMatchObject({ isOpen: false, submitting: false })+ expect(router.values.location.pathname).toContain(urls.taskSpace('space-new'))+ })++ it('keeps the dialog open and usable when the create fails', async () => {+ createStatus = 500+ const logic = newSpaceLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.openNewSpace()+ logic.actions.setName('mobile')+ logic.actions.submitNewSpace()+ await expectLogic(logic).toDispatchActions(['createSpaceFailure']).toFinishAllListeners()++ expect(logic.values).toMatchObject({ isOpen: true, submitting: false, name: 'mobile' })+ })++ it.each([+ ['', 'Enter a name for the space.'],+ ['Billing', '#billing already exists. Try another name.'],+ ['general', '"general" is reserved for your team\'s shared space.'],+ ])('does not create a space named %p', async (name, error) => {+ const logic = newSpaceLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.openNewSpace()+ logic.actions.setName(name)+ logic.actions.submitNewSpace()+ await expectLogic(logic).toFinishAllListeners()++ expect(createBody).toBeNull()+ expect(logic.values).toMatchObject({ isOpen: true, nameError: error })+ })+})diff --git a/products/tasks/frontend/spaces/newSpaceLogic.ts b/products/tasks/frontend/spaces/newSpaceLogic.tsnew file mode 100644index 000000000000..9152d5eed18e--- /dev/null+++ b/products/tasks/frontend/spaces/newSpaceLogic.ts@@ -0,0 +1,174 @@+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'+import { router } from 'kea-router'++import { toast } from '@posthog/quill'++import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { todaySpacesLogic } from '~/layout/today/todaySpacesLogic'++import { taskChannelsCreate, taskChannelsStarCreate } from '../generated/api'+import { ChannelDTOApi } from '../generated/api.schemas'++export const NEW_SPACE_NAME_MAX_LENGTH = 80++// The server stores names as lowercase letters, numbers, and hyphens, so the field shows that shape as the user types.+export function normalizeSpaceNameInput(name: string): string {+ return name+ .toLowerCase()+ .replace(/[^a-z0-9]+/g, '-')+ .replace(/^-+/, '')+}++export function normalizeSpaceName(name: string): string {+ return normalizeSpaceNameInput(name).replace(/-+$/, '')+}++export function spaceNameError(name: string, spaces: Pick<ChannelDTOApi, 'name'>[]): string | null {+ if (name === 'me' || name === 'personal') {+ return `"${name}" is reserved for your personal space.`+ }+ if (name === 'general') {+ return `"${name}" is reserved for your team's shared space.`+ }+ if (spaces.some((space) => space.name === name)) {+ return `#${name} already exists. Try another name.`+ }+ return null+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface newSpaceLogicValues {+ currentTeamId: number | null // teamLogic+ spaces: ChannelDTOApi[] // todaySpacesLogic+ isOpen: boolean+ name: string+ nameError: string | null+ normalizedName: string+ submitAttempted: boolean+ submitting: boolean+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface newSpaceLogicActions {+ loadSpaces: () => any // todaySpacesLogic+ closeNewSpace: () => {+ value: true+ }+ createSpace: (name: string) => {+ name: string+ }+ createSpaceFailure: () => {+ value: true+ }+ createSpaceSuccess: (space: ChannelDTOApi) => {+ space: ChannelDTOApi+ }+ openNewSpace: () => {+ value: true+ }+ setName: (name: string) => {+ name: string+ }+ submitNewSpace: () => {+ value: true+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface newSpaceLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ normalizedName: (name: string) => string+ nameError: (normalizedName: string, spaces: ChannelDTOApi[], submitAttempted: boolean) => string | null+ }+}++export type newSpaceLogicType = MakeLogicType<+ newSpaceLogicValues,+ newSpaceLogicActions,+ Record<string, any>,+ newSpaceLogicMeta+>++export const newSpaceLogic = kea<newSpaceLogicType>([+ path(['products', 'tasks', 'spaces', 'newSpaceLogic']),+ connect(() => ({+ values: [teamLogic, ['currentTeamId'], todaySpacesLogic, ['spaces']],+ actions: [todaySpacesLogic, ['loadSpaces']],+ })),+ actions({+ openNewSpace: true,+ closeNewSpace: true,+ setName: (name: string) => ({ name }),+ submitNewSpace: true,+ createSpace: (name: string) => ({ name }),+ createSpaceSuccess: (space: ChannelDTOApi) => ({ space }),+ createSpaceFailure: true,+ }),+ reducers({+ isOpen: [+ false,+ {+ openNewSpace: () => true,+ closeNewSpace: () => false,+ createSpaceSuccess: () => false,+ },+ ],+ name: ['', { openNewSpace: () => '', setName: (_, { name }) => normalizeSpaceNameInput(name) }],+ submitAttempted: [false, { openNewSpace: () => false, submitNewSpace: () => true }],+ submitting: [+ false,+ {+ createSpace: () => true,+ createSpaceSuccess: () => false,+ createSpaceFailure: () => false,+ },+ ],+ }),+ selectors({+ normalizedName: [(s) => [s.name], (name: string): string => normalizeSpaceName(name)],+ nameError: [+ (s) => [s.normalizedName, s.spaces, s.submitAttempted],+ (normalizedName: string, spaces: ChannelDTOApi[], submitAttempted: boolean): string | null =>+ normalizedName+ ? spaceNameError(normalizedName, spaces)+ : submitAttempted+ ? 'Enter a name for the space.'+ : null,+ ],+ }),+ listeners(({ actions, values }) => ({+ submitNewSpace: () => {+ if (values.submitting || !values.normalizedName || values.nameError) {+ return+ }+ actions.createSpace(values.normalizedName)+ },+ createSpace: async ({ name }) => {+ const projectId = String(values.currentTeamId)+ let space: ChannelDTOApi+ try {+ space = await taskChannelsCreate(projectId, { name, channel_type: 'public', star: true })+ } catch {+ toast.error({ title: 'Couldn’t create the space. Try again.' })+ actions.createSpaceFailure()+ return+ }+ if (!space.starred) {+ try {+ // Create returns an existing public space with that name unchanged, so star it here to match what the user asked for.+ await taskChannelsStarCreate(projectId, space.id, { starred: true })+ space = { ...space, starred: true }+ } catch {+ // The space exists either way, and starring it later is one click.+ }+ }+ actions.createSpaceSuccess(space)+ },+ createSpaceSuccess: ({ space }) => {+ actions.loadSpaces()+ router.actions.push(urls.taskSpace(space.id))+ },+ })),+])diff --git a/products/tasks/frontend/spaces/spacesSceneLogic.test.ts b/products/tasks/frontend/spaces/spacesSceneLogic.test.tsindex 0154aa41ed0e..336fdc90498a 100644--- a/products/tasks/frontend/spaces/spacesSceneLogic.test.ts+++ b/products/tasks/frontend/spaces/spacesSceneLogic.test.ts@@ -1,3 +1,5 @@+import { isLockedSpace } from '~/layout/today/todaySpacesLogic'+import { ChannelDTOApi } from '../generated/api.schemas'import { spacesIndexLists } from './spacesSceneLogic'@@ -22,4 +24,14 @@ describe('spacesSceneLogic', () => {expect(lists.starred.map((item) => item.id)).toEqual(starred)expect(lists.rest.map((item) => item.id)).toEqual(rest)})++ // The personal space comes back as `personal`, not `private`, and still shows a lock.+ it.each([+ ['the personal space', { channel_type: 'personal', system_role: 'personal' }, true],+ ['a private space', { channel_type: 'private', system_role: null }, true],+ ['a public space', { channel_type: 'public', system_role: null }, false],+ ['the general space', { channel_type: 'public', system_role: 'general' }, false],+ ])('locks %s: %s', (_, identity, locked) => {+ expect(isLockedSpace(identity as ChannelDTOApi)).toBe(locked)+ })})