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(channels): open threads in a side panel (#9146)

Jacob Beckermanceafb0675dc9
diff --git a/apps/web/src/features/channel/Channel/Channel.tsx b/apps/web/src/features/channel/Channel/Channel.tsx
index 4ce4bdd879..0bbcb66beb 100644
--- a/apps/web/src/features/channel/Channel/Channel.tsx
+++ b/apps/web/src/features/channel/Channel/Channel.tsx
@@ -143,6 +143,7 @@ import {
type ThreadManagerSnapshot,
} from './thread-manager';
import { createThreadPaginator } from './thread-paginator';
+import { useChannelThreadPanel } from './thread-panel';
import { UnifiedEditInput } from './UnifiedEditInput';
import { UnifiedReplyInput } from './UnifiedReplyInput';
import { UnreadNotificationsOverlay } from './UnreadNotificationsOverlay';
@@ -418,8 +419,22 @@ export function Channel(props: ChannelProps) {
},
});
+ const threadPanel = useChannelThreadPanel();
+ // A thread stays inline while channel navigation positions one of its
+ // replies, so notification jumps keep landing on the reply itself.
+ const opensInPanel = (threadId: string) =>
+ !!threadPanel?.enabled() &&
+ !(
+ targetMessageController.activeTargetMessageId() === threadId &&
+ targetMessageController.activeTargetMessageReplyId()
+ );
+
const openReplyInput = (message: MessageData) => {
const threadId = message.thread_id ?? message.id;
+ if (opensInPanel(threadId)) {
+ threadPanel?.open(threadId, { reply: true });
+ return;
+ }
const state = threadManager.getOrCreateThreadState(threadId);
if (isUnifiedInputMode()) {
unifiedInput.bindReply(message);
@@ -437,6 +452,10 @@ export function Channel(props: ChannelProps) {
renderedText?: string
) => {
const threadId = message.thread_id ?? message.id;
+ if (opensInPanel(threadId)) {
+ threadPanel?.open(threadId, { reply: true });
+ return;
+ }
const state = threadManager.getOrCreateThreadState(threadId);
const beforeSnapshot = state.replyInputState();
const nextSnapshot: InputSnapshot = {
@@ -527,6 +546,9 @@ export function Channel(props: ChannelProps) {
cancelLatestNavigation();
if (replyId) {
clearSelection();
+ // The reply lands inline; a narrow pane hides the timeline while a
+ // thread panel is open.
+ threadPanel?.close();
prepareTargetReply(messageId);
} else {
selectMessage(messageId);
@@ -960,6 +982,19 @@ export function Channel(props: ChannelProps) {
unreadMessageIds={unread
.unreadByThread()
.get(item.id)}
+ onOpenThread={
+ opensInPanel(item.id)
+ ? (options) =>
+ threadPanel?.open(
+ item.id,
+ options
+ )
+ : undefined
+ }
+ openInPanel={
+ threadPanel?.openThreadId() ===
+ item.id
+ }
isExpanded={state.isExpanded}
setIsExpanded={
state.setIsExpanded
diff --git a/apps/web/src/features/channel/Channel/ChannelDetail.tsx b/apps/web/src/features/channel/Channel/ChannelDetail.tsx
index 229589cef6..02adf0db7b 100644
--- a/apps/web/src/features/channel/Channel/ChannelDetail.tsx
+++ b/apps/web/src/features/channel/Channel/ChannelDetail.tsx
@@ -14,6 +14,7 @@ import { ChannelCallsTab } from '@channel/Calls/ChannelCallsTab';
import { ChannelInviteButton } from '@channel/channel-invite-button';
import { ChannelTitleIcon } from '@channel/components/ChannelTopIcon';
import { DebugSuspense } from '@channel/DebugSuspense';
+import { MediaDensityContext } from '@channel/Media/media-density';
import { ChannelParticipantsTab } from '@channel/Participants/ChannelParticipantsTab';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
import { HeaderActionGroup } from '@components/app/HeaderActionGroup';
@@ -34,9 +35,11 @@ import {
useChannelName,
useChannelType,
} from '@core/context/channels';
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { TOKENS } from '@core/hotkey/tokens';
import { createMethodRegistration } from '@core/orchestrator';
import { lazyNamed } from '@core/util/lazyNamed';
-import { Tabs } from '@ui';
+import { cn, Tabs } from '@ui';
import {
type Accessor,
children,
@@ -57,6 +60,8 @@ import {
type ChannelTargetRequest,
} from './ChannelSurface';
import { ChannelTabProvider, useChannelTab } from './ChannelTabContext';
+import { ChannelThreadLayoutToggle } from './ChannelThreadLayoutToggle';
+import { ChannelThreadPanel } from './ChannelThreadPanel';
import { ChannelLiveIndicators } from './ChannelTopBarLiveIndicators';
import { withChannelTabIcons } from './channel-tab-icons';
import { type ChannelTabId, DEFAULT_CHANNEL_TAB } from './channel-tabs';
@@ -66,6 +71,10 @@ import {
toChannelTargetRequest,
URL_PARAMS,
} from './link';
+import {
+ ChannelThreadPanelContext,
+ createChannelThreadPanel,
+} from './thread-panel';
import {
canUseInlineCallTab,
normalizeChannelTab,
@@ -251,6 +260,7 @@ export function ChannelDetailTopBar(
collapser={collapse.collapser}
/>
</DebugSuspense>
+ <ChannelThreadLayoutToggle />
</PriorityCollapseOverflowSensor>
<DebugSuspense name="ChannelDetail.actions">
<ChannelDetailActions
@@ -342,6 +352,7 @@ function ChannelDetailContent(props: ChannelDetailProps) {
setActiveTabInternal(DEFAULT_CHANNEL_TAB);
});
const [pendingJoinCall, setPendingJoinCall] = createSignal(false);
+ const threadPanel = createChannelThreadPanel();
// A new target within the already-mounted channel (a notification jump)
// must land on the messages pane, whichever tab is open.
@@ -388,6 +399,22 @@ function ChannelDetailContent(props: ChannelDetailProps) {
);
onCleanup(() => callCtx?.syncCallPageTab(channelId, false));
+ registerHotkey({
+ scopeId: panel.splitHotkeyScope,
+ hotkey: 'shift+cmd+e',
+ hotkeyToken: TOKENS.channel.toggleThreadPanel,
+ description: () =>
+ threadPanel.enabled()
+ ? 'Expand threads inline'
+ : 'Collapse threads into a side panel',
+ runWithInputFocused: true,
+ condition: threadPanel.available,
+ keyDownHandler: () => {
+ threadPanel.setEnabled(!threadPanel.enabled());
+ return true;
+ },
+ });
+
const botManagement = useChannelBotManagement({
channelId,
hotkeyScopeId: panel.splitHotkeyScope,
@@ -399,71 +426,104 @@ function ChannelDetailContent(props: ChannelDetailProps) {
<DebugSuspense name="ChannelDetail.call-event-sync">
<CallEventSync />
</DebugSuspense>
- <ChannelTabProvider activeTab={activeTab} setActiveTab={setActiveTab}>
- <DebugSuspense name="ChannelDetail.auto-join">
- <ChannelCallAutoJoin
- canCall={canCall}
- channelId={channelId}
- pendingJoinCall={pendingJoinCall}
- onHandled={() => setPendingJoinCall(false)}
- />
- </DebugSuspense>
- <div class="flex size-full min-h-0 flex-col">
- <DebugSuspense name="ChannelDetail.header">
- <ChannelDetailHeader
- render={props.children}
- context={{
- channelId,
- name: () => channelName() ?? 'New Channel',
- }}
+ <ChannelThreadPanelContext.Provider value={threadPanel}>
+ <ChannelTabProvider activeTab={activeTab} setActiveTab={setActiveTab}>
+ <DebugSuspense name="ChannelDetail.auto-join">
+ <ChannelCallAutoJoin
+ canCall={canCall}
+ channelId={channelId}
+ pendingJoinCall={pendingJoinCall}
+ onHandled={() => setPendingJoinCall(false)}
/>
</DebugSuspense>
- <div
- class="flex min-h-0 flex-1 flex-col px-2"
- data-channel-tab-content
- >
- <Switch>
- <Match when={activeTab() === 'messages'}>
- <DebugSuspense
- name="ChannelDetail.messages"
- fallback={<ChannelLoading />}
- >
- <ChannelMessages autofocus={props.autofocus ?? false} />
- </DebugSuspense>
- </Match>
- <Match when={activeTab() === 'attachments'}>
- <DebugSuspense name="ChannelDetail.attachments">
- <ChannelAttachmentsTab channelId={channelId} />
- </DebugSuspense>
- </Match>
- <Match when={activeTab() === 'calls' && ENABLE_CALLS}>
- <DebugSuspense name="ChannelDetail.calls">
- <ChannelCallsTab channelId={channelId} />
- </DebugSuspense>
- </Match>
- <Match when={activeTab() === 'participants'}>
- <DebugSuspense name="ChannelDetail.participants">
- <ChannelParticipantsTab
- channelId={channelId}
- botManagementEnabled={botManagement.enabled()}
- onCreateBot={botManagement.openCreateBot}
- inviteBotFocusRequest={botManagement.inviteFocusRequest()}
- onOpenBot={botManagement.openBot}
- />
- </DebugSuspense>
- </Match>
- <Match when={activeTab() === 'call' && canUseInlineCallTab()}>
- <DebugSuspense name="ChannelDetail.call">
- <ChannelCallTab
- channelId={channelId}
- pendingJoin={pendingJoinCall}
- />
- </DebugSuspense>
- </Match>
- </Switch>
+ <div class="flex size-full min-h-0 flex-col">
+ <DebugSuspense name="ChannelDetail.header">
+ <ChannelDetailHeader
+ render={props.children}
+ context={{
+ channelId,
+ name: () => channelName() ?? 'New Channel',
+ }}
+ />
+ </DebugSuspense>
+ <div
+ class="flex min-h-0 flex-1 flex-col px-2"
+ data-channel-tab-content
+ >
+ <Switch>
+ <Match when={activeTab() === 'messages'}>
+ {/* A narrow pane gives the open thread the whole width.
+ Collapsed threads shrink message media to thumbnails. */}
+ <MediaDensityContext.Provider
+ value={() =>
+ threadPanel.enabled() ? 'compact' : 'regular'
+ }
+ >
+ <div class="@container/channel-body flex min-h-0 flex-1">
+ <div
+ class={cn(
+ 'flex min-h-0 min-w-0 flex-1 flex-col',
+ threadPanel.openThreadId() &&
+ '@max-[44rem]/channel-body:hidden'
+ )}
+ >
+ <DebugSuspense
+ name="ChannelDetail.messages"
+ fallback={<ChannelLoading />}
+ >
+ <ChannelMessages
+ autofocus={props.autofocus ?? false}
+ />
+ </DebugSuspense>
+ </div>
+ <Show when={threadPanel.openThreadId()}>
+ {(threadId) => (
+ <DebugSuspense name="ChannelDetail.thread-panel">
+ <ChannelThreadPanel
+ channelId={channelId}
+ threadId={threadId()}
+ panel={threadPanel}
+ />
+ </DebugSuspense>
+ )}
+ </Show>
+ </div>
+ </MediaDensityContext.Provider>
+ </Match>
+ <Match when={activeTab() === 'attachments'}>
+ <DebugSuspense name="ChannelDetail.attachments">
+ <ChannelAttachmentsTab channelId={channelId} />
+ </DebugSuspense>
+ </Match>
+ <Match when={activeTab() === 'calls' && ENABLE_CALLS}>
+ <DebugSuspense name="ChannelDetail.calls">
+ <ChannelCallsTab channelId={channelId} />
+ </DebugSuspense>
+ </Match>
+ <Match when={activeTab() === 'participants'}>
+ <DebugSuspense name="ChannelDetail.participants">
+ <ChannelParticipantsTab
+ channelId={channelId}
+ botManagementEnabled={botManagement.enabled()}
+ onCreateBot={botManagement.openCreateBot}
+ inviteBotFocusRequest={botManagement.inviteFocusRequest()}
+ onOpenBot={botManagement.openBot}
+ />
+ </DebugSuspense>
+ </Match>
+ <Match when={activeTab() === 'call' && canUseInlineCallTab()}>
+ <DebugSuspense name="ChannelDetail.call">
+ <ChannelCallTab
+ channelId={channelId}
+ pendingJoin={pendingJoinCall}
+ />
+ </DebugSuspense>
+ </Match>
+ </Switch>
+ </div>
</div>
- </div>
- </ChannelTabProvider>
+ </ChannelTabProvider>
+ </ChannelThreadPanelContext.Provider>
</ChannelSurface>
);
}
diff --git a/apps/web/src/features/channel/Channel/ChannelThreadLayoutToggle.tsx b/apps/web/src/features/channel/Channel/ChannelThreadLayoutToggle.tsx
new file mode 100644
index 0000000000..758b6a22c6
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/ChannelThreadLayoutToggle.tsx
@@ -0,0 +1,43 @@
+import { TOKENS } from '@core/hotkey/tokens';
+import { cn, ToggleSwitch, Tooltip } from '@ui';
+import { Show } from 'solid-js';
+import { useChannelThreadPanel } from './thread-panel';
+
+/**
+ * Chooses whether threads collapse into a side panel or expand inline. Its
+ * own pill beside the channel tabs, matching their frame. Touch devices show
+ * one pane, so they keep threads inline and never offer it.
+ */
+export function ChannelThreadLayoutToggle() {
+ const panel = useChannelThreadPanel();
+
+ return (
+ <Show when={panel?.available() ? panel : undefined}>
+ {(panel) => (
+ <Tooltip
+ label={
+ panel().enabled()
+ ? 'Expand threads inline'
+ : 'Collapse threads into a side panel'
+ }
+ hotkey={TOKENS.channel.toggleThreadPanel}
+ class="shrink-0"
+ >
+ <div class="inline-flex min-h-8 items-stretch rounded-full border border-edge-button bg-control p-0.5">
+ <ToggleSwitch
+ label={panel().enabled() ? 'Collapse' : 'Expand'}
+ checked={panel().enabled()}
+ onChange={(checked) => panel().setEnabled(checked)}
+ // A view choice, not a setting: a neutral borderless track.
+ controlClass="border-transparent bg-ink/15 data-checked:border-transparent data-checked:bg-ink/60"
+ class={cn(
+ 'shrink-0 self-stretch rounded-full border border-transparent px-2 py-0 text-sm font-medium whitespace-nowrap text-ink-muted transition-colors duration-120 select-none motion-reduce:transition-none',
+ 'not-touch:not-data-checked:hover:overlay-hover not-touch:not-data-checked:hover:text-ink data-checked:overlay-active data-checked:text-ink'
+ )}
+ />
+ </div>
+ </Tooltip>
+ )}
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/channel/Channel/ChannelThreadPanel.tsx b/apps/web/src/features/channel/Channel/ChannelThreadPanel.tsx
new file mode 100644
index 0000000000..23df8cb09a
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/ChannelThreadPanel.tsx
@@ -0,0 +1,66 @@
+import { DebugSuspense } from '@channel/DebugSuspense';
+import { useChannelName } from '@core/context/channels';
+import XIcon from '@icon/system/regular/x.svg';
+import { Button, Scroll } from '@ui';
+import { Show } from 'solid-js';
+import { EditableThread } from '../StandaloneThread';
+import type { ChannelThreadPanel as ThreadPanelState } from './thread-panel';
+
+/**
+ * Thread pane beside the channel's messages: the root message,
+ * every reply, and a reply composer that stays open.
+ */
+export function ChannelThreadPanel(props: {
+ channelId: string;
+ threadId: string;
+ panel: ThreadPanelState;
+}) {
+ const channelName = useChannelName(props.channelId);
+
+ return (
+ <aside
+ aria-label="Thread"
+ class="flex min-h-0 w-[26rem] shrink-0 flex-col border-l border-edge-muted @max-[44rem]/channel-body:w-full @max-[44rem]/channel-body:border-l-0"
+ data-channel-thread-panel
+ >
+ <div class="flex h-10 shrink-0 items-center gap-2 pr-2 pl-4">
+ <div class="flex min-w-0 flex-1 items-baseline gap-2">
+ <span class="text-sm font-semibold">Thread</span>
+ <Show when={channelName()}>
+ {(name) => (
+ <span class="ph-no-capture truncate text-xs text-ink-muted">
+ {name()}
+ </span>
+ )}
+ </Show>
+ </div>
+ <Button
+ aria-label="Close thread"
+ tooltip="Close thread"
+ variant="ghost"
+ size="icon-sm"
+ onClick={() => props.panel.close()}
+ >
+ <XIcon class="size-3.5 shrink-0 pointer-events-none" />
+ </Button>
+ </div>
+ <Scroll class="min-h-0 flex-1">
+ <div class="ph-no-capture px-2 pb-4">
+ <DebugSuspense name="ChannelThreadPanel.thread">
+ <Show when={props.threadId} keyed>
+ {(threadId) => (
+ <EditableThread
+ channelId={props.channelId}
+ messageId={threadId}
+ expanded
+ keepReplying
+ replyInputFocusRequest={props.panel.replyFocusRequest}
+ />
+ )}
+ </Show>
+ </DebugSuspense>
+ </div>
+ </Scroll>
+ </aside>
+ );
+}
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
index c7f3bef1e6..e5f96e8de5 100644
--- 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
@@ -1,5 +1,5 @@
import type { ChannelEntity } from '@entity';
-import { cleanup, render, screen } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { createSignal, type JSX } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -124,6 +124,11 @@ vi.mock('../use-channel-tab-items', () => ({
}));
import { ChannelDetailTopBar } from '../ChannelDetail';
+import {
+ type ChannelThreadPanel,
+ ChannelThreadPanelContext,
+ createChannelThreadPanel,
+} from '../thread-panel';
const CHANNEL: ChannelEntity = {
id: 'channel-1',
@@ -177,3 +182,55 @@ describe('channel top bar title menu', () => {
expect(await screen.findByLabelText('Channel actions')).toBeTruthy();
});
});
+
+describe('channel top bar thread layout toggle', () => {
+ beforeEach(() => localStorage.clear());
+
+ function renderWithThreadPanel() {
+ let panel: ChannelThreadPanel | undefined;
+ render(() => {
+ panel = createChannelThreadPanel();
+ return (
+ <ChannelThreadPanelContext.Provider value={panel}>
+ <ChannelDetailTopBar channelId="channel-1" />
+ </ChannelThreadPanelContext.Provider>
+ );
+ });
+ return panel!;
+ }
+
+ const toggle = () => screen.getByRole('switch') as HTMLInputElement;
+
+ it('is offered only by hosts with a thread panel', () => {
+ render(() => <ChannelDetailTopBar channelId="channel-1" />);
+ expect(screen.queryByRole('switch')).toBeNull();
+ });
+
+ it('collapses threads into the side panel and expands them back inline', () => {
+ const panel = renderWithThreadPanel();
+ expect(toggle().checked).toBe(false);
+ expect(screen.getByText('Expand')).toBeTruthy();
+
+ panel.open('message-1');
+ expect(panel.openThreadId()).toBeUndefined();
+
+ fireEvent.click(toggle());
+ expect(toggle().checked).toBe(true);
+ expect(screen.getByText('Collapse')).toBeTruthy();
+ panel.open('message-1');
+ expect(panel.openThreadId()).toBe('message-1');
+
+ fireEvent.click(toggle());
+ expect(toggle().checked).toBe(false);
+ expect(panel.openThreadId()).toBeUndefined();
+ });
+
+ it('remembers the choice for the next channel', () => {
+ renderWithThreadPanel();
+ fireEvent.click(toggle());
+ cleanup();
+
+ renderWithThreadPanel();
+ expect(toggle().checked).toBe(true);
+ });
+});
diff --git a/apps/web/src/features/channel/Channel/thread-panel.ts b/apps/web/src/features/channel/Channel/thread-panel.ts
new file mode 100644
index 0000000000..76739f3e27
--- /dev/null
+++ b/apps/web/src/features/channel/Channel/thread-panel.ts
@@ -0,0 +1,63 @@
+import { usePreference } from '@app/lib/preferences/use-preference';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import {
+ type Accessor,
+ createContext,
+ createSignal,
+ useContext,
+} from 'solid-js';
+import { createFocusRequest, type FocusRequest } from '../Thread/focus-request';
+
+export type ChannelThreadPanel = {
+ /** Touch devices show one pane, so threads stay inline there. */
+ available: Accessor<boolean>;
+ /** Threads open in a side panel instead of expanding inline. */
+ enabled: Accessor<boolean>;
+ setEnabled: (enabled: boolean) => void;
+ /** The root message whose thread the panel shows, while it is open. */
+ openThreadId: Accessor<string | undefined>;
+ open: (threadId: string, options?: { reply?: boolean }) => void;
+ close: () => void;
+ /** Focus the panel's reply input once it mounts. */
+ replyFocusRequest: FocusRequest;
+};
+
+const THREAD_PANEL_PREFERENCE = 'macro:pref:channel:thread-panel';
+
+/**
+ * Per-channel thread panel state. The layout choice is a user preference
+ * shared by every channel; touch devices show one pane, so they keep threads
+ * inline.
+ */
+export function createChannelThreadPanel(): ChannelThreadPanel {
+ const [preferred, setPreferred] = usePreference(THREAD_PANEL_PREFERENCE, {
+ default: false,
+ });
+ const [threadId, setThreadId] = createSignal<string>();
+ const replyFocusRequest = createFocusRequest();
+ const available = () => !isTouchDevice();
+ const enabled = () => preferred() && available();
+
+ return {
+ available,
+ enabled,
+ setEnabled: (next) => {
+ setPreferred(next);
+ if (!next) setThreadId(undefined);
+ },
+ openThreadId: () => (enabled() ? threadId() : undefined),
+ open: (id, options) => {
+ setThreadId(id);
+ if (options?.reply) replyFocusRequest.request();
+ },
+ close: () => setThreadId(undefined),
+ replyFocusRequest,
+ };
+}
+
+export const ChannelThreadPanelContext = createContext<ChannelThreadPanel>();
+
+/** The enclosing channel's thread panel, when its host offers one. */
+export function useChannelThreadPanel(): ChannelThreadPanel | undefined {
+ return useContext(ChannelThreadPanelContext);
+}
diff --git a/apps/web/src/features/channel/Media/MediaGrid.tsx b/apps/web/src/features/channel/Media/MediaGrid.tsx
index cca902591c..da1afcf4af 100644
--- a/apps/web/src/features/channel/Media/MediaGrid.tsx
+++ b/apps/web/src/features/channel/Media/MediaGrid.tsx
@@ -11,6 +11,8 @@ import type { MediaItem } from './media-items';
// Square tile size in px; keep in sync with the `size-25.5` class and THUMB_SIZE.
const ATTACHMENT_TILE_SIZE = 102;
+// Keep in sync with the `size-6.5` class.
+const COMPACT_TILE_SIZE = 26;
const SINGLE_IMAGE_MAX_WIDTH = 400;
const SINGLE_IMAGE_MAX_HEIGHT = 400;
const MESSAGE_GALLERY_IMAGE_MAX_WIDTH = 200;
@@ -64,23 +66,37 @@ function MessageImageTile(props: {
);
}
-function AttachmentImageTile(props: { item: MediaItem; onOpen?: () => void }) {
+function AttachmentImageTile(props: {
+ item: MediaItem;
+ onOpen?: () => void;
+ /** A small thumbnail beside a collapsed message. */
+ compact?: boolean;
+}) {
+ const size = () => (props.compact ? COMPACT_TILE_SIZE : ATTACHMENT_TILE_SIZE);
return (
// Root holds the fixed square; image and fallback both fill it (no reflow).
- <MediaImage.Root class="size-25.5">
+ <MediaImage.Root
+ class={props.compact ? 'size-6.5 rounded-md' : 'size-25.5'}
+ >
<MediaImage.Image
// Small thumbnail for these ~100px boxes; src is the fallback.
src={props.item.thumbSrc ?? props.item.src}
previewSrc={props.item.previewSrc}
class={cn(
'size-full select-none rounded-2xl border border-edge object-cover',
+ props.compact && 'rounded-md',
props.onOpen && 'hover:opacity-80'
)}
onOpen={props.onOpen}
- width={ATTACHMENT_TILE_SIZE}
- height={ATTACHMENT_TILE_SIZE}
+ width={size()}
+ height={size()}
loading="lazy"
- fallback={<MediaImage.Fallback fill />}
+ fallback={
+ <MediaImage.Fallback
+ fill
+ class={props.compact ? 'rounded-md' : undefined}
+ />
+ }
/>
</MediaImage.Root>
);
@@ -168,22 +184,35 @@ function MessageVideoTile(props: {
);
}
-function AttachmentVideoTile(props: { item: MediaItem; onOpen?: () => void }) {
+function AttachmentVideoTile(props: {
+ item: MediaItem;
+ onOpen?: () => void;
+ compact?: boolean;
+}) {
return (
- <MediaVideo.Root class="size-25.5 group overflow-hidden border border-edge bg-surface">
+ <MediaVideo.Root
+ class={cn(
+ 'size-25.5 group overflow-hidden border border-edge bg-surface',
+ props.compact && 'size-6.5 rounded-md'
+ )}
+ >
<MediaVideo.Preview
src={props.item.src}
class="size-full object-cover"
onOpen={props.onOpen}
/>
- <MediaVideo.PlayOverlay onOpen={props.onOpen} />
+ <MediaVideo.PlayOverlay
+ onOpen={props.onOpen}
+ class={props.compact ? '[&_svg]:size-3' : undefined}
+ />
</MediaVideo.Root>
);
}
export function MediaGrid(props: {
items: MediaItem[];
- variant: 'message' | 'attachments';
+ /** `compact` shows every item as a small thumbnail. */
+ variant: 'message' | 'attachments' | 'compact';
onOpen: (index: number) => void;
/** An item whose file failed to load (message tiles only). */
onError?: (id: string) => void;
@@ -196,9 +225,9 @@ export function MediaGrid(props: {
return (
<div
class={cn(
- props.variant === 'attachments'
- ? 'flex flex-row flex-wrap gap-1.5'
- : 'flex flex-row flex-wrap gap-2',
+ props.variant === 'message'
+ ? 'flex flex-row flex-wrap gap-2'
+ : 'flex flex-row flex-wrap gap-1.5',
props.class
)}
>
@@ -213,11 +242,10 @@ export function MediaGrid(props: {
onError={() => props.onError?.(item.id)}
/>
</Match>
- <Match
- when={item.kind === 'image' && props.variant === 'attachments'}
- >
+ <Match when={item.kind === 'image'}>
<AttachmentImageTile
item={item}
+ compact={props.variant === 'compact'}
onOpen={() => props.onOpen(index())}
/>
</Match>
@@ -231,6 +259,7 @@ export function MediaGrid(props: {
<Match when={true}>
<AttachmentVideoTile
item={item}
+ compact={props.variant === 'compact'}
onOpen={() => props.onOpen(index())}
/>
</Match>
diff --git a/apps/web/src/features/channel/Media/MediaImage.tsx b/apps/web/src/features/channel/Media/MediaImage.tsx
index 9d3209cad0..48d4b203fb 100644
--- a/apps/web/src/features/channel/Media/MediaImage.tsx
+++ b/apps/web/src/features/channel/Media/MediaImage.tsx
@@ -18,12 +18,14 @@ function ImagePlaceholder(props: {
square?: boolean;
/** Fill the parent's fixed box, so the placeholder matches the loaded image. */
fill?: boolean;
+ class?: string;
}) {
return (
<div
class={cn(
'flex items-center justify-center rounded-2xl border border-edge bg-surface',
- props.fill && 'size-full'
+ props.fill && 'size-full',
+ props.class
)}
style={
props.fill
@@ -61,12 +63,14 @@ function Fallback(props: {
dims?: { width: number; height: number };
square?: boolean;
fill?: boolean;
+ class?: string;
}) {
return (
<ImagePlaceholder
dims={props.dims}
square={props.square}
fill={props.fill}
+ class={props.class}
/>
);
}
diff --git a/apps/web/src/features/channel/Media/media-density.ts b/apps/web/src/features/channel/Media/media-density.ts
new file mode 100644
index 0000000000..01a5c49f73
--- /dev/null
+++ b/apps/web/src/features/channel/Media/media-density.ts
@@ -0,0 +1,13 @@
+import { type Accessor, createContext, useContext } from 'solid-js';
+
+/** `compact` shows message images and videos as small thumbnails. */
+export type MediaDensity = 'regular' | 'compact';
+
+const REGULAR: Accessor<MediaDensity> = () => 'regular';
+
+export const MediaDensityContext =
+ createContext<Accessor<MediaDensity>>(REGULAR);
+
+export function useMediaDensity(): Accessor<MediaDensity> {
+ return useContext(MediaDensityContext) ?? REGULAR;
+}
diff --git a/apps/web/src/features/channel/Message/MediaPreview.tsx b/apps/web/src/features/channel/Message/MediaPreview.tsx
index c91de2b74c..7e4c95800b 100644
--- a/apps/web/src/features/channel/Message/MediaPreview.tsx
+++ b/apps/web/src/features/channel/Message/MediaPreview.tsx
@@ -1,5 +1,6 @@
import { MediaGrid } from '@channel/Media/MediaGrid';
import { MediaViewerDialog } from '@channel/Media/MediaViewerDialog';
+import { useMediaDensity } from '@channel/Media/media-density';
import type { MediaItem } from '@channel/Media/media-items';
import { createSignal } from 'solid-js';
@@ -13,12 +14,13 @@ type MediaPreviewProps = {
export function MediaPreview(props: MediaPreviewProps) {
const [selectedIndex, setSelectedIndex] = createSignal(0);
const [viewerOpen, setViewerOpen] = createSignal(false);
+ const density = useMediaDensity();
return (
<>
<MediaGrid
items={props.items}
- variant="message"
+ variant={density() === 'compact' ? 'compact' : 'message'}
class={props.class}
onError={props.onError}
onOpen={(index) => {
diff --git a/apps/web/src/features/channel/StandaloneThread/EditableThread.tsx b/apps/web/src/features/channel/StandaloneThread/EditableThread.tsx
index 3c69a2d963..dc11cef258 100644
--- a/apps/web/src/features/channel/StandaloneThread/EditableThread.tsx
+++ b/apps/web/src/features/channel/StandaloneThread/EditableThread.tsx
@@ -10,6 +10,7 @@ import { createChannelMessageActions } from '../Channel/create-channel-message-a
import { createDeleteMessageConfirmation } from '../Channel/create-delete-message-confirmation';
import type { InputHandle, InputSnapshot } from '../Input';
import { Thread } from '../Thread';
+import type { FocusRequest } from '../Thread/focus-request';
import { buildReplyTargetValue } from '../Thread/utils/message-actions';
import { channelReplyInputOffsetX } from '../Thread/utils/thread-rail-geometry';
import { useStandaloneThread } from './context';
@@ -19,6 +20,9 @@ type EditableThreadProps = {
channelId: string;
messageId: string;
data?: MessageListItem;
+ expanded?: boolean;
+ keepReplying?: boolean;
+ replyInputFocusRequest?: FocusRequest;
};
function EditableThreadInner() {
@@ -110,6 +114,9 @@ export function EditableThread(props: EditableThreadProps) {
channelId={props.channelId}
messageId={props.messageId}
data={props.data}
+ expanded={props.expanded}
+ keepReplying={props.keepReplying}
+ replyInputFocusRequest={props.replyInputFocusRequest}
>
<EditableThreadInner />
</StandaloneThread.Root>
diff --git a/apps/web/src/features/channel/StandaloneThread/Root.tsx b/apps/web/src/features/channel/StandaloneThread/Root.tsx
index 0aae26d634..843c03154a 100644
--- a/apps/web/src/features/channel/StandaloneThread/Root.tsx
+++ b/apps/web/src/features/channel/StandaloneThread/Root.tsx
@@ -6,7 +6,7 @@ import type {
MessageListItem,
} from '@service-storage/messages';
import { createSignal, type ParentProps } from 'solid-js';
-import { createFocusRequest } from '../Thread/focus-request';
+import { createFocusRequest, type FocusRequest } from '../Thread/focus-request';
import { getVisibleReplyCount } from '../Thread/utils/thread-reply-indicator-helpers';
import { StandaloneThreadContext } from './context';
@@ -14,6 +14,12 @@ type RootProps = ParentProps<{
channelId: string;
messageId: string;
data?: MessageListItem;
+ /** Show every reply instead of the latest few. */
+ expanded?: boolean;
+ /** Keep the reply input open, as a thread panel does. */
+ keepReplying?: boolean;
+ /** Shared with a host that asks for the reply input's focus. */
+ replyInputFocusRequest?: FocusRequest;
}>;
export function Root(props: RootProps) {
@@ -25,9 +31,11 @@ export function Root(props: RootProps) {
}
function RootInner(props: RootProps) {
- const [isExpanded, setIsExpanded] = createSignal(false);
- const [isReplying, setIsReplying] = createSignal(false);
- const replyInputFocusRequest = createFocusRequest();
+ const [isExpanded, setIsExpanded] = createSignal(props.expanded ?? false);
+ const [replying, setIsReplying] = createSignal(false);
+ const isReplying = () => !!props.keepReplying || replying();
+ const replyInputFocusRequest =
+ props.replyInputFocusRequest ?? createFocusRequest();
const parentQuery = useMessageTimelineByIdsQuery(
() => ({ type: 'channel', id: (() => props.channelId)() }),
diff --git a/apps/web/src/features/channel/Thread/ChannelThread.tsx b/apps/web/src/features/channel/Thread/ChannelThread.tsx
index ad66800696..07cee9530d 100644
--- a/apps/web/src/features/channel/Thread/ChannelThread.tsx
+++ b/apps/web/src/features/channel/Thread/ChannelThread.tsx
@@ -52,6 +52,7 @@ export function ChannelThread(props: ThreadProps) {
});
const isSelected = () => props.selectedMessageId?.() === props.data().id;
+ const repliesInPanel = () => !!props.onOpenThread;
// The unified input's reply binding, resolved against this thread.
// `undefined` unless the binding points into this thread; otherwise it is
@@ -170,38 +171,49 @@ export function ChannelThread(props: ThreadProps) {
collapseThread: () => props.setIsExpanded(false),
isSelected,
hasReplies,
- expandThread: () => props.setIsExpanded(true),
+ expandThread: () =>
+ props.onOpenThread ? props.onOpenThread() : props.setIsExpanded(true),
isThreadExpanded: props.isExpanded,
- setIsReplying: (v) => props.setIsReplying(v),
+ setIsReplying: (v) =>
+ v && props.onOpenThread
+ ? props.onOpenThread({ reply: true })
+ : props.setIsReplying(v),
});
+ // With replies in the panel, the summary stands for every reply.
+ const inlineReplyCount = () => (repliesInPanel() ? 0 : visibleReplyCount());
const collapsedRepliesCount = () =>
- getCollapsedRepliesCount(thread().reply_count, visibleReplyCount());
+ getCollapsedRepliesCount(thread().reply_count, inlineReplyCount());
const collapsedRepliesContainsNewMessages = () =>
activeReplies()
- .slice(visibleReplyCount())
+ .slice(inlineReplyCount())
.some((reply: EntityMessage) => props.isNewMessage?.(reply));
const collapsedRepliesHaveUnreadNotifications = () =>
props.unreadMessageIds?.some(
(id) =>
id !== props.data().id &&
- !displayReplies().some((reply) => reply.id === id)
+ (repliesInPanel() || !displayReplies().some((reply) => reply.id === id))
) ?? false;
const collapsedReplyUsers = () =>
- getUniqueReplyUserIds(activeReplies().slice(visibleReplyCount()));
+ getUniqueReplyUserIds(activeReplies().slice(inlineReplyCount()));
const collapsedLatestReplyAt = () =>
getThreadLatestReplyAt(thread().latest_reply_at, activeReplies());
// Replying to this thread — inline input open, or the unified input bound.
const isReplyingToThread = () =>
props.isReplying() || unifiedReplyBinding() !== undefined;
const hasInlineReplyInput = () =>
- props.isReplying() && props.inputMode !== 'unified';
+ !repliesInPanel() && props.isReplying() && props.inputMode !== 'unified';
const rootRailVisible = () =>
!props.hideRail && (hasReplies() || hasInlineReplyInput());
const shouldShowCollapsedIndicator = () =>
- !isReplyingToThread() && !props.isExpanded() && collapsedRepliesCount() > 0;
+ repliesInPanel()
+ ? collapsedRepliesCount() > 0
+ : !isReplyingToThread() &&
+ !props.isExpanded() &&
+ collapsedRepliesCount() > 0;
const replyAction = () => props.getMessageActions?.(props.data())?.onReply;
const shouldShowReplyButton = () =>
+ !repliesInPanel() &&
hasReplies() &&
!!replyAction() &&
!isReplyingToThread() &&
@@ -345,9 +357,12 @@ export function ChannelThread(props: ThreadProps) {
onClick={selectThreadMessage}
selected={isSelected() && !isThreadFocused()}
targeted={
- // The unified input's reply is bound to this root, or
- // channel navigation landed on it.
- unifiedReplyBinding()?.boundToRoot || isRootNavTargeted()
+ // The unified input's reply is bound to this root,
+ // channel navigation landed on it, or the thread panel
+ // shows its thread.
+ unifiedReplyBinding()?.boundToRoot ||
+ isRootNavTargeted() ||
+ props.openInPanel
}
/>
</DebugSuspense>
@@ -374,32 +389,34 @@ export function ChannelThread(props: ThreadProps) {
<DebugSuspense name="ChannelThread.replies">
<Thread.RepliesContainer flat={props.monorail}>
<DebugSuspense name="ChannelThread.ReplyList">
- <Thread.ReplyList
- parent={props.parent()}
- threadId={props.data().id}
- replies={displayReplies()}
- onMessageMount={props.onMessageMount}
- getMessageActions={props.getMessageActions}
- inputMode={props.inputMode}
- messageEditor={props.messageEditor}
- isNewMessage={props.isNewMessage}
- onReady={setReplyListHandle}
- positionTarget={props.targetNavigation?.positionTarget}
- selectedReplyId={replySelection.selectedId}
- targetedReplyId={() =>
- props.targetNavigation?.activeTargetReplyId() ??
- unifiedReplyBinding()?.boundReplyId
- }
- isThreadFocused={isThreadFocused}
- onSelectReply={selectReply}
- monorail={props.monorail}
- hideRail={props.hideRail}
- railContinues={
- hasInlineReplyInput() ||
- shouldShowCollapsedIndicator() ||
- shouldShowReplyButton()
- }
- />
+ <Show when={!repliesInPanel()}>
+ <Thread.ReplyList
+ parent={props.parent()}
+ threadId={props.data().id}
+ replies={displayReplies()}
+ onMessageMount={props.onMessageMount}
+ getMessageActions={props.getMessageActions}
+ inputMode={props.inputMode}
+ messageEditor={props.messageEditor}
+ isNewMessage={props.isNewMessage}
+ onReady={setReplyListHandle}
+ positionTarget={props.targetNavigation?.positionTarget}
+ selectedReplyId={replySelection.selectedId}
+ targetedReplyId={() =>
+ props.targetNavigation?.activeTargetReplyId() ??
+ unifiedReplyBinding()?.boundReplyId
+ }
+ isThreadFocused={isThreadFocused}
+ onSelectReply={selectReply}
+ monorail={props.monorail}
+ hideRail={props.hideRail}
+ railContinues={
+ hasInlineReplyInput() ||
+ shouldShowCollapsedIndicator() ||
+ shouldShowReplyButton()
+ }
+ />
+ </Show>
</DebugSuspense>
<Show when={hasInlineReplyInput()}>
@@ -471,7 +488,15 @@ export function ChannelThread(props: ThreadProps) {
collapsedRepliesCount={collapsedRepliesCount()}
participants={collapsedReplyUsers()}
latestReplyAt={collapsedLatestReplyAt()}
- onClick={() => props.setIsExpanded(true)}
+ title={
+ repliesInPanel() ? 'Open thread' : 'Expand thread'
+ }
+ allReplies={repliesInPanel()}
+ onClick={() =>
+ props.onOpenThread
+ ? props.onOpenThread()
+ : props.setIsExpanded(true)
+ }
hasNewMessages={collapsedRepliesContainsNewMessages()}
/>
</Show>
diff --git a/apps/web/src/features/channel/Thread/ThreadCollapsedIndicator.tsx b/apps/web/src/features/channel/Thread/ThreadCollapsedIndicator.tsx
index 577dd439b8..a1f3949c2d 100644
--- a/apps/web/src/features/channel/Thread/ThreadCollapsedIndicator.tsx
+++ b/apps/web/src/features/channel/Thread/ThreadCollapsedIndicator.tsx
@@ -12,6 +12,8 @@ type ThreadCollapsedIndicatorProps =
latestReplyAt?: string;
hasNewMessages?: boolean;
hasUnreadNotifications?: boolean;
+ /** The count is every reply (the thread opens elsewhere), not a remainder. */
+ allReplies?: boolean;
};
const MAX_VISIBLE_PARTICIPANTS = 4;
@@ -24,6 +26,7 @@ export function ThreadCollapsedIndicator(props: ThreadCollapsedIndicatorProps) {
'latestReplyAt',
'hasNewMessages',
'hasUnreadNotifications',
+ 'allReplies',
]);
const visibleParticipants = () =>
local.participants.slice(0, MAX_VISIBLE_PARTICIPANTS);
@@ -76,7 +79,9 @@ export function ThreadCollapsedIndicator(props: ThreadCollapsedIndicatorProps) {
/>
</Show>
<span class="text-accent font-medium whitespace-nowrap">
- {getThreadReplyCountLabel(local.collapsedRepliesCount)}
+ {getThreadReplyCountLabel(local.collapsedRepliesCount, {
+ all: local.allReplies,
+ })}
</span>
<Show when={local.hasUnreadNotifications}>
<span class="sr-only">Unread</span>
diff --git a/apps/web/src/features/channel/Thread/tests/thread-reply-indicator-helpers.test.ts b/apps/web/src/features/channel/Thread/tests/thread-reply-indicator-helpers.test.ts
index 118cb550cc..f63f59f4eb 100644
--- a/apps/web/src/features/channel/Thread/tests/thread-reply-indicator-helpers.test.ts
+++ b/apps/web/src/features/channel/Thread/tests/thread-reply-indicator-helpers.test.ts
@@ -23,6 +23,8 @@ describe('thread-reply-indicator-helpers', () => {
it('formats collapsed reply labels', () => {
expect(getThreadReplyCountLabel(1)).toBe('1 more reply');
expect(getThreadReplyCountLabel(2)).toBe('2 more replies');
+ expect(getThreadReplyCountLabel(1, { all: true })).toBe('1 reply');
+ expect(getThreadReplyCountLabel(3, { all: true })).toBe('3 replies');
});
it('returns unique user ids in reply order', () => {
diff --git a/apps/web/src/features/channel/Thread/types.ts b/apps/web/src/features/channel/Thread/types.ts
index 7e27f464bf..360b774844 100644
--- a/apps/web/src/features/channel/Thread/types.ts
+++ b/apps/web/src/features/channel/Thread/types.ts
@@ -90,4 +90,11 @@ export type ThreadProps = {
monorail?: boolean;
/** Flat chat surfaces do not draw thread connector rails. */
hideRail?: boolean;
+ /**
+ * Replies live in the channel's thread panel: the row shows only a reply
+ * summary that opens it, and replying opens the panel's composer.
+ */
+ onOpenThread?: (options?: { reply?: boolean }) => void;
+ /** This thread is the one open in the thread panel. */
+ openInPanel?: boolean;
} & ThreadState;
diff --git a/apps/web/src/features/channel/Thread/utils/thread-reply-indicator-helpers.ts b/apps/web/src/features/channel/Thread/utils/thread-reply-indicator-helpers.ts
index 7bc426886d..00ff83c950 100644
--- a/apps/web/src/features/channel/Thread/utils/thread-reply-indicator-helpers.ts
+++ b/apps/web/src/features/channel/Thread/utils/thread-reply-indicator-helpers.ts
@@ -32,10 +32,12 @@ export function getCollapsedRepliesCount(
return Math.max(totalReplies - visibleReplies, 0);
}
+/** `all` labels a summary that stands for the whole thread, not a remainder. */
export function getThreadReplyCountLabel(
- collapsedRepliesCount: number
+ collapsedRepliesCount: number,
+ options?: { all?: boolean }
): string {
- return `${collapsedRepliesCount} more repl${
+ return `${collapsedRepliesCount}${options?.all ? '' : ' more'} repl${
collapsedRepliesCount === 1 ? 'y' : 'ies'
}`;
}
diff --git a/apps/web/src/lib/core/hotkey/tokens.ts b/apps/web/src/lib/core/hotkey/tokens.ts
index 3e7c6f4fd2..4aa82b0eda 100644
--- a/apps/web/src/lib/core/hotkey/tokens.ts
+++ b/apps/web/src/lib/core/hotkey/tokens.ts
@@ -364,6 +364,7 @@ export const TOKENS = {
threadEditReply: 'channel.threadEditReply',
threadDeleteReply: 'channel.threadDeleteReply',
findInChannel: 'channel.findInChannel',
+ toggleThreadPanel: 'channel.toggleThreadPanel',
},
// drawer
diff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.md
index 0c39fac409..986ceb1240 100644
--- a/docs/agent-guide/channels.md
+++ b/docs/agent-guide/channels.md
@@ -264,6 +264,22 @@ and reload to verify that the system entry persists in chronological order.
Also reload a short channel containing mostly system updates. Every entry should
remain visible when the entire timeline fits without scrolling.
+## Thread side panel
+
+On desktop, a switch in its own pill right of a channel's tabs chooses the
+thread layout. Its label names the current mode: **Collapse** (on) collapses
+threads into a panel on the right, **Expand** (off) expands them inline. The
+tooltip names the action and its shortcut, `Cmd/Ctrl+Shift+E`, which also
+works from the composer. The choice persists across channels and sessions.
+In collapsed mode a root shows only an `N replies` summary; clicking it,
+`Reply`, or the reply and expand hotkeys opens the panel with every reply and
+a composer that stays open, and the root stays highlighted. Message images and
+videos shrink to small thumbnails that still open the viewer. A pane narrower
+than 44rem gives the panel its full width. A notification jump to a reply
+closes the panel and expands that thread inline so it can land on the reply.
+Touch devices never offer the switch and keep threads inline. Check opening,
+replying, switching threads, closing, the shortcut, and toggling back.
+
## Agent session entities
The Agents list includes owned and shared sessions. Rows show the shared agent