Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions webview-ui/src/components/chat/ChatRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1032,12 +1032,16 @@ export const ChatRowContent = ({
const isApiRequestInProgress =
apiReqCancelReason === undefined && apiRequestFailedMessage === undefined && cost === undefined

// For completed requests (with cost), make them expandable
const isCompletedRequest = cost !== null && cost !== undefined
const canExpand = isCompletedRequest && message.text !== null && message.text !== undefined

return (
<>
<div
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For accessibility, consider adding role='button' and tabIndex='0' (with keyboard event handlers) to the clickable header <div> so that the expand/collapse functionality is accessible.

className={`group text-sm transition-opacity ${
isApiRequestInProgress ? "opacity-100" : "opacity-40 hover:opacity-100"
}`}
} ${canExpand ? "cursor-pointer" : ""}`}
style={{
...headerStyle,
marginBottom:
Expand All @@ -1046,9 +1050,27 @@ export const ChatRowContent = ({
? 10
: 0,
justifyContent: "space-between",
}}>
}}
onClick={canExpand ? handleToggleExpand : undefined}>
<div style={{ display: "flex", alignItems: "center", gap: "10px", flexGrow: 1 }}>
{icon}
{/* Use chevron icon for expandable completed requests, otherwise use the computed icon */}
{canExpand ? (
<div
style={{
width: 16,
height: 16,
display: "flex",
alignItems: "center",
justifyContent: "center",
}}>
<span
className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}
style={{ color: normalColor, fontSize: 16, marginBottom: "-1.5px" }}
/>
</div>
) : (
icon
)}
{title}
</div>
<div
Expand All @@ -1057,6 +1079,17 @@ export const ChatRowContent = ({
${Number(cost || 0)?.toFixed(4)}
</div>
</div>
{/* Show API request details when expanded */}
{canExpand && isExpanded && message.text && (
<div className="pl-6 mt-2">
<CodeAccordian
code={message.text}
language="json"
isExpanded={true}
onToggleExpand={handleToggleExpand}
/>
</div>
)}
{(((cost === null || cost === undefined) && apiRequestFailedMessage) ||
apiReqStreamingFailedMessage) && (
<ErrorRow
Expand Down
Loading