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.7 KB
Raw Blame
import { isExplicitlyImportedExternalWorktreePath } from './external-worktree-inbox'
import {
  effectiveAgentWorktreeVisibility,
  effectiveExternalWorktreeVisibility
} from './external-worktree-visibility'
import {
  effectiveWorktreeSourceVisibility,
  type WorktreeVisibilitySourceMatcher
} from './worktree/visibility-sources'
import type { GlobalSettings } from './global-settings-types'
import type { Repo } from './repo-types'
import type { Worktree, WorktreeOwnership } from './worktree/types'

export function shouldShowWorktree(args: {
  worktree: Pick<Worktree, 'path'>
  ownership: WorktreeOwnership
  repo: Repo
  isLegacyRepoForVisibility: boolean
  isSelectedCheckout: boolean
  visibilityDefaults?: GlobalSettings['worktreeVisibilityDefaults']
  importedExternalWorktreePaths?: readonly string[] | undefined
  visibilitySource?: ReturnType<WorktreeVisibilitySourceMatcher>
}): boolean {
  if (args.isSelectedCheckout || args.ownership === 'orca-managed') {
    return true
  }
  if (
    isExplicitlyImportedExternalWorktreePath(args.worktree.path, {
      importedExternalWorktreePaths: args.importedExternalWorktreePaths
    })
  ) {
    return true
  }
  if (args.visibilitySource) {
    return (
      effectiveWorktreeSourceVisibility(
        args.repo,
        args.visibilitySource,
        args.visibilityDefaults
      ) === 'show'
    )
  }
  if (args.ownership === 'agent-scratch') {
    return effectiveAgentWorktreeVisibility(args.repo) === 'show'
  }
  if (args.ownership === 'unknown-legacy' && args.isLegacyRepoForVisibility) {
    return true
  }
  return (
    effectiveExternalWorktreeVisibility(
      args.repo,
      args.isLegacyRepoForVisibility,
      args.visibilityDefaults
    ) === 'show'
  )
}