MegaTask umbrella e2e scenario + batch root-subtask completion fix; comms dead-code deletion (#296)

* chore(panel): delete the five dead comms components

The comms audit found communications-view, channel-sidebar,
channel-item, message-list, and message-item exported but rendered by
no page — the live /communications page and the session detail render
their own inline content and import only MessageComposer and
MessageTypeBadge, which stay. Verified zero consumers outside the dead
cluster before deletion; panel gates green (tsc, lint, 187 tests).

* feat(tests): e2e scenario 4 — MegaTask umbrella; fix batch root-subtask completion wall

Scenario 4 seeds an umbrella + two dependency-linked root-subtasks:
sequencing hold proven (unmet_dependency on RS2's i_will_plan while RS1
lives), RS1 completed through the entire real chain to a master merge,
hold lifts, RS2 completes, umbrella closes branchless via ceo-approve
and never carries a PR.

Product fix it surfaced on first run: _main_pm_complete_guard and
escalate_to_ceo refused ANY parented task as 'not a root', but a batch
root-subtask is parented (the umbrella) BY DESIGN — both sites now
consult is_batch_root_subtask, plain subtasks stay refused. Live
root-subtasks previously needed CEO god-mode to close. Regression
tests added; built subagent-driven (Sonnet 5) and reviewed.

---------

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
Renzo F
2026-07-02 22:02:39 +02:00
committed by GitHub
co-authored by Renn F
parent d1cf6ecbf3
commit 48f2944086
14 changed files with 622 additions and 426 deletions
@@ -1,46 +0,0 @@
"use client";
import { Channel } from "@/types";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Hash, Lock } from "lucide-react";
import { cn } from "@/lib/utils";
interface ChannelItemProps {
channel: Channel;
isSelected: boolean;
onClick: () => void;
unreadCount?: number;
}
export function ChannelItem({
channel,
isSelected,
onClick,
unreadCount = 0,
}: ChannelItemProps) {
return (
<Button
onClick={onClick}
variant="ghost"
className={cn(
"w-full h-auto justify-start gap-2 px-2 py-1.5 font-normal whitespace-normal",
isSelected
? "bg-primary/10 text-primary hover:bg-primary/10 hover:text-primary"
: "text-muted-foreground hover:bg-muted hover:text-foreground",
)}
>
{channel.is_private ? (
<Lock className="h-4 w-4 shrink-0" />
) : (
<Hash className="h-4 w-4 shrink-0" />
)}
<span className="flex-1 truncate text-sm">{channel.name}</span>
{unreadCount > 0 && (
<Badge variant="destructive" className="h-5 px-1.5 text-xs">
{unreadCount}
</Badge>
)}
</Button>
);
}
@@ -1,91 +0,0 @@
"use client";
import { Channel } from "@/types";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Skeleton } from "@/components/ui/skeleton";
import { ChannelItem } from "./channel-item";
interface ChannelSidebarProps {
channels: Channel[] | undefined;
isLoading: boolean;
selectedChannelId: string | null;
onSelectChannel: (channelId: string) => void;
}
// Group channels by type
function groupChannels(channels: Channel[]): Record<string, Channel[]> {
const groups: Record<string, Channel[]> = {
"Cell Channels": [],
"Cross-Cell": [],
Management: [],
Special: [],
};
channels.forEach((channel) => {
if (channel.name.includes("-cell")) {
groups["Cell Channels"].push(channel);
} else if (channel.name.includes("-all")) {
groups["Cross-Cell"].push(channel);
} else if (channel.name.includes("pm") || channel.name.includes("board")) {
groups["Management"].push(channel);
} else {
groups["Special"].push(channel);
}
});
return groups;
}
export function ChannelSidebar({
channels,
isLoading,
selectedChannelId,
onSelectChannel,
}: ChannelSidebarProps) {
if (isLoading) {
return (
<div className="space-y-2 p-2">
{[...Array(8)].map((_, i) => (
<Skeleton key={i} className="h-8" />
))}
</div>
);
}
if (!channels || channels.length === 0) {
return (
<div className="p-4 text-center text-muted-foreground text-sm">
No channels available
</div>
);
}
const grouped = groupChannels(channels);
return (
<ScrollArea className="h-[calc(100vh-200px)]">
<div className="p-2 space-y-4">
{Object.entries(grouped).map(([group, groupChannels]) => {
if (groupChannels.length === 0) return null;
return (
<div key={group}>
<h3 className="text-xs font-medium text-muted-foreground uppercase tracking-wider px-2 mb-2">
{group}
</h3>
<div className="space-y-0.5">
{groupChannels.map((channel) => (
<ChannelItem
key={channel.id}
channel={channel}
isSelected={selectedChannelId === channel.id}
onClick={() => onSelectChannel(channel.id)}
/>
))}
</div>
</div>
);
})}
</div>
</ScrollArea>
);
}
@@ -1,146 +0,0 @@
"use client";
import { useState } from "react";
import { useChannels } from "@/hooks/use-channels";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { ChannelSidebar } from "./channel-sidebar";
import { RefreshCw, Hash, Users, ExternalLink } from "lucide-react";
import Link from "next/link";
export function CommunicationsView() {
const [selectedChannelId, setSelectedChannelId] = useState<string | null>(
null,
);
const { data: channels, isLoading: loadingChannels, refetch } = useChannels();
// Get selected channel
const selectedChannel = channels?.find((c) => c.id === selectedChannelId);
return (
<div className="space-y-6">
{/* Header */}
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold tracking-tight">Communications</h1>
<p className="text-muted-foreground">
Browse channels and view messages
</p>
</div>
<div className="flex items-center gap-2">
<Link href="/communications" prefetch={false}>
<Button variant="outline">
<ExternalLink className="h-4 w-4 mr-2" />
Full View
</Button>
</Link>
<Button variant="outline" onClick={() => refetch()}>
<RefreshCw className="h-4 w-4 mr-2" />
Refresh
</Button>
</div>
</div>
{/* Main Content */}
<div className="grid grid-cols-12 gap-6 h-[calc(100vh-220px)]">
{/* Channel Sidebar */}
<div className="col-span-12 lg:col-span-3">
<Card className="h-full">
<CardHeader className="py-3">
<CardTitle className="text-sm font-medium">Channels</CardTitle>
</CardHeader>
<CardContent className="p-0">
<ChannelSidebar
channels={channels}
isLoading={loadingChannels}
selectedChannelId={selectedChannelId}
onSelectChannel={setSelectedChannelId}
/>
</CardContent>
</Card>
</div>
{/* Channel Info Area */}
<div className="col-span-12 lg:col-span-9">
<Card className="h-full flex flex-col">
{selectedChannel ? (
<>
{/* Channel Header */}
<CardHeader className="py-3 border-b shrink-0">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<Hash className="h-5 w-5 text-muted-foreground" />
<CardTitle className="text-lg">
{selectedChannel.name}
</CardTitle>
<Badge variant="outline" className="text-xs">
<Users className="h-3 w-3 mr-1" />
{selectedChannel.member_count}
</Badge>
</div>
<Link
prefetch={false}
href={`/communications?channel=${selectedChannel.id}`}
>
<Button variant="outline" size="sm">
<ExternalLink className="h-4 w-4 mr-2" />
Open Channel
</Button>
</Link>
</div>
{selectedChannel.description && (
<p className="text-sm text-muted-foreground">
{selectedChannel.description}
</p>
)}
</CardHeader>
{/* Channel Stats */}
<CardContent className="flex-1 flex items-center justify-center">
<div className="text-center space-y-4">
<div className="grid grid-cols-2 gap-8">
<div>
<p className="text-3xl font-bold">
{selectedChannel.message_count}
</p>
<p className="text-sm text-muted-foreground">
Messages
</p>
</div>
<div>
<p className="text-3xl font-bold">
{selectedChannel.group_count}
</p>
<p className="text-sm text-muted-foreground">Groups</p>
</div>
</div>
<p className="text-sm text-muted-foreground">
Open the channel to view sessions and send messages
</p>
<Link
prefetch={false}
href={`/communications?channel=${selectedChannel.id}`}
>
<Button>View Sessions</Button>
</Link>
</div>
</CardContent>
</>
) : (
<div className="flex-1 flex items-center justify-center text-muted-foreground">
<div className="text-center">
<Hash className="h-12 w-12 mx-auto mb-4 opacity-50" />
<p className="text-lg font-medium">Select a Channel</p>
<p className="text-sm">
Choose a channel from the sidebar to view details
</p>
</div>
</div>
)}
</Card>
</div>
</div>
</div>
);
}
@@ -1,7 +1,2 @@
export { CommunicationsView } from "./communications-view";
export { ChannelSidebar } from "./channel-sidebar";
export { ChannelItem } from "./channel-item";
export { MessageList } from "./message-list";
export { MessageItem } from "./message-item";
export { MessageComposer } from "./message-composer";
export { MessageTypeBadge } from "./message-type-badge";
@@ -1,74 +0,0 @@
"use client";
import { Message } from "@/types";
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Badge } from "@/components/ui/badge";
import { Markdown } from "@/components/ui/markdown";
import { CopyButton } from "@/components/ui/copy-button";
import { MessageTypeBadge } from "./message-type-badge";
import { Clock, Link2 } from "lucide-react";
import Link from "next/link";
import { getAgentDisplayName, getAgentInitials } from "@/lib/agent-utils";
interface MessageItemProps {
message: Message;
}
function formatTime(timestamp: string): string {
const date = new Date(timestamp);
return date.toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
});
}
export function MessageItem({ message }: MessageItemProps) {
return (
<div className="group relative flex gap-3 py-3 hover:bg-muted/30 px-2 rounded-lg">
<Avatar className="h-8 w-8 shrink-0">
<AvatarFallback className="bg-primary/10 text-primary text-xs">
{getAgentInitials(message.agent_id)}
</AvatarFallback>
</Avatar>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 flex-wrap">
<span className="font-medium text-sm">
{getAgentDisplayName(message.agent_id)}
</span>
<span className="text-xs text-muted-foreground flex items-center gap-1">
<Clock className="h-3 w-3" />
{formatTime(message.timestamp)}
</span>
<MessageTypeBadge type={message.type} />
</div>
<div className="text-sm mt-1">
<Markdown>{message.content}</Markdown>
</div>
{/* Mentions */}
{message.mentions.length > 0 && (
<div className="flex items-center gap-1 mt-2">
{message.mentions.map((mention) => (
<Badge key={mention} variant="outline" className="text-xs">
@{mention.slice(0, 8)}
</Badge>
))}
</div>
)}
{/* Related Task */}
{message.task_id && (
<Link href={"/tasks/" + message.task_id} prefetch={false}>
<Badge variant="outline" className="text-xs mt-2 hover:bg-muted">
<Link2 className="h-3 w-3 mr-1" />
Task #{message.task_id.slice(0, 8)}
</Badge>
</Link>
)}
</div>
{/* Copy button — visible on hover */}
<CopyButton
value={message.content}
className="absolute right-2 top-3 opacity-0 transition-opacity group-hover:opacity-100"
/>
</div>
);
}
@@ -1,60 +0,0 @@
"use client";
import { useRef, useEffect } from "react";
import { Message } from "@/types";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Skeleton } from "@/components/ui/skeleton";
import { MessageItem } from "./message-item";
import { MessageSquare } from "lucide-react";
interface MessageListProps {
messages: Message[] | undefined;
isLoading: boolean;
}
export function MessageList({ messages, isLoading }: MessageListProps) {
const bottomRef = useRef<HTMLDivElement>(null);
// Auto-scroll to the newest message using a sentinel div + scrollIntoView
useEffect(() => {
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
}, [messages]);
if (isLoading) {
return (
<div className="space-y-4 p-4">
{[...Array(5)].map((_, i) => (
<div key={i} className="flex gap-3">
<Skeleton className="h-8 w-8 rounded-full" />
<div className="flex-1 space-y-2">
<Skeleton className="h-4 w-32" />
<Skeleton className="h-16 w-full" />
</div>
</div>
))}
</div>
);
}
if (!messages || messages.length === 0) {
return (
<div className="flex flex-col items-center justify-center h-full text-muted-foreground">
<MessageSquare className="h-12 w-12 mb-4 opacity-50" />
<p>No messages yet</p>
<p className="text-sm">Start the conversation</p>
</div>
);
}
return (
<ScrollArea className="flex-1 p-4">
<div className="space-y-1">
{messages.map((message) => (
<MessageItem key={message.id} message={message} />
))}
{/* Sentinel div — scrollIntoView targets this to keep the newest message visible */}
<div ref={bottomRef} />
</div>
</ScrollArea>
);
}