Files
kandev/apps/web/components/task/chat/context-items/walkthrough-comment-item.tsx
T
João Salavisa d3058276d7 feat(i18n): localize task chat surface (#2303)
Co-authored-by: Kandev Agent <agent@kandev.dev>
2026-08-06 03:01:51 +02:00

49 lines
1.5 KiB
TypeScript

"use client";
import { memo } from "react";
import type { WalkthroughCommentContextItem } from "@/lib/types/context";
import { getFileName } from "@/lib/utils/file-path";
import { ContextChip } from "./context-chip";
import { useTranslation } from "react-i18next";
function lineLabel(start: number, end: number) {
return start === end ? `${start}` : `${start}-${end}`;
}
export const WalkthroughCommentItem = memo(function WalkthroughCommentItem({
item,
}: {
item: WalkthroughCommentContextItem;
}) {
const { t } = useTranslation();
const preview = (
<div className="space-y-2">
{item.comments.map((comment) => (
<div key={comment.id} className="text-xs space-y-1">
<div className="font-medium text-muted-foreground truncate" title={comment.filePath}>
{getFileName(comment.filePath)}:{lineLabel(comment.startLine, comment.endLine)}
</div>
<div className="line-clamp-2 text-muted-foreground">{comment.stepText}</div>
<div className="break-words">{comment.text}</div>
<button
type="button"
className="text-muted-foreground hover:text-foreground cursor-pointer"
onClick={() => item.onRemoveComment(comment.id)}
>
{t("task:remove")}
</button>
</div>
))}
</div>
);
return (
<ContextChip
kind="walkthrough-comment"
label={item.label}
preview={preview}
onRemove={item.onRemove}
/>
);
});