Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(channel): create team channel and auto join (#5093)
dev-rbeabec09d7e09
diff --git a/apps/web/src/features/channel/CreateChannelModal.tsx b/apps/web/src/features/channel/CreateChannelModal.tsxindex dd51985641..8e02e86570 100644--- a/apps/web/src/features/channel/CreateChannelModal.tsx+++ b/apps/web/src/features/channel/CreateChannelModal.tsx@@ -1,19 +1,30 @@import { useSplitLayout } from '@components/app/split-layout/layout';import { RecipientSelector } from '@core/component/RecipientSelector';+import { TabsInset } from '@core/component/TabsInset';import { toast } from '@core/component/Toast/Toast';+import { useUserId } from '@core/context/user';import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';import type { WithCustomUserInput } from '@core/user';import { useFocusLock } from '@core/util/createControlledOpenSignal';import { getDestinationFromOptions } from '@core/util/destination';import HashIcon from '@phosphor/hash.svg';+import InfoIcon from '@phosphor/info.svg';import XIcon from '@phosphor/x.svg';import { useCreateChannelMutation } from '@queries/channel/channels';-import { Button, Dialog, Panel } from '@ui';+import { useUserTeamsQuery } from '@queries/team/teams';+import { Button, Dialog, Panel, ToggleSwitch, Tooltip } from '@ui';import { createMemo, createSignal, Show } from 'solid-js';const [newChannelModalOpen, setNewChannelModalOpen] = createSignal(false);const newChannelModalFocusLock = useFocusLock('create-channel');+const CHANNEL_TYPE_TABS = [+ { value: 'private', label: 'Private' },+ { value: 'team', label: 'Team' },+];++type CreatableChannelType = 'private' | 'team';+export function openNewChannelModal() {newChannelModalFocusLock.acquire();setNewChannelModalOpen(true);@@ -21,20 +32,28 @@ export function openNewChannelModal() {export function CreateChannelModal() {const { replaceOrInsertSplit } = useSplitLayout();+ const userId = useUserId();const { users: recipientOptions } = useCombinedRecipients();const createChannelMutation = useCreateChannelMutation();+ const userTeamsQuery = useUserTeamsQuery();const [name, setName] = createSignal('');+ const [channelType, setChannelType] =+ createSignal<CreatableChannelType>('private');+ const [autoJoinTeam, setAutoJoinTeam] = createSignal(false);const [selectedRecipients, setSelectedRecipients] = createSignal<WithCustomUserInput<'user' | 'contact'>[]>([]);const [error, setError] = createSignal<string>();const channelName = createMemo(() => name().trim());+ const team = createMemo(() => userTeamsQuery.data?.[0]);const canSubmit = createMemo(() => channelName().length > 0 && !createChannelMutation.isPending);function reset() {setName('');+ setChannelType('private');+ setAutoJoinTeam(false);setSelectedRecipients([]);setError(undefined);}@@ -60,12 +79,28 @@ export function CreateChannelModal() {setError(undefined);const destination = getDestinationFromOptions(selectedRecipients());+ const selectedChannelType = channelType();+ const isTeamChannel = selectedChannelType === 'team';+ const selectedTeam = team();+ if (isTeamChannel && !selectedTeam) {+ setError('Select a team to create a team channel');+ return;+ }++ // Team channels currently require a non-empty participant list. The+ // repository filters out the owner after satisfying that validation.+ const participants =+ isTeamChannel && destination.users.length === 0 && userId()+ ? [userId()!]+ : destination.users;try {const { id } = await createChannelMutation.mutateAsync({- channel_type: 'private',+ channel_type: selectedChannelType,name: trimmedName,- participants: destination.users,+ participants,+ team_id: isTeamChannel ? selectedTeam?.id : undefined,+ auto_join_team: isTeamChannel && autoJoinTeam(),});resetAndClose();replaceOrInsertSplit({ type: 'channel', id });@@ -85,6 +120,18 @@ export function CreateChannelModal() {<Panel.Body><form class="flex flex-col gap-4 p-4" onSubmit={handleSubmit}><div class="flex items-center gap-1">+ <Show when={team()}>+ <TabsInset+ depth={2}+ list={CHANNEL_TYPE_TABS}+ value={channelType()}+ onChange={(value) => {+ if (value !== 'private' && value !== 'team') return;+ setChannelType(value);+ setError(undefined);+ }}+ />+ </Show><div class="flex-1" /><Dialog.CloseButtonas={Button}@@ -151,7 +198,33 @@ export function CreateChannelModal() {)}</Show>- <div class="flex shrink-0 items-end justify-end gap-2">+ <div class="flex shrink-0 items-center justify-end gap-3 px-2">+ <Show when={channelType() === 'private'}>+ <p class="mr-auto text-xs text-ink-extra-muted">+ Only people you invite can see this channel.+ </p>+ </Show>+ <Show when={channelType() === 'team' && team()}>+ <div class="mr-auto flex items-center gap-1.5">+ <ToggleSwitch+ labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"+ onChange={setAutoJoinTeam}+ checked={autoJoinTeam()}+ label="Team Auto-Join"+ />+ <Tooltip+ as="span"+ placement="bottom"+ label={+ autoJoinTeam()+ ? 'New team members will automatically join this channel.'+ : 'Team members can choose whether to join this channel.'+ }+ >+ <InfoIcon class="size-3.5 text-ink-extra-muted" />+ </Tooltip>+ </div>+ </Show><Buttontype="submit"variant={canSubmit() ? 'active' : 'ghost'}