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.

1.0 KB
Raw Blame
import { useCallback, useSyncExternalStore } from 'react'
import type { RpcClient } from '../transport/rpc-client'
import { mobileStructuredSessionStatusFeed } from './mobile-structured-session-status-feed'

const noSubscription = (): (() => void) => () => {}

// Only trust host Stopping while its status-feed capability and transport are live.
export function useMobileStructuredSessionHostStopping(args: {
  client: RpcClient | null
  sessionId: string | null
  enabled: boolean
}): boolean {
  const { client, sessionId, enabled } = args
  const feed = enabled && client && sessionId ? mobileStructuredSessionStatusFeed(client) : null
  const subscribe = useCallback(
    (listener: () => void) => (feed ? feed.subscribe(listener) : noSubscription()),
    [feed]
  )
  const readStopping = (): boolean => {
    const summary = feed && sessionId ? feed.getSnapshot().get(sessionId) : undefined
    return summary?.status === 'working' && summary.stopping === true
  }
  return useSyncExternalStore(subscribe, readStopping, readStopping)
}