export const PROJECT_STATUSES = ['open', 'archived'] as const;
export type ProjectStatus = typeof PROJECT_STATUSES[number];

export interface Project {
  id: string;
  name: string;
  path: string;
  added_at: string;
  last_session_id: string | null;
  status: ProjectStatus;
  gitea_remote: string | null;
  // per-project defaults. Empty string on default_system_prompt means
  // "no override" — inference falls through to the base system prompt.
  default_system_prompt: string;
  default_web_search_enabled: boolean;
}

export interface AvailableProject {
  path: string;
  name: string;
}

// shape returned by GET /api/projects/:id/git. Mirrors services/git_meta.ts
// on the server. branch=null means "not a git repo".
export interface GitMeta {
  branch: string | null;
  is_dirty: boolean;
  ahead: number;
  behind: number;
}

// git-diff-panel Phase 1: shapes returned by GET /api/projects/:id/git/diff.
export type GitDiffMode = 'uncommitted' | 'committed';
export type GitDiffChangeType = 'added' | 'modified' | 'deleted' | 'renamed' | 'untracked';

export interface GitDiffFile {
  path: string;
  old_path: string | null;
  change_type: GitDiffChangeType;
  added_lines: number;
  removed_lines: number;
  staged: boolean;
  diff_body: string | null;
  is_binary: boolean;
  is_too_large: boolean;
}

export interface GitDiffResult {
  git_repo: boolean;
  mode: GitDiffMode;
  /** Server-computed mode based on dirty state — used for auto-select (FIX 1) and mode suggestion (FIX 4). */
  auto_mode?: GitDiffMode;
  base_label: string | null;
  in_progress_op: string | null;
  files: GitDiffFile[];
}

// git-diff-panel Phase 2: per-file info for the discard endpoint.
export interface GitDiscardFileInfo {
  path: string;
  change_type: GitDiffChangeType;
  staged: boolean;
}

export interface FileEntry {
  name: string;
  kind: 'file' | 'dir';
  size?: number;
}

export interface ListDirResult {
  entries: FileEntry[];
  truncated: boolean;
  total: number;
}

export interface ViewFileResult {
  content: string;
  truncated: boolean;
  total_bytes: number;
  bytes_returned: number;
}
