From a43bc8877e9363477d3ead25a4ddab0a1ce23b94 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Fri, 31 Jan 2025 09:45:41 -0500 Subject: [PATCH 1/4] Revert "Fix boolean logic for cost, apiReqCancelReason (they are never null)" This reverts commit b5340915f73ed7340c33a0c9b03c9648a88e73a4. --- webview-ui/src/components/chat/ChatRow.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index cb4649a..ffa340e 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -183,28 +183,26 @@ export const ChatRowContent = ({ ) return [ - apiReqCancelReason ? ( + apiReqCancelReason !== null ? ( apiReqCancelReason === "user_cancelled" ? ( getIconSpan("error", cancelledColor) ) : ( getIconSpan("error", errorColor) ) - ) : cost ? ( + ) : cost !== null ? ( getIconSpan("check", successColor) ) : apiRequestFailedMessage ? ( getIconSpan("error", errorColor) ) : ( ), - apiReqCancelReason ? ( + apiReqCancelReason !== null ? ( apiReqCancelReason === "user_cancelled" ? ( API Request Cancelled ) : ( - - API Streaming Failed ({JSON.stringify(apiReqCancelReason)}) - + API Streaming Failed ) - ) : cost ? ( + ) : cost !== null ? ( API Request ) : apiRequestFailedMessage ? ( API Request Failed @@ -512,7 +510,9 @@ export const ChatRowContent = ({ style={{ ...headerStyle, marginBottom: - (!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage ? 10 : 0, + (cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage + ? 10 + : 0, justifyContent: "space-between", cursor: "pointer", userSelect: "none", @@ -530,7 +530,7 @@ export const ChatRowContent = ({ - {((!cost && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && ( + {((cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && ( <>

{apiRequestFailedMessage || apiReqStreamingFailedMessage} From 1496b232f55b00ef19524e41e4ffe0eb93dbb1f1 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Fri, 31 Jan 2025 09:45:53 -0500 Subject: [PATCH 2/4] Revert "Revert lint rules in webview-ui too" This reverts commit ab4d717211594c8354dc8d9fab1cb7fe8db98245. --- webview-ui/.eslintrc.json | 40 +++++++++++++++++++ webview-ui/src/components/chat/ChatRow.tsx | 16 ++++---- webview-ui/src/components/chat/ChatView.tsx | 6 +-- .../src/components/welcome/WelcomeView.tsx | 2 +- 4 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 webview-ui/.eslintrc.json diff --git a/webview-ui/.eslintrc.json b/webview-ui/.eslintrc.json new file mode 100644 index 0000000..0c69367 --- /dev/null +++ b/webview-ui/.eslintrc.json @@ -0,0 +1,40 @@ +{ + "root": true, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react-hooks/recommended" + ], + "parser": "@typescript-eslint/parser", + "plugins": ["react", "@typescript-eslint", "react-hooks"], + "rules": { + "react/react-in-jsx-scope": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "warn", + "react/display-name": "warn", + "no-case-declarations": "warn", + "react/no-unescaped-entities": "warn", + "react/jsx-key": "warn", + "no-extra-semi": "warn", + "@typescript-eslint/no-var-requires": "warn", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" + } + ] + }, + "settings": { + "react": { + "version": "detect" + } + }, + "env": { + "browser": true, + "es2021": true, + "node": true + } +} diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index ffa340e..1ec109f 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -89,7 +89,7 @@ export const ChatRowContent = ({ } }, [isLast, message.say]) const [cost, apiReqCancelReason, apiReqStreamingFailedMessage] = useMemo(() => { - if (message.text && message.say === "api_req_started") { + if (message.text != null && message.say === "api_req_started") { const info: ClineApiReqInfo = JSON.parse(message.text) return [info.cost, info.cancelReason, info.streamingFailedMessage] } @@ -183,26 +183,26 @@ export const ChatRowContent = ({ ) return [ - apiReqCancelReason !== null ? ( + apiReqCancelReason != null ? ( apiReqCancelReason === "user_cancelled" ? ( getIconSpan("error", cancelledColor) ) : ( getIconSpan("error", errorColor) ) - ) : cost !== null ? ( + ) : cost != null ? ( getIconSpan("check", successColor) ) : apiRequestFailedMessage ? ( getIconSpan("error", errorColor) ) : ( ), - apiReqCancelReason !== null ? ( + apiReqCancelReason != null ? ( apiReqCancelReason === "user_cancelled" ? ( API Request Cancelled ) : ( API Streaming Failed ) - ) : cost !== null ? ( + ) : cost != null ? ( API Request ) : apiRequestFailedMessage ? ( API Request Failed @@ -510,7 +510,7 @@ export const ChatRowContent = ({ style={{ ...headerStyle, marginBottom: - (cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage + (cost == null && apiRequestFailedMessage) || apiReqStreamingFailedMessage ? 10 : 0, justifyContent: "space-between", @@ -524,13 +524,13 @@ export const ChatRowContent = ({

{icon} {title} - + 0 ? 1 : 0 }}> ${Number(cost || 0)?.toFixed(4)}
- {((cost === null && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && ( + {((cost == null && apiRequestFailedMessage) || apiReqStreamingFailedMessage) && ( <>

{apiRequestFailedMessage || apiReqStreamingFailedMessage} diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 3f58c7a..519b7e5 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -275,7 +275,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie return true } else { const lastApiReqStarted = findLast(modifiedMessages, (message) => message.say === "api_req_started") - if (lastApiReqStarted && lastApiReqStarted.text && lastApiReqStarted.say === "api_req_started") { + if (lastApiReqStarted && lastApiReqStarted.text != null && lastApiReqStarted.say === "api_req_started") { const cost = JSON.parse(lastApiReqStarted.text).cost if (cost === undefined) { // api request has not finished yet @@ -718,9 +718,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie if (message.say === "api_req_started") { // 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 const lastApiReqStarted = [...currentGroup].reverse().find((m) => m.say === "api_req_started") - if (lastApiReqStarted?.text) { + if (lastApiReqStarted?.text != null) { const info = JSON.parse(lastApiReqStarted.text) - const isCancelled = info.cancelReason !== null + const isCancelled = info.cancelReason != null if (isCancelled) { endBrowserSession() result.push(message) diff --git a/webview-ui/src/components/welcome/WelcomeView.tsx b/webview-ui/src/components/welcome/WelcomeView.tsx index d72d856..3e3bbd7 100644 --- a/webview-ui/src/components/welcome/WelcomeView.tsx +++ b/webview-ui/src/components/welcome/WelcomeView.tsx @@ -10,7 +10,7 @@ const WelcomeView = () => { const [apiErrorMessage, setApiErrorMessage] = useState(undefined) - const disableLetsGoButton = !!apiErrorMessage + const disableLetsGoButton = apiErrorMessage != null const handleSubmit = () => { vscode.postMessage({ type: "apiConfiguration", apiConfiguration }) From 9d1d7267518082025be8cf1e6b26bc0e8e81b149 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Fri, 31 Jan 2025 09:46:05 -0500 Subject: [PATCH 3/4] Remove webview-specific lint rules --- webview-ui/.eslintrc.json | 40 --------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 webview-ui/.eslintrc.json diff --git a/webview-ui/.eslintrc.json b/webview-ui/.eslintrc.json deleted file mode 100644 index 0c69367..0000000 --- a/webview-ui/.eslintrc.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "root": true, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended", - "plugin:react-hooks/recommended" - ], - "parser": "@typescript-eslint/parser", - "plugins": ["react", "@typescript-eslint", "react-hooks"], - "rules": { - "react/react-in-jsx-scope": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/no-explicit-any": "warn", - "react/display-name": "warn", - "no-case-declarations": "warn", - "react/no-unescaped-entities": "warn", - "react/jsx-key": "warn", - "no-extra-semi": "warn", - "@typescript-eslint/no-var-requires": "warn", - "@typescript-eslint/no-unused-vars": [ - "warn", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - "caughtErrorsIgnorePattern": "^_" - } - ] - }, - "settings": { - "react": { - "version": "detect" - } - }, - "env": { - "browser": true, - "es2021": true, - "node": true - } -} From 1a400508141ebb4ed907de04be04cf018cb7cf56 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Fri, 31 Jan 2025 09:47:52 -0500 Subject: [PATCH 4/4] Add @cte as codeowner --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8032afe..c4c59d4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ # These owners will be the default owners for everything in the repo -* @stea9499 @ColemanRoo @mrubens \ No newline at end of file +* @stea9499 @ColemanRoo @mrubens @cte