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.1 KB
Raw Blame
import {
  deleteHostPageCache,
  forgetHostUpdateFailures
} from '../mobile-web-shell/removed-host-shell-cache'
import { unregisterPushForRemovedHost } from '../notifications/push-registration'
import { forgetHostDescriptor } from './host-descriptor-store'
import { removeHost } from './host-store'

export async function removeHostAndCloseClient(
  hostId: string,
  forgetHostClient: (hostId: string) => void
): Promise<void> {
  // Unregister before removal while the client is authenticated; desktop revocation covers undelivered requests.
  const restorePushRegistration = await unregisterPushForRemovedHost(hostId)
  // Close only after metadata commits so storage failure cannot strand a still-paired host.
  try {
    await removeHost(hostId)
  } catch (error) {
    restorePushRegistration()
    throw error
  }
  forgetHostClient(hostId)
  forgetHostDescriptor(hostId)
  // After commit, cache cleanup must not delay/fail removal; later eviction can reclaim failures.
  void forgetHostUpdateFailures(hostId).catch(() => undefined)
  void deleteHostPageCache(hostId).catch(() => undefined)
}