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
refactor(channels-view): channel rail composition (#6254)
dev-rb4ba410c4daac
diff --git a/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx b/apps/web/src/features/channels-view/components/ChannelsMobileView.tsxindex f50d159a3a..58db8138df 100644--- a/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx+++ b/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx@@ -24,7 +24,7 @@ import { filterChannelsForScope } from '../queries';import type { ChannelsQueryScope } from '../types';import { channelMentionsUser } from '../utils';import { ChannelsEmptyState } from './ChannelsEmptyState';-import { ConversationCard } from './rail/ConversationCard';+import { ConversationCard } from './rail/ChannelRailItems';import { useChannelCalls } from './rail/hooks/useChannelCalls';import { useChannelRailActivity } from './rail/hooks/useChannelRailActivity';@@ -58,10 +58,10 @@ export function ChannelsMobileView(props: {DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES);const listId = createUniqueId();- const { callActivity, incomingCallIds, callStatuses } = useChannelCalls();+ const channelCalls = useChannelCalls();const channelActivity = useChannelRailActivity(() => props.channels,- callActivity+ channelCalls);const visibleChannels = createMemo(() =>@@ -183,8 +183,10 @@ export function ChannelsMobileView(props: {currentUserId())}unread={channelActivity.unreadChannelIds().has(channel.id)}- callStatus={callStatuses().get(channel.id)}- incomingCallId={incomingCallIds().get(channel.id)}+ callStatus={channelActivity.callStatuses().get(channel.id)}+ incomingCallId={channelActivity+ .incomingCallIds()+ .get(channel.id)}selected={state.selectedChannelId === channel.id}focused={false}onActivate={() => openChannel(channel)}diff --git a/apps/web/src/features/channels-view/components/rail/Browse.tsx b/apps/web/src/features/channels-view/components/rail/Browse.tsxdeleted file mode 100644index a191339f12..0000000000--- a/apps/web/src/features/channels-view/components/rail/Browse.tsx+++ /dev/null@@ -1,219 +0,0 @@-import { runCreateAction } from '@app/features/command/Launcher';-import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';-import { openNewChannelModal } from '@channel/CreateChannelModal';-import ChannelIcon from '@icon/wide-channel.svg';-import CaretDownIcon from '@phosphor/caret-down.svg';-import ChatTeardropIcon from '@phosphor/chat-teardrop.svg';-import { Key } from '@solid-primitives/keyed';-import { cn } from '@ui';-import { type Component, For, Match, Show, Switch } from 'solid-js';-import { Dynamic } from 'solid-js/web';-import type { ChannelsGroup } from '../../types';-import { ChannelsEmptyState } from '../ChannelsEmptyState';-import { useChannelRail } from './Context';-import { ChannelOption, SlimChannelItem } from './Item';-import { CollapsibleSection, CreateRailAction } from './Section';--type GroupConfig = {- group: ChannelsGroup;- label: string;- emptyLabel: string;- createLabel: string;- icon: Component;- onCreate: () => void;-};--const GROUPS: GroupConfig[] = [- {- group: 'channels',- label: 'Channels',- emptyLabel: 'No channels',- createLabel: 'Create channel',- icon: ChannelIcon,- onCreate: openNewChannelModal,- },- {- group: 'direct_messages',- label: 'DMs',- emptyLabel: 'No direct messages',- createLabel: 'Start direct message',- icon: ChatTeardropIcon,- onCreate: () => runCreateAction('channel'),- },-];--function ChannelGroupSection(props: { config: GroupConfig }) {- const rail = useChannelRail();- const forceEmptyState = useDebugSetting(- DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES- );-- const group = () => props.config.group;-- const expanded = () => rail.mode() === 'full';-- const channels = () => rail.items(group());-- return (- <CollapsibleSection.Root- open={rail.section.isOpen(group())}- fillAvailable={- group() === 'direct_messages' && !rail.section.isOpen('channels')- }- class={expanded() ? undefined : 'items-center'}- >- <CollapsibleSection.Header- focused={rail.section.isFocused(group())}- focusWithin={rail.section.containsFocus(group())}- class={- expanded()- ? 'h-9 has-[[data-section-action]:hover]:bg-transparent has-[[data-section-action]:focus-within]:bg-transparent'- : 'h-10 justify-center'- }- >- <button- id={rail.section.domId(group())}- type="button"- role="treeitem"- tabIndex={-1}- class={cn(- 'relative flex outline-none focus-visible:ring-2 focus-visible:ring-accent',- expanded()- ? 'h-full min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left'- : 'size-10 min-w-10 flex-none items-center justify-center rounded-full'- )}- aria-expanded={rail.section.isOpen(group())}- aria-label={expanded() ? undefined : props.config.label}- onClick={() => rail.section.activate(group())}- >- <Switch>- <Match when={expanded()}>- <CaretDownIcon- class={cn(- 'size-3 shrink-0 transition-transform',- !rail.section.isOpen(group()) && '-rotate-90'- )}- />- <span class="min-w-0 truncate">{props.config.label}</span>- </Match>- <Match when={true}>- <span class="flex items-center justify-center [&_svg]:size-4">- <Dynamic component={props.config.icon} />- </span>- </Match>- </Switch>- <Show when={rail.activity.unreadCount(group()) > 0}>- <span- class={cn(- 'flex h-4 min-w-4 items-center justify-center rounded-full bg-accent px-1 text-xs font-medium leading-none text-accent-contrast',- expanded()- ? 'tabular-nums'- : 'absolute right-0 top-0 ring-2 ring-surface'- )}- >- {rail.activity.unreadCount(group())}- </span>- </Show>- </button>- <Show when={expanded()}>- <div data-section-action="" class="pr-1">- <CreateRailAction- label={props.config.createLabel}- onClick={props.config.onCreate}- />- </div>- </Show>- </CollapsibleSection.Header>- <CollapsibleSection.Content- open={rail.section.isOpen(group())}- contentRef={rail.section.registerScrollRef(group())}- containerClass={expanded() ? undefined : 'w-full'}- class={- expanded()- ? 'flex min-h-0 flex-col gap-0.5'- : 'flex min-h-0 w-full flex-col items-center gap-0.5'- }- activityTargetId={rail.activity.targetId(group())}- activityLabel={expanded() ? rail.activity.label(group()) : undefined}- activityTooltip={!expanded()}- onActivityVisible={(targetId) =>- rail.activity.onVisible(group(), targetId)- }- >- <Switch>- <Match when={!forceEmptyState() && channels().length > 0}>- <Key each={channels()} by={(channel) => channel.id}>- {(channel) => (- <Switch>- <Match when={expanded()}>- <ChannelOption- id={rail.item.domId(channel().id)}- channel={channel()}- unread={rail.activity.isUnread(channel().id)}- callStatus={rail.activity.callStatus(channel().id)}- incomingCallId={rail.activity.incomingCallId(- channel().id- )}- selected={rail.item.isSelected(channel().id)}- focused={rail.item.isFocused(channel().id)}- onActivate={() => rail.item.activate(channel().id)}- />- </Match>- <Match when={true}>- <SlimChannelItem- id={rail.item.domId(channel().id)}- channel={channel()}- unread={rail.activity.isUnread(channel().id)}- callStatus={rail.activity.callStatus(channel().id)}- selected={rail.item.isSelected(channel().id)}- focused={rail.item.isFocused(channel().id)}- onActivate={() => rail.item.activate(channel().id)}- />- </Match>- </Switch>- )}- </Key>- </Match>- <Match when={expanded()}>- <div class="px-2 py-2 text-xs text-ink-extra-muted">- {props.config.emptyLabel}- </div>- </Match>- </Switch>- </CollapsibleSection.Content>- </CollapsibleSection.Root>- );-}--export function ChannelsRailBrowse() {- const rail = useChannelRail();- const forceEmptyState = useDebugSetting(- DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES- );-- const hasItems = () =>- rail.items('channels').length > 0 ||- rail.items('direct_messages').length > 0;-- return (- <Switch>- <Match- when={rail.mode() === 'full' && (forceEmptyState() || !hasItems())}- >- <ChannelsEmptyState scope="channels" topAligned />- </Match>- <Match when={true}>- <div- class={cn(- 'flex h-full min-h-0 flex-col gap-3',- rail.mode() === 'full' ? 'px-4' : 'px-2'- )}- >- <For each={GROUPS}>- {(config) => <ChannelGroupSection config={config} />}- </For>- </div>- </Match>- </Switch>- );-}diff --git a/apps/web/src/features/channels-view/components/rail/ConversationCard.tsx b/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsxsimilarity index 58%rename from apps/web/src/features/channels-view/components/rail/ConversationCard.tsxrename to apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsxindex f1acf474e4..1629a3ed5d 100644--- a/apps/web/src/features/channels-view/components/rail/ConversationCard.tsx+++ b/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx@@ -1,20 +1,148 @@+import { dismissIncomingCallEverywhere } from '@app/features/block-call/sidebar/incoming-calls';+import { joinChannelCall } from '@channel/Call/join-channel-call';import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';+import { toast } from '@core/component/Toast/Toast';import { useUserId } from '@core/context/user';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { getDisplayName, tryMacroId } from '@core/user';import type { MacroId } from '@core/user/macroId';-import { Entity } from '@entity';+import { type ChannelEntity, Entity } from '@entity';import ReplyIcon from '@phosphor/arrow-bend-up-left.svg';import AtIcon from '@phosphor/at.svg';-import { cn, Tooltip } from '@ui';+import XIcon from '@phosphor/x.svg';+import PhoneCallIcon from '@phosphor-fill/phone-call-fill.svg';+import PhoneIncomingIcon from '@phosphor-fill/phone-incoming-fill.svg';+import { getBotDisplayName } from '@queries/channel/message-sender';+import { Button, cn, Tooltip } from '@ui';import { Match, Show, Switch } from 'solid-js';-import { formatDetailedTimestamp } from '../../utils';-import {- ChannelAvatar,- ChannelCallIndicator,- type ChannelRailItemProps,- IncomingCallActions,-} from './Item';+import { formatDetailedTimestamp, isDirectMessage } from '../../utils';++export type ChannelCallStatus = 'active' | 'incoming';++export type ChannelRailItemProps = {+ id: string;+ channel: ChannelEntity;+ unread: boolean;+ callStatus?: ChannelCallStatus;+ incomingCallId?: string;+ selected: boolean;+ focused: boolean;+ onActivate: () => void;+};++export function ChannelCallIndicator(props: {+ status: ChannelCallStatus | undefined;+ class?: string;+}) {+ return (+ <Show when={props.status}>+ {(status) => (+ <span+ aria-label={status() === 'incoming' ? 'Incoming call' : 'Active call'}+ class={cn(+ 'flex size-4 shrink-0 items-center justify-center text-accent',+ props.class+ )}+ >+ <Switch>+ <Match when={status() === 'incoming'}>+ <PhoneIncomingIcon class="incoming-call-shake size-full" />+ </Match>+ <Match when={true}>+ <PhoneCallIcon class="size-full" />+ </Match>+ </Switch>+ </span>+ )}+ </Show>+ );+}++export function IncomingCallActions(props: {+ callId: string | undefined;+ channelId: string;+}) {+ return (+ <Show when={props.callId}>+ {(callId) => (+ <span class="flex shrink-0 items-center gap-1">+ <Button+ variant="success"+ size="icon-xs"+ class="rounded-md"+ label="Accept incoming call"+ onPointerDown={(event) => event.stopPropagation()}+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ void joinChannelCall(props.channelId).catch((error) => {+ console.error('Failed to join call', error);+ toast.failure('Failed to join call');+ });+ }}+ >+ <PhoneIncomingIcon class="incoming-call-shake size-3" />+ </Button>+ <Button+ variant="danger"+ size="icon-xs"+ class="rounded-md"+ label="Decline incoming call"+ onPointerDown={(event) => event.stopPropagation()}+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ dismissIncomingCallEverywhere(callId());+ }}+ >+ <XIcon class="size-3" />+ </Button>+ </span>+ )}+ </Show>+ );+}++export function ChannelAvatar(props: {+ channel: ChannelEntity;+ size?: 'sm' | 'md';+}) {+ const sizeClass = () =>+ props.size === 'md' ? 'size-9 [&_svg]:size-4.5' : 'size-6 [&_svg]:size-3.5';++ return (+ <Switch>+ <Match when={isDirectMessage(props.channel)}>+ <span+ class={cn(+ 'relative flex shrink-0 items-center justify-center overflow-hidden rounded-full border border-edge bg-surface-2 [&_img]:size-full [&_svg]:shrink-0',+ sizeClass()+ )}+ >+ <Entity.Icon+ entity={props.channel}+ suppressClick+ showTooltip={false}+ />+ </span>+ </Match>+ <Match when={true}>+ <span+ class={cn(+ 'flex shrink-0 items-center justify-center text-ink-muted [&_svg]:shrink-0',+ sizeClass()+ )}+ >+ <Entity.Icon+ entity={props.channel}+ suppressClick+ showTooltip={false}+ />+ </span>+ </Match>+ </Switch>+ );+}export type ConversationCardProps = ChannelRailItemProps & {class?: string;@@ -34,9 +162,8 @@ function UserDisplayName(props: { id: MacroId }) {function MessageSenderName(props: { id?: string }) {const currentUserId = useUserId();-const macroId = () => (props.id ? tryMacroId(props.id) : undefined);-+ const botName = () => (props.id ? getBotDisplayName(props.id) : undefined);const isCurrentUser = () =>props.id?.toLocaleLowerCase() === currentUserId()?.toLocaleLowerCase();@@ -44,10 +171,9 @@ function MessageSenderName(props: { id?: string }) {<Switch><Match when={!props.id}>Unknown sender</Match><Match when={isCurrentUser()}>You</Match>+ <Match when={botName()}>{(name) => name()}</Match><Match when={macroId()}>{(id) => <UserDisplayName id={id()} />}</Match>- <Match when={true}>- {props.id?.startsWith('bot|') ? 'Bot' : 'Someone'}- </Match>+ <Match when={true}>Someone</Match></Switch>);}diff --git a/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsxindex 790a75d7eb..da0d2b11e3 100644--- a/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx@@ -10,73 +10,123 @@ import {withSplitPanelOwner,} from '@components/app/split-layout/layoutUtils';import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';+import { compareDateDesc } from '@core/util/date';import type { ChannelEntity } from '@entity';-import { cn, Hotkey } from '@ui';import {createEffect,+ createMemo,createSignal,createUniqueId,- Match,on,onCleanup,- Show,- Switch,} from 'solid-js';import { useChannelsView } from '../../channels-view-context';import type { ChannelsGroup, ChannelsTab } from '../../types';-import { ChannelsRailBrowse } from './Browse';-import { type ChannelRailContext, ChannelRailProvider } from './Context';-import { ChannelsRailHeader } from './Header';-import { useChannelCalls } from './hooks/useChannelCalls';-import { useChannelRailActivity } from './hooks/useChannelRailActivity';-import { useChannelRailRows } from './hooks/useChannelRailRows';+import { channelHasMessages, isDirectMessage } from '../../utils';import {- CHANNEL_GROUPS,type ChannelRailRow,+ type ChannelsRailContext,+ ChannelsRailProvider,+ domIdForRow,rowKeyForChannel,rowKeyForSection,-} from './model';-import { ChannelsRailRecents } from './Recents';+} from './ChannelsRailContext';+import { ExpandedChannelsRail } from './ExpandedChannelsRail';+import { useChannelCalls } from './hooks/useChannelCalls';+import { useChannelRailActivity } from './hooks/useChannelRailActivity';+import { SlimChannelsRail } from './SlimChannelsRail';+const CHANNEL_GROUPS: ChannelsGroup[] = ['channels', 'direct_messages'];const CHANNEL_TAB_IDS: ChannelsTab[] = ['browse', 'recents'];-export function ChannelsRail(props: {+export type ChannelsRailProps = {channels: ChannelEntity[];mode: 'full' | 'slim';onModeChange: (mode: 'full' | 'slim') => void;-}) {+};++export function ChannelsRail(props: ChannelsRailProps) {const { state, setGroupOpen, setSelectedChannelId, setTab } =useChannelsView();-const panel = useSplitPanelOrThrow();-const listDomId = createUniqueId();-const [sectionScrollRoots, setSectionScrollRoots] = createSignal<Partial<Record<ChannelsGroup, HTMLDivElement>>>({});+ const [listRoot, setListRoot] = createSignal<HTMLDivElement>();- const { callActivity, incomingCallIds, callStatuses } = useChannelCalls();-+ const channelCalls = useChannelCalls();const channelActivity = useChannelRailActivity(() => props.channels,- callActivity+ channelCalls);- useViewTabHotkeys({- scopeId: panel.splitHotkeyScope,- enabled: panel.isPanelActive,- ids: () => CHANNEL_TAB_IDS,- activeId: () => state.tab,- setActiveId: setTab,- });+ const teamChannels = createMemo(() =>+ props.channels.filter((channel) => !isDirectMessage(channel))+ );+ const directMessages = createMemo(() =>+ props.channels.filter(isDirectMessage)+ );+ const recentConversations = createMemo(() =>+ props.channels+ .filter(channelHasMessages)+ .sort((a, b) =>+ compareDateDesc(+ a.latestRootMessage?.createdAt,+ b.latestRootMessage?.createdAt+ )+ )+ );++ const visibleRows = createMemo<ChannelRailRow[]>(() => {+ if (state.tab === 'recents') {+ return recentConversations().map((channel) => ({+ kind: 'conversation',+ id: `channel:${channel.id}`,+ channel,+ }));+ }- const { directMessages, recentConversations, teamChannels, visibleRows } =- useChannelRailRows({- channels: () => props.channels,- tab: () => state.tab,- isGroupExpanded: (group) => state.expandedGroups[group],+ const rows: ChannelRailRow[] = [+ {+ kind: 'section',+ id: 'section:channels',+ group: 'channels',+ },+ ];+ if (state.expandedGroups.channels) {+ rows.push(+ ...teamChannels().map(+ (channel): ChannelRailRow => ({+ kind: 'conversation',+ id: `channel:${channel.id}`,+ group: 'channels',+ channel,+ })+ )+ );+ }++ rows.push({+ kind: 'section',+ id: 'section:direct_messages',+ group: 'direct_messages',});+ if (state.expandedGroups.direct_messages) {+ rows.push(+ ...directMessages().map(+ (channel): ChannelRailRow => ({+ kind: 'conversation',+ id: `channel:${channel.id}`,+ group: 'direct_messages',+ channel,+ })+ )+ );+ }++ return rows;+ });const list = withSplitPanelOwner(listOwnedSlotName('controller'), () =>createListController<ChannelRailRow>({@@ -98,51 +148,17 @@ export function ChannelsRail(props: {}));- const domIdForRow = (rowId: string) => `${listDomId}-${rowId}`;-- const activityTargetId = (group: ChannelsGroup) => {- const channelId = channelActivity.targetChannelId(group);- return channelId === undefined- ? undefined- : domIdForRow(rowKeyForChannel(channelId));- };-- const clearVisibleActivity = (- group: ChannelsGroup,- visibleTargetId: string- ) => {- const channelId = channelActivity.targetChannelId(group);- if (- channelId === undefined ||- domIdForRow(rowKeyForChannel(channelId)) !== visibleTargetId- ) {- return;- }-- channelActivity.clearTarget(group, channelId);- };-- let listRoot: HTMLDivElement | undefined;-- const registerSectionScrollRef =- (group: ChannelsGroup) => (element: HTMLDivElement) => {- setSectionScrollRoots((current) => ({- ...current,- [group]: element,- }));- };-const scrollHandle: ListScrollHandle = {scrollToIndex: (index) => {const row = list.items.at(index);if (!row) return;- const element = document.getElementById(domIdForRow(row.id));+ const element = document.getElementById(domIdForRow(listDomId, row.id));const scrollRoot =row.kind === 'conversation' && row.group? sectionScrollRoots()[row.group]: state.tab === 'recents'- ? listRoot+ ? listRoot(): undefined;if (!element || !scrollRoot) return;@@ -156,6 +172,14 @@ export function ChannelsRail(props: {},};+ useViewTabHotkeys({+ scopeId: panel.splitHotkeyScope,+ enabled: panel.isPanelActive,+ ids: () => CHANNEL_TAB_IDS,+ activeId: () => state.tab,+ setActiveId: setTab,+ });+withSplitPanelOwner(listOwnedSlotName('navigation-hotkeys'), () =>useListInteractions({controller: list,@@ -164,7 +188,7 @@ export function ChannelsRail(props: {enabled: panel.isPanelActive,navigation: {onNavigate: (event) => {- listRoot?.focus({ preventScroll: true });+ listRoot()?.focus({ preventScroll: true });const row = event.result?.item;if (row?.kind === 'conversation') {@@ -188,7 +212,6 @@ export function ChannelsRail(props: {? CHANNEL_GROUPS.indexOf(currentGroup): -1;const origin = currentIndex === -1 ? (offset === 1 ? -1 : 0) : currentIndex;-const nextIndex =(origin + offset + CHANNEL_GROUPS.length) % CHANNEL_GROUPS.length;const nextGroup = CHANNEL_GROUPS[nextIndex];@@ -199,13 +222,12 @@ export function ChannelsRail(props: {});if (!result) return false;- listRoot?.focus({ preventScroll: true });+ listRoot()?.focus({ preventScroll: true });scrollHandle.scrollToIndex(result.index);return true;};const sectionHotkeys = createHotkeyGroup();-const sectionHotkeysEnabled = () =>panel.isPanelActive() && state.tab === 'browse';@@ -216,7 +238,6 @@ export function ChannelsRail(props: {condition: sectionHotkeysEnabled,keyDownHandler: () => jumpToSection(1),}).withGroup(sectionHotkeys);-registerHotkey({hotkey: '[',scopeId: panel.splitHotkeyScope,@@ -224,19 +245,7 @@ export function ChannelsRail(props: {condition: sectionHotkeysEnabled,keyDownHandler: () => jumpToSection(-1),}).withGroup(sectionHotkeys);-- onCleanup(() => {- sectionHotkeys.dispose();- });-- const activateRow = (rowId: string) => {- list.activate.key(rowId, { reason: 'pointer' });- };-- const activeDescendant = () => {- const rowId = list.focus.key();- return rowId === undefined ? undefined : domIdForRow(rowId);- };+ onCleanup(() => sectionHotkeys.dispose());createEffect(on(@@ -248,89 +257,50 @@ export function ChannelsRail(props: {const frame = requestAnimationFrame(() => {scrollHandle.scrollToIndex(focusedIndex);});-onCleanup(() => cancelAnimationFrame(frame));},{ defer: true }));- const itemsForGroup = (group: ChannelsGroup) =>- group === 'channels' ? teamChannels() : directMessages();+ const activateRow = (rowId: ChannelRailRow['id']) => {+ list.activate.key(rowId, { reason: 'pointer' });+ };- const railContext: ChannelRailContext = {- mode: () => props.mode,+ const rail: ChannelsRailContext = {+ railId: listDomId,+ list,tab: () => state.tab,- setTab,- onModeChange: props.onModeChange,- items: itemsForGroup,+ selectTab: setTab,+ setMode: (mode) => props.onModeChange(mode),+ teamChannels,+ directMessages,recentConversations,- activity: {- isUnread: (channelId) =>- channelActivity.unreadChannelIds().has(channelId),- callStatus: (channelId) => callStatuses().get(channelId),- incomingCallId: (channelId) => incomingCallIds().get(channelId),- unreadCount: channelActivity.unreadCount,- targetId: activityTargetId,- label: channelActivity.targetLabel,- onVisible: clearVisibleActivity,- },- item: {- domId: (channelId) => domIdForRow(rowKeyForChannel(channelId)),- isSelected: (channelId) => state.selectedChannelId === channelId,- isFocused: (channelId) =>- list.focus.key() === rowKeyForChannel(channelId),- activate: (channelId) => activateRow(rowKeyForChannel(channelId)),- },- section: {- domId: (group) => domIdForRow(rowKeyForSection(group)),- isOpen: (group) => state.expandedGroups[group],- isFocused: (group) => list.focus.key() === rowKeyForSection(group),- containsFocus: (group) => list.focus.item()?.group === group,- activate: (group) => activateRow(rowKeyForSection(group)),- registerScrollRef: registerSectionScrollRef,+ selectedChannelId: () => state.selectedChannelId,+ isGroupOpen: (group) => state.expandedGroups[group],+ registerRootRef: setListRoot,+ activateRow,+ registerScrollRef: (group, element) => {+ setSectionScrollRoots((current) => ({+ ...current,+ [group]: element,+ }));},+ channelActivity,};return (- <ChannelRailProvider value={railContext}>+ <ChannelsRailProvider value={rail}><asidearia-label="Chat navigation"class="flex size-full min-h-0 flex-col gap-3 bg-inset pt-2">- <ChannelsRailHeader />- <div class="flex min-h-0 flex-1 flex-col">- <div- ref={(element) => {- listRoot = element;- }}- role="tree"- tabIndex={-1}- aria-activedescendant={activeDescendant()}- class={cn(- 'scrollbar-hidden min-h-0 flex-1 outline-none',- state.tab === 'browse' ? 'overflow-hidden' : 'overflow-y-auto'- )}- >- <Switch>- <Match when={state.tab === 'browse'}>- <ChannelsRailBrowse />- </Match>- <Match when={state.tab === 'recents'}>- <ChannelsRailRecents />- </Match>- </Switch>- </div>- <Show when={props.mode === 'full' && state.tab === 'browse'}>- <footer class="flex h-9 shrink-0 items-center justify-start gap-1 border-t border-edge-muted px-4 text-xxs text-ink-extra-muted">- <span>Use</span>- <Hotkey shortcut="[" theme="subtle" />- <Hotkey shortcut="]" theme="subtle" />- <span>to jump sections</span>- </footer>- </Show>- </div>+ {props.mode === 'full' ? (+ <ExpandedChannelsRail />+ ) : (+ <SlimChannelsRail />+ )}</aside>- </ChannelRailProvider>+ </ChannelsRailProvider>);}diff --git a/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.ts b/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.tsnew file mode 100644index 0000000000..3971961768--- /dev/null+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRailContext.ts@@ -0,0 +1,58 @@+import type { ListController } from '@app/components/list';+import { createAssertedContextProvider } from '@core/context/createContext';+import type { ChannelEntity } from '@entity';+import type { ContextProviderProps } from '@solid-primitives/context';+import type { Accessor } from 'solid-js';+import type { ChannelsGroup, ChannelsTab } from '../../types';+import type { useChannelRailActivity } from './hooks/useChannelRailActivity';++type ChannelRailActivity = ReturnType<typeof useChannelRailActivity>;++export type ChannelRailRow =+ | {+ kind: 'section';+ id: `section:${ChannelsGroup}`;+ group: ChannelsGroup;+ }+ | {+ kind: 'conversation';+ id: `channel:${string}`;+ group?: ChannelsGroup;+ channel: ChannelEntity;+ };++export const rowKeyForChannel = (channelId: string) =>+ `channel:${channelId}` as const;++export const rowKeyForSection = (group: ChannelsGroup) =>+ `section:${group}` as const;++export const domIdForRow = (railId: string, rowId: string) =>+ `${railId}-${rowId}`;++export type ChannelsRailContext = {+ railId: string;+ list: ListController<ChannelRailRow>;+ tab: Accessor<ChannelsTab>;+ selectTab: (tab: ChannelsTab) => void;+ setMode: (mode: 'full' | 'slim') => void;+ teamChannels: Accessor<readonly ChannelEntity[]>;+ directMessages: Accessor<readonly ChannelEntity[]>;+ recentConversations: Accessor<readonly ChannelEntity[]>;+ selectedChannelId: Accessor<string | undefined>;+ isGroupOpen: (group: ChannelsGroup) => boolean;+ registerRootRef: (element: HTMLDivElement) => void;+ activateRow: (rowId: ChannelRailRow['id']) => void;+ registerScrollRef: (group: ChannelsGroup, element: HTMLDivElement) => void;+ channelActivity: ChannelRailActivity;+};++type ChannelsRailProviderProps = ContextProviderProps & {+ value: ChannelsRailContext;+};++export const [ChannelsRailProvider, useChannelsRail] =+ createAssertedContextProvider<ChannelsRailContext, ChannelsRailProviderProps>(+ 'ChannelsRail',+ (props) => props.value+ );diff --git a/apps/web/src/features/channels-view/components/rail/Section.tsx b/apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsxsimilarity index 88%rename from apps/web/src/features/channels-view/components/rail/Section.tsxrename to apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsxindex 2adeda4b56..cbc2712498 100644--- a/apps/web/src/features/channels-view/components/rail/Section.tsx+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRailSection.tsx@@ -1,8 +1,9 @@import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';+import { AnimatedSquareSidebarIcon } from '@icon/square-sidebar';import CaretDownIcon from '@phosphor/caret-down.svg';import CaretUpIcon from '@phosphor/caret-up.svg';import PlusIcon from '@phosphor/plus.svg';-import { cn, Scroll, Tooltip } from '@ui';+import { Button, cn, Scroll, Tooltip } from '@ui';import { createSignal, type JSX, Match, Show, Switch } from 'solid-js';import { useOffscreenActivity } from './hooks/useOffscreenActivity';@@ -17,7 +18,6 @@ function SectionScrollArea(props: {children: JSX.Element;}) {const [scrollRoot, setScrollRoot] = createSignal<HTMLDivElement>();-const activity = useOffscreenActivity({scrollRoot,targetId: () => props.activityTargetId,@@ -170,3 +170,24 @@ export function CreateRailAction(props: {</button>);}++export function RailModeButton(props: {+ expanded: boolean;+ onToggle: () => void;+}) {+ const [hovering, setHovering] = createSignal(false);++ return (+ <Button+ variant="ghost"+ size="icon-sm"+ label={props.expanded ? 'Collapse chat rail' : 'Expand chat rail'}+ tooltipPlacement={props.expanded ? 'bottom' : 'right'}+ onClick={props.onToggle}+ onMouseEnter={() => setHovering(true)}+ onMouseLeave={() => setHovering(false)}+ >+ <AnimatedSquareSidebarIcon class="size-4" triggerAnimation={hovering()} />+ </Button>+ );+}diff --git a/apps/web/src/features/channels-view/components/rail/Context.tsx b/apps/web/src/features/channels-view/components/rail/Context.tsxdeleted file mode 100644index 1eb5d5542b..0000000000--- a/apps/web/src/features/channels-view/components/rail/Context.tsx+++ /dev/null@@ -1,50 +0,0 @@-import { createAssertedContextProvider } from '@core/context/createContext';-import type { ChannelEntity } from '@entity';-import type { ContextProviderProps } from '@solid-primitives/context';-import type { Accessor } from 'solid-js';-import type { ChannelsGroup, ChannelsTab } from '../../types';-import type { ChannelCallStatus } from './Item';--export type ChannelRailContext = {- mode: Accessor<'full' | 'slim'>;- tab: Accessor<ChannelsTab>;- setTab: (tab: ChannelsTab) => void;- onModeChange: (mode: 'full' | 'slim') => void;- items: (group: ChannelsGroup) => ChannelEntity[];- recentConversations: Accessor<ChannelEntity[]>;- activity: {- isUnread: (channelId: string) => boolean;- callStatus: (channelId: string) => ChannelCallStatus | undefined;- incomingCallId: (channelId: string) => string | undefined;- unreadCount: (group: ChannelsGroup) => number;- targetId: (group: ChannelsGroup) => string | undefined;- label: (group: ChannelsGroup) => string | undefined;- onVisible: (group: ChannelsGroup, targetId: string) => void;- };- item: {- domId: (channelId: string) => string;- isSelected: (channelId: string) => boolean;- isFocused: (channelId: string) => boolean;- activate: (channelId: string) => void;- };- section: {- domId: (group: ChannelsGroup) => string;- isOpen: (group: ChannelsGroup) => boolean;- isFocused: (group: ChannelsGroup) => boolean;- containsFocus: (group: ChannelsGroup) => boolean;- activate: (group: ChannelsGroup) => void;- registerScrollRef: (- group: ChannelsGroup- ) => (element: HTMLDivElement) => void;- };-};--type ChannelRailProviderProps = ContextProviderProps & {- value: ChannelRailContext;-};--export const [ChannelRailProvider, useChannelRail] =- createAssertedContextProvider<ChannelRailContext, ChannelRailProviderProps>(- 'ChannelRail',- (props) => props.value- );diff --git a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsxnew file mode 100644index 0000000000..5c0321406f--- /dev/null+++ b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx@@ -0,0 +1,330 @@+import { runCreateAction } from '@app/features/command/Launcher';+import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';+import { openNewChannelModal } from '@channel/CreateChannelModal';+import { SplitPanel } from '@components/app/split-panel';+import { useUserId } from '@core/context/user';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import type { ChannelEntity } from '@entity';+import CaretDownIcon from '@phosphor/caret-down.svg';+import { Key } from '@solid-primitives/keyed';+import { cn, Hotkey, Tabs } from '@ui';+import { For, Match, Show, Switch } from 'solid-js';+import type { ChannelsGroup } from '../../types';+import { channelMentionsUser, isDirectMessage } from '../../utils';+import { ChannelsEmptyState } from '../ChannelsEmptyState';+import {+ ChannelAvatar,+ ChannelCallIndicator,+ ConversationCard,+ IncomingCallActions,+} from './ChannelRailItems';+import {+ domIdForRow,+ rowKeyForChannel,+ rowKeyForSection,+ useChannelsRail,+} from './ChannelsRailContext';+import {+ CollapsibleSection,+ CreateRailAction,+ RailModeButton,+} from './ChannelsRailSection';+import {+ useChannelRailItemState,+ useChannelRailSectionState,+} from './hooks/useChannelRailState';++const CHANNEL_TABS = [+ { value: 'browse', label: 'Browse' },+ { value: 'recents', label: 'Recents' },+];++type GroupConfig = {+ group: ChannelsGroup;+ label: string;+ emptyLabel: string;+ createLabel: string;+ onCreate: () => void;+};++const GROUPS: GroupConfig[] = [+ {+ group: 'channels',+ label: 'Channels',+ emptyLabel: 'No channels',+ createLabel: 'Create channel',+ onCreate: openNewChannelModal,+ },+ {+ group: 'direct_messages',+ label: 'DMs',+ emptyLabel: 'No direct messages',+ createLabel: 'Start direct message',+ onCreate: () => runCreateAction('channel'),+ },+];++function ChannelOption(props: { channel: ChannelEntity }) {+ const rail = useChannelsRail();+ const item = useChannelRailItemState(() => props.channel.id);++ return (+ <div+ id={item().domId}+ role="treeitem"+ tabIndex={-1}+ class={cn(+ 'relative flex w-full min-w-0 items-center gap-2 rounded-xl px-2 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-accent touch:focus-visible:ring-0',+ isDirectMessage(props.channel) ? 'min-h-10 py-2' : 'h-8',+ item().selected && !isTouchDevice() && 'bg-active text-ink',+ (!item().selected || isTouchDevice()) && 'text-ink-muted',+ !item().selected &&+ !isTouchDevice() &&+ item().focused &&+ 'bg-hover text-ink',+ !item().selected &&+ !isTouchDevice() &&+ !item().focused &&+ 'hover:bg-hover hover:text-ink'+ )}+ aria-current={item().selected ? 'page' : undefined}+ onClick={() => rail.activateRow(rowKeyForChannel(props.channel.id))}+ >+ <ChannelAvatar channel={props.channel} />+ <span class="min-w-0 flex-1 truncate text-sm font-medium">+ {props.channel.name}+ </span>+ <ChannelCallIndicator+ status={item().incomingCallId ? undefined : item().callStatus}+ />+ <IncomingCallActions+ callId={item().incomingCallId}+ channelId={props.channel.id}+ />+ <Show when={item().unread}>+ <span+ aria-label="Unread"+ class="size-2 shrink-0 rounded-full bg-accent"+ />+ </Show>+ </div>+ );+}++function ExpandedHeader() {+ const rail = useChannelsRail();+ const selectTab = (value: string) => {+ if (value === 'browse' || value === 'recents') {+ rail.selectTab(value);+ }+ };++ return (+ <div class="flex shrink-0 flex-col gap-3 px-4">+ <div class="flex items-center">+ <SplitPanel.ControlGroup>+ <SplitPanel.CloseButton />+ <SplitPanel.BackButton />+ <SplitPanel.ForwardButton />+ </SplitPanel.ControlGroup>+ </div>+ <div class="flex h-8 items-center gap-2">+ <RailModeButton expanded onToggle={() => rail.setMode('slim')} />+ <h1 class="m-0 min-w-0 flex-1 truncate text-2xl font-semibold tracking-[-0.03em] text-ink">+ Chat+ </h1>+ </div>+ <Tabs+ aria-label="Chat sidebar views"+ fullWidth+ list={CHANNEL_TABS}+ value={rail.tab()}+ onChange={selectTab}+ />+ </div>+ );+}++function ExpandedGroupSection(props: { config: GroupConfig }) {+ const rail = useChannelsRail();+ const { state: section, clearVisibleActivity } = useChannelRailSectionState(+ () => props.config.group+ );+ const registerScrollRef = (element: HTMLDivElement) =>+ rail.registerScrollRef(props.config.group, element);++ return (+ <CollapsibleSection.Root+ open={section().open}+ fillAvailable={section().fillAvailable}+ >+ <CollapsibleSection.Header+ focused={section().focused}+ focusWithin={section().containsFocus}+ class="h-9 has-[[data-section-action]:hover]:bg-transparent has-[[data-section-action]:focus-within]:bg-transparent"+ >+ <button+ id={section().domId}+ type="button"+ role="treeitem"+ tabIndex={-1}+ class="relative flex h-full min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-accent"+ aria-expanded={section().open}+ onClick={() => rail.activateRow(rowKeyForSection(props.config.group))}+ >+ <CaretDownIcon+ class={cn(+ 'size-3 shrink-0 transition-transform',+ !section().open && '-rotate-90'+ )}+ />+ <span class="min-w-0 truncate">{props.config.label}</span>+ <Show when={section().unreadCount > 0}>+ <span class="flex h-4 min-w-4 items-center justify-center rounded-full bg-accent px-1 text-xs font-medium leading-none tabular-nums text-accent-contrast">+ {section().unreadCount}+ </span>+ </Show>+ </button>+ <div data-section-action="" class="pr-1">+ <CreateRailAction+ label={props.config.createLabel}+ onClick={props.config.onCreate}+ />+ </div>+ </CollapsibleSection.Header>+ <CollapsibleSection.Content+ open={section().open}+ contentRef={registerScrollRef}+ class="flex min-h-0 flex-col gap-0.5"+ activityTargetId={section().targetId}+ activityLabel={section().label}+ onActivityVisible={clearVisibleActivity}+ >+ <Switch>+ <Match when={section().items.length > 0}>+ <Key each={section().items} by={(channel) => channel.id}>+ {(channel) => <ChannelOption channel={channel()} />}+ </Key>+ </Match>+ <Match when={true}>+ <div class="px-2 py-2 text-xs text-ink-extra-muted">+ {props.config.emptyLabel}+ </div>+ </Match>+ </Switch>+ </CollapsibleSection.Content>+ </CollapsibleSection.Root>+ );+}++function ExpandedBrowse() {+ const rail = useChannelsRail();+ const forceEmptyState = useDebugSetting(+ DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES+ );+ const hasItems = () =>+ rail.teamChannels().length > 0 || rail.directMessages().length > 0;++ return (+ <Switch>+ <Match when={forceEmptyState() || !hasItems()}>+ <ChannelsEmptyState scope="channels" topAligned />+ </Match>+ <Match when={true}>+ <div class="flex h-full min-h-0 flex-col gap-3 px-4">+ <For each={GROUPS}>+ {(config) => <ExpandedGroupSection config={config} />}+ </For>+ </div>+ </Match>+ </Switch>+ );+}++function RecentConversationCard(props: { channel: ChannelEntity }) {+ const rail = useChannelsRail();+ const currentUserId = useUserId();+ const item = useChannelRailItemState(() => props.channel.id);++ return (+ <ConversationCard+ id={item().domId}+ channel={props.channel}+ senderId={props.channel.latestRootMessage?.senderId}+ mentionedCurrentUser={channelMentionsUser(props.channel, currentUserId())}+ unread={item().unread}+ callStatus={item().callStatus}+ incomingCallId={item().incomingCallId}+ selected={item().selected}+ focused={item().focused}+ onActivate={() => rail.activateRow(rowKeyForChannel(props.channel.id))}+ />+ );+}++function ExpandedRecents() {+ const rail = useChannelsRail();+ const forceEmptyState = useDebugSetting(+ DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES+ );+ const hasItems = () =>+ !forceEmptyState() && rail.recentConversations().length > 0;++ return (+ <Switch>+ <Match when={!hasItems()}>+ <ChannelsEmptyState scope="recents" topAligned />+ </Match>+ <Match when={true}>+ <div class="flex w-full flex-col divide-y divide-edge-muted">+ <Key each={rail.recentConversations()} by={(channel) => channel.id}>+ {(channel) => <RecentConversationCard channel={channel()} />}+ </Key>+ </div>+ </Match>+ </Switch>+ );+}++export function ExpandedChannelsRail() {+ const rail = useChannelsRail();+ const activeDescendant = () => {+ const rowId = rail.list.focus.key();+ return rowId === undefined ? undefined : domIdForRow(rail.railId, rowId);+ };++ return (+ <>+ <ExpandedHeader />+ <div class="flex min-h-0 flex-1 flex-col">+ <div+ ref={rail.registerRootRef}+ role="tree"+ tabIndex={-1}+ aria-activedescendant={activeDescendant()}+ class={cn(+ 'scrollbar-hidden min-h-0 flex-1 outline-none',+ rail.tab() === 'browse' ? 'overflow-hidden' : 'overflow-y-auto'+ )}+ >+ <Switch>+ <Match when={rail.tab() === 'browse'}>+ <ExpandedBrowse />+ </Match>+ <Match when={rail.tab() === 'recents'}>+ <ExpandedRecents />+ </Match>+ </Switch>+ </div>+ <Show when={rail.tab() === 'browse'}>+ <footer class="flex h-9 shrink-0 items-center justify-start gap-1 border-t border-edge-muted px-4 text-xxs text-ink-extra-muted">+ <span>Use</span>+ <Hotkey shortcut="[" theme="subtle" />+ <Hotkey shortcut="]" theme="subtle" />+ <span>to jump sections</span>+ </footer>+ </Show>+ </div>+ </>+ );+}diff --git a/apps/web/src/features/channels-view/components/rail/Header.tsx b/apps/web/src/features/channels-view/components/rail/Header.tsxdeleted file mode 100644index 894b2df599..0000000000--- a/apps/web/src/features/channels-view/components/rail/Header.tsx+++ /dev/null@@ -1,175 +0,0 @@-import { runCreateAction } from '@app/features/command/Launcher';-import { openNewChannelModal } from '@channel/CreateChannelModal';-import { SplitPanel } from '@components/app/split-panel';-import { AnimatedSquareSidebarIcon } from '@icon/square-sidebar';-import ChannelIcon from '@icon/wide-channel.svg';-import ChatTeardropIcon from '@phosphor/chat-teardrop.svg';-import ChatTextIcon from '@phosphor/chat-text.svg';-import ChatsIcon from '@phosphor/chats-circle.svg';-import PlusIcon from '@phosphor/plus.svg';-import { Button, Dropdown, Tabs } from '@ui';-import { createSignal, Match, Switch } from 'solid-js';-import { useChannelRail } from './Context';--const CHANNEL_TABS = [- {- value: 'browse',- label: 'Browse',- },- {- value: 'recents',- label: 'Recents',- },-];--function BrowseTabLabel() {- return (- <>- <span class="sr-only">Browse</span>- <span aria-hidden="true" class="[&_svg]:size-4">- <ChatsIcon />- </span>- </>- );-}--function RecentsTabLabel() {- return (- <>- <span class="sr-only">Recents</span>- <span aria-hidden="true" class="[&_svg]:size-4">- <ChatTextIcon />- </span>- </>- );-}--const SLIM_CHANNEL_TABS = [- {- value: 'browse',- label: BrowseTabLabel,- },- {- value: 'recents',- label: RecentsTabLabel,- },-];--const openMessageComposer = () => runCreateAction('channel');--function RailModeButton() {- const rail = useChannelRail();-- const expanded = () => rail.mode() === 'full';-- const [hovering, setHovering] = createSignal(false);-- return (- <Button- variant="ghost"- size="icon-sm"- label={expanded() ? 'Collapse chat rail' : 'Expand chat rail'}- tooltipPlacement={expanded() ? 'bottom' : 'right'}- onClick={() => rail.onModeChange(expanded() ? 'slim' : 'full')}- onMouseEnter={() => setHovering(true)}- onMouseLeave={() => setHovering(false)}- >- <AnimatedSquareSidebarIcon class="size-4" triggerAnimation={hovering()} />- </Button>- );-}--function SlimCreateMenu() {- return (- <Dropdown placement="right-start" gutter={8}>- <Dropdown.Trigger- variant="outline"- size="icon-sm"- class="size-10 rounded-full bg-transparent"- label="Create conversation"- >- <PlusIcon class="size-4" />- </Dropdown.Trigger>- <Dropdown.Content class="min-w-44">- <Dropdown.Group>- <Dropdown.Item onSelect={() => openNewChannelModal()}>- <ChannelIcon class="size-4 shrink-0" />- <span>Create channel</span>- </Dropdown.Item>- <Dropdown.Item onSelect={openMessageComposer}>- <ChatTeardropIcon class="size-4 shrink-0" />- <span>Start direct message</span>- </Dropdown.Item>- </Dropdown.Group>- </Dropdown.Content>- </Dropdown>- );-}--export function ChannelsRailHeader() {- const rail = useChannelRail();-- const selectTab = (value: string) => {- if (value !== 'browse' && value !== 'recents') return;-- rail.setTab(value);- };-- return (- <Switch>- <Match when={rail.mode() === 'full'}>- <div class="flex shrink-0 flex-col gap-3 px-4">- <div class="flex items-center">- <SplitPanel.ControlGroup>- <SplitPanel.CloseButton />- <SplitPanel.BackButton />- <SplitPanel.ForwardButton />- </SplitPanel.ControlGroup>- </div>- <div class="flex h-8 items-center gap-2">- <RailModeButton />- <h1 class="m-0 min-w-0 flex-1 truncate text-2xl font-semibold tracking-[-0.03em] text-ink">- Chat- </h1>- </div>- <Tabs- aria-label="Chat sidebar views"- fullWidth- list={CHANNEL_TABS}- value={rail.tab()}- onChange={selectTab}- />- </div>- </Match>- <Match when={rail.mode() === 'slim'}>- <div class="flex shrink-0 flex-col items-center gap-3">- <div class="flex w-full items-center justify-center px-2">- <SplitPanel.ControlGroup>- <SplitPanel.CloseButton size="icon-sm" />- </SplitPanel.ControlGroup>- </div>- <div class="flex h-8 w-full items-center justify-center px-2">- <RailModeButton />- </div>- <div class="w-full px-3">- <Tabs- aria-label="Chat sidebar views"- class="h-[76px] flex-col"- itemClass="h-auto min-h-0 w-full"- labelClass="size-full p-0"- fullWidth- list={SLIM_CHANNEL_TABS}- value={rail.tab()}- onChange={selectTab}- />- </div>- <div class="w-full border-t border-edge-muted" />- <div class="flex w-full justify-center px-2">- <SlimCreateMenu />- </div>- <div class="w-full border-t border-edge-muted" />- </div>- </Match>- </Switch>- );-}diff --git a/apps/web/src/features/channels-view/components/rail/Item.tsx b/apps/web/src/features/channels-view/components/rail/Item.tsxdeleted file mode 100644index 71189c5e6a..0000000000--- a/apps/web/src/features/channels-view/components/rail/Item.tsx+++ /dev/null@@ -1,249 +0,0 @@-import { dismissIncomingCallEverywhere } from '@app/features/block-call/sidebar/incoming-calls';-import { joinChannelCall } from '@channel/Call/join-channel-call';-import { toast } from '@core/component/Toast/Toast';-import { isTouchDevice } from '@core/mobile/isTouchDevice';-import { type ChannelEntity, Entity } from '@entity';-import XIcon from '@phosphor/x.svg';-import PhoneCallIcon from '@phosphor-fill/phone-call-fill.svg';-import PhoneIncomingIcon from '@phosphor-fill/phone-incoming-fill.svg';-import { Button, cn, Tooltip } from '@ui';-import { Match, Show, Switch } from 'solid-js';-import { channelInitials, isDirectMessage } from '../../utils';--export type ChannelCallStatus = 'active' | 'incoming';--export type ChannelRailItemProps = {- id: string;- channel: ChannelEntity;- unread: boolean;- callStatus?: ChannelCallStatus;- incomingCallId?: string;- selected: boolean;- focused: boolean;- onActivate: () => void;-};--export function ChannelCallIndicator(props: {- status: ChannelCallStatus | undefined;- class?: string;-}) {- return (- <Show when={props.status}>- {(status) => (- <span- aria-label={status() === 'incoming' ? 'Incoming call' : 'Active call'}- class={cn(- 'flex size-4 shrink-0 items-center justify-center text-accent',- props.class- )}- >- <Switch>- <Match when={status() === 'incoming'}>- <PhoneIncomingIcon class="incoming-call-shake size-full" />- </Match>- <Match when={true}>- <PhoneCallIcon class="size-full" />- </Match>- </Switch>- </span>- )}- </Show>- );-}--export function IncomingCallActions(props: {- callId: string | undefined;- channelId: string;-}) {- return (- <Show when={props.callId}>- {(callId) => (- <span class="flex shrink-0 items-center gap-1">- <Button- variant="success"- size="icon-xs"- class="rounded-md"- label="Accept incoming call"- onPointerDown={(event) => event.stopPropagation()}- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- void joinChannelCall(props.channelId).catch((error) => {- console.error('Failed to join call', error);- toast.failure('Failed to join call');- });- }}- >- <PhoneIncomingIcon class="incoming-call-shake size-3" />- </Button>- <Button- variant="danger"- size="icon-xs"- class="rounded-md"- label="Decline incoming call"- onPointerDown={(event) => event.stopPropagation()}- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- dismissIncomingCallEverywhere(callId());- }}- >- <XIcon class="size-3" />- </Button>- </span>- )}- </Show>- );-}--export function ChannelAvatar(props: {- channel: ChannelEntity;- size?: 'sm' | 'md';-}) {- const sizeClass = () =>- props.size === 'md' ? 'size-9 [&_svg]:size-4.5' : 'size-6 [&_svg]:size-3.5';-- return (- <Switch>- <Match when={isDirectMessage(props.channel)}>- <span- class={cn(- 'relative flex shrink-0 items-center justify-center overflow-hidden rounded-full border border-edge bg-surface-2 [&_img]:size-full [&_svg]:shrink-0',- sizeClass()- )}- >- <Entity.Icon- entity={props.channel}- suppressClick- showTooltip={false}- />- </span>- </Match>- <Match when={true}>- <span- class={cn(- 'flex shrink-0 items-center justify-center text-ink-muted [&_svg]:shrink-0',- sizeClass()- )}- >- <Entity.Icon- entity={props.channel}- suppressClick- showTooltip={false}- />- </span>- </Match>- </Switch>- );-}--function SlimChannelAvatar(props: { channel: ChannelEntity }) {- return (- <Switch>- <Match when={isDirectMessage(props.channel)}>- <span class="relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full border border-edge bg-surface-2 [&_img]:size-full [&_svg]:size-4 [&_svg]:shrink-0">- <Entity.Icon- entity={props.channel}- suppressClick- showTooltip={false}- />- </span>- </Match>- <Match when={true}>- <span class="flex size-8 shrink-0 items-center justify-center rounded-full border border-edge bg-surface-2 text-xs font-semibold tracking-wide text-ink">- {channelInitials(props.channel.name)}- </span>- </Match>- </Switch>- );-}--export function ChannelOption(props: ChannelRailItemProps) {- return (- <div- id={props.id}- role="treeitem"- tabIndex={-1}- class={cn(- 'relative flex w-full min-w-0 items-center gap-2 rounded-xl px-2 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-accent touch:focus-visible:ring-0',- isDirectMessage(props.channel) ? 'min-h-10 py-2' : 'h-8',- props.selected && !isTouchDevice() && 'bg-active text-ink',- (!props.selected || isTouchDevice()) && 'text-ink-muted',- !props.selected &&- !isTouchDevice() &&- props.focused &&- 'bg-hover text-ink',- !props.selected &&- !isTouchDevice() &&- !props.focused &&- 'hover:bg-hover hover:text-ink'- )}- aria-current={props.selected ? 'page' : undefined}- onClick={props.onActivate}- >- <ChannelAvatar channel={props.channel} />- <span class="min-w-0 flex-1 truncate text-sm font-medium">- {props.channel.name}- </span>- <ChannelCallIndicator- status={props.incomingCallId ? undefined : props.callStatus}- />- <IncomingCallActions- callId={props.incomingCallId}- channelId={props.channel.id}- />- <Show when={props.unread}>- <span- aria-label="Unread"- class="size-2 shrink-0 rounded-full bg-accent"- />- </Show>- </div>- );-}--export function SlimChannelItem(props: ChannelRailItemProps) {- return (- <Tooltip- label={props.channel.name}- placement="right"- class="size-10 self-center"- >- <button- id={props.id}- type="button"- role="treeitem"- tabIndex={-1}- class={cn(- 'flex size-10 items-center justify-center rounded-full text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent touch:focus-visible:ring-0',- props.selected && !isTouchDevice() && 'bg-active text-ink',- (!props.selected || isTouchDevice()) && 'text-ink-muted',- !props.selected &&- !isTouchDevice() &&- props.focused &&- 'bg-hover text-ink',- !props.selected &&- !isTouchDevice() &&- !props.focused &&- 'hover:bg-hover hover:text-ink'- )}- aria-current={props.selected ? 'page' : undefined}- onClick={props.onActivate}- >- <span class="relative">- <SlimChannelAvatar channel={props.channel} />- <ChannelCallIndicator- status={props.callStatus}- class="absolute -bottom-0.5 -right-0.5 rounded-full bg-inset p-0.5"- />- <Show when={props.unread}>- <span- aria-label="Unread"- class="absolute -right-0.5 -top-0.5 size-2.5 rounded-full bg-accent ring-2 ring-surface"- />- </Show>- </span>- </button>- </Tooltip>- );-}diff --git a/apps/web/src/features/channels-view/components/rail/Recents.tsx b/apps/web/src/features/channels-view/components/rail/Recents.tsxdeleted file mode 100644index 32799ecb58..0000000000--- a/apps/web/src/features/channels-view/components/rail/Recents.tsx+++ /dev/null@@ -1,68 +0,0 @@-import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';-import { useUserId } from '@core/context/user';-import { Key } from '@solid-primitives/keyed';-import { Match, Switch } from 'solid-js';-import { channelMentionsUser } from '../../utils';-import { ChannelsEmptyState } from '../ChannelsEmptyState';-import { useChannelRail } from './Context';-import { ConversationCard } from './ConversationCard';-import { SlimChannelItem } from './Item';--export function ChannelsRailRecents() {- const rail = useChannelRail();- const currentUserId = useUserId();- const forceEmptyState = useDebugSetting(- DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES- );-- const hasItems = () =>- !forceEmptyState() && rail.recentConversations().length > 0;-- return (- <Switch>- <Match when={rail.mode() === 'full' && !hasItems()}>- <ChannelsEmptyState scope="recents" topAligned />- </Match>- <Match when={rail.mode() === 'full'}>- <div class="flex w-full flex-col divide-y divide-edge-muted">- <Key each={rail.recentConversations()} by={(channel) => channel.id}>- {(channel) => (- <ConversationCard- id={rail.item.domId(channel().id)}- channel={channel()}- senderId={channel().latestRootMessage?.senderId}- mentionedCurrentUser={channelMentionsUser(- channel(),- currentUserId()- )}- unread={rail.activity.isUnread(channel().id)}- callStatus={rail.activity.callStatus(channel().id)}- incomingCallId={rail.activity.incomingCallId(channel().id)}- selected={rail.item.isSelected(channel().id)}- focused={rail.item.isFocused(channel().id)}- onActivate={() => rail.item.activate(channel().id)}- />- )}- </Key>- </div>- </Match>- <Match when={hasItems()}>- <div class="flex w-full flex-col gap-0.5">- <Key each={rail.recentConversations()} by={(channel) => channel.id}>- {(channel) => (- <SlimChannelItem- id={rail.item.domId(channel().id)}- channel={channel()}- unread={rail.activity.isUnread(channel().id)}- callStatus={rail.activity.callStatus(channel().id)}- selected={rail.item.isSelected(channel().id)}- focused={rail.item.isFocused(channel().id)}- onActivate={() => rail.item.activate(channel().id)}- />- )}- </Key>- </div>- </Match>- </Switch>- );-}diff --git a/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsxnew file mode 100644index 0000000000..599682fefb--- /dev/null+++ b/apps/web/src/features/channels-view/components/rail/SlimChannelsRail.tsx@@ -0,0 +1,335 @@+import { runCreateAction } from '@app/features/command/Launcher';+import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';+import { openNewChannelModal } from '@channel/CreateChannelModal';+import { SplitPanel } from '@components/app/split-panel';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { type ChannelEntity, Entity } from '@entity';+import ChannelIcon from '@icon/wide-channel.svg';+import ChatTeardropIcon from '@phosphor/chat-teardrop.svg';+import ChatTextIcon from '@phosphor/chat-text.svg';+import ChatsIcon from '@phosphor/chats-circle.svg';+import PlusIcon from '@phosphor/plus.svg';+import { Key } from '@solid-primitives/keyed';+import { cn, Dropdown, Tabs, Tooltip } from '@ui';+import { type Component, For, Match, Show, Switch } from 'solid-js';+import { Dynamic } from 'solid-js/web';+import type { ChannelsGroup } from '../../types';+import { channelInitials, isDirectMessage } from '../../utils';+import { ChannelCallIndicator } from './ChannelRailItems';+import {+ domIdForRow,+ rowKeyForChannel,+ rowKeyForSection,+ useChannelsRail,+} from './ChannelsRailContext';+import { CollapsibleSection, RailModeButton } from './ChannelsRailSection';+import {+ useChannelRailItemState,+ useChannelRailSectionState,+} from './hooks/useChannelRailState';++function BrowseTabLabel() {+ return (+ <>+ <span class="sr-only">Browse</span>+ <span aria-hidden="true" class="[&_svg]:size-4">+ <ChatsIcon />+ </span>+ </>+ );+}++function RecentsTabLabel() {+ return (+ <>+ <span class="sr-only">Recents</span>+ <span aria-hidden="true" class="[&_svg]:size-4">+ <ChatTextIcon />+ </span>+ </>+ );+}++const SLIM_CHANNEL_TABS = [+ { value: 'browse', label: BrowseTabLabel },+ { value: 'recents', label: RecentsTabLabel },+];++type GroupConfig = {+ group: ChannelsGroup;+ label: string;+ icon: Component;+};++const GROUPS: GroupConfig[] = [+ { group: 'channels', label: 'Channels', icon: ChannelIcon },+ {+ group: 'direct_messages',+ label: 'DMs',+ icon: ChatTeardropIcon,+ },+];++function SlimChannelAvatar(props: { channel: ChannelEntity }) {+ return (+ <Switch>+ <Match when={isDirectMessage(props.channel)}>+ <span class="relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full border border-edge bg-surface-2 [&_img]:size-full [&_svg]:size-4 [&_svg]:shrink-0">+ <Entity.Icon+ entity={props.channel}+ suppressClick+ showTooltip={false}+ />+ </span>+ </Match>+ <Match when={true}>+ <span class="flex size-8 shrink-0 items-center justify-center rounded-full border border-edge bg-surface-2 text-xs font-semibold tracking-wide text-ink">+ {channelInitials(props.channel.name)}+ </span>+ </Match>+ </Switch>+ );+}++function SlimChannelItem(props: { channel: ChannelEntity }) {+ const rail = useChannelsRail();+ const item = useChannelRailItemState(() => props.channel.id);++ return (+ <Tooltip+ label={props.channel.name}+ placement="right"+ class="size-10 self-center"+ >+ <button+ id={item().domId}+ type="button"+ role="treeitem"+ tabIndex={-1}+ class={cn(+ 'flex size-10 items-center justify-center rounded-full text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent touch:focus-visible:ring-0',+ item().selected && !isTouchDevice() && 'bg-active text-ink',+ (!item().selected || isTouchDevice()) && 'text-ink-muted',+ !item().selected &&+ !isTouchDevice() &&+ item().focused &&+ 'bg-hover text-ink',+ !item().selected &&+ !isTouchDevice() &&+ !item().focused &&+ 'hover:bg-hover hover:text-ink'+ )}+ aria-current={item().selected ? 'page' : undefined}+ onClick={() => rail.activateRow(rowKeyForChannel(props.channel.id))}+ >+ <span class="relative">+ <SlimChannelAvatar channel={props.channel} />+ <ChannelCallIndicator+ status={item().callStatus}+ class="absolute -bottom-0.5 -right-0.5 rounded-full bg-inset p-0.5"+ />+ <Show when={item().unread}>+ <span+ aria-label="Unread"+ class="absolute -right-0.5 -top-0.5 size-2.5 rounded-full bg-accent ring-2 ring-surface"+ />+ </Show>+ </span>+ </button>+ </Tooltip>+ );+}++function SlimCreateMenu() {+ return (+ <Dropdown placement="right-start" gutter={8}>+ <Dropdown.Trigger+ variant="outline"+ size="icon-sm"+ class="size-10 rounded-full bg-transparent"+ label="Create conversation"+ >+ <PlusIcon class="size-4" />+ </Dropdown.Trigger>+ <Dropdown.Content class="min-w-44">+ <Dropdown.Group>+ <Dropdown.Item onSelect={() => openNewChannelModal()}>+ <ChannelIcon class="size-4 shrink-0" />+ <span>Create channel</span>+ </Dropdown.Item>+ <Dropdown.Item onSelect={() => runCreateAction('channel')}>+ <ChatTeardropIcon class="size-4 shrink-0" />+ <span>Start direct message</span>+ </Dropdown.Item>+ </Dropdown.Group>+ </Dropdown.Content>+ </Dropdown>+ );+}++function SlimHeader() {+ const rail = useChannelsRail();+ const selectTab = (value: string) => {+ if (value === 'browse' || value === 'recents') {+ rail.selectTab(value);+ }+ };++ return (+ <div class="flex shrink-0 flex-col items-center gap-3">+ <div class="flex w-full items-center justify-center px-2">+ <SplitPanel.ControlGroup>+ <SplitPanel.CloseButton size="icon-sm" />+ </SplitPanel.ControlGroup>+ </div>+ <div class="flex h-8 w-full items-center justify-center px-2">+ <RailModeButton+ expanded={false}+ onToggle={() => rail.setMode('full')}+ />+ </div>+ <div class="w-full px-3">+ <Tabs+ aria-label="Chat sidebar views"+ class="h-20 flex-col"+ itemClass="h-auto min-h-0 w-full"+ labelClass="size-full p-0"+ fullWidth+ list={SLIM_CHANNEL_TABS}+ value={rail.tab()}+ onChange={selectTab}+ />+ </div>+ <div class="w-full border-t border-edge-muted" />+ <div class="flex w-full justify-center px-2">+ <SlimCreateMenu />+ </div>+ <div class="w-full border-t border-edge-muted" />+ </div>+ );+}++function SlimGroupSection(props: { config: GroupConfig }) {+ const rail = useChannelsRail();+ const forceEmptyState = useDebugSetting(+ DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES+ );+ const { state: section, clearVisibleActivity } = useChannelRailSectionState(+ () => props.config.group+ );+ const registerScrollRef = (element: HTMLDivElement) =>+ rail.registerScrollRef(props.config.group, element);++ return (+ <CollapsibleSection.Root+ open={section().open}+ fillAvailable={section().fillAvailable}+ class="items-center"+ >+ <CollapsibleSection.Header+ focused={section().focused}+ focusWithin={section().containsFocus}+ class="h-10 justify-center"+ >+ <button+ id={section().domId}+ type="button"+ role="treeitem"+ tabIndex={-1}+ class="relative flex size-10 min-w-10 flex-none items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-accent"+ aria-expanded={section().open}+ aria-label={props.config.label}+ onClick={() => rail.activateRow(rowKeyForSection(props.config.group))}+ >+ <span class="flex items-center justify-center [&_svg]:size-4">+ <Dynamic component={props.config.icon} />+ </span>+ <Show when={section().unreadCount > 0}>+ <span class="absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-accent px-1 text-xs font-medium leading-none text-accent-contrast ring-2 ring-surface">+ {section().unreadCount}+ </span>+ </Show>+ </button>+ </CollapsibleSection.Header>+ <CollapsibleSection.Content+ open={section().open}+ contentRef={registerScrollRef}+ containerClass="w-full"+ class="flex min-h-0 w-full flex-col items-center gap-0.5"+ activityTargetId={section().targetId}+ activityTooltip+ onActivityVisible={clearVisibleActivity}+ >+ <Show when={!forceEmptyState()}>+ <Key each={section().items} by={(channel) => channel.id}>+ {(channel) => <SlimChannelItem channel={channel()} />}+ </Key>+ </Show>+ </CollapsibleSection.Content>+ </CollapsibleSection.Root>+ );+}++function SlimBrowse() {+ return (+ <div class="flex h-full min-h-0 flex-col gap-3 px-2">+ <For each={GROUPS}>+ {(config) => <SlimGroupSection config={config} />}+ </For>+ </div>+ );+}++function SlimRecents() {+ const rail = useChannelsRail();+ const forceEmptyState = useDebugSetting(+ DEBUG_SETTING_KEYS.FORCE_EMPTY_STATES+ );+ const hasItems = () =>+ !forceEmptyState() && rail.recentConversations().length > 0;++ return (+ <Show when={hasItems()}>+ <div class="flex w-full flex-col gap-0.5">+ <Key each={rail.recentConversations()} by={(channel) => channel.id}>+ {(channel) => <SlimChannelItem channel={channel()} />}+ </Key>+ </div>+ </Show>+ );+}++export function SlimChannelsRail() {+ const rail = useChannelsRail();+ const activeDescendant = () => {+ const rowId = rail.list.focus.key();+ return rowId === undefined ? undefined : domIdForRow(rail.railId, rowId);+ };++ return (+ <>+ <SlimHeader />+ <div class="flex min-h-0 flex-1 flex-col">+ <div+ ref={rail.registerRootRef}+ role="tree"+ tabIndex={-1}+ aria-activedescendant={activeDescendant()}+ class={cn(+ 'scrollbar-hidden min-h-0 flex-1 outline-none',+ rail.tab() === 'browse' ? 'overflow-hidden' : 'overflow-y-auto'+ )}+ >+ <Switch>+ <Match when={rail.tab() === 'browse'}>+ <SlimBrowse />+ </Match>+ <Match when={rail.tab() === 'recents'}>+ <SlimRecents />+ </Match>+ </Switch>+ </div>+ </div>+ </>+ );+}diff --git a/apps/web/src/features/channels-view/components/rail/hooks/useChannelCalls.ts b/apps/web/src/features/channels-view/components/rail/hooks/useChannelCalls.tsindex 226b12dda2..08bcac7a6d 100644--- a/apps/web/src/features/channels-view/components/rail/hooks/useChannelCalls.ts+++ b/apps/web/src/features/channels-view/components/rail/hooks/useChannelCalls.ts@@ -1,7 +1,7 @@import { useVisibleIncomingCalls } from '@app/features/block-call/sidebar/incoming-calls';import { useActiveCallsQuery } from '@queries/call/call';import { createMemo } from 'solid-js';-import type { ChannelCallStatus } from '../Item';+import type { ChannelCallStatus } from '../ChannelRailItems';export function useChannelCalls() {const activeCallsQuery = useActiveCallsQuery();diff --git a/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailActivity.ts b/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailActivity.tsindex 79d84a8e50..098d8e2f18 100644--- a/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailActivity.ts+++ b/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailActivity.ts@@ -6,7 +6,9 @@ import { type Accessor, createEffect, createMemo, onCleanup } from 'solid-js';import { createStore } from 'solid-js/store';import type { ChannelsGroup } from '../../../types';import { channelGroup } from '../../../utils';-import { CHANNEL_GROUPS } from '../model';+import type { useChannelCalls } from './useChannelCalls';++const CHANNEL_GROUPS: ChannelsGroup[] = ['channels', 'direct_messages'];type ChannelActivityTarget = {channelId: string;@@ -19,15 +21,9 @@ type ChannelActivityTarget = {};};-type ChannelCallActivity = {- callId: string;- channelId: string;- status: 'active' | 'incoming';-};-export function useChannelRailActivity(channels: Accessor<ChannelEntity[]>,- calls: Accessor<ChannelCallActivity[]>+ calls: ReturnType<typeof useChannelCalls>) {const notificationSource = useGlobalNotificationSource();const [activityTargets, setActivityTargets] = createStore<@@ -40,8 +36,9 @@ export function useChannelRailActivity(() => new Map(channels().map((channel) => [channel.id, channel])));- const callStatuses = createMemo(- () => new Map(calls().map((call) => [call.callId, call.status]))+ const callStatusesByCallId = createMemo(+ () =>+ new Map(calls.callActivity().map((call) => [call.callId, call.status])));const notificationActivity = createMemo(() => {@@ -147,13 +144,13 @@ export function useChannelRailActivity(latestMessageTimes = nextMessageTimes;});- let activeCallStatuses = new Map<string, ChannelCallActivity['status']>();+ let activeCallStatuses = new Map<string, 'active' | 'incoming'>();createEffect(() => {- const nextActiveCallStatuses = callStatuses();+ const nextActiveCallStatuses = callStatusesByCallId();const recordedGroups = new Set<ChannelsGroup>();- for (const call of calls()) {+ for (const call of calls.callActivity()) {const channel = channelsById().get(call.channelId);if (!channel) continue;@@ -197,7 +194,7 @@ export function useChannelRailActivity(if (!source) return;if (source.type !== 'call') return 'New activity';- return callStatuses().get(source.callId) === 'incoming'+ return callStatusesByCallId().get(source.callId) === 'incoming'? 'Incoming call': 'Active call';};@@ -217,7 +214,9 @@ export function useChannelRailActivity(};return {+ callStatuses: calls.callStatuses,clearTarget,+ incomingCallIds: calls.incomingCallIds,targetChannelId,targetLabel,unreadChannelIds: () => notificationActivity().unreadChannelIds,diff --git a/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailRows.ts b/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailRows.tsdeleted file mode 100644index c0e63d7b28..0000000000--- a/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailRows.ts+++ /dev/null@@ -1,63 +0,0 @@-import { compareDateDesc } from '@core/util/date';-import type { ChannelEntity } from '@entity';-import { type Accessor, createMemo } from 'solid-js';-import type { ChannelsGroup, ChannelsTab } from '../../../types';-import { channelHasMessages, isDirectMessage } from '../../../utils';-import { type ChannelRailRow, conversationRow, sectionRow } from '../model';--export function useChannelRailRows(options: {- channels: Accessor<ChannelEntity[]>;- tab: Accessor<ChannelsTab>;- isGroupExpanded: (group: ChannelsGroup) => boolean;-}) {- const teamChannels = createMemo(() =>- options.channels().filter((channel) => !isDirectMessage(channel))- );-- const directMessages = createMemo(() =>- options.channels().filter(isDirectMessage)- );-- const recentConversations = createMemo(() =>- options- .channels()- .filter(channelHasMessages)- .sort((a, b) =>- compareDateDesc(- a.latestRootMessage?.createdAt,- b.latestRootMessage?.createdAt- )- )- );-- const visibleRows = createMemo<ChannelRailRow[]>(() => {- if (options.tab() === 'recents') {- return recentConversations().map((channel) => conversationRow(channel));- }-- const rows: ChannelRailRow[] = [sectionRow('channels')];- if (options.isGroupExpanded('channels')) {- rows.push(- ...teamChannels().map((channel) => conversationRow(channel, 'channels'))- );- }-- rows.push(sectionRow('direct_messages'));- if (options.isGroupExpanded('direct_messages')) {- rows.push(- ...directMessages().map((channel) =>- conversationRow(channel, 'direct_messages')- )- );- }-- return rows;- });-- return {- directMessages,- recentConversations,- teamChannels,- visibleRows,- };-}diff --git a/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailState.ts b/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailState.tsnew file mode 100644index 0000000000..ea90a2c9d1--- /dev/null+++ b/apps/web/src/features/channels-view/components/rail/hooks/useChannelRailState.ts@@ -0,0 +1,68 @@+import { type Accessor, createMemo } from 'solid-js';+import type { ChannelsGroup } from '../../../types';+import {+ domIdForRow,+ rowKeyForChannel,+ rowKeyForSection,+ useChannelsRail,+} from '../ChannelsRailContext';++export function useChannelRailItemState(channelId: Accessor<string>) {+ const rail = useChannelsRail();++ return createMemo(() => {+ const id = channelId();+ const rowId = rowKeyForChannel(id);++ return {+ domId: domIdForRow(rail.railId, rowId),+ selected: rail.selectedChannelId() === id,+ focused: rail.list.focus.key() === rowId,+ unread: rail.channelActivity.unreadChannelIds().has(id),+ callStatus: rail.channelActivity.callStatuses().get(id),+ incomingCallId: rail.channelActivity.incomingCallIds().get(id),+ };+ });+}++export function useChannelRailSectionState(group: Accessor<ChannelsGroup>) {+ const rail = useChannelsRail();+ const state = createMemo(() => {+ const section = group();+ const rowId = rowKeyForSection(section);+ const targetChannelId = rail.channelActivity.targetChannelId(section);++ return {+ items:+ section === 'channels' ? rail.teamChannels() : rail.directMessages(),+ open: rail.isGroupOpen(section),+ fillAvailable:+ section === 'direct_messages' && !rail.isGroupOpen('channels'),+ focused: rail.list.focus.key() === rowId,+ containsFocus: rail.list.focus.item()?.group === section,+ domId: domIdForRow(rail.railId, rowId),+ unreadCount: rail.channelActivity.unreadCount(section),+ targetId:+ targetChannelId === undefined+ ? undefined+ : domIdForRow(rail.railId, rowKeyForChannel(targetChannelId)),+ label: rail.channelActivity.targetLabel(section),+ };+ });++ const clearVisibleActivity = (visibleTargetId: string) => {+ const section = group();+ const targetChannelId = rail.channelActivity.targetChannelId(section);+ if (+ targetChannelId === undefined ||+ domIdForRow(rail.railId, rowKeyForChannel(targetChannelId)) !==+ visibleTargetId+ ) {+ return;+ }++ rail.channelActivity.clearTarget(section, targetChannelId);+ };++ return { state, clearVisibleActivity };+}diff --git a/apps/web/src/features/channels-view/components/rail/model.ts b/apps/web/src/features/channels-view/components/rail/model.tsdeleted file mode 100644index 2629e0de12..0000000000--- a/apps/web/src/features/channels-view/components/rail/model.ts+++ /dev/null@@ -1,37 +0,0 @@-import type { ChannelEntity } from '@entity';-import type { ChannelsGroup } from '../../types';--export const CHANNEL_GROUPS: ChannelsGroup[] = ['channels', 'direct_messages'];--export type ChannelRailRow =- | {- kind: 'section';- id: `section:${ChannelsGroup}`;- group: ChannelsGroup;- }- | {- kind: 'conversation';- id: `channel:${string}`;- group?: ChannelsGroup;- channel: ChannelEntity;- };--export const sectionRow = (group: ChannelsGroup): ChannelRailRow => ({- kind: 'section',- id: `section:${group}`,- group,-});--export const conversationRow = (- channel: ChannelEntity,- group?: ChannelsGroup-): ChannelRailRow => ({- kind: 'conversation',- id: `channel:${channel.id}`,- group,- channel,-});--export const rowKeyForChannel = (channelId: string) => `channel:${channelId}`;--export const rowKeyForSection = (group: ChannelsGroup) => `section:${group}`;