({ message, cwd, onOpenFile }: { message: CustomMessage; cwd?: string; onOpenFile?: (filePath: string) => void })
| 1134 | } |
| 1135 | |
| 1136 | function CustomMessageView({ message, cwd, onOpenFile }: { message: CustomMessage; cwd?: string; onOpenFile?: (filePath: string) => void }) { |
| 1137 | const isHiddenDisplay = message.display === false; |
| 1138 | const [contentExpanded, setContentExpanded] = useState(!isHiddenDisplay); |
| 1139 | const [detailsExpanded, setDetailsExpanded] = useState(false); |
| 1140 | const [copied, setCopied] = useState(false); |
| 1141 | const text = getMessageText(message.content); |
| 1142 | const images = getMessageImages(message.content); |
| 1143 | const hasDetails = message.details !== undefined; |
| 1144 | const detailsText = hasDetails ? safeJson(message.details) : ""; |
| 1145 | const title = formatCustomType(message.customType); |
| 1146 | const time = formatTime(message.timestamp); |
| 1147 | |
| 1148 | const copyContent = () => { |
| 1149 | copyText(text || detailsText).then(() => { |
| 1150 | setCopied(true); |
| 1151 | setTimeout(() => setCopied(false), 1500); |
| 1152 | }); |
| 1153 | }; |
| 1154 | |
| 1155 | return ( |
| 1156 | <div style={{ marginBottom: 16 }}> |
| 1157 | <div |
| 1158 | style={{ |
| 1159 | border: "1px solid var(--border)", |
| 1160 | borderRadius: 8, |
| 1161 | overflow: "hidden", |
| 1162 | background: isHiddenDisplay ? "var(--bg-subtle)" : "var(--bg)", |
| 1163 | opacity: isHiddenDisplay && !contentExpanded ? 0.82 : 1, |
| 1164 | }} |
| 1165 | > |
| 1166 | <div |
| 1167 | style={{ |
| 1168 | display: "flex", |
| 1169 | alignItems: "center", |
| 1170 | gap: 8, |
| 1171 | padding: "7px 10px", |
| 1172 | borderBottom: "1px solid var(--border)", |
| 1173 | background: "var(--bg-panel)", |
| 1174 | color: "var(--text-muted)", |
| 1175 | fontSize: 12, |
| 1176 | }} |
| 1177 | > |
| 1178 | <span style={{ color: "var(--text-muted)", fontFamily: "var(--font-mono)", fontSize: 11, fontWeight: 650 }}> |
| 1179 | {title} |
| 1180 | </span> |
| 1181 | {isHiddenDisplay && <span style={{ color: "var(--text-dim)", fontSize: 11 }}>hidden extension message</span>} |
| 1182 | {time && <span style={{ marginLeft: "auto", color: "var(--text-dim)", fontSize: 10 }}>{time}</span>} |
| 1183 | </div> |
| 1184 | |
| 1185 | {contentExpanded ? ( |
| 1186 | <div style={{ padding: "6px 9px" }}> |
| 1187 | {images.length > 0 && ( |
| 1188 | <div style={{ display: "flex", gap: 6, flexWrap: "wrap", marginBottom: text ? 8 : 0 }}> |
| 1189 | {images.map((img, i) => { |
| 1190 | const src = imageSource(img); |
| 1191 | if (!src) return null; |
| 1192 | return ( |
| 1193 | // eslint-disable-next-line @next/next/no-img-element |
nothing calls this directly
no test coverage detected