Skip to content

Commit b534091

Browse files
committed
Fix boolean logic for cost, apiReqCancelReason (they are never null)
1 parent 5b6c6be commit b534091

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,28 @@ export const ChatRowContent = ({
183183
</div>
184184
)
185185
return [
186-
apiReqCancelReason !== null ? (
186+
apiReqCancelReason ? (
187187
apiReqCancelReason === "user_cancelled" ? (
188188
getIconSpan("error", cancelledColor)
189189
) : (
190190
getIconSpan("error", errorColor)
191191
)
192-
) : cost !== null ? (
192+
) : cost ? (
193193
getIconSpan("check", successColor)
194194
) : apiRequestFailedMessage ? (
195195
getIconSpan("error", errorColor)
196196
) : (
197197
<ProgressIndicator />
198198
),
199-
apiReqCancelReason !== null ? (
199+
apiReqCancelReason ? (
200200
apiReqCancelReason === "user_cancelled" ? (
201201
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request Cancelled</span>
202202
) : (
203-
<span style={{ color: errorColor, fontWeight: "bold" }}>API Streaming Failed</span>
203+
<span style={{ color: errorColor, fontWeight: "bold" }}>
204+
API Streaming Failed ({JSON.stringify(apiReqCancelReason)})
205+
</span>
204206
)
205-
) : cost !== null ? (
207+
) : cost ? (
206208
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request</span>
207209
) : apiRequestFailedMessage ? (
208210
<span style={{ color: errorColor, fontWeight: "bold" }}>API Request Failed</span>
@@ -510,9 +512,7 @@ export const ChatRowContent = ({
510512
style={{
511513
...headerStyle,
512514
marginBottom:
513-
(cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage
514-
? 10
515-
: 0,
515+
(!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage ? 10 : 0,
516516
justifyContent: "space-between",
517517
cursor: "pointer",
518518
userSelect: "none",
@@ -530,7 +530,7 @@ export const ChatRowContent = ({
530530
</div>
531531
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
532532
</div>
533-
{((cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && (
533+
{((!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && (
534534
<>
535535
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>
536536
{apiRequestFailedMessage || apiReqStreamingFailedMessage}

0 commit comments

Comments
 (0)