feat(workstate): panneau Work state encore plus compact — intention tronquée + badge indicateur, ligne summary repliée supprimée — #235 (QA verte)

This commit is contained in:
2026-08-23 15:38:41 +02:00
parent a02f3a567d
commit a3b1c845ed
2 changed files with 92 additions and 21 deletions

View File

@ -159,6 +159,28 @@ function backgroundTaskSummary(tasks: BackgroundCompletion[]): string | null {
return `${tasks.length} background task${tasks.length > 1 ? "s" : ""}`;
}
function compactIntent(text: string | null): string | null {
const normalized = text?.replace(/\s+/g, " ").trim();
if (!normalized) return null;
return normalized.length <= 44 ? normalized : `${normalized.slice(0, 41)}...`;
}
function compactIndicator({
tickets,
inboxDepth,
backgroundTasks,
}: {
tickets: AgentTicketState[];
inboxDepth: number;
backgroundTasks: BackgroundCompletion[];
}): string | null {
const queuedTickets = tickets.filter((ticket) => ticket.status === "queued").length;
if (queuedTickets > 0) return `+${queuedTickets}`;
if (inboxDepth > 0) return `${inboxDepth} inbox`;
if (backgroundTasks.length > 0) return `${backgroundTasks.length} bg`;
return null;
}
function requesterLabel(ticket: AgentTicketState): string {
if (ticket.source.kind === "human") return "Human";
const id = shortTicket(ticket.source.agentId);
@ -592,16 +614,13 @@ function AgentRow({
const currentTurn =
busy || tickets.some((ticket) => ticket.status === "inProgress");
const activeTicket = tickets.find((ticket) => ticket.status === "inProgress");
const activeSummary = activeTicket
? conversations.get(activeTicket.conversationId)
: undefined;
const statusLabel = agentStatusLabel(live, busy);
const taskSummary = backgroundTaskSummary(backgroundTasks);
const activityLine =
const activityLine = compactIntent(
activeTicket?.taskPreview ??
(busyState.state === "busy" ? `Ticket ${shortTicket(busyState.ticket)}` : null) ??
(inboxDepth > 0 ? `${inboxDepth} queued` : null) ??
taskSummary;
(busyState.state === "busy" ? `Ticket ${shortTicket(busyState.ticket)}` : null),
);
const indicator = compactIndicator({ tickets, inboxDepth, backgroundTasks });
const hasActions = Boolean(agent.live);
const hasDetails =
hasActions ||
@ -665,18 +684,26 @@ function AgentRow({
return (
<li className="py-2 first:pt-0 last:pb-0">
<div className="flex min-w-0 items-start justify-between gap-3">
<span className="min-w-0 flex-1">
<span className="block truncate text-sm font-semibold text-content">
<div className="flex min-w-0 items-center justify-between gap-2">
<span className="flex min-w-0 flex-1 items-baseline gap-2">
<span className="min-w-0 truncate text-sm font-semibold text-content">
{agent.name}
</span>
{activityLine && (
<span className="mt-0.5 block truncate text-xs text-muted">
<span
className="min-w-0 truncate text-xs text-muted"
title={activeTicket?.taskPreview ?? activityLine}
>
{activityLine}
</span>
)}
</span>
<span className="flex shrink-0 items-center gap-2">
<span className="flex shrink-0 items-center gap-1.5">
{indicator && (
<span className="rounded-full bg-raised px-1.5 py-0.5 text-[11px] font-medium text-muted">
{indicator}
</span>
)}
<span
className={cn(
"rounded-full px-2 py-0.5 text-xs font-medium",
@ -699,13 +726,6 @@ function AgentRow({
</span>
</div>
{!detailsOpen && activeSummary && (
<ConversationSummaryLine
summary={activeSummary}
onOpenConversation={onOpenConversation}
/>
)}
{detailsOpen && (
<div
id={`work-agent-details-${agent.agentId}`}