from __future__ import annotations import json from dataclasses import dataclass, field from typing import TYPE_CHECKING from project_manager import config from project_manager.pool.db import OwnerKind, PoolDB from project_manager.stacker import git from project_manager.stacker.models import ( ColorMode, Details, MergedStyle, PRState, Scope, SelectorTarget, TrackedBranch, ) from project_manager.stacker.ops.track import require_tracked from project_manager.stacker.pr.lineage import lineage from project_manager.stacker.pr.refresh import refresh_review_state from . import format as fmt from . import graph from . import prefetch as prefetch_mod if TYPE_CHECKING: from pathlib import Path from project_manager.paths import Paths from project_manager.stacker.ctx import StackerCtx @dataclass(frozen=True) class RenderOptions: """Visual knobs for the text renderer. Grows across stages — icons/color-mode/merged-style are scaffolded here in Stage 1, applied in full in Stage 2. `online` is flipped on in Stage 5 when bulk GraphQL fetching lands. """ icons: bool = True hide_merged: bool = False merged_style: MergedStyle = "dimmed" color_mode: ColorMode = "icon" online: bool = True @dataclass(frozen=True) class LsOptions: """Knobs for `ls_text`: scope selection + render detail + output format.""" target_branch: str | None = None scope: Scope = "all" details: Details = "status-counts" json_output: bool = False # (repo_name, branch) of the branch checked out in the cwd's pm slot, # or None when cwd is not inside a slot. Used to mark the current row # with `> ` / `(current)`. current: tuple[str, str] | None = None # Prepend a legend explaining icons, commit groups, and suffix tokens. # Ignored in JSON mode — JSON consumers don't need glyph docs. legend: bool = False render: RenderOptions = field(default_factory=RenderOptions) # Optional per-branch label that replaces the generic `(current)` # marker with `(