refactor: Improve layout and organization of KanbanCard component

- Adjusted spacing and alignment in the KanbanCard component for better visual consistency.
- Refactored badge rendering logic to use a more compact layout, enhancing readability.
- Cleaned up code formatting for improved maintainability and clarity.
- Updated Card component styles to ensure consistent padding and margins.
This commit is contained in:
Test User
2025-12-20 11:57:50 -05:00
parent 532d03c231
commit c9e7e4f1e0
2 changed files with 192 additions and 165 deletions

View File

@@ -11,11 +11,12 @@ function Card({ className, gradient = false, ...props }: CardProps) {
<div <div
data-slot="card" data-slot="card"
className={cn( className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border border-white/10 backdrop-blur-md py-6", "bg-card text-card-foreground flex flex-col gap-1 rounded-xl border border-white/10 backdrop-blur-md py-6",
// Premium layered shadow // Premium layered shadow
"shadow-[0_1px_2px_rgba(0,0,0,0.05),0_4px_6px_rgba(0,0,0,0.05),0_10px_20px_rgba(0,0,0,0.04)]", "shadow-[0_1px_2px_rgba(0,0,0,0.05),0_4px_6px_rgba(0,0,0,0.05),0_10px_20px_rgba(0,0,0,0.04)]",
// Gradient border option // Gradient border option
gradient && "relative before:absolute before:inset-0 before:rounded-xl before:p-[1px] before:bg-gradient-to-br before:from-white/20 before:to-transparent before:pointer-events-none before:-z-10", gradient &&
"relative before:absolute before:inset-0 before:rounded-xl before:p-[1px] before:bg-gradient-to-br before:from-white/20 before:to-transparent before:pointer-events-none before:-z-10",
className className
)} )}
{...props} {...props}

View File

