aiLoaderMessage.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {useEffect, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import shuffle from 'lodash/shuffle';
  4. import {t} from 'sentry/locale';
  5. const LOADING_MESSAGES = [
  6. t('Heating up them GPUs'),
  7. t('Engineering a prompt'),
  8. t('Demonstrating value'),
  9. t('Moving the needle'),
  10. t('Preventing prompt injection attacks'),
  11. t('Remove traces of depression from answers'),
  12. t('Reticulating splines or whatever'),
  13. t('Loading marketing material'),
  14. t('Wiping node_modules'),
  15. t('Installing dependencies'),
  16. t('Searching StackOverflow'),
  17. t('Googling for solutions'),
  18. t('Runing spell checker'),
  19. t('Searching for the perfect emoji'),
  20. t('Adding trace amounts of human touch'),
  21. t("Don't be like Sydney, don't be like Sydney"),
  22. t('Initiating quantum leap'),
  23. t('Charging flux capacitors'),
  24. t('Summoning a demon'),
  25. ];
  26. export function AiLoaderMessage() {
  27. const [messages] = useState(() => shuffle(LOADING_MESSAGES));
  28. const [messageIndex, setMessageIndex] = useState(0);
  29. useEffect(() => {
  30. const id = setInterval(() => {
  31. if (messageIndex < messages.length - 1) {
  32. setMessageIndex(messageIndex + 1);
  33. }
  34. }, Math.random() * 700 + 800);
  35. return () => clearInterval(id);
  36. });
  37. return (
  38. <div>
  39. <Message>{messages[messageIndex]}…</Message>
  40. </div>
  41. );
  42. }
  43. // Hacky way until we have proper darkmode/lightmode ai loaders
  44. const Message = styled('strong')`
  45. color: #3e3446;
  46. `;