Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1010 B
Raw Blame
import { useCallback, useRef, useState } from 'react'
import { shouldApplyAutoName } from './composer-linked-work-item'
import type { MobileLinkedWorkItem } from './mobile-composer-source-types'

export function useMobileComposerName(linkedWorkItem: MobileLinkedWorkItem | null) {
  const [name, setNameState] = useState('')
  const lastAutoNameRef = useRef('')
  const setName = useCallback((value: string) => setNameState(value), [])
  const applyAutoName = useCallback(
    (suggested: string, currentName: string) => {
      if (
        suggested &&
        shouldApplyAutoName({
          currentName,
          lastAutoName: lastAutoNameRef.current,
          lookupTextIsQuery: !linkedWorkItem
        })
      ) {
        setNameState(suggested)
        lastAutoNameRef.current = suggested
      }
    },
    [linkedWorkItem]
  )
  const isNameAutoManaged = !name.trim() || name === lastAutoNameRef.current
  return { name, setName, setNameState, lastAutoNameRef, applyAutoName, isNameAutoManaged }
}