({ error }: StreamErrorProps)
| 24 | } |
| 25 | |
| 26 | const StreamErrorDialog = ({ error }: StreamErrorProps) => { |
| 27 | const dispatch = useAppDispatch(); |
| 28 | const ideMessenger = useContext(IdeMessengerContext); |
| 29 | const selectedModel = useAppSelector(selectSelectedChatModel); |
| 30 | const { refreshProfiles } = useAuth(); |
| 31 | const { mainEditor } = useMainEditor(); |
| 32 | |
| 33 | const { |
| 34 | parsedError, |
| 35 | statusCode, |
| 36 | message, |
| 37 | modelTitle, |
| 38 | providerName, |
| 39 | apiKeyUrl, |
| 40 | helpUrl, |
| 41 | customErrorMessage, |
| 42 | } = useMemo(() => analyzeError(error, selectedModel), [error, selectedModel]); |
| 43 | |
| 44 | const handleRefreshProfiles = () => { |
| 45 | void refreshProfiles("Clicked reload config from stream error dialog"); |
| 46 | dispatch(setShowDialog(false)); |
| 47 | dispatch(setDialogMessage(undefined)); |
| 48 | }; |
| 49 | |
| 50 | const copyErrorToClipboard = () => { |
| 51 | void navigator.clipboard.writeText(parsedError); |
| 52 | }; |
| 53 | |
| 54 | const history = useAppSelector((store) => store.session.history); |
| 55 | |
| 56 | const checkKeysButton = apiKeyUrl ? ( |
| 57 | <GhostButton |
| 58 | className="flex items-center" |
| 59 | onClick={() => ideMessenger.ide.openUrl(apiKeyUrl)} |
| 60 | > |
| 61 | <KeyIcon className="mr-1.5 h-3.5 w-3.5" /> |
| 62 | <span>Check API key</span> |
| 63 | </GhostButton> |
| 64 | ) : null; |
| 65 | |
| 66 | const handleEditModel = useEditModel(); |
| 67 | |
| 68 | const configButton = ( |
| 69 | <GhostButton |
| 70 | className="flex items-center" |
| 71 | onClick={() => handleEditModel(selectedModel)} |
| 72 | > |
| 73 | <Cog6ToothIcon className="mr-1.5 h-3.5 w-3.5" /> |
| 74 | <span>View config</span> |
| 75 | </GhostButton> |
| 76 | ); |
| 77 | |
| 78 | const resubmitButton = ( |
| 79 | <GhostButton |
| 80 | className="flex items-center" |
| 81 | onClick={() => { |
| 82 | let index = -1; |
| 83 | for (let i = history.length - 1; i >= 0; i--) { |
nothing calls this directly
no test coverage detected