瀏覽代碼

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

cte 11 月之前
父節點
當前提交
b5340915f7
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      webview-ui/src/components/chat/ChatRow.tsx

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

@@ -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
-											? 10
-											: 0,
+										(!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage ? 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}