Fix boolean logic for cost, apiReqCancelReason (they are never null)

This commit is contained in:
cte
2025-01-30 21:50:19 -08:00
parent 5b6c6be022
commit b5340915f7

View File

@@ -183,26 +183,28 @@ export const ChatRowContent = ({
</div> </div>
) )
return [ return [
apiReqCancelReason !== null ? ( apiReqCancelReason ? (
apiReqCancelReason === "user_cancelled" ? ( apiReqCancelReason === "user_cancelled" ? (
getIconSpan("error", cancelledColor) getIconSpan("error", cancelledColor)
) : ( ) : (
getIconSpan("error", errorColor) getIconSpan("error", errorColor)
) )
) : cost !== null ? ( ) : cost ? (
getIconSpan("check", successColor) getIconSpan("check", successColor)
) : apiRequestFailedMessage ? ( ) : apiRequestFailedMessage ? (
getIconSpan("error", errorColor) getIconSpan("error", errorColor)
) : ( ) : (
<ProgressIndicator /> <ProgressIndicator />
), ),
apiReqCancelReason !== null ? ( apiReqCancelReason ? (
apiReqCancelReason === "user_cancelled" ? ( apiReqCancelReason === "user_cancelled" ? (
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request Cancelled</span> <span style={{ color: normalColor, fontWeight: "bold" }}>API Request Cancelled</span>
) : ( ) : (
<span style={{ color: errorColor, fontWeight: "bold" }}>API Streaming Failed</span> <span style={{ color: errorColor, fontWeight: "bold" }}>
API Streaming Failed ({JSON.stringify(apiReqCancelReason)})
</span>
) )
) : cost !== null ? ( ) : cost ? (
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request</span> <span style={{ color: normalColor, fontWeight: "bold" }}>API Request</span>
) : apiRequestFailedMessage ? ( ) : apiRequestFailedMessage ? (
<span style={{ color: errorColor, fontWeight: "bold" }}>API Request Failed</span> <span style={{ color: errorColor, fontWeight: "bold" }}>API Request Failed</span>
@@ -510,9 +512,7 @@ export const ChatRowContent = ({
style={{ style={{
...headerStyle, ...headerStyle,
marginBottom: marginBottom:
(cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage (!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage ? 10 : 0,
? 10
: 0,
justifyContent: "space-between", justifyContent: "space-between",
cursor: "pointer", cursor: "pointer",
userSelect: "none", userSelect: "none",
@@ -530,7 +530,7 @@ export const ChatRowContent = ({
</div> </div>
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span> <span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
</div> </div>
{((cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && ( {((!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && (
<> <>
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}> <p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>
{apiRequestFailedMessage || apiReqStreamingFailedMessage} {apiRequestFailedMessage || apiReqStreamingFailedMessage}