Repository: supabase/supabase
File: apps/studio/components/interfaces/Support/AIAssistantOption.tsx (TypeScript)

Code before:
  isCondensed = false,
}: AIAssistantOptionProps) => {
  const { mutate: sendEvent } = useSendEventMutation()
  const [isVisible, setIsVisible] = useState(isCondensed ? true : false)

  useEffect(() => {
    const timer = setTimeout(() => setIsVisible(true), 800)
    return () => clearTimeout(timer)
  }, [])

  const onAiAssistantClicked = useCallback(() => {
    sendEvent({
      action: 'ai_assistant_in_support_form_clicked',
      groups: {
        project: projectRef === 'no-project' ? undefined : projectRef,
        organization: organizationSlug,
      },
    })
  }, [projectRef, organizationSlug, sendEvent])

  if (!organizationSlug || organizationSlug === 'no-org') {
    return null
  }

  // If no specific project selected, use the wildcard route
  const aiLink = `/project/${projectRef !== 'no-project' ? projectRef : '_'}?aiAssistantPanelOpen=true`

  return (
    <AnimatePresence initial={false}>
      {isVisible && (
        <motion.div
          initial={{ height: 0, opacity: 0 }}
          animate={{ height: 'auto', opacity: 1 }}
          exit={{ height: 0, opacity: 0 }}
          className="w-full overflow-hidden border rounded-md relative"
        >
          <div className={`flex flex-col xl:flex-row ${isCondensed ? 'py-4 px-5' : 'py-8 px-10'}`}>
            <div className="flex flex-col gap-3 z-[2] flex-shrink-0 w-full">
              <div>
                <p className="text-sm text-foreground">Try the AI Assistant</p>
                <p className="text-sm text-foreground-lighter">
                  Ask the AI assistant to help you with your support issue
                </p>
              </div>
              <div>
                <Link href={aiLink} onClick={onAiAssistantClicked}>
                  <Button size="tiny" type="default">
                    Ask AI assistant
                  </Button>
                </Link>
              </div>

Review comment (suggestion):
This is a change in behaviour, it used to preselect the first project in the org but now it always sends you to select a project. Not sure if expected.

Code after:
  isCondensed = false,
}: AIAssistantOptionProps) => {
  const { mutate: sendEvent } = useSendEventMutation()
  const [isVisible, setIsVisible] = useState(isCondensed ? true : false)

  useEffect(() => {
    const timer = setTimeout(() => setIsVisible(true), 800)
    return () => clearTimeout(timer)
  }, [])

  const onAiAssistantClicked = useCallback(() => {
    sendEvent({
      action: 'ai_assistant_in_support_form_clicked',
      groups: {
        project: projectRef === 'no-project' ? undefined : projectRef,
        organization: organizationSlug,
      },
    })
  }, [projectRef, organizationSlug, sendEvent])

  if (!organizationSlug || organizationSlug === 'no-org') {
    return null
  }

  // If no specific project selected, use the wildcard route
  const aiLink = `/project/${projectRef !== 'no-project' ? projectRef : '_'}?aiAssistantPanelOpen=true&slug=${organizationSlug}`

  return (
    <AnimatePresence initial={false}>
      {isVisible && (
        <motion.div
          initial={{ height: 0, opacity: 0 }}
          animate={{ height: 'auto', opacity: 1 }}
          exit={{ height: 0, opacity: 0 }}
          className="w-full overflow-hidden border rounded-md relative"
        >
          <div className={`flex flex-col xl:flex-row ${isCondensed ? 'py-4 px-5' : 'py-8 px-10'}`}>
            <div className="flex flex-col gap-3 z-[2] flex-shrink-0 w-full">
              <div>
                <p className="text-sm text-foreground">Try the AI Assistant</p>
                <p className="text-sm text-foreground-lighter">
                  Ask the AI assistant to help you with your support issue
                </p>
              </div>
              <div>
                <Link href={aiLink} onClick={onAiAssistantClicked}>
                  <Button size="tiny" type="default">
                    Ask AI assistant
                  </Button>
                </Link>
              </div>