Repository: TabbyML/tabby
File: ee/tabby-ui/app/chat/page.tsx (TypeScript)

Code before:
    })
    .join('')
}

export default function ChatPage() {
  const [isInit, setIsInit] = useState(false)
  const [fetcherOptions, setFetcherOptions] = useState<FetcherOptions | null>(
    null
  )
  const [activeChatId, setActiveChatId] = useState('')
  const [pendingMessages, setPendingMessages] = useState<ChatMessage[]>([])
  const [pendingRelevantContexts, setPendingRelevantContexts] = useState<
    Context[]
  >([])
  const [errorMessage, setErrorMessage] = useState<ErrorMessage | null>(null)
  const [isRefreshLoading, setIsRefreshLoading] = useState(false)

  const chatRef = useRef<ChatRef>(null)
  const [chatLoaded, setChatLoaded] = useState(false)
  const { width } = useWindowSize()
  const prevWidthRef = useRef(width)

  const searchParams = useSearchParams()
  const client = searchParams.get('client') as ClientType
  const isInEditor = !!client || undefined
  const [focusKeybinding, setFocusKeyBinding] = useState<FocusKeybinding>()

  const sendMessage = (message: ChatMessage) => {
    if (chatRef.current) {
      chatRef.current.sendUserChat(message)
    } else {
      const newPendingMessages = [...pendingMessages]
      newPendingMessages.push(message)
      setPendingMessages(newPendingMessages)
    }
  }

  const addRelevantContext = (ctx: Context) => {
    if (chatRef.current) {
      chatRef.current.addRelevantContext(ctx)
    } else {
      const newPendingRelevantContexts = [...pendingRelevantContexts]
      newPendingRelevantContexts.push(ctx)
      setPendingRelevantContexts(newPendingRelevantContexts)
    }
  }

  const server = useServer({
    init: (request: InitRequest) => {
      if (chatRef.current) return
      setActiveChatId(nanoid())

Review comment (suggestion):
```suggestion
  const focusKeybinding = useRef<FocusKeybinding>()
```

Code after:
      if (idx === 0) return parseFloat(item).toFixed(1)
      return item
    })
    .join('')
}

export default function ChatPage() {
  const [isInit, setIsInit] = useState(false)
  const [fetcherOptions, setFetcherOptions] = useState<FetcherOptions | null>(
    null
  )
  const [activeChatId, setActiveChatId] = useState('')
  const [pendingMessages, setPendingMessages] = useState<ChatMessage[]>([])
  const [pendingRelevantContexts, setPendingRelevantContexts] = useState<
    Context[]
  >([])
  const [errorMessage, setErrorMessage] = useState<ErrorMessage | null>(null)
  const [isRefreshLoading, setIsRefreshLoading] = useState(false)

  const chatRef = useRef<ChatRef>(null)
  const [chatLoaded, setChatLoaded] = useState(false)
  const { width } = useWindowSize()
  const prevWidthRef = useRef(width)
  const chatInputRef = useRef<HTMLTextAreaElement>(null)

  const searchParams = useSearchParams()
  const client = searchParams.get('client') as ClientType
  const isInEditor = !!client || undefined
  const focusKeybinding = useRef<FocusKeybinding>()

  const sendMessage = (message: ChatMessage) => {
    if (chatRef.current) {
      chatRef.current.sendUserChat(message)
    } else {
      const newPendingMessages = [...pendingMessages]
      newPendingMessages.push(message)
      setPendingMessages(newPendingMessages)
    }
  }

  const addRelevantContext = (ctx: Context) => {
    if (chatRef.current) {
      chatRef.current.addRelevantContext(ctx)
    } else {
      const newPendingRelevantContexts = [...pendingRelevantContexts]
      newPendingRelevantContexts.push(ctx)
      setPendingRelevantContexts(newPendingRelevantContexts)
    }
  }

  const server = useServer({