export type TodoFilter = "all" | "active" | "completed";

export interface TodoItem {
  id: string;
  title: string;
  completed: boolean;
  expanded: boolean;
  reminderAt: string | null;
  createdAt: string;
  updatedAt: string;
  children: TodoItem[];
}

export interface TodoInstance {
  id: string;
  name: string;
  filePath: string;
  historyPath: string;
  createdAt: string;
  updatedAt: string;
  historyPointer: number;
  todos: TodoItem[];
}

export interface InstanceSummary {
  id: string;
  name: string;
  filePath: string;
  historyPath: string;
  createdAt: string;
  updatedAt: string;
  todoCount: number;
  completedCount: number;
}

export interface Registry {
  instances: InstanceSummary[];
}

export type TodoAction =
  | { type: "addTodo"; title: string; parentId?: string }
  | { type: "updateTodoTitle"; todoId: string; title: string }
  | { type: "toggleTodoCompleted"; todoId: string }
  | { type: "toggleTodoExpanded"; todoId: string }
  | { type: "setAllTodosExpanded"; expanded: boolean }
  | { type: "setTodoReminder"; todoId: string; reminderAt: string | null }
  | { type: "moveTodo"; todoId: string; targetParentId?: string; targetIndex: number }
  | { type: "deleteTodo"; todoId: string }
  | { type: "renameInstance"; name: string };

export interface HistoryEntry {
  sequence: number;
  timestamp: string;
  kind: "snapshot" | "command";
  action: string;
  snapshot?: TodoInstance;
  detail?: Record<string, unknown>;
}
