Skip to content

Commit 4c494ca

Browse files
authored
Merge pull request RooCodeInc#762 from RooVetGit/fix_webview_lints
Fix webview lints
2 parents 053a940 + ee2e719 commit 4c494ca

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const ChatRowContent = ({
8989
}
9090
}, [isLast, message.say])
9191
const [cost, apiReqCancelReason, apiReqStreamingFailedMessage] = useMemo(() => {
92-
if (message.text != null && message.say === "api_req_started") {
92+
if (message.text !== null && message.text !== undefined && message.say === "api_req_started") {
9393
const info: ClineApiReqInfo = JSON.parse(message.text)
9494
return [info.cost, info.cancelReason, info.streamingFailedMessage]
9595
}
@@ -183,26 +183,26 @@ export const ChatRowContent = ({
183183
</div>
184184
)
185185
return [
186-
apiReqCancelReason != null ? (
186+
apiReqCancelReason !== null && apiReqCancelReason !== undefined ? (
187187
apiReqCancelReason === "user_cancelled" ? (
188188
getIconSpan("error", cancelledColor)
189189
) : (
190190
getIconSpan("error", errorColor)
191191
)
192-
) : cost != null ? (
192+
) : cost !== null && cost !== undefined ? (
193193
getIconSpan("check", successColor)
194194
) : apiRequestFailedMessage ? (
195195
getIconSpan("error", errorColor)
196196
) : (
197197
<ProgressIndicator />
198198
),
199-
apiReqCancelReason != null ? (
199+
apiReqCancelReason !== null && apiReqCancelReason !== undefined ? (
200200
apiReqCancelReason === "user_cancelled" ? (
201201
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request Cancelled</span>
202202
) : (
203203
<span style={{ color: errorColor, fontWeight: "bold" }}>API Streaming Failed</span>
204204
)
205-
) : cost != null ? (
205+
) : cost !== null && cost !== undefined ? (
206206
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request</span>
207207
) : apiRequestFailedMessage ? (
208208
<span style={{ color: errorColor, fontWeight: "bold" }}>API Request Failed</span>
@@ -510,7 +510,8 @@ export const ChatRowContent = ({
510510
style={{
511511
...headerStyle,
512512
marginBottom:
513-
(cost == null && apiRequestFailedMessage) || apiReqStreamingFailedMessage
513+
((cost === null || cost === undefined) && apiRequestFailedMessage) ||
514+
apiReqStreamingFailedMessage
514515
? 10
515516
: 0,
516517
justifyContent: "space-between",
@@ -524,13 +525,15 @@ export const ChatRowContent = ({
524525
<div style={{ display: "flex", alignItems: "center", gap: "10px", flexGrow: 1 }}>
525526
{icon}
526527
{title}
527-
<VSCodeBadge style={{ opacity: cost != null && cost > 0 ? 1 : 0 }}>
528+
<VSCodeBadge
529+
style={{ opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0 }}>
528530
${Number(cost || 0)?.toFixed(4)}
529531
</VSCodeBadge>
530532
</div>
531533
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
532534
</div>
533-
{((cost == null && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && (
535+
{(((cost === null || cost === undefined) && apiRequestFailedMessage) ||
536+
apiReqStreamingFailedMessage) && (
534537
<>
535538
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>
536539
{apiRequestFailedMessage || apiReqStreamingFailedMessage}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
275275
return true
276276
} else {
277277
const lastApiReqStarted = findLast(modifiedMessages, (message) => message.say === "api_req_started")
278-
if (lastApiReqStarted && lastApiReqStarted.text != null && lastApiReqStarted.say === "api_req_started") {
278+
if (
279+
lastApiReqStarted &&
280+
lastApiReqStarted.text !== null &&
281+
lastApiReqStarted.text !== undefined &&
282+
lastApiReqStarted.say === "api_req_started"
283+
) {
279284
const cost = JSON.parse(lastApiReqStarted.text).cost
280285
if (cost === undefined) {
281286
// api request has not finished yet
@@ -718,9 +723,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
718723
if (message.say === "api_req_started") {
719724
// get last api_req_started in currentGroup to check if it's cancelled. If it is then this api req is not part of the current browser session
720725
const lastApiReqStarted = [...currentGroup].reverse().find((m) => m.say === "api_req_started")
721-
if (lastApiReqStarted?.text != null) {
726+
if (lastApiReqStarted?.text !== null && lastApiReqStarted?.text !== undefined) {
722727
const info = JSON.parse(lastApiReqStarted.text)
723-
const isCancelled = info.cancelReason != null
728+
const isCancelled = info.cancelReason !== null && info.cancelReason !== undefined
724729
if (isCancelled) {
725730
endBrowserSession()
726731
result.push(message)

webview-ui/src/components/welcome/WelcomeView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const WelcomeView = () => {
1010

1111
const [apiErrorMessage, setApiErrorMessage] = useState<string | undefined>(undefined)
1212

13-
const disableLetsGoButton = apiErrorMessage != null
13+
const disableLetsGoButton = apiErrorMessage !== null && apiErrorMessage !== undefined
1414

1515
const handleSubmit = () => {
1616
vscode.postMessage({ type: "apiConfiguration", apiConfiguration })

0 commit comments

Comments
 (0)