// 共享类型定义 — 主进程和渲染进程共用

export interface FileNode {
  name: string
  path: string
  type: 'file' | 'dir'
  children?: FileNode[]
}

export interface ReadFileResult {
  success: boolean
  content?: string
  error?: string
}

export interface SaveFilePayload {
  filePath: string | null
  content: string
}

export interface SaveAsPayload {
  content: string
}

export interface SaveFileResult {
  success: boolean
  filePath?: string
  error?: string
  canceled?: boolean
}

export interface ReloadFileResult {
  success: boolean
  content?: string
  filePath?: string
  error?: string
}

export interface FileStatsResult {
  success: boolean
  size?: number
  mtime?: string
  error?: string
}

export interface ReadDirTreeResult {
  success: boolean
  tree?: FileNode[]
  rootPath?: string
  error?: string
}

export interface OpenFileResult {
  filePath: string
  content: string
  error?: never
}

export interface OpenFileError {
  error: string
  filePath?: never
  content?: never
}

export type OpenFileResponse = OpenFileResult | OpenFileError | null
