Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

2.7 KB
Raw Blame
import { useState } from 'react'
import appIcon from '../../../resources/icon.png'
import { Button } from '../components/Controls'
import { Icon } from '../components/Icon'
import { ModalHeader, Sheet } from '../components/Overlay'
import { HStack, VStack } from '../components/Stack'
import { Text } from '../components/Text'
import { useModel } from '../lib/observable'
import { prefs, usePref } from '../lib/prefs'
import { useStarAsk } from '../lib/use-star-ask'
import { useApp } from '../store/context'
import { useTr } from '../lib/use-language'
import './star-prompt.css'

const copy = {
  first: {
    title: 'Star Codync on GitHub',
    message: 'Codync is free and open source. A star on GitHub is how other people find it.',
  },
  second: {
    title: 'Enjoying Codync?',
    message: 'If Codync saves you trips to your desk, a star on GitHub helps other people find it.',
  },
}

/**
 * Invites again at the fifth prompt after the setup invitation; also covers older
 * installations that have not seen the setup invitation.
 * Starring ends it.
 */
export function StarPrompt() {
  const tr = useTr()
  const app = useApp()
  const local = useModel(app.local)
  const [onboarded] = usePref(prefs.onboardingDone)
  const { due, prompts, answer } = useStarAsk()
  // The prompt count when this sheet last closed: the next ask waits for a later prompt, so two never follow each other.
  const [closedAt, setClosedAt] = useState(-1)
  const open = due !== null && onboarded && prompts > closedAt && local?.connection.kind === 'online'

  const finish = (starred: boolean) => {
    if (!open) return
    setClosedAt(prompts)
    answer(starred)
  }

  const text = copy[due ?? 'first']
  return (
    <Sheet open={open} onClose={() => finish(false)} width={400} dismissOnDim>
      <VStack className="star-prompt">
        <ModalHeader
          icon={<Icon name="star.fill" size={22} className="star-prompt-symbol" />}
          title={tr(text.title)}
          onClose={null}
        />
        <VStack gap={16} className="star-prompt-body">
          <Text as="div" size="body" tone="secondary" className="star-prompt-message">{tr(text.message)}</Text>
          <HStack gap={10}>
            <img src={appIcon} alt="" className="star-prompt-app-icon" draggable={false} />
            <Text size="callout" tone="secondary">github.com/leepokai/Codync</Text>
          </HStack>
          <HStack gap={8} justify="flex-end" wrap>
            <Button kind="secondary" onClick={() => finish(false)}>
              Not now
            </Button>
            <Button onClick={() => finish(true)}>
              Star on GitHub
            </Button>
          </HStack>
        </VStack>
      </VStack>
    </Sheet>
  )
}