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(agents): remove the linked conversation drawer from agent sessions (#6828)
Wolf Mermelstein83518292c4af
diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsxindex ceeec0a0a4..613d671fc7 100644--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx@@ -862,11 +862,6 @@ if (LOCAL_ONLY) {'agent-changes-ui',lazy(() => import('@app/features/agent-changes/debug/Gallery')));-- registerComponent(- 'linked-conversation',- withAuth(lazy(() => import('@core/linked-conversation/debug/Demo')))- );}if (import.meta.env.DEV) {diff --git a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsxindex 9d5a1b9e57..117b84f439 100644--- a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx+++ b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx@@ -5,7 +5,6 @@ import {ResponsiveBlockToolbar,ToolButton,} from '@components/app/ResponsiveBlockToolbar';-import { useDrawerControl } from '@components/app/split-layout/components/SplitDrawerContext';import type { FileOperation } from '@components/app/split-layout/components/SplitFileMenu';import {SplitHeaderLeft,@@ -23,16 +22,11 @@ import { isMobile } from '@core/mobile/isMobile';import { openExternalUrl } from '@core/util/url';import type { AgentSessionEntity } from '@entity';import ArrowSquareOut from '@phosphor/arrow-square-out.svg';-import ChatCircleDots from '@phosphor/chat-circle-dots.svg';import GitBranch from '@phosphor/git-branch.svg';import ShareIcon from '@phosphor/share.svg';import type { AgentSessionResponse } from '@service-agent-harness/generated/schemas';import { createSignal, For, Show, Suspense } from 'solid-js';import { useAgentSession } from '../context/AgentSessionContext';-import {- ORIGIN_THREAD_DRAWER_ID,- sessionOriginThread,-} from '../context/origin-thread';import { AgentPullRequestChip } from './AgentPullRequestChip';import {harnessTitle,@@ -70,7 +64,6 @@ export function AgentSplitHeader(props: {// against a placeholder and keeps reporting it (see `Block.tsx`), so the// block id is the one thing here that is not a shareable session id.const { sessionId, metadata, userId } = useAgentSession();- const conversation = useDrawerControl(ORIGIN_THREAD_DRAWER_ID);const title = () => agentSessionTitle(props.session, props.title);const permissions = () =>userId() && props.session?.ownerId === userId()@@ -114,12 +107,6 @@ export function AgentSplitHeader(props: {];const tools: BlockTool[] = [- {- label: 'Open conversation',- icon: ChatCircleDots,- action: () => conversation.toggle(),- condition: () => sessionOriginThread(props.session) !== undefined,- },{label: () => {const provider = props.session?.external?.provider;diff --git a/apps/web/src/features/block-agent/component/Block.tsx b/apps/web/src/features/block-agent/component/Block.tsxindex 1952dae07a..16971e0a96 100644--- a/apps/web/src/features/block-agent/component/Block.tsx+++ b/apps/web/src/features/block-agent/component/Block.tsx@@ -13,7 +13,6 @@ import { useNavigatedFromJK } from '@components/app/useNavigatedFromJK';import { useBlockId } from '@core/block';import { LoadErrorPanel } from '@core/component/EntityLoadGate';import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';-import { LinkedConversationDrawer } from '@core/linked-conversation';import { nativeNetworkStatus } from '@core/mobile/native-network-status';import { createMethodRegistration } from '@core/orchestrator';import { blockHandleSignal } from '@core/signal/load';@@ -23,10 +22,6 @@ import { EmptyStatePanel } from '@ui';import { createSignal, Show, useContext } from 'solid-js';import { AgentSessionProvider } from '../agent-session-provider';import { useAgentSession } from '../context/AgentSessionContext';-import {- ORIGIN_THREAD_DRAWER_ID,- sessionOriginThread,-} from '../context/origin-thread';import { forgetPendingSession } from '../context/pending-session';import { parseAgentMessageTarget } from '../core/search-location';import { AgentComposer } from './AgentComposer';@@ -136,15 +131,6 @@ function AgentBlockContent(props: {</div></FloatRegionOrInline></AgentChangesSplit>- <Show when={sessionOriginThread(session())}>- {(origin) => (- <LinkedConversationDrawer- id={ORIGIN_THREAD_DRAWER_ID}- parent={{ type: 'channel', id: origin().channelId }}- messageId={origin().messageId}- />- )}- </Show></SidePanel.Layout></div></StaticMarkdownContext>diff --git a/apps/web/src/features/block-agent/component/session-read-hosts.test.tsx b/apps/web/src/features/block-agent/component/session-read-hosts.test.tsxindex 97c87d758c..52a598243e 100644--- a/apps/web/src/features/block-agent/component/session-read-hosts.test.tsx+++ b/apps/web/src/features/block-agent/component/session-read-hosts.test.tsx@@ -93,9 +93,6 @@ vi.mock('@core/component/TopBar/ShareButton', () => ({ShareModal: () => null,ShareTrigger: () => null,}));-vi.mock('@core/linked-conversation', () => ({- LinkedConversationDrawer: () => null,-}));vi.mock('@components/app/mobile/float-regions/FloatRegion', () => ({FloatRegionOrInline: (props: { children: JSX.Element }) => props.children,}));diff --git a/apps/web/src/features/block-agent/context/origin-thread.ts b/apps/web/src/features/block-agent/context/origin-thread.tsdeleted file mode 100644index 4b86dc46f7..0000000000--- a/apps/web/src/features/block-agent/context/origin-thread.ts+++ /dev/null@@ -1,17 +0,0 @@-import type { AgentSessionResponse } from '@service-agent-harness/generated/schemas';--/** Drawer id for the "thread this session was spawned from" drawer. */-export const ORIGIN_THREAD_DRAWER_ID = 'agent-origin-thread';--/** A channel-thread reference: the channel plus the thread's root message. */-export type OriginThreadRef = { channelId: string; messageId: string };--/** The thread this session was spawned from, when renderable. */-export function sessionOriginThread(- session: AgentSessionResponse | undefined-): OriginThreadRef | undefined {- const messageId = session?.threadId;- const channelId = session?.threadChannelId;- if (!messageId || !channelId) return undefined;- return { channelId, messageId };-}diff --git a/apps/web/src/features/channel/Thread/ThreadRail.tsx b/apps/web/src/features/channel/Thread/ThreadRail.tsxdeleted file mode 100644index 5c2c487c36..0000000000--- a/apps/web/src/features/channel/Thread/ThreadRail.tsx+++ /dev/null@@ -1,10 +0,0 @@-export function ThreadRail() {- return (- <div- class="pointer-events-none absolute top-0 bottom-0 channel-rail-left border-thread-rail -z-1"- style={{- left: 'var(--left-of-channel-rail)',- }}- />- );-}diff --git a/apps/web/src/lib/core/linked-conversation/LinkedConversation.tsx b/apps/web/src/lib/core/linked-conversation/LinkedConversation.tsxdeleted file mode 100644index d14c439c52..0000000000--- a/apps/web/src/lib/core/linked-conversation/LinkedConversation.tsx+++ /dev/null@@ -1,186 +0,0 @@-import {- type GroupableMessage,- shouldGroupWithPreviousMessage,-} from '@channel/Channel/message-grouping-meta';-import { Message } from '@channel/Message/Message';-import { Thread } from '@channel/Thread/Thread';-import { ThreadRail } from '@channel/Thread/ThreadRail';-import { ThreadReplyRail } from '@channel/Thread/ThreadReplyRail';-import {- DEFAULT_VISIBLE_REPLY_COUNT,- getCollapsedRepliesCount,- getThreadLatestReplyAt,- getUniqueReplyUserIds,-} from '@channel/Thread/utils/thread-reply-indicator-helpers';-import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';-import type { MessageData } from '@core/messages/types';-import { senderFromStorageId } from '@queries/messages/message-sender';-import { cn } from '@ui';-import { createMemo, createSignal, For, Show, Suspense } from 'solid-js';-import type { LinkedConversationSource } from './types';--type LinkedConversationProps = {- source: LinkedConversationSource;- /** Navigate-style click handler; message rows get a hover affordance when set. */- onClickMessage?: (messageId: string, e: MouseEvent) => void;- class?: string;-};--/**- * Read-only rendering of a linked conversation — a root message and its reply- * chain — from a [`LinkedConversationSource`]. Source-agnostic: back it with- * `createMessageThreadSource` for native message threads, or supply another source.- * Long reply chains collapse behind a `Thread.CollapsedIndicator` and expand- * in place.- */-export function LinkedConversation(props: LinkedConversationProps) {- const [isExpanded, setIsExpanded] = createSignal(false);-- const replies = () => props.source.replies();- const hasReplies = () => replies().length > 0;- const totalReplyCount = () => props.source.replyCount?.() ?? replies().length;-- const displayReplies = () =>- isExpanded() ? replies() : replies().slice(0, DEFAULT_VISIBLE_REPLY_COUNT);- const isGroupedById = createMemo(() => buildIsGroupedById(displayReplies()));-- const collapsedRepliesCount = () =>- getCollapsedRepliesCount(totalReplyCount());- const showCollapsedIndicator = () =>- !isExpanded() && collapsedRepliesCount() > 0;- const collapsedReplyUsers = () =>- getUniqueReplyUserIds(replies().slice(DEFAULT_VISIBLE_REPLY_COUNT));- const collapsedLatestReplyAt = () =>- getThreadLatestReplyAt(undefined, replies());-- const rowClass = () => (props.onClickMessage ? 'hover:bg-hover' : undefined);-- return (- <StaticMarkdownContext>- <Suspense>- <div class={cn('relative', props.class)}>- <Show when={hasReplies()}>- <ThreadRail />- </Show>- <Show when={props.source.root()}>- {(rootMessage) => (- <ConversationMessage- message={rootMessage()}- onClick={props.onClickMessage}- class={rowClass()}- />- )}- </Show>- <Show when={hasReplies()}>- <div class="relative w-full">- <Thread.ReplyRailDecorations />- <Thread.RepliesContainer>- <For each={displayReplies()}>- {(reply) => (- <div class="relative">- <ThreadReplyRail grouped={isGroupedById()[reply.id]} />- <ConversationMessage- message={reply}- grouped={isGroupedById()[reply.id]}- onClick={props.onClickMessage}- class={rowClass()}- />- </div>- )}- </For>- <Show when={showCollapsedIndicator()}>- <Thread.ActionsFooter>- <Thread.CollapsedIndicator- collapsedRepliesCount={collapsedRepliesCount()}- participants={collapsedReplyUsers()}- latestReplyAt={collapsedLatestReplyAt()}- onClick={() => setIsExpanded(true)}- />- </Thread.ActionsFooter>- </Show>- </Thread.RepliesContainer>- </div>- </Show>- </div>- </Suspense>- </StaticMarkdownContext>- );-}--function ConversationMessage(props: {- message: MessageData;- grouped?: boolean;- onClick?: (messageId: string, e: MouseEvent) => void;- class?: string;-}) {- return (- <Message.Root- message={props.message}- onClick={- props.onClick- ? (e: MouseEvent) => props.onClick!(props.message.id, e)- : undefined- }- class={props.class}- >- <Message.Layout- class={props.grouped ? undefined : 'pt-(--regular-message-padding-t)'}- >- <Message.Slot placement="icon">- <Message.SenderIcon hidden={props.grouped} />- </Message.Slot>- <Show when={!props.grouped}>- <Message.Slot- placement="header"- class="flex flex-col gap-0.5 min-w-0"- >- <div class="flex items-center gap-1 min-w-0">- <Message.SenderName />- <Message.AgentBadge />- <Message.EditedIndicator />- <Message.Timestamp- class="ml-auto shrink-0"- format="dateAndTime"- />- </div>- <Message.FromPill />- </Message.Slot>- </Show>- <Message.Slot placement="content">- <Message.Content />- </Message.Slot>- <Message.Slot placement="footer" class="flex flex-col min-w-0">- <Message.Attachments />- <Message.Reactions />- </Message.Slot>- </Message.Layout>- </Message.Root>- );-}--function toGroupable(message: MessageData): GroupableMessage {- return {- id: message.id,- sender_id: message.sender_id,- sender: message.sender ?? senderFromStorageId(message.sender_id),- created_at: message.created_at,- attachments: message.attachments,- deleted_at: message.deleted_at ?? null,- };-}--/**- * Grouping over `MessageData` rather than `buildThreadReplyListMeta`'s- * `EntityMessage` — linked-conversation messages may come from non-channel- * sources where `sender` is absent.- */-function buildIsGroupedById(replies: MessageData[]): Record<string, boolean> {- const grouped: Record<string, boolean> = {};- let previous: GroupableMessage | undefined;- for (const reply of replies) {- const current = toGroupable(reply);- grouped[reply.id] = shouldGroupWithPreviousMessage(current, previous);- previous = current;- }- return grouped;-}diff --git a/apps/web/src/lib/core/linked-conversation/LinkedConversationDrawer.tsx b/apps/web/src/lib/core/linked-conversation/LinkedConversationDrawer.tsxdeleted file mode 100644index a88208a5ca..0000000000--- a/apps/web/src/lib/core/linked-conversation/LinkedConversationDrawer.tsx+++ /dev/null@@ -1,125 +0,0 @@-import { navigateToChannelMessage } from '@block-channel/utils/link';-import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';-import { SplitDrawer } from '@components/app/split-layout/components/SplitDrawer';-import { useDrawerControl } from '@components/app/split-layout/components/SplitDrawerContext';-import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';-import ArrowSquareOut from '@phosphor/arrow-square-out.svg';-import { useDocumentMetadataQuery } from '@queries/storage/document-metadata';-import type { MessageParent } from '@service-storage/messages';-import { createCallback } from '@solid-primitives/rootless';-import { Button } from '@ui';-import { Show } from 'solid-js';-import { LinkedConversation } from './LinkedConversation';-import { createMessageThreadSource } from './message-thread-source';--type LinkedConversationDrawerProps = {- /**- * Drawer id, unique within the split. Toggle the drawer from anywhere in- * the same split (e.g. a toolbar `BlockTool`) with `useDrawerControl(id)`.- */- id: string;- /** Document or channel containing the linked thread. */- parent: MessageParent;- /** Root message of the linked thread — the conversation's parent id. */- messageId: string;- /** Target drawer width in px. */- size?: number;-};--/**- * A right-hand [`SplitDrawer`] rendering an originating message thread inside the current split — the "show the thread this came from"- * affordance. Fully decoupled from any block: it only needs the thread's- * parent + root message ids. Clicking a message (or the open button in the- * drawer header) navigates to the referenced thread in its parent and- * closes the drawer.- */-export function LinkedConversationDrawer(props: LinkedConversationDrawerProps) {- const orchestrator = useGlobalBlockOrchestrator();- const drawer = useDrawerControl(props.id);-- const document = useDocumentMetadataQuery(() =>- props.parent.type === 'document' ? props.parent.id : ''- );- const openInParent = createCallback((clickedMessageId?: string) => {- const target = clickedMessageId ?? props.messageId;- const isReply = target !== props.messageId;- if (props.parent.type === 'channel') {- void navigateToChannelMessage(- orchestrator,- props.parent.id,- target,- isReply ? props.messageId : undefined- );- } else if (document.isSuccess && document.data.fileType) {- openDocument(- document.data.fileType,- props.parent.id,- { comment_id: target },- true- );- } else {- return;- }- drawer.close();- });-- return (- <SplitDrawer- id={props.id}- side="right"- size={props.size ?? 420}- title={- <Button- variant="ghost"- size="icon-sm"- label="Open thread"- onClick={() => openInParent()}- >- <ArrowSquareOut />- </Button>- }- >- <DrawerConversation- parent={props.parent}- messageId={props.messageId}- onOpenMessage={openInParent}- />- </SplitDrawer>- );-}--/**- * Separate component so the thread queries mount only while the drawer is- * open — `SplitDrawer` only creates its children then.- */-function DrawerConversation(props: {- parent: MessageParent;- messageId: string;- onOpenMessage: (messageId: string) => void;-}) {- const source = createMessageThreadSource(- () => props.parent,- () => props.messageId- );-- return (- <Show- when={source.root()}- fallback={- <p class="px-2 text-sm text-ink-muted">- {source.unavailable?.()- ? 'This thread is unavailable.'- : 'Loading thread…'}- </p>- }- >- <LinkedConversation- source={source}- onClickMessage={(messageId, e) => {- e.stopPropagation();- props.onOpenMessage(messageId);- }}- />- </Show>- );-}diff --git a/apps/web/src/lib/core/linked-conversation/debug/Demo.tsx b/apps/web/src/lib/core/linked-conversation/debug/Demo.tsxdeleted file mode 100644index cb3db16b78..0000000000--- a/apps/web/src/lib/core/linked-conversation/debug/Demo.tsx+++ /dev/null@@ -1,204 +0,0 @@-/**- * Demo for `LinkedConversation`: point it at a channel or document thread by- * entering its parent + root message id (or pasting a channel link). Mounted at- * `/component/linked-conversation`.- */--import { URL_PARAMS } from '@channel/Channel/link';-import { useDrawerControl } from '@components/app/split-layout/components/SplitDrawerContext';-import type { MessageParent } from '@service-storage/messages';-import { createSignal, Show, Suspense } from 'solid-js';-import { LinkedConversation } from '../LinkedConversation';-import { LinkedConversationDrawer } from '../LinkedConversationDrawer';-import { createMessageThreadSource } from '../message-thread-source';--const DEMO_DRAWER_ID = 'linked-conversation-demo';--const STORAGE_KEY = 'linked-conversation-demo-parent-target';--type Target = { parent: MessageParent; messageId: string };--function loadSavedTarget(): Target {- try {- const raw = localStorage.getItem(STORAGE_KEY);- if (raw) return JSON.parse(raw) as Target;- } catch {- // fall through to the empty target- }- return { parent: { type: 'channel', id: '' }, messageId: '' };-}--/**- * Parses a copied channel message link- * (`/app/channel/{channelId}?channel_message_id=…&channel_thread_id=…`).- * The thread id wins as the root when present, so links copied from replies- * load the whole conversation.- */-function parseMessageLink(link: string): Target | undefined {- try {- const url = new URL(link);- const channelId = /\/app\/channel\/([^/?#]+)/.exec(url.pathname)?.[1];- const messageId =- url.searchParams.get(URL_PARAMS.thread) ??- url.searchParams.get(URL_PARAMS.message);- if (channelId && messageId)- return { parent: { type: 'channel', id: channelId }, messageId };- } catch {- // not a URL- }- return undefined;-}--export default function LinkedConversationDemo() {- const saved = loadSavedTarget();- const [parentType, setParentType] = createSignal(saved.parent.type);- const [parentIdInput, setParentIdInput] = createSignal(saved.parent.id);- const [messageIdInput, setMessageIdInput] = createSignal(saved.messageId);- const [target, setTarget] = createSignal<Target>();- const [showPreview, setShowPreview] = createSignal(false);-- const load = (event: Event) => {- event.preventDefault();- const next = {- parent: { type: parentType(), id: parentIdInput().trim() },- messageId: messageIdInput().trim(),- };- if (!next.parent.id || !next.messageId) return;- localStorage.setItem(STORAGE_KEY, JSON.stringify(next));- setTarget(next);- };-- const handleLinkPaste = (value: string) => {- const parsed = parseMessageLink(value);- if (!parsed) return;- setParentType(parsed.parent.type);- setParentIdInput(parsed.parent.id);- setMessageIdInput(parsed.messageId);- };-- const inputClass =- 'w-80 rounded border border-edge-muted bg-surface px-2 py-1 text-sm text-ink font-mono';-- return (- <div class="p-8 space-y-6 bg-surface min-h-full overflow-auto">- <div>- <h1 class="text-xl font-bold text-ink mb-2">LinkedConversation</h1>- <p class="text-sm text-ink-muted">- Read-only rendering of a conversation (root message + reply chain)- from a channel or document using{' '}- <code>createMessageThreadSource</code>.- </p>- </div>-- <form onSubmit={load} class="flex flex-col gap-3">- <label class="flex flex-col gap-1 text-xs text-ink-muted">- Paste a message link (fills the ids below)- <input- class={inputClass}- placeholder="https://macro.com/app/channel/…?channel_message_id=…"- onInput={(e) => handleLinkPaste(e.currentTarget.value)}- />- </label>- <label class="flex flex-col gap-1 text-xs text-ink-muted">- Parent type- <select- class={inputClass}- value={parentType()}- onChange={(e) =>- setParentType(e.currentTarget.value as MessageParent['type'])- }- >- <option value="channel">Channel</option>- <option value="document">Document</option>- </select>- </label>- <label class="flex flex-col gap-1 text-xs text-ink-muted">- Parent id- <input- class={inputClass}- value={parentIdInput()}- onInput={(e) => setParentIdInput(e.currentTarget.value)}- />- </label>- <label class="flex flex-col gap-1 text-xs text-ink-muted">- Message id (thread root)- <input- class={inputClass}- value={messageIdInput()}- onInput={(e) => setMessageIdInput(e.currentTarget.value)}- />- </label>- <button- type="submit"- class="w-fit rounded border border-edge-muted bg-surface px-3 py-1 text-sm text-ink hover:bg-hover"- disabled={!parentIdInput().trim() || !messageIdInput().trim()}- >- Load conversation- </button>- </form>-- <Show when={target()} keyed>- {(t) => (- <>- <DrawerToggle />- <label class="flex items-center gap-2 text-sm text-ink-muted">- <input- type="checkbox"- checked={showPreview()}- onChange={(e) => setShowPreview(e.currentTarget.checked)}- />- Show inline preview- </label>- <Show when={showPreview()}>- <div class="max-w-2xl rounded-md border border-edge-muted p-3">- <Suspense- fallback={<p class="text-sm text-ink-muted">Loading…</p>}- >- <ConversationViewer target={t} />- </Suspense>- </div>- </Show>- <LinkedConversationDrawer- id={DEMO_DRAWER_ID}- parent={t.parent}- messageId={t.messageId}- />- </>- )}- </Show>- </div>- );-}--function DrawerToggle() {- const drawer = useDrawerControl(DEMO_DRAWER_ID);- return (- <button- type="button"- class="w-fit rounded border border-edge-muted bg-surface px-3 py-1 text-sm text-ink hover:bg-hover"- onClick={drawer.toggle}- >- Open in drawer- </button>- );-}--function ConversationViewer(props: { target: Target }) {- const source = createMessageThreadSource(- () => props.target.parent,- () => props.target.messageId- );-- return (- <Show- when={source.root()}- fallback={- <p class="text-sm text-ink-muted">- No message found — check the parent and message ids.- </p>- }- >- <LinkedConversation source={source} />- </Show>- );-}diff --git a/apps/web/src/lib/core/linked-conversation/index.ts b/apps/web/src/lib/core/linked-conversation/index.tsdeleted file mode 100644index 17312a3f60..0000000000--- a/apps/web/src/lib/core/linked-conversation/index.ts+++ /dev/null@@ -1,7 +0,0 @@-export { LinkedConversation } from './LinkedConversation';-export { LinkedConversationDrawer } from './LinkedConversationDrawer';-export { createMessageThreadSource } from './message-thread-source';-export type {- LinkedConversationMessage,- LinkedConversationSource,-} from './types';diff --git a/apps/web/src/lib/core/linked-conversation/message-thread-source.test.ts b/apps/web/src/lib/core/linked-conversation/message-thread-source.test.tsdeleted file mode 100644index f623af00a8..0000000000--- a/apps/web/src/lib/core/linked-conversation/message-thread-source.test.ts+++ /dev/null@@ -1,69 +0,0 @@-import type { Message, MessageThread } from '@service-storage/messages';-import { createRoot, createSignal } from 'solid-js';-import { expect, it, vi } from 'vitest';-import { createMessageThreadSource } from './message-thread-source';--const query = vi.hoisted(() => ({ useMessageThreadQuery: vi.fn() }));-vi.mock('@queries/messages/thread-replies', () => query);-vi.mock('@core/messages/message-data', () => ({- messageToMessageData: (message: Message) => message,-}));--it('removes a deleted discussion from a linked drawer while its cached root remains', () => {- createRoot((dispose) => {- try {- const parent = { type: 'document', id: 'document' } as const;- const root: Message = {- id: 'root',- parent,- sender_id: 'user',- content: 'Discussion that will be deleted',- mentions: [],- attachments: [],- reactions: [],- created_at: '2026-09-09T00:00:00Z',- updated_at: '2026-09-09T00:00:00Z',- };- const [thread, setThread] = createSignal<MessageThread>({- root,- replies: [{ ...root, id: 'reply', thread_id: root.id }],- state: {- root_id: root.id,- user_id: root.sender_id,- resolved: false,- anchor: null,- created_at: root.created_at,- updated_at: root.updated_at,- },- });- query.useMessageThreadQuery.mockReturnValue({- isSuccess: true,- isError: false,- get data() {- return thread();- },- });- const source = createMessageThreadSource(- () => parent,- () => root.id- );- expect(source.root()?.content).toBe(root.content);- expect(source.replyCount?.()).toBe(1);- expect(source.unavailable?.()).toBe(false);-- // ThreadUpdated carries state, not replacement message bodies.- setThread((current) => ({- ...current,- state: { ...current.state, deleted_at: '2026-09-09T01:00:00Z' },- replies: [],- }));- expect(thread().root.content).toBe(root.content);- expect(source.root()).toBeUndefined();- expect(source.replies()).toEqual([]);- expect(source.replyCount?.()).toBeUndefined();- expect(source.unavailable?.()).toBe(true);- } finally {- dispose();- }- });-});diff --git a/apps/web/src/lib/core/linked-conversation/message-thread-source.ts b/apps/web/src/lib/core/linked-conversation/message-thread-source.tsdeleted file mode 100644index 078f64b9b0..0000000000--- a/apps/web/src/lib/core/linked-conversation/message-thread-source.ts+++ /dev/null@@ -1,25 +0,0 @@-import { messageToMessageData } from '@core/messages/message-data';-import { useMessageThreadQuery } from '@queries/messages/thread-replies';-import type { MessageParent } from '@service-storage/messages';-import type { Accessor } from 'solid-js';-import type { LinkedConversationSource } from './types';--/** A linked thread uses the same messages and live updates on documents and channels. */-export function createMessageThreadSource(- parent: Accessor<MessageParent>,- id: Accessor<string>-): LinkedConversationSource {- const query = useMessageThreadQuery(parent, id);- const thread = () =>- query.isSuccess && !query.data.state.deleted_at ? query.data : undefined;- return {- root: () => {- const value = thread();- return value ? messageToMessageData(value.root) : undefined;- },- replies: () => thread()?.replies.map(messageToMessageData) ?? [],- replyCount: () => thread()?.replies.length,- unavailable: () =>- query.isError || (query.isSuccess && !!query.data.state.deleted_at),- };-}diff --git a/apps/web/src/lib/core/linked-conversation/types.ts b/apps/web/src/lib/core/linked-conversation/types.tsdeleted file mode 100644index ff1894e7c2..0000000000--- a/apps/web/src/lib/core/linked-conversation/types.ts+++ /dev/null@@ -1,31 +0,0 @@-import type { MessageData } from '@core/messages/types';-import type { Accessor } from 'solid-js';--/**- * A message in a linked conversation. Structurally the channel `Message`- * primitive contract, so any plain object matching it renders — sources- * backed by other systems adapt their records into this shape (see- * `@core/comments/discussion/messageAdapter.ts` for the precedent).- */-export type LinkedConversationMessage = MessageData;--/**- * Backing data for a linked conversation, supplied per backend. The- * presentational component is agnostic to which source backs it — this is the- * seam that lets the same UI render channel threads today and other- * conversation stores later. Read-only for now: contribution actions (reply,- * react) will be added here when users can participate from the linked view.- */-export interface LinkedConversationSource {- /** Root message of the conversation, once loaded. */- root: Accessor<LinkedConversationMessage | undefined>;- /** The source is deleted or cannot be read, rather than still loading. */- unavailable?: Accessor<boolean>;- /** Replies to the root, oldest-first. May be a preview subset — see {@link replyCount}. */- replies: Accessor<LinkedConversationMessage[]>;- /**- * Total reply count when the source knows it ahead of a full load (e.g.- * channel thread metadata). Falls back to `replies().length` when omitted.- */- replyCount?: Accessor<number | undefined>;-}