Hide new task action in read-only channels

This commit is contained in:
klopez4212
2026-06-30 13:56:41 +01:00
parent e05076f14b
commit 5e28bde927
5 changed files with 29 additions and 1 deletions
@@ -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}
@@ -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<string>;
canCreateAgentConversation?: boolean;
channelId?: string | null;
collapseDepthGuideActions?: ReadonlyArray<ThreadDepthGuideAction>;
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 &&
@@ -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)
@@ -47,6 +47,7 @@ type MessageTimelineProps = {
emptyTitle?: string;
emptyDescription?: string;
currentPubkey?: string;
canCreateAgentConversation?: boolean;
fetchOlder?: () => Promise<void>;
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}
@@ -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({
<MessageRow
agentConversationMarkers={agentConversationMarkers}
agentPubkeys={agentPubkeys}
canCreateAgentConversation={canCreateAgentConversation}
channelId={channelId}
highlighted={false}
hoverBackground={false}
@@ -464,6 +471,7 @@ function MessageRowItem({
<MessageRow
agentConversationMarkers={agentConversationMarkers}
agentPubkeys={agentPubkeys}
canCreateAgentConversation={canCreateAgentConversation}
channelId={channelId}
highlighted={message.id === highlightedMessageId || isSearchActive}
huddleMemberPubkeys={huddleMemberPubkeys}