Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(channel): render the title menu from the shared channel top bar (#7749)

Peter Chinman485dc1df98cf
diff --git a/apps/web/src/features/channel/Channel/ChannelDetail.tsx b/apps/web/src/features/channel/Channel/ChannelDetail.tsx
index 7f1d2db45d..b9466eec11 100644
--- a/apps/web/src/features/channel/Channel/ChannelDetail.tsx
+++ b/apps/web/src/features/channel/Channel/ChannelDetail.tsx
@@ -34,6 +34,7 @@ import {
useChannelType,
} from '@core/context/channels';
import { createMethodRegistration } from '@core/orchestrator';
+import { lazyNamed } from '@core/util/lazyNamed';
import { useChannelParticipantsQuery } from '@queries/channel/channel-participants';
import {
type Accessor,
@@ -118,6 +119,13 @@ export function ChannelDetailTitle(props: ChannelDetailHeaderProps) {
);
}
+// Every channel host composes the top bar, so the menu's entity-action graph
+// is a chunk of its own rather than weight in each of them.
+const ChannelTitleMenu = lazyNamed(
+ () => import('./ChannelTitleMenu'),
+ 'ChannelTitleMenu'
+);
+
/**
* The channel's tab strip. Given the top bar's `collapser`, the strip
* registers as its first item to give up space, dropping text labels for
@@ -197,7 +205,8 @@ export function ChannelDetailActions(props: ChannelDetailHeaderProps) {
/**
* Channel top bar: leading content and tabs share one priority-collapse row
* so a narrow pane shrinks the tabs to icons before the title truncates.
- * `leading` replaces the default title (a host's breadcrumbs, say).
+ * `leading` replaces the default title (a host's breadcrumbs, say); the title
+ * menu, tabs, and actions are the bar's own, identical for every host.
*/
export function ChannelDetailTopBar(
props: ChannelDetailHeaderProps & { leading?: JSX.Element }
@@ -212,19 +221,24 @@ export function ChannelDetailTopBar(
class="relative h-full min-w-0 shrink overflow-hidden"
contentClass="flex h-full items-center gap-3"
>
- <DebugSuspense name="ChannelDetail.title">
- <Show
- when={props.leading}
- fallback={
- <ChannelDetailTitle
- channelId={props.channelId}
- fallbackName={props.fallbackName}
- />
- }
- >
- {props.leading}
- </Show>
- </DebugSuspense>
+ <div class="flex min-w-0 shrink items-center gap-1">
+ <DebugSuspense name="ChannelDetail.title">
+ <Show
+ when={props.leading}
+ fallback={
+ <ChannelDetailTitle
+ channelId={props.channelId}
+ fallbackName={props.fallbackName}
+ />
+ }
+ >
+ {props.leading}
+ </Show>
+ </DebugSuspense>
+ <DebugSuspense name="ChannelDetail.title-menu">
+ <ChannelTitleMenu channelId={props.channelId} />
+ </DebugSuspense>
+ </div>
<DebugSuspense name="ChannelDetail.tab-strip">
<ChannelDetailTabs
channelId={props.channelId}
diff --git a/apps/web/src/features/channel/Channel/ChannelTitleMenu.tsx b/apps/web/src/features/channel/Channel/ChannelTitleMenu.tsx
new file mode 100644
index 0000000000..3eab8e29e2
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/ChannelTitleMenu.tsx
@@ -0,0 +1,43 @@
+import { toSingleEntityActionListState } from '@app/features/next-soup/actions';
+import { withEntityNotifications } from '@app/features/soup/entity-notifications';
+import { SoupEntityActionsDropdown } from '@app/features/soup/SoupEntityActionsDropdown';
+import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
+import DotsThreeIcon from '@phosphor/dots-three.svg';
+import { Show } from 'solid-js';
+import { CHANNEL_ACTION_VIEW_CONTEXT } from './channel-actions';
+import { useChannelEntity } from './channel-entity';
+
+/**
+ * The conversation's entity actions behind the same ellipsis a document's
+ * title menu uses. The actions match the channel's row in the rail, so
+ * favoriting, muting or renaming a conversation does not depend on finding
+ * that row.
+ *
+ * Owned by the channel top bar rather than by each of its hosts: the menu
+ * resolves the conversation from its id, so a surface that opens a channel
+ * cannot forget to offer it.
+ */
+export function ChannelTitleMenu(props: { channelId: string }) {
+ const notificationSource = useGlobalNotificationSource();
+ const channel = useChannelEntity(() => props.channelId);
+ const entity = () => {
+ const resolved = channel();
+ return resolved && withEntityNotifications(resolved, notificationSource);
+ };
+ const list = toSingleEntityActionListState(entity);
+
+ return (
+ <Show when={entity()}>
+ {(current) => (
+ <SoupEntityActionsDropdown
+ entity={current()}
+ list={list}
+ viewContext={CHANNEL_ACTION_VIEW_CONTEXT}
+ triggerProps={{ size: 'icon-sm', label: 'Channel actions' }}
+ >
+ <DotsThreeIcon />
+ </SoupEntityActionsDropdown>
+ )}
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/channel/Channel/channel-actions.ts b/apps/web/src/features/channel/Channel/channel-actions.ts
new file mode 100644
index 0000000000..c9d4e970d3
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/channel-actions.ts
@@ -0,0 +1,13 @@
+import type { EntityActionViewContext } from '@app/features/next-soup/actions';
+
+/**
+ * How entity actions behave for the channel family: a conversation is never
+ * marked done and has no sender to bucket. Shared by every channel surface —
+ * the rail rows, the mobile list, and the detail header's title menu — so
+ * they offer one set of actions.
+ */
+export const CHANNEL_ACTION_VIEW_CONTEXT: EntityActionViewContext = {
+ supportsMarkDone: false,
+ supportsOpenInNewSplit: false,
+ senderBucket: undefined,
+};
diff --git a/apps/web/src/features/channel/Channel/channel-entity.test.ts b/apps/web/src/features/channel/Channel/channel-entity.test.ts
new file mode 100644
index 0000000000..9d0c7707ad
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/channel-entity.test.ts
@@ -0,0 +1,183 @@
+import type { ChannelEntity } from '@entity/types/entity';
+import type { SoupAstItemsQuery } from '@queries/soup/items';
+import { QueryClient } from '@tanstack/query-core';
+import { type Client, cacheExchange, createClient } from '@urql/core';
+import { createRoot, createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { filter, map, pipe } from 'wonka';
+
+const mocks = vi.hoisted(() => ({
+ graphql: true,
+ client: undefined as Client | undefined,
+ rest: vi.fn<typeof import('@queries/soup/items').useSoupAstItemsQuery>(),
+}));
+
+vi.mock('@app/lib/analytics/posthog', () => ({
+ useFeatureFlag: () => () => ({ enabled: mocks.graphql }),
+}));
+vi.mock('@queries/soup/items', () => ({
+ useSoupAstItemsQuery: mocks.rest,
+}));
+vi.mock('@service-storage/graphql-soup', () => ({
+ getGraphqlSoupClient: () => mocks.client,
+ mapGraphqlSoupPage: (data: { entities: ChannelEntity[] }) => ({
+ items: data.entities,
+ }),
+}));
+vi.mock('@queries/soup/transform-utils', () => ({
+ mapApiSoupItemToEntity: (entity: ChannelEntity) => entity,
+}));
+
+import { useChannelByIdQuery, useChannelEntity } from './channel-entity';
+
+const CHANNEL: ChannelEntity = {
+ id: 'channel-1',
+ type: 'channel',
+ name: 'Design',
+ ownerId: 'owner',
+ channelType: 'private',
+};
+const restResult: SoupAstItemsQuery = {
+ isPending: false,
+ isEnabled: true,
+ isLoading: false,
+ isFetching: false,
+ isPlaceholderData: false,
+ isFetchingNextPage: false,
+ isFetchNextPageError: false,
+ hasNextPage: false,
+ transport: 'rest',
+ error: null,
+ data: { entities: [CHANNEL], groups: undefined },
+ fetchNextPage: async () => {},
+ refetch: async () => {},
+ resetToInitialPage: () => {},
+ refresh: async () => {},
+};
+const disposals: (() => void)[] = [];
+const requests = vi.fn();
+
+beforeEach(() => {
+ mocks.graphql = true;
+ mocks.rest.mockReset();
+ mocks.rest.mockReturnValue(restResult);
+ requests.mockClear();
+ mocks.client = createClient({
+ url: 'https://example.test/graphql',
+ exchanges: [
+ cacheExchange,
+ () => (operations) =>
+ pipe(
+ operations,
+ filter((operation) => operation.kind === 'query'),
+ map((operation) => {
+ requests(operation);
+ return {
+ operation,
+ data: { entities: [CHANNEL] },
+ stale: false,
+ hasNext: false,
+ };
+ })
+ ),
+ ],
+ });
+});
+afterEach(() => {
+ for (const dispose of disposals.splice(0)) dispose();
+});
+
+describe('channel menu entity', () => {
+ it('reuses a completed GraphQL activation without another network request', () => {
+ createRoot((dispose) => {
+ disposals.push(dispose);
+ const opened = useChannelByIdQuery(
+ () => CHANNEL.id,
+ () => true
+ );
+ expect(opened.data?.entities).toEqual([CHANNEL]);
+ expect(requests).toHaveBeenCalledTimes(1);
+
+ const menu = useChannelEntity(() => CHANNEL.id);
+ expect(menu()).toEqual(CHANNEL);
+ expect(requests).toHaveBeenCalledTimes(1);
+
+ // Opening a conversation again must still refresh its unread edge.
+ const reopened = useChannelByIdQuery(
+ () => CHANNEL.id,
+ () => true
+ );
+ expect(reopened.data?.entities).toEqual([CHANNEL]);
+ expect(requests).toHaveBeenCalledTimes(2);
+ });
+ });
+
+ it('fetches a menu whose conversation is not cached', () => {
+ createRoot((dispose) => {
+ disposals.push(dispose);
+ const menu = useChannelEntity(() => CHANNEL.id);
+ expect(menu()).toEqual(CHANNEL);
+ expect(requests).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ it('reuses the REST cache without making activation reads stale', async () => {
+ mocks.graphql = false;
+ createRoot((dispose) => {
+ disposals.push(dispose);
+ useChannelEntity(() => CHANNEL.id);
+ useChannelByIdQuery(
+ () => CHANNEL.id,
+ () => true
+ );
+ });
+ const client = new QueryClient();
+ const queryKey = ['channel', CHANNEL.id];
+ const queryFn = vi.fn(async () => [CHANNEL]);
+ client.setQueryData(queryKey, [CHANNEL]);
+ try {
+ const [, menuOptions] = mocks.rest.mock.calls[0];
+ await client.fetchQuery({
+ queryKey,
+ queryFn,
+ staleTime: menuOptions?.().staleTime,
+ });
+ expect(queryFn).not.toHaveBeenCalled();
+
+ const [, activationOptions] = mocks.rest.mock.calls[1];
+ await client.fetchQuery({
+ queryKey,
+ queryFn,
+ staleTime: activationOptions?.().staleTime,
+ });
+ expect(queryFn).toHaveBeenCalledTimes(1);
+ } finally {
+ client.clear();
+ }
+ });
+
+ it('never offers the previous conversation while a new channel is pending', () => {
+ mocks.graphql = false;
+ const [pending, setPending] = createSignal(false);
+ mocks.rest.mockReturnValue({
+ ...restResult,
+ get isPending() {
+ return pending();
+ },
+ get data() {
+ if (pending()) throw new Error('Pending data must not be read');
+ return { entities: [CHANNEL], groups: undefined };
+ },
+ });
+ createRoot((dispose) => {
+ disposals.push(dispose);
+ const [id, setId] = createSignal(CHANNEL.id);
+ const menu = useChannelEntity(id);
+ expect(menu()).toEqual(CHANNEL);
+ setPending(true);
+ expect(menu()).toEqual(CHANNEL);
+ setId('channel-2');
+ expect(menu()).toBeUndefined();
+ });
+ });
+});
diff --git a/apps/web/src/features/channel/Channel/channel-entity.ts b/apps/web/src/features/channel/Channel/channel-entity.ts
new file mode 100644
index 0000000000..230c29ad99
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/channel-entity.ts
@@ -0,0 +1,96 @@
+import {
+ compileToAst,
+ defineQueryFilters,
+ queryStateFrom,
+} from '@app/features/next-soup/filters/filter-store';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
+import { enableGraphqlSoup } from '@core/constant/featureFlags';
+import type { ChannelEntity } from '@entity';
+import { createChannelDetailQuery } from '@queries/channel/detail';
+import { queryReadyGate } from '@queries/gate';
+import {
+ type SoupAstItemsQueryArgs,
+ useSoupAstItemsQuery,
+} from '@queries/soup/items';
+import { type Accessor, createMemo } from 'solid-js';
+
+function channelByIdQueryArgs(channelId: string): SoupAstItemsQueryArgs {
+ return {
+ params: { limit: 1, sort_method: 'created_at' },
+ body: compileToAst(
+ queryStateFrom(
+ defineQueryFilters({
+ include: { channelId: [channelId] },
+ })
+ )
+ ),
+ };
+}
+
+export function useChannelByIdQuery(
+ channelId: Accessor<string | undefined>,
+ enabled: Accessor<boolean>,
+ options: { revalidateOnMount?: boolean } = {}
+) {
+ // Every activation needs a fresh complete unread edge for marking read.
+ // Menu observers reuse that result; activation observers still revalidate.
+ const graphqlSoup = useFeatureFlag(enableGraphqlSoup);
+ const graphql = createChannelDetailQuery(
+ channelId,
+ () => enabled() && graphqlSoup().enabled,
+ options.revalidateOnMount === false ? 'cache-first' : 'cache-and-network'
+ );
+ const rest = useSoupAstItemsQuery(
+ () => ({ ...channelByIdQueryArgs(channelId() ?? ''), transport: 'rest' }),
+ () => ({
+ enabled: enabled() && !graphqlSoup().enabled,
+ staleTime: options.revalidateOnMount === false ? Infinity : 0,
+ })
+ );
+ const query = () => (graphqlSoup().enabled ? graphql : rest);
+ return {
+ get isEnabled() {
+ return query().isEnabled;
+ },
+ get isPending() {
+ return query().isPending;
+ },
+ get isLoading() {
+ return query().isLoading;
+ },
+ get isFetching() {
+ return query().isFetching;
+ },
+ get error() {
+ return query().error;
+ },
+ get data() {
+ return query().data;
+ },
+ refresh: () => query().refresh(),
+ };
+}
+
+/**
+ * The open conversation as a soup entity, for surfaces that hold a channel id
+ * and need the row behind it (its entity actions, say). Shares the by-id
+ * query with any other reader of the same channel, so a host that already
+ * resolves the conversation does not pay for a second request.
+ */
+export function useChannelEntity(
+ channelId: Accessor<string | undefined>
+): Accessor<ChannelEntity | undefined> {
+ const query = useChannelByIdQuery(channelId, () => !!channelId(), {
+ revalidateOnMount: false,
+ });
+
+ return createMemo<ChannelEntity | undefined>((previous) => {
+ const id = channelId();
+ if (!id) return undefined;
+ // A pending read suspends, and a revalidation must not blank what it feeds.
+ if (!queryReadyGate(query))
+ return previous?.id === id ? previous : undefined;
+ const entity = query.data.entities.find((entity) => entity.id === id);
+ return entity?.type === 'channel' ? entity : undefined;
+ });
+}
diff --git a/apps/web/src/features/channel/Channel/tests/channel-detail-top-bar.test.tsx b/apps/web/src/features/channel/Channel/tests/channel-detail-top-bar.test.tsx
new file mode 100644
index 0000000000..07ce729d99
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/tests/channel-detail-top-bar.test.tsx
@@ -0,0 +1,180 @@
+import type { ChannelEntity } from '@entity';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { createSignal, type JSX } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+const mocks = vi.hoisted(() => ({
+ pass: (props: { children?: JSX.Element }) => props.children,
+ channel: (): ChannelEntity | undefined => undefined,
+}));
+
+vi.mock('@app/components/view-shell', () => ({
+ ViewShell: { TopBar: mocks.pass },
+}));
+vi.mock('@app/features/chat/ChatWithAgentButton', () => ({
+ ChatWithAgentButton: () => null,
+}));
+vi.mock('@app/features/next-soup/actions', () => ({
+ toSingleEntityActionListState: () => ({}),
+}));
+vi.mock('@app/features/soup/entity-notifications', () => ({
+ withEntityNotifications: (entity: ChannelEntity) => entity,
+}));
+// The dropdown's own contents are the soup menu's concern; this test is about
+// the top bar offering it at all.
+vi.mock('@app/features/soup/SoupEntityActionsDropdown', () => ({
+ SoupEntityActionsDropdown: (props: {
+ entity: ChannelEntity;
+ triggerProps?: { label?: string };
+ }) => (
+ <button type="button" aria-label={props.triggerProps?.label}>
+ {props.entity.id}
+ </button>
+ ),
+}));
+vi.mock('@channel/Attachments/ChannelAttachmentsTab', () => ({
+ ChannelAttachmentsTab: () => null,
+}));
+vi.mock('@channel/Bots/use-channel-bot-management', () => ({
+ useChannelBotManagement: () => ({
+ enabled: () => false,
+ openCreateBot: vi.fn(),
+ openBot: vi.fn(),
+ inviteFocusRequest: () => undefined,
+ }),
+}));
+vi.mock('@channel/Call/CallContext', () => ({
+ useCallContextOptional: () => undefined,
+}));
+vi.mock('@channel/Call/CallEventSync', () => ({ CallEventSync: () => null }));
+vi.mock('@channel/Call/ChannelCallAutoJoin', () => ({
+ ChannelCallAutoJoin: () => null,
+}));
+vi.mock('@channel/Call/ChannelCallButton', () => ({
+ ChannelCallButton: () => null,
+}));
+vi.mock('@channel/Call/ChannelCallTab', () => ({ ChannelCallTab: () => null }));
+vi.mock('@channel/Call/use-call', () => ({
+ useCall: () => ({ isInThisChannel: () => false }),
+}));
+vi.mock('@channel/Calls/ChannelCallsTab', () => ({
+ ChannelCallsTab: () => null,
+}));
+vi.mock('@channel/channel-invite-button', () => ({
+ ChannelInviteButton: () => null,
+}));
+vi.mock('@channel/components/ChannelTopIcon', () => ({
+ ChannelTopIcon: () => null,
+}));
+vi.mock('@channel/Participants/ChannelParticipantsTab', () => ({
+ ChannelParticipantsTab: () => null,
+}));
+vi.mock('@components/app/GlobalAppState', () => ({
+ useGlobalBlockOrchestrator: () => ({}),
+ useGlobalNotificationSource: () => ({}),
+}));
+vi.mock(
+ '@components/app/split-layout/components/PriorityCollapseOverflowSensor',
+ () => ({
+ createPriorityCollapseController: () => ({
+ setRow: () => {},
+ collapser: undefined,
+ }),
+ PriorityCollapseOverflowSensor: mocks.pass,
+ })
+);
+vi.mock('@components/app/split-layout/layoutUtils', () => ({
+ useRegisterPriorityCollapseItem: () => () => false,
+ useSplitDisplayName: () => {},
+ useSplitPanelOrThrow: () => ({ splitHotkeyScope: 'test-scope' }),
+}));
+vi.mock('@core/component/TabsInset', () => ({ TabsInset: () => null }));
+vi.mock('@core/constant/allBlocks', () => ({
+ blocks: {},
+ resolveBlockAlias: (type: string) => type,
+}));
+vi.mock('@core/context/channels', () => ({
+ useChannel: () => () => ({ agent_dm: false }),
+ useChannelName: () => () => 'Design',
+ useChannelType: () => () => 'private',
+}));
+vi.mock('@queries/channel/channel-participants', () => ({
+ useChannelParticipantsQuery: () => ({ isSuccess: false, data: undefined }),
+}));
+vi.mock('../ChannelSurface', () => ({
+ ChannelSurface: mocks.pass,
+ ChannelMessages: () => null,
+}));
+vi.mock('../ChannelTabContext', () => ({
+ ChannelTabProvider: mocks.pass,
+ useChannelTab: () => ({
+ activeTab: () => 'messages',
+ setActiveTab: () => {},
+ }),
+}));
+vi.mock('../ChannelTopBarLiveIndicators', () => ({
+ ChannelLiveIndicators: () => null,
+}));
+vi.mock('../channel-entity', () => ({
+ useChannelEntity: () => () => mocks.channel(),
+}));
+vi.mock('../use-channel-tab-items', () => ({
+ canUseInlineCallTab: () => false,
+ normalizeChannelTab: (tab: string) => tab,
+ useChannelTabItems: () => () => [],
+}));
+
+import { ChannelDetailTopBar } from '../ChannelDetail';
+
+const CHANNEL: ChannelEntity = {
+ id: 'channel-1',
+ type: 'channel',
+ name: 'Design',
+ ownerId: 'owner',
+ channelType: 'private',
+};
+
+const [resolved, setResolved] = createSignal<ChannelEntity | undefined>();
+mocks.channel = resolved;
+
+beforeEach(() => setResolved(CHANNEL));
+afterEach(cleanup);
+
+/**
+ * Every surface that opens a conversation composes this one top bar, so the
+ * title menu must come from the bar rather than from each host. Home supplies
+ * breadcrumbs through `leading`; Chat lets the bar render its own title.
+ */
+describe('channel top bar title menu', () => {
+ it('offers the conversation actions beside its own title', async () => {
+ render(() => <ChannelDetailTopBar channelId="channel-1" />);
+
+ const actions = await screen.findByLabelText('Channel actions');
+ expect(actions.textContent).toBe('channel-1');
+ });
+
+ it('offers the same actions beside a host-supplied leading slot', async () => {
+ render(() => (
+ <ChannelDetailTopBar
+ channelId="channel-1"
+ leading={<span data-testid="breadcrumbs">Home / Design</span>}
+ />
+ ));
+
+ const actions = await screen.findByLabelText('Channel actions');
+ expect(actions.textContent).toBe('channel-1');
+ expect(actions.parentElement).toBe(
+ screen.getByTestId('breadcrumbs').parentElement
+ );
+ });
+
+ it('waits for the conversation rather than showing an empty menu', async () => {
+ setResolved(undefined);
+ render(() => <ChannelDetailTopBar channelId="channel-1" />);
+ expect(screen.queryByLabelText('Channel actions')).toBeNull();
+
+ setResolved(CHANNEL);
+
+ expect(await screen.findByLabelText('Channel actions')).toBeTruthy();
+ });
+});
diff --git a/apps/web/src/features/channels-view/channels-view.test.tsx b/apps/web/src/features/channels-view/channels-view.test.tsx
index b08922f455..905f1a0046 100644
--- a/apps/web/src/features/channels-view/channels-view.test.tsx
+++ b/apps/web/src/features/channels-view/channels-view.test.tsx
@@ -133,6 +133,9 @@ vi.mock('./components/ChannelsMobileView', () => ({
),
}));
vi.mock('./components/rail/ChannelsRail', () => ({ ChannelsRail: () => null }));
+vi.mock('@channel/Channel/channel-entity', () => ({
+ useChannelByIdQuery: mocks.selectedQuery,
+}));
vi.mock('@core/mobile/isTouchDevice', () => ({
isTouchDevice: () => mocks.mobileLayout(),
}));
@@ -169,7 +172,6 @@ vi.mock('./queries', () => ({
loaded: ChannelEntity[],
fallback: ChannelEntity[] = []
) => [...loaded, ...fallback].find((channel) => channel.id === id),
- useChannelByIdQuery: mocks.selectedQuery,
useChannelsSources: (enabled: (scope: string) => boolean) => {
mocks.sourceEnabled = enabled;
return {
diff --git a/apps/web/src/features/channels-view/channels-view.tsx b/apps/web/src/features/channels-view/channels-view.tsx
index 537c255ec6..0447fb9642 100644
--- a/apps/web/src/features/channels-view/channels-view.tsx
+++ b/apps/web/src/features/channels-view/channels-view.tsx
@@ -6,6 +6,7 @@ import { MaybeSoupEntityActionDrawerManager } from '@app/features/soup';
import { withEntityNotifications } from '@app/features/soup/entity-notifications';
import { ViewTour } from '@app/features/tours/ViewTour';
import { SplitRouter } from '@app/lib/split-router';
+import { useChannelByIdQuery } from '@channel/Channel/channel-entity';
import { DebugSuspense } from '@channel/DebugSuspense';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
@@ -31,7 +32,6 @@ import {
type ChannelsSources,
deduplicateChannels,
resolveSelectedChannel,
- useChannelByIdQuery,
useChannelsSources,
} from './queries';
import { createChannelDetailSource } from './queries/channel-detail-source';
diff --git a/apps/web/src/features/channels-view/components/ChannelDetailView.test.tsx b/apps/web/src/features/channels-view/components/ChannelDetailView.test.tsx
index afe9a75f42..cfa34e2c1b 100644
--- a/apps/web/src/features/channels-view/components/ChannelDetailView.test.tsx
+++ b/apps/web/src/features/channels-view/components/ChannelDetailView.test.tsx
@@ -28,7 +28,6 @@ vi.mock('@channel/Channel/ChannelDetail', () => ({
),
ChannelDetailTopBar: () => null,
}));
-vi.mock('./ChannelTitleMenu', () => ({ ChannelTitleMenu: () => null }));
import { ChannelDetailView } from './ChannelDetailView';
diff --git a/apps/web/src/features/channels-view/components/ChannelDetailView.tsx b/apps/web/src/features/channels-view/components/ChannelDetailView.tsx
index bdb005d5bd..abaff0c188 100644
--- a/apps/web/src/features/channels-view/components/ChannelDetailView.tsx
+++ b/apps/web/src/features/channels-view/components/ChannelDetailView.tsx
@@ -8,7 +8,6 @@ import type { ChannelTargetRequest } from '@channel/Channel/ChannelSurface';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import type { ChannelEntity } from '@entity';
import { channelsSearch } from '../channels-route';
-import { ChannelTitleMenu } from './ChannelTitleMenu';
/** Adapts a resolved conversation and navigation intent to the shared surface. */
export function ChannelDetailView(props: {
@@ -35,7 +34,6 @@ export function ChannelDetailView(props: {
<ChannelDetailTopBar
channelId={channel.channelId}
fallbackName={props.channel.name}
- leading={<ChannelTitleMenu channel={props.channel} />}
/>
)}
</ChannelDetail>
diff --git a/apps/web/src/features/channels-view/components/ChannelTitleMenu.tsx b/apps/web/src/features/channels-view/components/ChannelTitleMenu.tsx
deleted file mode 100644
index e355e1de5d..0000000000
--- a/apps/web/src/features/channels-view/components/ChannelTitleMenu.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { toSingleEntityActionListState } from '@app/features/next-soup/actions';
-import { SoupEntityActionsDropdown } from '@app/features/soup/SoupEntityActionsDropdown';
-import { ChannelDetailTitle } from '@channel/Channel/ChannelDetail';
-import type { ChannelEntity } from '@entity';
-import DotsThreeIcon from '@phosphor/dots-three.svg';
-import { CHANNEL_ACTION_VIEW_CONTEXT } from './rail/ChannelRailItems';
-
-/**
- * The conversation's title followed by its entity actions, behind the same
- * ellipsis a block's title menu uses. The actions match the channel's row in
- * the rail, so favoriting, muting or renaming a conversation does not depend
- * on finding that row.
- */
-export function ChannelTitleMenu(props: { channel: ChannelEntity }) {
- const list = toSingleEntityActionListState(() => props.channel);
-
- return (
- <div class="flex min-w-0 shrink items-center gap-1">
- <ChannelDetailTitle
- channelId={props.channel.id}
- fallbackName={props.channel.name}
- />
- <SoupEntityActionsDropdown
- entity={props.channel}
- list={list}
- viewContext={CHANNEL_ACTION_VIEW_CONTEXT}
- triggerProps={{ size: 'icon-sm', label: 'Channel actions' }}
- >
- <DotsThreeIcon />
- </SoupEntityActionsDropdown>
- </div>
- );
-}
diff --git a/apps/web/src/features/channels-view/components/ChannelsMobileView.test.tsx b/apps/web/src/features/channels-view/components/ChannelsMobileView.test.tsx
index 2445acb307..5c97604c5b 100644
--- a/apps/web/src/features/channels-view/components/ChannelsMobileView.test.tsx
+++ b/apps/web/src/features/channels-view/components/ChannelsMobileView.test.tsx
@@ -74,8 +74,10 @@ vi.mock('virtua/solid', () => ({
}) => <For each={props.data}>{props.children}</For>,
}));
vi.mock('./ChannelsEmptyState', () => ({ ChannelsEmptyState: () => null }));
-vi.mock('./rail/ChannelRailItems', () => ({
+vi.mock('@channel/Channel/channel-actions', () => ({
CHANNEL_ACTION_VIEW_CONTEXT: {},
+}));
+vi.mock('./rail/ChannelRailItems', () => ({
CONVERSATION_CARD_HEIGHT: 80,
ConversationCard: (props: {
channel: ChannelEntity;
diff --git a/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx b/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx
index 7ac25aeda4..3a28df46fd 100644
--- a/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx
+++ b/apps/web/src/features/channels-view/components/ChannelsMobileView.tsx
@@ -3,6 +3,7 @@ import { toEntityActionListState } from '@app/features/next-soup/actions';
import { openEntityInSplitFromUnifiedList } from '@app/features/next-soup/utils';
import { SoupEntityContextMenu } from '@app/features/soup';
import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';
+import { CHANNEL_ACTION_VIEW_CONTEXT } from '@channel/Channel/channel-actions';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import { PullToRefresh } from '@components/app/mobile/PullToRefresh';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
@@ -32,7 +33,6 @@ import type { ChannelsDataSource } from '../queries';
import { channelMentionsUser } from '../utils';
import { ChannelsEmptyState } from './ChannelsEmptyState';
import {
- CHANNEL_ACTION_VIEW_CONTEXT,
CONVERSATION_CARD_HEIGHT,
ConversationCard,
} from './rail/ChannelRailItems';
diff --git a/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx b/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx
index 7a023f541c..319e3f2c77 100644
--- a/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ChannelRailItems.tsx
@@ -1,10 +1,8 @@
import { dismissIncomingCallEverywhere } from '@app/features/block-call/sidebar/incoming-calls';
-import {
- type EntityActionViewContext,
- toEntityActionListState,
-} from '@app/features/next-soup/actions';
+import { toEntityActionListState } from '@app/features/next-soup/actions';
import { SoupEntityContextMenu } from '@app/features/soup/SoupEntityContextMenu';
import { joinChannelCall } from '@channel/Call/join-channel-call';
+import { CHANNEL_ACTION_VIEW_CONTEXT } from '@channel/Channel/channel-actions';
import { ChannelMutedIndicator } from '@channel/components/ChannelMutedIndicator';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { inlineWrappingMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
@@ -45,12 +43,6 @@ export type ChannelRailItemProps = {
onActivate: (event: MouseEvent) => void;
};
-export const CHANNEL_ACTION_VIEW_CONTEXT: EntityActionViewContext = {
- supportsMarkDone: false,
- supportsOpenInNewSplit: false,
- senderBucket: undefined,
-};
-
/**
* Rail rows activate on mousedown rather than click so the selection lands
* the instant the button goes down. Only the primary button counts: the
diff --git a/apps/web/src/features/channels-view/queries.test.ts b/apps/web/src/features/channels-view/queries.test.ts
index ccb310d2dd..2174c9d500 100644
--- a/apps/web/src/features/channels-view/queries.test.ts
+++ b/apps/web/src/features/channels-view/queries.test.ts
@@ -44,11 +44,8 @@ vi.mock('@entity', () => ({
}));
vi.mock('@core/context/user', () => ({ useUserId: () => () => 'user-1' }));
-import {
- resolveReferencedChannels,
- useChannelByIdQuery,
- useChannelsSources,
-} from './queries';
+import { useChannelByIdQuery } from '@channel/Channel/channel-entity';
+import { resolveReferencedChannels, useChannelsSources } from './queries';
const channelEntity = (id: string) =>
({
diff --git a/apps/web/src/features/channels-view/queries.ts b/apps/web/src/features/channels-view/queries.ts
index d1b37c9758..c8273da419 100644
--- a/apps/web/src/features/channels-view/queries.ts
+++ b/apps/web/src/features/channels-view/queries.ts
@@ -4,8 +4,6 @@ import {
defineQueryFilters,
queryStateFrom,
} from '@app/features/next-soup/filters/filter-store';
-import { useFeatureFlag } from '@app/lib/analytics/posthog';
-import { enableGraphqlSoup } from '@core/constant/featureFlags';
import { useUserId } from '@core/context/user';
import { compareDateDesc } from '@core/util/date';
import { fireAndForget } from '@core/util/fireAndForget';
@@ -15,7 +13,6 @@ import {
isChannelEntity,
isChannelThreadEntity,
} from '@entity';
-import { createChannelDetailQuery } from '@queries/channel/detail';
import {
type SoupAstItemsQueryArgs,
type SoupAstParams,
@@ -118,23 +115,6 @@ export function filterChannelsForScope(
return channels.filter(CHANNELS_QUERY_DEFINITIONS[scope].matches);
}
-export function channelByIdQueryArgs(channelId: string): SoupAstItemsQueryArgs {
- return {
- params: {
- ...CHANNELS_QUERY_PARAMS,
- limit: 1,
- sort_method: 'created_at',
- },
- body: compileToAst(
- queryStateFrom(
- defineQueryFilters({
- include: { channelId: [channelId] },
- })
- )
- ),
- };
-}
-
/**
* Fetch specific channels by id, for labelled channels the paginated Channels
* source has not reached yet. Page through the requested IDs independently
@@ -427,42 +407,3 @@ export function useChannelsSources(
),
};
}
-
-export function useChannelByIdQuery(
- channelId: Accessor<string | undefined>,
- enabled: Accessor<boolean>
-) {
- // Every activation needs a fresh complete unread edge for marking read.
- // GraphQL revalidates on activation; keep the REST fallback stale too.
- const graphqlSoup = useFeatureFlag(enableGraphqlSoup);
- const graphql = createChannelDetailQuery(
- channelId,
- () => enabled() && graphqlSoup().enabled
- );
- const rest = useSoupAstItemsQuery(
- () => ({ ...channelByIdQueryArgs(channelId() ?? ''), transport: 'rest' }),
- () => ({ enabled: enabled() && !graphqlSoup().enabled, staleTime: 0 })
- );
- const query = () => (graphqlSoup().enabled ? graphql : rest);
- return {
- get isEnabled() {
- return query().isEnabled;
- },
- get isPending() {
- return query().isPending;
- },
- get isLoading() {
- return query().isLoading;
- },
- get isFetching() {
- return query().isFetching;
- },
- get error() {
- return query().error;
- },
- get data() {
- return query().data;
- },
- refresh: () => query().refresh(),
- };
-}
diff --git a/apps/web/src/lib/queries/channel/detail.ts b/apps/web/src/lib/queries/channel/detail.ts
index e1cfa1582b..aab5adc636 100644
--- a/apps/web/src/lib/queries/channel/detail.ts
+++ b/apps/web/src/lib/queries/channel/detail.ts
@@ -3,19 +3,21 @@ import {
getGraphqlSoupClient,
mapGraphqlSoupPage,
} from '@service-storage/graphql-soup';
+import type { RequestPolicy } from '@urql/core';
import type { Accessor } from 'solid-js';
import { createLiveQuery } from '../../graphql-cache/solid/create-live-query';
import { buildGraphqlEntitySoupInput } from '../soup/graphql/entity-input';
import { mapApiSoupItemToEntity } from '../soup/transform-utils';
/**
- * A conversation and its complete unread edge, revalidated on every open. Its
- * variables match the open channel's unread navigation, so both share one
- * request.
+ * A conversation and its complete unread edge. Activation readers revalidate
+ * on every open; display-only readers can reuse the cache. Its variables match
+ * the open channel's unread navigation, so both share one request.
*/
export function createChannelDetailQuery(
channelId: Accessor<string | undefined>,
- enabled: Accessor<boolean>
+ enabled: Accessor<boolean>,
+ requestPolicy: RequestPolicy = 'cache-and-network'
) {
const query = createLiveQuery(
ChannelDetailSoupDocument,
@@ -27,7 +29,7 @@ export function createChannelDetailQuery(
() => ({
client: getGraphqlSoupClient(),
enabled: enabled(),
- requestPolicy: 'cache-and-network' as const,
+ requestPolicy,
select: (data) => ({
entities: mapGraphqlSoupPage(data).items.map(mapApiSoupItemToEntity),
}),
diff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.md
index 4b54d96361..d82cb2e968 100644
--- a/docs/agent-guide/channels.md
+++ b/docs/agent-guide/channels.md
@@ -1147,14 +1147,17 @@ In the Chat workspace — and wherever a channel opens inline inside another
view's detail stack (a channel mention followed from the email view, say) — the
conversation renders an inline detail whose top bar holds the channel avatar
and name, the same inset tab strip, live viewer avatars, and the `Call` and
-`Ask Macro` buttons. In Chat an ellipsis follows the name and opens the same
-entity actions as right-clicking the conversation's rail row — `Open in new
-split`, `Rename`, `Set channel picture`, `Remove channel picture` (only when the
-channel has one), `Favorite`/`Unfavorite`, `Remind me`, `Snooze notifications…`, `Mute
-notifications`, `Copy Link`, `Copy ID` — so a channel can be favorited or given
-a picture without finding its row. A channel inlined in
-another view's detail stack has no such menu. The split's own title `...` menu
-offers the same picture actions.
+`Ask Macro` buttons. An ellipsis follows the name — after the breadcrumb where
+the host supplies one, as in Home — and opens the same entity actions as
+right-clicking the conversation's rail row: `Rename`, `Set channel picture`,
+`Remove channel picture` (only when the channel has one),
+`Favorite`/`Unfavorite`, `Snooze notifications…`, `Mute notifications`,
+`Remind me`, `Copy Link`, `Copy ID`. A channel can therefore be favorited or
+given a picture without finding its row, from Chat and from every view that
+opens one inline. The menu appears once the conversation itself has loaded,
+reusing a cached conversation without another activation fetch. Opening the
+conversation still refreshes its unread notifications. The split's own title
+`...` menu offers the same picture actions.
`Calls` tab: recordings, transcriptions, and summaries for this channel. Click a
row to open the call. The search field above the list matches call names and