@@ -1,4 +1,3 @@
import { useState, useEffect, useMemo, memo } from "react"; import { useState, useEffect, useMemo, memo } from "react";
import { useSortable } from "@dnd-kit/sortable"; import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
@@ -150,7 +149,12 @@ export const KanbanCard = memo(function KanbanCard({
const [agentInfo, setAgentInfo] = useState<AgentTaskInfo | null>(null); const [agentInfo, setAgentInfo] = useState<AgentTaskInfo | null>(null);
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false); const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false);
const [currentTime, setCurrentTime] = useState(() => Date.now()); const [currentTime, setCurrentTime] = useState(() => Date.now());
const { kanbanCardDetailLevel, enableDependencyBlocking, features, useWorktrees } = useAppStore(); const {
kanbanCardDetailLevel,
enableDependencyBlocking,
features,
useWorktrees,
} = useAppStore();
// Calculate blocking dependencies (if feature is in backlog and has incomplete dependencies) // Calculate blocking dependencies (if feature is in backlog and has incomplete dependencies)
const blockingDependencies = useMemo(() => { const blockingDependencies = useMemo(() => {
@@ -287,9 +291,8 @@ export const KanbanCard = memo(function KanbanCard({
(borderStyle as Record<string, string>).borderColor = "transparent"; (borderStyle as Record<string, string>).borderColor = "transparent";
} else if (cardBorderOpacity !== 100) { } else if (cardBorderOpacity !== 100) {
(borderStyle as Record<string, string>).borderWidth = "1px"; (borderStyle as Record<string, string>).borderWidth = "1px";
( (borderStyle as Record<string, string>).borderColor =
borderStyle as Record<string, string> `color-mix(in oklch, var(--border) ${cardBorderOpacity}%, transparent)`;
).borderColor = `color-mix(in oklch, var(--border) ${cardBorderOpacity}%, transparent)`;
} }
const cardElement = ( const cardElement = (
@@ -336,152 +339,169 @@ export const KanbanCard = memo(function KanbanCard({
/> />
)} )}
{/* Priority badge */} {/* Compact Badge Row */}
{feature.priority && ( {(feature.error ||
<TooltipProvider delayDuration={200}> (blockingDependencies.length > 0 &&
<Tooltip> !feature.error &&
<TooltipTrigger asChild> !feature.skipTests &&
<div feature.status === "backlog") ||
className={cn( isJustFinished) && (
"absolute px-2 py-1 h-8 text-sm font-bold rounded-md flex items-center justify-center z-10", <div className="flex flex-wrap items-center gap-1.5 px-3 pt-1.5 min-h-[24px]">
"top-2 left-2 min-w-[36px]", {/* Error badge */}
feature.priority === 1 && {feature.error && (
"bg-red-500/20 text-red-500 border-2 border-red-500/50", <TooltipProvider delayDuration={200}>
feature.priority === 2 && <Tooltip>
"bg-yellow-500/20 text-yellow-500 border-2 border-yellow-500/50", <TooltipTrigger asChild>
feature.priority === 3 && <div
"bg-blue-500/20 text-blue-500 border-2 border-blue-500/50" className={cn(
)} "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",
data-testid={`priority-badge-${feature.id}`} "bg-[var(--status-error-bg)] border-[var(--status-error)]/40 text-[var(--status-error)]"
> )}
{feature.priority === 1 ? "H" : feature.priority === 2 ? "M" : "L"} data-testid={`error-badge-${feature.id}`}
</div> >
</TooltipTrigger> <AlertCircle className="w-3 h-3" />
<TooltipContent side="right" className="text-xs"> </div>
<p> </TooltipTrigger>
{feature.priority === 1 <TooltipContent side="bottom" className="text-xs max-w-[250px]">
? "High Priority" <p>{feature.error}</p>
: feature.priority === 2 </TooltipContent>
? "Medium Priority" </Tooltip>
: "Low Priority"} </TooltipProvider>
</p> )}
</TooltipContent>
</Tooltip> {/* Blocked badge */}
</TooltipProvider> {blockingDependencies.length > 0 &&
)} !feature.error &&
!feature.skipTests &&
{/* Category text next to priority badge */} feature.status === "backlog" && (
{feature.priority && ( <TooltipProvider delayDuration={200}>
<div className="absolute top-2 left-[54px] right-12 z-10 flex items-center h-[32px]"> <Tooltip>
<span className="text-[11px] text-muted-foreground/70 font-medium truncate"> <TooltipTrigger asChild>
{feature.category} <div
</span> className={cn(
</div> "inline-flex items-center gap-1 rounded-full border-2 px-1.5 py-0.5 text-[10px] font-bold",
)} "bg-orange-500/20 border-orange-500/50 text-orange-500"
)}
{/* Skip Tests (Manual) indicator badge - positioned at top right */} data-testid={`blocked-badge-${feature.id}`}
{feature.skipTests && !feature.error && feature.status === "backlog" && ( >
<TooltipProvider delayDuration={200}> <Lock className="w-3 h-3" />
<Tooltip> </div>
<TooltipTrigger asChild> </TooltipTrigger>
<div <TooltipContent
className={cn( side="bottom"
"absolute px-2 py-1 h-8 text-sm font-bold rounded-md flex items-center justify-center z-10", className="text-xs max-w-[250px]"
"min-w-[36px]", >
"top-2 right-2", <p className="font-medium mb-1">
"bg-[var(--status-warning-bg)] border-2 border-[var(--status-warning)]/50 text-[var(--status-warning)]" Blocked by {blockingDependencies.length} incomplete{" "}
)} {blockingDependencies.length === 1
data-testid={`skip-tests-badge-${feature.id}`} ? "dependency"
> : "dependencies"}
<Hand className="w-4 h-4" /> </p>
</div> <p className="text-muted-foreground">
</TooltipTrigger> {blockingDependencies
<TooltipContent side="left" className="text-xs"> .map((depId) => {
<p>Manual verification required</p> const dep = features.find((f) => f.id === depId);
</TooltipContent> return dep?.description || depId;
</Tooltip> })
</TooltipProvider> .join(", ")}
)} </p>
</TooltipContent>
{/* Error indicator badge */} </Tooltip>
{feature.error && ( </TooltipProvider>
<TooltipProvider delayDuration={200}> )}
<Tooltip>
<TooltipTrigger asChild> {/* Just Finished badge */}
<div {isJustFinished && (
className={cn( <div
"absolute px-2 py-1 text-[11px] font-medium rounded-md flex items-center justify-center z-10", className={cn(
"min-w-[36px]", "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",
feature.priority ? "top-11 left-2" : "top-2 left-2", "bg-[var(--status-success-bg)] border-[var(--status-success)]/40 text-[var(--status-success)]",
"bg-[var(--status-error-bg)] border border-[var(--status-error)]/40 text-[var(--status-error)]" "animate-pulse"
)} )}
data-testid={`error-badge-${feature.id}`} data-testid={`just-finished-badge-${feature.id}`}
> title="Agent just finished working on this feature"
<AlertCircle className="w-3.5 h-3.5" /> >
</div> <Sparkles className="w-3 h-3" />
</TooltipTrigger> </div>
<TooltipContent side="right" className="text-xs max-w-[250px]">
<p>{feature.error}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{/* Blocked by dependencies badge - positioned at top right */}
{blockingDependencies.length > 0 && !feature.error && !feature.skipTests && feature.status === "backlog" && (
<TooltipProvider delayDuration={200}>
<Tooltip>
<TooltipTrigger asChild>
<div
className={cn(
"absolute px-2 py-1 h-8 text-sm font-bold rounded-md flex items-center justify-center z-10",
"min-w-[36px]",
"top-2 right-2",
"bg-orange-500/20 border-2 border-orange-500/50 text-orange-500"
)}
data-testid={`blocked-badge-${feature.id}`}
>
<Lock className="w-4 h-4" />
</div>
</TooltipTrigger>
<TooltipContent side="left" className="text-xs max-w-[250px]">
<p className="font-medium mb-1">Blocked by {blockingDependencies.length} incomplete {blockingDependencies.length === 1 ? 'dependency' : 'dependencies'}</p>
<p className="text-muted-foreground">
{blockingDependencies.map(depId => {
const dep = features.find(f => f.id === depId);
return dep?.description || depId;
}).join(', ')}
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{/* Just Finished indicator badge */}
{isJustFinished && (
<div
className={cn(
"absolute px-1.5 py-0.5 text-[10px] font-medium rounded-md flex items-center gap-1 z-10",
feature.priority ? "top-11 left-2" : "top-2 left-2",
"bg-[var(--status-success-bg)] border border-[var(--status-success)]/40 text-[var(--status-success)]",
"animate-pulse"
)} )}
data-testid={`just-finished-badge-${feature.id}`}
title="Agent just finished working on this feature"
>
<Sparkles className="w-3 h-3" />
</div> </div>
)} )}
<CardHeader {/* Category row */}
className={cn( <div className="px-3 pt-4">
"p-3 pb-2 block", <span className="text-[11px] text-muted-foreground/70 font-medium">
feature.priority && "pt-12", {feature.category}
!feature.priority && </span>
(feature.skipTests || feature.error || isJustFinished) && </div>
"pt-10"
<CardHeader className="p-3 pb-2 block">
{/* Priority and Manual Verification badges - top left, aligned with delete button */}
{(feature.priority ||
(feature.skipTests &&
!feature.error &&
feature.status === "backlog")) && (
<div className="absolute top-2 left-2 flex items-center gap-1.5">
{/* Priority badge */}
{feature.priority && (
<TooltipProvider delayDuration={200}>
<Tooltip>
<TooltipTrigger asChild>
<div
className={cn(
"inline-flex items-center justify-center gap-1 rounded-full border-2 px-1.5 py-0.5 text-[10px] font-bold",
feature.priority === 1 &&
"bg-red-500/20 text-red-500 border-red-500/50",
feature.priority === 2 &&
"bg-yellow-500/20 text-yellow-500 border-yellow-500/50",
feature.priority === 3 &&
"bg-blue-500/20 text-blue-500 border-blue-500/50"
)}
data-testid={`priority-badge-${feature.id}`}
>
{feature.priority === 1
? "H"
: feature.priority === 2
? "M"
: "L"}
</div>
</TooltipTrigger>
<TooltipContent side="bottom" className="text-xs">
<p>
{feature.priority === 1
? "High Priority"
: feature.priority === 2
? "Medium Priority"
: "Low Priority"}
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{/* Manual verification badge */}
{feature.skipTests &&
!feature.error &&
feature.status === "backlog" && (
<TooltipProvider delayDuration={200}>
<Tooltip>
<TooltipTrigger asChild>
<div
className={cn(
"inline-flex items-center gap-1 rounded-full border-2 px-1.5 py-0.5 text-[10px] font-bold",
"bg-[var(--status-warning-bg)] border-[var(--status-warning)]/50 text-[var(--status-warning)]"
)}
data-testid={`skip-tests-badge-${feature.id}`}
>
<Hand className="w-3 h-3" />
</div>
</TooltipTrigger>
<TooltipContent side="bottom" className="text-xs">
<p>Manual verification required</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
</div>
)} )}
>
{isCurrentAutoTask && ( {isCurrentAutoTask && (
<div className="absolute top-2 right-2 flex items-center gap-1"> <div className="absolute top-2 right-2 flex items-center gap-1">
<div className="flex items-center justify-center gap-2 bg-[var(--status-in-progress)]/15 border border-[var(--status-in-progress)]/50 rounded-md px-2 py-0.5"> <div className="flex items-center justify-center gap-2 bg-[var(--status-in-progress)]/15 border border-[var(--status-in-progress)]/50 rounded-md px-2 py-0.5">
@@ -522,7 +542,9 @@ export const KanbanCard = memo(function KanbanCard({
<div className="px-2 py-1.5 text-[10px] text-muted-foreground border-t mt-1 pt-1.5"> <div className="px-2 py-1.5 text-[10px] text-muted-foreground border-t mt-1 pt-1.5">
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<Cpu className="w-3 h-3" /> <Cpu className="w-3 h-3" />
<span>{formatModelName(feature.model ?? DEFAULT_MODEL)}</span> <span>
{formatModelName(feature.model ?? DEFAULT_MODEL)}
</span>
</div> </div>
</div> </div>
</DropdownMenuContent> </DropdownMenuContent>
@@ -561,7 +583,9 @@ export const KanbanCard = memo(function KanbanCard({
}} }}
onPointerDown={(e) => e.stopPropagation()} onPointerDown={(e) => e.stopPropagation()}
data-testid={`edit-${ data-testid={`edit-${
feature.status === "waiting_approval" ? "waiting" : "verified" feature.status === "waiting_approval"
? "waiting"
: "verified"
}-${feature.id}`} }-${feature.id}`}
title="Edit" title="Edit"
> >
@@ -597,7 +621,9 @@ export const KanbanCard = memo(function KanbanCard({
}} }}
onPointerDown={(e) => e.stopPropagation()} onPointerDown={(e) => e.stopPropagation()}
data-testid={`delete-${ data-testid={`delete-${
feature.status === "waiting_approval" ? "waiting" : "verified" feature.status === "waiting_approval"
? "waiting"
: "verified"
}-${feature.id}`} }-${feature.id}`}
title="Delete" title="Delete"
> >
@@ -665,7 +691,9 @@ export const KanbanCard = memo(function KanbanCard({
<div className="px-2 py-1.5 text-[10px] text-muted-foreground border-t mt-1 pt-1.5"> <div className="px-2 py-1.5 text-[10px] text-muted-foreground border-t mt-1 pt-1.5">
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<Cpu className="w-3 h-3" /> <Cpu className="w-3 h-3" />
<span>{formatModelName(feature.model ?? DEFAULT_MODEL)}</span> <span>
{formatModelName(feature.model ?? DEFAULT_MODEL)}
</span>
</div> </div>
</div> </div>
</DropdownMenuContent> </DropdownMenuContent>
@@ -686,7 +714,9 @@ export const KanbanCard = memo(function KanbanCard({
{feature.titleGenerating ? ( {feature.titleGenerating ? (
<div className="flex items-center gap-1.5 mb-1"> <div className="flex items-center gap-1.5 mb-1">
<Loader2 className="w-3 h-3 animate-spin text-muted-foreground" /> <Loader2 className="w-3 h-3 animate-spin text-muted-foreground" />
<span className="text-xs text-muted-foreground italic">Generating title...</span> <span className="text-xs text-muted-foreground italic">
Generating title...
</span>
</div> </div>
) : feature.title ? ( ) : feature.title ? (
<CardTitle className="text-sm font-semibold text-foreground mb-1 line-clamp-2"> <CardTitle className="text-sm font-semibold text-foreground mb-1 line-clamp-2">
@@ -724,16 +754,11 @@ export const KanbanCard = memo(function KanbanCard({
)} )}
</button> </button>
)} )}
{!feature.priority && (
<CardDescription className="text-[11px] mt-1.5 truncate text-muted-foreground/70">
{feature.category}
</CardDescription>
)}
</div> </div>
</div> </div>
</CardHeader> </CardHeader>
<CardContent className="p-3 pt-0"> <CardContent className="px-3 pt-0 pb-0">
{/* Target Branch Display */} {/* Target Branch Display */}
{useWorktrees && feature.branchName && ( {useWorktrees && feature.branchName && (
<div className="mb-2 flex items-center gap-1.5 text-[11px] text-muted-foreground"> <div className="mb-2 flex items-center gap-1.5 text-[11px] text-muted-foreground">
@@ -746,8 +771,9 @@ export const KanbanCard = memo(function KanbanCard({
{/* PR URL Display */} {/* PR URL Display */}
{typeof feature.prUrl === "string" && {typeof feature.prUrl === "string" &&
/^https?:\/\//i.test(feature.prUrl) && (() => { /^https?:\/\//i.test(feature.prUrl) &&
const prNumber = feature.prUrl.split('/').pop(); (() => {
const prNumber = feature.prUrl.split("/").pop();
return ( return (
<div className="mb-2"> <div className="mb-2">
<a <a
@@ -762,7 +788,7 @@ export const KanbanCard = memo(function KanbanCard({
> >
<GitPullRequest className="w-3 h-3 shrink-0" /> <GitPullRequest className="w-3 h-3 shrink-0" />
<span className="truncate max-w-[150px]"> <span className="truncate max-w-[150px]">
{prNumber ? `Pull Request #${prNumber}` : 'Pull Request'} {prNumber ? `Pull Request #${prNumber}` : "Pull Request"}
</span> </span>
<ExternalLink className="w-2.5 h-2.5 shrink-0" /> <ExternalLink className="w-2.5 h-2.5 shrink-0" />
</a> </a>
@@ -953,11 +979,11 @@ export const KanbanCard = memo(function KanbanCard({
)} )}
{/* Actions */} {/* Actions */}
<div className="flex flex-wrap gap-1.5"> <div className="flex flex-wrap gap-1.5 -mx-3 -mb-3 px-3 pb-3">
{isCurrentAutoTask && ( {isCurrentAutoTask && (
<> <>
{/* Approve Plan button - PRIORITY: shows even when agent is "running" (paused for approval) */} {/* Approve Plan button - PRIORITY: shows even when agent is "running" (paused for approval) */}
{feature.planSpec?.status === 'generated' && onApprovePlan && ( {feature.planSpec?.status === "generated" && onApprovePlan && (
<Button <Button
variant="default" variant="default"
size="sm" size="sm"
@@ -1017,7 +1043,7 @@ export const KanbanCard = memo(function KanbanCard({
{!isCurrentAutoTask && feature.status === "in_progress" && ( {!isCurrentAutoTask && feature.status === "in_progress" && (
<> <>
{/* Approve Plan button - shows when plan is generated and waiting for approval */} {/* Approve Plan button - shows when plan is generated and waiting for approval */}
{feature.planSpec?.status === 'generated' && onApprovePlan && ( {feature.planSpec?.status === "generated" && onApprovePlan && (
<Button <Button
variant="default" variant="default"
size="sm" size="sm"