Changesets · Branches · Tags · Compare
| Changeset | 5c04796c86d62bbbb9221cdfcf76167e227089e1c86e42e530dd0008e6774eb1 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-05-23 17:01 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-05-23 17:01 -07:00 |
| Parents | 8fdd1cf6fd08, 8c1a4323bdf6 |
1 file changed
modified gui/src/pages/gui/StreamError.tsx +86 −47
| @@ -1,12 +1,15 @@ | ||
| 1 | 1 | import { |
| 2 | 2 | ArrowTopRightOnSquareIcon, |
| 3 | - Cog8ToothIcon, | |
| 3 | + ClipboardIcon, | |
| 4 | + Cog6ToothIcon, | |
| 5 | + KeyIcon, | |
| 4 | 6 | } from "@heroicons/react/24/outline"; |
| 5 | 7 | import { DISCORD_LINK, GITHUB_LINK } from "core/util/constants"; |
| 6 | 8 | import { useContext, useMemo } from "react"; |
| 7 | -import { Button, SecondaryButton } from "../../components"; | |
| 9 | +import { GhostButton, SecondaryButton } from "../../components"; | |
| 8 | 10 | import { DiscordIcon } from "../../components/svg/DiscordIcon"; |
| 9 | 11 | import { GithubIcon } from "../../components/svg/GithubIcon"; |
| 12 | +import ToggleDiv from "../../components/ToggleDiv"; | |
| 10 | 13 | import { useAuth } from "../../context/Auth"; |
| 11 | 14 | import { IdeMessengerContext } from "../../context/IdeMessenger"; |
| 12 | 15 | import { selectSelectedProfile } from "../../redux/"; |
| @@ -48,11 +51,15 @@ | ||
| 48 | 51 | ); |
| 49 | 52 | |
| 50 | 53 | const handleRefreshProfiles = () => { |
| 51 | - refreshProfiles(); | |
| 54 | + void refreshProfiles(); | |
| 52 | 55 | dispatch(setShowDialog(false)); |
| 53 | 56 | dispatch(setDialogMessage(undefined)); |
| 54 | 57 | }; |
| 55 | 58 | |
| 59 | + const copyErrorToClipboard = () => { | |
| 60 | + void navigator.clipboard.writeText(parsedError); | |
| 61 | + }; | |
| 62 | + | |
| 56 | 63 | // Collect model information to display useful error info |
| 57 | 64 | let modelTitle = "Chat model"; |
| 58 | 65 | let providerName = "the model provider"; |
| @@ -99,30 +106,29 @@ | ||
| 99 | 106 | } |
| 100 | 107 | |
| 101 | 108 | const checkKeysButton = apiKeyUrl ? ( |
| 102 | - <Button | |
| 103 | - className="cursor-pointer hover:underline" | |
| 109 | + <GhostButton | |
| 110 | + className="flex items-center" | |
| 104 | 111 | onClick={() => { |
| 105 | 112 | ideMessenger.post("openUrl", apiKeyUrl!); |
| 106 | 113 | }} |
| 107 | 114 | > |
| 108 | - Check keys/usage | |
| 109 | - </Button> | |
| 115 | + <KeyIcon className="mr-1.5 h-3.5 w-3.5" /> | |
| 116 | + <span>View key</span> | |
| 117 | + </GhostButton> | |
| 110 | 118 | ) : null; |
| 111 | 119 | |
| 112 | 120 | const configButton = ( |
| 113 | - <SecondaryButton | |
| 114 | - className="flex flex-row items-center gap-1.5 hover:underline hover:opacity-70" | |
| 121 | + <GhostButton | |
| 122 | + className="flex items-center" | |
| 115 | 123 | onClick={() => { |
| 116 | 124 | ideMessenger.post("config/openProfile", { |
| 117 | 125 | profileId: undefined, |
| 118 | 126 | }); |
| 119 | 127 | }} |
| 120 | 128 | > |
| 121 | - <div> | |
| 122 | - <Cog8ToothIcon className="h-4 w-4" /> | |
| 123 | - </div> | |
| 124 | - <span>Open Assistant configuration</span> | |
| 125 | - </SecondaryButton> | |
| 129 | + <Cog6ToothIcon className="mr-1.5 h-3.5 w-3.5" /> | |
| 130 | + <span>View config</span> | |
| 131 | + </GhostButton> | |
| 126 | 132 | ); |
| 127 | 133 | |
| 128 | 134 | if ( |
| @@ -131,7 +137,20 @@ | ||
| 131 | 137 | return <ModelsAddOnLimitDialog />; |
| 132 | 138 | } |
| 133 | 139 | |
| 134 | - let errorContent: React.ReactNode = <></>; | |
| 140 | + let errorContent = ( | |
| 141 | + <div className="mb-3 mt-1"> | |
| 142 | + <div className="m-0 p-0"> | |
| 143 | + <p className="m-0 mb-2 p-0"> | |
| 144 | + There was an error handling the response from{" "} | |
| 145 | + {selectedModel?.title || "the model"}. | |
| 146 | + </p> | |
| 147 | + <p className="m-0 p-0"> | |
| 148 | + Please try to submit your message again, and if the error persists, | |
| 149 | + let us know by reporting the issue using the buttons below. | |
| 150 | + </p> | |
| 151 | + </div> | |
| 152 | + </div> | |
| 153 | + ); | |
| 135 | 154 | |
| 136 | 155 | // Display components for specific errors |
| 137 | 156 | if (statusCode === 429) { |
| @@ -141,7 +160,7 @@ | ||
| 141 | 160 | {`This might mean your ${modelTitle} usage has been rate limited |
| 142 | 161 | by ${providerName}.`} |
| 143 | 162 | </span> |
| 144 | - <div className="flex flex-row flex-wrap gap-2"> | |
| 163 | + <div className="flex flex-row flex-wrap justify-start gap-3 py-4"> | |
| 145 | 164 | {checkKeysButton} |
| 146 | 165 | {configButton} |
| 147 | 166 | </div> |
| @@ -230,51 +249,71 @@ | ||
| 230 | 249 | ); |
| 231 | 250 | } |
| 232 | 251 | |
| 252 | + console.log({ message }); | |
| 253 | + | |
| 233 | 254 | return ( |
| 234 | - <div className={`flex flex-col gap-1 px-3 pb-2 pt-3`}> | |
| 235 | - <p className="m-0 p-0 text-lg text-red-500"> | |
| 236 | - {statusCode ? `Error (status code ${statusCode})` : "Error"} | |
| 237 | - </p> | |
| 238 | - | |
| 239 | - {message ? ( | |
| 240 | - <div className="mt-2 flex flex-col gap-0 rounded-sm"> | |
| 241 | - <code className="max-h-20 overflow-y-auto p-2 font-mono"> | |
| 242 | - {parsedError} | |
| 243 | - </code> | |
| 244 | - <div | |
| 245 | - className="flex cursor-pointer flex-row items-center justify-end px-1 py-1 text-gray-500 hover:underline" | |
| 246 | - onClick={() => { | |
| 247 | - ideMessenger.post("toggleDevTools", undefined); | |
| 248 | - }} | |
| 249 | - > | |
| 250 | - <span className="px-2">View Logs</span> | |
| 251 | - <ArrowTopRightOnSquareIcon className="h-4 w-4" /> | |
| 252 | - </div> | |
| 255 | + <div className="flex flex-col gap-4 px-3 pb-3 pt-3"> | |
| 256 | + {/* Concise error title */} | |
| 257 | + <h3 className="text-error m-0 p-0 text-lg font-medium"> | |
| 258 | + Error handling model response | |
| 259 | + </h3> | |
| 260 | + | |
| 261 | + {errorContent} | |
| 262 | + | |
| 263 | + {/* Expandable technical details using ToggleDiv */} | |
| 264 | + {message && ( | |
| 265 | + <div className="mb-2"> | |
| 266 | + <ToggleDiv title="View error output" testId="error-output-toggle"> | |
| 267 | + <div className="flex flex-col gap-0 rounded-sm"> | |
| 268 | + <code className="text-editor-foreground block max-h-48 overflow-y-auto p-3 font-mono text-xs"> | |
| 269 | + {parsedError} | |
| 270 | + </code> | |
| 271 | + | |
| 272 | + <div className="flex flex-row items-center justify-end gap-2 p-2"> | |
| 273 | + <GhostButton | |
| 274 | + onClick={copyErrorToClipboard} | |
| 275 | + className="flex items-center" | |
| 276 | + > | |
| 277 | + <ClipboardIcon className="mr-1.5 h-3.5 w-3.5" /> | |
| 278 | + <span>Copy output</span> | |
| 279 | + </GhostButton> | |
| 280 | + | |
| 281 | + <GhostButton | |
| 282 | + onClick={() => { | |
| 283 | + ideMessenger.post("toggleDevTools", undefined); | |
| 284 | + }} | |
| 285 | + className="flex items-center" | |
| 286 | + > | |
| 287 | + <ArrowTopRightOnSquareIcon className="mr-1.5 h-4 w-4" /> | |
| 288 | + <span className="text-xs">View Logs</span> | |
| 289 | + </GhostButton> | |
| 290 | + </div> | |
| 291 | + </div> | |
| 292 | + </ToggleDiv> | |
| 253 | 293 | </div> |
| 254 | - ) : null} | |
| 255 | - <div className="mt-3">{errorContent}</div> | |
| 256 | - | |
| 257 | - <div className="mt-2 flex flex-col gap-1.5"> | |
| 258 | - <span>Report this error:</span> | |
| 259 | - <div className="flex flex-row flex-wrap items-center gap-2"> | |
| 260 | - <SecondaryButton | |
| 261 | - className="flex flex-row items-center gap-2 hover:opacity-70" | |
| 294 | + )} | |
| 295 | + | |
| 296 | + <div> | |
| 297 | + <span className="text-base font-medium">Report this error</span> | |
| 298 | + <div className="mt-2 flex flex-row flex-wrap items-center gap-2"> | |
| 299 | + <GhostButton | |
| 300 | + className="flex flex-row items-center gap-2 rounded px-3 py-1.5" | |
| 262 | 301 | onClick={() => { |
| 263 | 302 | ideMessenger.post("openUrl", GITHUB_LINK); |
| 264 | 303 | }} |
| 265 | 304 | > |
| 266 | 305 | <GithubIcon className="h-5 w-5" /> |
| 267 | 306 | <span className="xs:flex hidden">Github</span> |
| 268 | - </SecondaryButton> | |
| 269 | - <SecondaryButton | |
| 270 | - className="flex flex-row items-center gap-2 hover:opacity-70" | |
| 307 | + </GhostButton> | |
| 308 | + <GhostButton | |
| 309 | + className="flex flex-row items-center gap-2 rounded px-3 py-1.5" | |
| 271 | 310 | onClick={() => { |
| 272 | 311 | ideMessenger.post("openUrl", DISCORD_LINK); |
| 273 | 312 | }} |
| 274 | 313 | > |
| 275 | 314 | <DiscordIcon className="h-5 w-5" /> |
| 276 | 315 | <span className="xs:flex hidden">Discord</span> |
| 277 | - </SecondaryButton> | |
| 316 | + </GhostButton> | |
| 278 | 317 | </div> |
| 279 | 318 | </div> |
| 280 | 319 | </div> |