mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend): address CodeRabbit review comments
- MarkdownRenderer: add null guard for empty image src - GenericTool: use composite key for todo items - ViewAgentOutput/BlockOutputCard: use parent key + index instead of bare index - SidebarItemCard: extract onKeyDown to named function declaration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -557,8 +557,11 @@ function getTodoAccordionData(input: unknown): AccordionData {
|
||||
description: `${completed}/${total} completed`,
|
||||
content: (
|
||||
<div className="space-y-1 py-1">
|
||||
{todos.map((todo) => (
|
||||
<div key={todo.content} className="flex items-start gap-2 text-xs">
|
||||
{todos.map((todo, idx) => (
|
||||
<div
|
||||
key={`${todo.status}:${todo.content}:${idx}`}
|
||||
className="flex items-start gap-2 text-xs"
|
||||
>
|
||||
<span className="mt-0.5 flex-shrink-0">
|
||||
{todo.status === "completed" ? (
|
||||
<CheckCircleIcon
|
||||
|
||||
@@ -103,8 +103,7 @@ function OutputKeySection({
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
{visibleItems.map((item, i) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<RenderOutputValue key={i} value={item} />
|
||||
<RenderOutputValue key={`${outputKey}-${i}`} value={item} />
|
||||
))}
|
||||
</div>
|
||||
{hasMoreItems && (
|
||||
|
||||
@@ -209,8 +209,10 @@ export function ViewAgentOutputTool({ part }: Props) {
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
{items.slice(0, 3).map((item, i) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<RenderOutputValue key={i} value={item} />
|
||||
<RenderOutputValue
|
||||
key={`${key}-${i}`}
|
||||
value={item}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</ContentCard>
|
||||
|
||||
@@ -23,6 +23,13 @@ export function SidebarItemCard({
|
||||
onClick,
|
||||
actions,
|
||||
}: Props) {
|
||||
function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
onClick?.();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
role="button"
|
||||
@@ -32,12 +39,7 @@ export function SidebarItemCard({
|
||||
selected ? "border-slate-800 ring-slate-800" : undefined,
|
||||
)}
|
||||
onClick={onClick}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
onClick?.();
|
||||
}
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<div className="flex min-w-0 items-center justify-start gap-3">
|
||||
{icon}
|
||||
|
||||
@@ -366,9 +366,11 @@ function renderMarkdown(
|
||||
return renderVideoEmbed(src);
|
||||
}
|
||||
|
||||
if (!src) return null;
|
||||
|
||||
return (
|
||||
<Image
|
||||
src={src || ""}
|
||||
src={src}
|
||||
alt={alt || "Image"}
|
||||
width={0}
|
||||
height={0}
|
||||
|
||||
Reference in New Issue
Block a user