From 5e28bde92786683af15f2390bab2e5ce7caa45ad Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Tue, 30 Jun 2026 07:42:04 +0100 Subject: [PATCH] Hide new task action in read-only channels --- desktop/src/features/channels/ui/ChannelPane.tsx | 8 ++++++++ desktop/src/features/messages/ui/MessageRow.tsx | 7 ++++++- desktop/src/features/messages/ui/MessageThreadPanel.tsx | 4 ++++ desktop/src/features/messages/ui/MessageTimeline.tsx | 3 +++ desktop/src/features/messages/ui/TimelineMessageList.tsx | 8 ++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/channels/ui/ChannelPane.tsx b/desktop/src/features/channels/ui/ChannelPane.tsx index 520f6e916..1153d9ee6 100644 --- a/desktop/src/features/channels/ui/ChannelPane.tsx +++ b/desktop/src/features/channels/ui/ChannelPane.tsx @@ -534,6 +534,12 @@ export const ChannelPane = React.memo(function ChannelPane({ resolveTaskAgentForMessage, ], ); + const canCreateAgentConversation = React.useMemo( + () => + enableAgentConversations && + canOpenAgentConversationInChannel({ channel: activeChannel }), + [activeChannel, enableAgentConversations], + ); React.useEffect(() => { if (!pendingAgentConversationOpen) { return; @@ -1003,6 +1009,7 @@ export const ChannelPane = React.memo(function ChannelPane({ directMessageIntro={directMessageIntro} scrollContainerRef={timelineScrollRef} currentPubkey={currentPubkey} + canCreateAgentConversation={canCreateAgentConversation} fetchOlder={fetchOlder} followThreadById={followThreadById} hasComposerOverlay={hasMainComposerOverlay} @@ -1216,6 +1223,7 @@ export const ChannelPane = React.memo(function ChannelPane({ ? handleOpenAgentConversation : undefined } + canCreateAgentConversation={canCreateAgentConversation} onSelectReplyTarget={onSelectThreadReplyTarget} onSend={handleSendThreadReply} onScrollTargetResolved={onThreadScrollTargetResolved} diff --git a/desktop/src/features/messages/ui/MessageRow.tsx b/desktop/src/features/messages/ui/MessageRow.tsx index af3c2c2e3..dfc862562 100644 --- a/desktop/src/features/messages/ui/MessageRow.tsx +++ b/desktop/src/features/messages/ui/MessageRow.tsx @@ -118,6 +118,7 @@ export const MessageRow = React.memo( function MessageRow({ channelId = null, collapseDepthGuideActions, + canCreateAgentConversation = true, connectDescendants = false, depthGuideDepths, highlighted = false, @@ -155,6 +156,7 @@ export const MessageRow = React.memo( }: { agentConversationMarkers?: readonly AgentConversationMarker[]; agentPubkeys?: ReadonlySet; + canCreateAgentConversation?: boolean; channelId?: string | null; collapseDepthGuideActions?: ReadonlyArray; connectDescendants?: boolean; @@ -471,7 +473,9 @@ export const MessageRow = React.memo( isUnread={isUnread} message={message} onContinueConversation={ - message.pending ? undefined : onOpenAgentConversation + message.pending || !canCreateAgentConversation + ? undefined + : onOpenAgentConversation } onDelete={onDelete} onEdit={onEdit} @@ -867,6 +871,7 @@ export const MessageRow = React.memo( prev.message.personaDisplayName === next.message.personaDisplayName && prev.agentConversationMarkers === next.agentConversationMarkers && prev.agentPubkeys === next.agentPubkeys && + prev.canCreateAgentConversation === next.canCreateAgentConversation && prev.collapseDepthGuideActions === next.collapseDepthGuideActions && prev.collapseDescendantsLabel === next.collapseDescendantsLabel && prev.connectDescendants === next.connectDescendants && diff --git a/desktop/src/features/messages/ui/MessageThreadPanel.tsx b/desktop/src/features/messages/ui/MessageThreadPanel.tsx index a72961501..33096039f 100644 --- a/desktop/src/features/messages/ui/MessageThreadPanel.tsx +++ b/desktop/src/features/messages/ui/MessageThreadPanel.tsx @@ -44,6 +44,7 @@ type MessageThreadPanelProps = { channelId: string | null; channelName: string; currentPubkey?: string; + canCreateAgentConversation?: boolean; disabled?: boolean; enableAgentConversationLinks?: boolean; firstUnreadReplyId?: string | null; @@ -356,6 +357,7 @@ export function MessageThreadPanel({ channelId, channelName, currentPubkey, + canCreateAgentConversation = true, disabled = false, enableAgentConversationLinks = false, firstUnreadReplyId, @@ -518,6 +520,7 @@ export function MessageThreadPanel({ isFollowingThread={isFollowingThread} isUnread={isMessageUnreadById?.(threadHead.id)} message={threadHead} + canCreateAgentConversation={canCreateAgentConversation} onDelete={ onDelete && canManageMessage(threadHead, currentPubkey) ? onDelete @@ -584,6 +587,7 @@ export function MessageThreadPanel({ huddleMemberPubkeysPending={huddleMemberPubkeysPending} isUnread={isMessageUnreadById?.(entry.message.id)} message={entry.message} + canCreateAgentConversation={canCreateAgentConversation} onDelete={ onDelete && canManageMessage(entry.message, currentPubkey) diff --git a/desktop/src/features/messages/ui/MessageTimeline.tsx b/desktop/src/features/messages/ui/MessageTimeline.tsx index 5a2901693..1f3e335b2 100644 --- a/desktop/src/features/messages/ui/MessageTimeline.tsx +++ b/desktop/src/features/messages/ui/MessageTimeline.tsx @@ -47,6 +47,7 @@ type MessageTimelineProps = { emptyTitle?: string; emptyDescription?: string; currentPubkey?: string; + canCreateAgentConversation?: boolean; fetchOlder?: () => Promise; hasOlderMessages?: boolean; /** Optional external ref to the scroll container — used by the parent to @@ -159,6 +160,7 @@ const MessageTimelineBase = React.forwardRef< emptyTitle = "No messages yet", emptyDescription = "Send the first message to start the thread.", currentPubkey, + canCreateAgentConversation = true, fetchOlder, hasComposerOverlay = true, contentTopPadding = "chrome", @@ -619,6 +621,7 @@ const MessageTimelineBase = React.forwardRef< channelName={channelName} channelType={channelType} currentPubkey={currentPubkey} + canCreateAgentConversation={canCreateAgentConversation} firstUnreadMessageId={firstUnreadMessageId} followThreadById={followThreadById} highlightedMessageId={highlightedMessageId} diff --git a/desktop/src/features/messages/ui/TimelineMessageList.tsx b/desktop/src/features/messages/ui/TimelineMessageList.tsx index 699dab149..fb766e89f 100644 --- a/desktop/src/features/messages/ui/TimelineMessageList.tsx +++ b/desktop/src/features/messages/ui/TimelineMessageList.tsx @@ -33,6 +33,7 @@ type TimelineMessageListProps = { channelName?: string; channelType?: ChannelType | null; currentPubkey?: string; + canCreateAgentConversation?: boolean; huddleMemberPubkeys?: readonly string[]; huddleMemberPubkeysPending?: boolean; /** Event id of the oldest unread top-level message; renders a "New" divider above it. */ @@ -90,6 +91,7 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({ channelName, channelType, currentPubkey, + canCreateAgentConversation = true, firstUnreadMessageId = null, followThreadById, highlightedMessageId = null, @@ -214,6 +216,7 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({ agentConversationMarker={agentConversationMarkerByMessageId.get( item.entry.message.id, )} + canCreateAgentConversation={canCreateAgentConversation} channelId={channelId} currentPubkey={currentPubkey} entry={item.entry} @@ -248,6 +251,7 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({ agentConversationMarkers, agentPubkeys, agentConversationMarkerByMessageId, + canCreateAgentConversation, channelId, currentPubkey, followThreadById, @@ -315,6 +319,7 @@ type MessageRowItemProps = Pick< TimelineMessageListProps, | "agentPubkeys" | "agentConversationMarkers" + | "canCreateAgentConversation" | "channelId" | "currentPubkey" | "followThreadById" @@ -347,6 +352,7 @@ function MessageRowItem({ agentPubkeys, agentConversationMarkers, agentConversationMarker, + canCreateAgentConversation, channelId, currentPubkey, entry, @@ -402,6 +408,7 @@ function MessageRowItem({