8f2fe7a8e6
* feat(web): add agent message comments * fix(web): harden agent message comments * fix(web): address message comment review findings * fix(web): allow comments on legacy agent messages * fix(web): address latest message comment review * fix(web): address follow-up message comment review * fix(web): address remaining message comment review * fix(web): keep failed mobile comments open * fix(web): preserve selections over message comments
50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
"use client";
|
|
|
|
import { memo } from "react";
|
|
import { ContextChip } from "./context-chip";
|
|
|
|
type SelectionComment = {
|
|
id: string;
|
|
selectedText: string;
|
|
text: string;
|
|
};
|
|
|
|
export const SelectionCommentItem = memo(function SelectionCommentItem({
|
|
kind,
|
|
label,
|
|
comments,
|
|
onClick,
|
|
onRemove,
|
|
}: {
|
|
kind: "plan-comment" | "agent-message-comment";
|
|
label: string;
|
|
comments: SelectionComment[];
|
|
onClick?: () => void;
|
|
onRemove?: () => void;
|
|
}) {
|
|
const preview = (
|
|
<div className="space-y-1.5">
|
|
{comments.map((comment) => (
|
|
<div key={comment.id} className="space-y-0.5 text-xs">
|
|
{comment.selectedText ? (
|
|
<div className="line-clamp-2 text-muted-foreground italic">
|
|
“{comment.selectedText}”
|
|
</div>
|
|
) : null}
|
|
<div className="break-words">{comment.text}</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
|
|
return (
|
|
<ContextChip
|
|
kind={kind}
|
|
label={label}
|
|
preview={preview}
|
|
onClick={onClick}
|
|
onRemove={onRemove}
|
|
/>
|
|
);
|
|
});
|